babylon.module.d.ts 5.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/observable" {
  50. import { Nullable } from "babylonjs/types";
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module "babylonjs/Misc/domManagement" {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module "babylonjs/Misc/logger" {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static readonly LogCache: string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static LogLevels: number;
  363. }
  364. }
  365. declare module "babylonjs/Misc/typeStore" {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module "babylonjs/Misc/deepCopier" {
  377. /**
  378. * Class containing a set of static utilities functions for deep copy.
  379. */
  380. export class DeepCopier {
  381. /**
  382. * Tries to copy an object by duplicating every property
  383. * @param source defines the source object
  384. * @param destination defines the target object
  385. * @param doNotCopyList defines a list of properties to avoid
  386. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  387. */
  388. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  389. }
  390. }
  391. declare module "babylonjs/Misc/precisionDate" {
  392. /**
  393. * Class containing a set of static utilities functions for precision date
  394. */
  395. export class PrecisionDate {
  396. /**
  397. * Gets either window.performance.now() if supported or Date.now() else
  398. */
  399. static readonly Now: number;
  400. }
  401. }
  402. declare module "babylonjs/Misc/devTools" {
  403. /** @hidden */
  404. export class _DevTools {
  405. static WarnImport(name: string): string;
  406. }
  407. }
  408. declare module "babylonjs/Misc/webRequest" {
  409. /**
  410. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  411. */
  412. export class WebRequest {
  413. private _xhr;
  414. /**
  415. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  416. * i.e. when loading files, where the server/service expects an Authorization header
  417. */
  418. static CustomRequestHeaders: {
  419. [key: string]: string;
  420. };
  421. /**
  422. * Add callback functions in this array to update all the requests before they get sent to the network
  423. */
  424. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  425. private _injectCustomRequestHeaders;
  426. /**
  427. * Gets or sets a function to be called when loading progress changes
  428. */
  429. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  430. /**
  431. * Returns client's state
  432. */
  433. readonly readyState: number;
  434. /**
  435. * Returns client's status
  436. */
  437. readonly status: number;
  438. /**
  439. * Returns client's status as a text
  440. */
  441. readonly statusText: string;
  442. /**
  443. * Returns client's response
  444. */
  445. readonly response: any;
  446. /**
  447. * Returns client's response url
  448. */
  449. readonly responseURL: string;
  450. /**
  451. * Returns client's response as text
  452. */
  453. readonly responseText: string;
  454. /**
  455. * Gets or sets the expected response type
  456. */
  457. responseType: XMLHttpRequestResponseType;
  458. /** @hidden */
  459. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  460. /** @hidden */
  461. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  462. /**
  463. * Cancels any network activity
  464. */
  465. abort(): void;
  466. /**
  467. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  468. * @param body defines an optional request body
  469. */
  470. send(body?: Document | BodyInit | null): void;
  471. /**
  472. * Sets the request method, request URL
  473. * @param method defines the method to use (GET, POST, etc..)
  474. * @param url defines the url to connect with
  475. */
  476. open(method: string, url: string): void;
  477. }
  478. }
  479. declare module "babylonjs/Misc/fileRequest" {
  480. import { Observable } from "babylonjs/Misc/observable";
  481. /**
  482. * File request interface
  483. */
  484. export interface IFileRequest {
  485. /**
  486. * Raised when the request is complete (success or error).
  487. */
  488. onCompleteObservable: Observable<IFileRequest>;
  489. /**
  490. * Aborts the request for a file.
  491. */
  492. abort: () => void;
  493. }
  494. }
  495. declare module "babylonjs/Misc/performanceMonitor" {
  496. /**
  497. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  498. */
  499. export class PerformanceMonitor {
  500. private _enabled;
  501. private _rollingFrameTime;
  502. private _lastFrameTimeMs;
  503. /**
  504. * constructor
  505. * @param frameSampleSize The number of samples required to saturate the sliding window
  506. */
  507. constructor(frameSampleSize?: number);
  508. /**
  509. * Samples current frame
  510. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  511. */
  512. sampleFrame(timeMs?: number): void;
  513. /**
  514. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  515. */
  516. readonly averageFrameTime: number;
  517. /**
  518. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  519. */
  520. readonly averageFrameTimeVariance: number;
  521. /**
  522. * Returns the frame time of the most recent frame
  523. */
  524. readonly instantaneousFrameTime: number;
  525. /**
  526. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  527. */
  528. readonly averageFPS: number;
  529. /**
  530. * Returns the average framerate in frames per second using the most recent frame time
  531. */
  532. readonly instantaneousFPS: number;
  533. /**
  534. * Returns true if enough samples have been taken to completely fill the sliding window
  535. */
  536. readonly isSaturated: boolean;
  537. /**
  538. * Enables contributions to the sliding window sample set
  539. */
  540. enable(): void;
  541. /**
  542. * Disables contributions to the sliding window sample set
  543. * Samples will not be interpolated over the disabled period
  544. */
  545. disable(): void;
  546. /**
  547. * Returns true if sampling is enabled
  548. */
  549. readonly isEnabled: boolean;
  550. /**
  551. * Resets performance monitor
  552. */
  553. reset(): void;
  554. }
  555. /**
  556. * RollingAverage
  557. *
  558. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  559. */
  560. export class RollingAverage {
  561. /**
  562. * Current average
  563. */
  564. average: number;
  565. /**
  566. * Current variance
  567. */
  568. variance: number;
  569. protected _samples: Array<number>;
  570. protected _sampleCount: number;
  571. protected _pos: number;
  572. protected _m2: number;
  573. /**
  574. * constructor
  575. * @param length The number of samples required to saturate the sliding window
  576. */
  577. constructor(length: number);
  578. /**
  579. * Adds a sample to the sample set
  580. * @param v The sample value
  581. */
  582. add(v: number): void;
  583. /**
  584. * Returns previously added values or null if outside of history or outside the sliding window domain
  585. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  586. * @return Value previously recorded with add() or null if outside of range
  587. */
  588. history(i: number): number;
  589. /**
  590. * Returns true if enough samples have been taken to completely fill the sliding window
  591. * @return true if sample-set saturated
  592. */
  593. isSaturated(): boolean;
  594. /**
  595. * Resets the rolling average (equivalent to 0 samples taken so far)
  596. */
  597. reset(): void;
  598. /**
  599. * Wraps a value around the sample range boundaries
  600. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  601. * @return Wrapped position in sample range
  602. */
  603. protected _wrapPosition(i: number): number;
  604. }
  605. }
  606. declare module "babylonjs/Misc/stringDictionary" {
  607. import { Nullable } from "babylonjs/types";
  608. /**
  609. * This class implement a typical dictionary using a string as key and the generic type T as value.
  610. * The underlying implementation relies on an associative array to ensure the best performances.
  611. * The value can be anything including 'null' but except 'undefined'
  612. */
  613. export class StringDictionary<T> {
  614. /**
  615. * This will clear this dictionary and copy the content from the 'source' one.
  616. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  617. * @param source the dictionary to take the content from and copy to this dictionary
  618. */
  619. copyFrom(source: StringDictionary<T>): void;
  620. /**
  621. * Get a value based from its key
  622. * @param key the given key to get the matching value from
  623. * @return the value if found, otherwise undefined is returned
  624. */
  625. get(key: string): T | undefined;
  626. /**
  627. * Get a value from its key or add it if it doesn't exist.
  628. * This method will ensure you that a given key/data will be present in the dictionary.
  629. * @param key the given key to get the matching value from
  630. * @param factory the factory that will create the value if the key is not present in the dictionary.
  631. * The factory will only be invoked if there's no data for the given key.
  632. * @return the value corresponding to the key.
  633. */
  634. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  635. /**
  636. * Get a value from its key if present in the dictionary otherwise add it
  637. * @param key the key to get the value from
  638. * @param val if there's no such key/value pair in the dictionary add it with this value
  639. * @return the value corresponding to the key
  640. */
  641. getOrAdd(key: string, val: T): T;
  642. /**
  643. * Check if there's a given key in the dictionary
  644. * @param key the key to check for
  645. * @return true if the key is present, false otherwise
  646. */
  647. contains(key: string): boolean;
  648. /**
  649. * Add a new key and its corresponding value
  650. * @param key the key to add
  651. * @param value the value corresponding to the key
  652. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  653. */
  654. add(key: string, value: T): boolean;
  655. /**
  656. * Update a specific value associated to a key
  657. * @param key defines the key to use
  658. * @param value defines the value to store
  659. * @returns true if the value was updated (or false if the key was not found)
  660. */
  661. set(key: string, value: T): boolean;
  662. /**
  663. * Get the element of the given key and remove it from the dictionary
  664. * @param key defines the key to search
  665. * @returns the value associated with the key or null if not found
  666. */
  667. getAndRemove(key: string): Nullable<T>;
  668. /**
  669. * Remove a key/value from the dictionary.
  670. * @param key the key to remove
  671. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  672. */
  673. remove(key: string): boolean;
  674. /**
  675. * Clear the whole content of the dictionary
  676. */
  677. clear(): void;
  678. /**
  679. * Gets the current count
  680. */
  681. readonly count: number;
  682. /**
  683. * Execute a callback on each key/val of the dictionary.
  684. * Note that you can remove any element in this dictionary in the callback implementation
  685. * @param callback the callback to execute on a given key/value pair
  686. */
  687. forEach(callback: (key: string, val: T) => void): void;
  688. /**
  689. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  690. * If the callback returns null or undefined the method will iterate to the next key/value pair
  691. * Note that you can remove any element in this dictionary in the callback implementation
  692. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  693. * @returns the first item
  694. */
  695. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  696. private _count;
  697. private _data;
  698. }
  699. }
  700. declare module "babylonjs/Meshes/dataBuffer" {
  701. /**
  702. * Class used to store gfx data (like WebGLBuffer)
  703. */
  704. export class DataBuffer {
  705. /**
  706. * Gets or sets the number of objects referencing this buffer
  707. */
  708. references: number;
  709. /** Gets or sets the size of the underlying buffer */
  710. capacity: number;
  711. /**
  712. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  713. */
  714. is32Bits: boolean;
  715. /**
  716. * Gets the underlying buffer
  717. */
  718. readonly underlyingResource: any;
  719. }
  720. }
  721. declare module "babylonjs/Meshes/buffer" {
  722. import { Nullable, DataArray } from "babylonjs/types";
  723. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  724. /**
  725. * Class used to store data that will be store in GPU memory
  726. */
  727. export class Buffer {
  728. private _engine;
  729. private _buffer;
  730. /** @hidden */
  731. _data: Nullable<DataArray>;
  732. private _updatable;
  733. private _instanced;
  734. /**
  735. * Gets the byte stride.
  736. */
  737. readonly byteStride: number;
  738. /**
  739. * Constructor
  740. * @param engine the engine
  741. * @param data the data to use for this buffer
  742. * @param updatable whether the data is updatable
  743. * @param stride the stride (optional)
  744. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  745. * @param instanced whether the buffer is instanced (optional)
  746. * @param useBytes set to true if the stride in in bytes (optional)
  747. */
  748. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  749. /**
  750. * Create a new VertexBuffer based on the current buffer
  751. * @param kind defines the vertex buffer kind (position, normal, etc.)
  752. * @param offset defines offset in the buffer (0 by default)
  753. * @param size defines the size in floats of attributes (position is 3 for instance)
  754. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  755. * @param instanced defines if the vertex buffer contains indexed data
  756. * @param useBytes defines if the offset and stride are in bytes
  757. * @returns the new vertex buffer
  758. */
  759. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  760. /**
  761. * Gets a boolean indicating if the Buffer is updatable?
  762. * @returns true if the buffer is updatable
  763. */
  764. isUpdatable(): boolean;
  765. /**
  766. * Gets current buffer's data
  767. * @returns a DataArray or null
  768. */
  769. getData(): Nullable<DataArray>;
  770. /**
  771. * Gets underlying native buffer
  772. * @returns underlying native buffer
  773. */
  774. getBuffer(): Nullable<DataBuffer>;
  775. /**
  776. * Gets the stride in float32 units (i.e. byte stride / 4).
  777. * May not be an integer if the byte stride is not divisible by 4.
  778. * DEPRECATED. Use byteStride instead.
  779. * @returns the stride in float32 units
  780. */
  781. getStrideSize(): number;
  782. /**
  783. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  784. * @param data defines the data to store
  785. */
  786. create(data?: Nullable<DataArray>): void;
  787. /** @hidden */
  788. _rebuild(): void;
  789. /**
  790. * Update current buffer data
  791. * @param data defines the data to store
  792. */
  793. update(data: DataArray): void;
  794. /**
  795. * Updates the data directly.
  796. * @param data the new data
  797. * @param offset the new offset
  798. * @param vertexCount the vertex count (optional)
  799. * @param useBytes set to true if the offset is in bytes
  800. */
  801. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  802. /**
  803. * Release all resources
  804. */
  805. dispose(): void;
  806. }
  807. /**
  808. * Specialized buffer used to store vertex data
  809. */
  810. export class VertexBuffer {
  811. /** @hidden */
  812. _buffer: Buffer;
  813. private _kind;
  814. private _size;
  815. private _ownsBuffer;
  816. private _instanced;
  817. private _instanceDivisor;
  818. /**
  819. * The byte type.
  820. */
  821. static readonly BYTE: number;
  822. /**
  823. * The unsigned byte type.
  824. */
  825. static readonly UNSIGNED_BYTE: number;
  826. /**
  827. * The short type.
  828. */
  829. static readonly SHORT: number;
  830. /**
  831. * The unsigned short type.
  832. */
  833. static readonly UNSIGNED_SHORT: number;
  834. /**
  835. * The integer type.
  836. */
  837. static readonly INT: number;
  838. /**
  839. * The unsigned integer type.
  840. */
  841. static readonly UNSIGNED_INT: number;
  842. /**
  843. * The float type.
  844. */
  845. static readonly FLOAT: number;
  846. /**
  847. * Gets or sets the instance divisor when in instanced mode
  848. */
  849. instanceDivisor: number;
  850. /**
  851. * Gets the byte stride.
  852. */
  853. readonly byteStride: number;
  854. /**
  855. * Gets the byte offset.
  856. */
  857. readonly byteOffset: number;
  858. /**
  859. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  860. */
  861. readonly normalized: boolean;
  862. /**
  863. * Gets the data type of each component in the array.
  864. */
  865. readonly type: number;
  866. /**
  867. * Constructor
  868. * @param engine the engine
  869. * @param data the data to use for this vertex buffer
  870. * @param kind the vertex buffer kind
  871. * @param updatable whether the data is updatable
  872. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  873. * @param stride the stride (optional)
  874. * @param instanced whether the buffer is instanced (optional)
  875. * @param offset the offset of the data (optional)
  876. * @param size the number of components (optional)
  877. * @param type the type of the component (optional)
  878. * @param normalized whether the data contains normalized data (optional)
  879. * @param useBytes set to true if stride and offset are in bytes (optional)
  880. */
  881. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  882. /** @hidden */
  883. _rebuild(): void;
  884. /**
  885. * Returns the kind of the VertexBuffer (string)
  886. * @returns a string
  887. */
  888. getKind(): string;
  889. /**
  890. * Gets a boolean indicating if the VertexBuffer is updatable?
  891. * @returns true if the buffer is updatable
  892. */
  893. isUpdatable(): boolean;
  894. /**
  895. * Gets current buffer's data
  896. * @returns a DataArray or null
  897. */
  898. getData(): Nullable<DataArray>;
  899. /**
  900. * Gets underlying native buffer
  901. * @returns underlying native buffer
  902. */
  903. getBuffer(): Nullable<DataBuffer>;
  904. /**
  905. * Gets the stride in float32 units (i.e. byte stride / 4).
  906. * May not be an integer if the byte stride is not divisible by 4.
  907. * DEPRECATED. Use byteStride instead.
  908. * @returns the stride in float32 units
  909. */
  910. getStrideSize(): number;
  911. /**
  912. * Returns the offset as a multiple of the type byte length.
  913. * DEPRECATED. Use byteOffset instead.
  914. * @returns the offset in bytes
  915. */
  916. getOffset(): number;
  917. /**
  918. * Returns the number of components per vertex attribute (integer)
  919. * @returns the size in float
  920. */
  921. getSize(): number;
  922. /**
  923. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  924. * @returns true if this buffer is instanced
  925. */
  926. getIsInstanced(): boolean;
  927. /**
  928. * Returns the instancing divisor, zero for non-instanced (integer).
  929. * @returns a number
  930. */
  931. getInstanceDivisor(): number;
  932. /**
  933. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  934. * @param data defines the data to store
  935. */
  936. create(data?: DataArray): void;
  937. /**
  938. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  939. * This function will create a new buffer if the current one is not updatable
  940. * @param data defines the data to store
  941. */
  942. update(data: DataArray): void;
  943. /**
  944. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  945. * Returns the directly updated WebGLBuffer.
  946. * @param data the new data
  947. * @param offset the new offset
  948. * @param useBytes set to true if the offset is in bytes
  949. */
  950. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  951. /**
  952. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  953. */
  954. dispose(): void;
  955. /**
  956. * Enumerates each value of this vertex buffer as numbers.
  957. * @param count the number of values to enumerate
  958. * @param callback the callback function called for each value
  959. */
  960. forEach(count: number, callback: (value: number, index: number) => void): void;
  961. /**
  962. * Positions
  963. */
  964. static readonly PositionKind: string;
  965. /**
  966. * Normals
  967. */
  968. static readonly NormalKind: string;
  969. /**
  970. * Tangents
  971. */
  972. static readonly TangentKind: string;
  973. /**
  974. * Texture coordinates
  975. */
  976. static readonly UVKind: string;
  977. /**
  978. * Texture coordinates 2
  979. */
  980. static readonly UV2Kind: string;
  981. /**
  982. * Texture coordinates 3
  983. */
  984. static readonly UV3Kind: string;
  985. /**
  986. * Texture coordinates 4
  987. */
  988. static readonly UV4Kind: string;
  989. /**
  990. * Texture coordinates 5
  991. */
  992. static readonly UV5Kind: string;
  993. /**
  994. * Texture coordinates 6
  995. */
  996. static readonly UV6Kind: string;
  997. /**
  998. * Colors
  999. */
  1000. static readonly ColorKind: string;
  1001. /**
  1002. * Matrix indices (for bones)
  1003. */
  1004. static readonly MatricesIndicesKind: string;
  1005. /**
  1006. * Matrix weights (for bones)
  1007. */
  1008. static readonly MatricesWeightsKind: string;
  1009. /**
  1010. * Additional matrix indices (for bones)
  1011. */
  1012. static readonly MatricesIndicesExtraKind: string;
  1013. /**
  1014. * Additional matrix weights (for bones)
  1015. */
  1016. static readonly MatricesWeightsExtraKind: string;
  1017. /**
  1018. * Deduces the stride given a kind.
  1019. * @param kind The kind string to deduce
  1020. * @returns The deduced stride
  1021. */
  1022. static DeduceStride(kind: string): number;
  1023. /**
  1024. * Gets the byte length of the given type.
  1025. * @param type the type
  1026. * @returns the number of bytes
  1027. */
  1028. static GetTypeByteLength(type: number): number;
  1029. /**
  1030. * Enumerates each value of the given parameters as numbers.
  1031. * @param data the data to enumerate
  1032. * @param byteOffset the byte offset of the data
  1033. * @param byteStride the byte stride of the data
  1034. * @param componentCount the number of components per element
  1035. * @param componentType the type of the component
  1036. * @param count the number of values to enumerate
  1037. * @param normalized whether the data is normalized
  1038. * @param callback the callback function called for each value
  1039. */
  1040. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1041. private static _GetFloatValue;
  1042. }
  1043. }
  1044. declare module "babylonjs/Maths/math.scalar" {
  1045. /**
  1046. * Scalar computation library
  1047. */
  1048. export class Scalar {
  1049. /**
  1050. * Two pi constants convenient for computation.
  1051. */
  1052. static TwoPi: number;
  1053. /**
  1054. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1055. * @param a number
  1056. * @param b number
  1057. * @param epsilon (default = 1.401298E-45)
  1058. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1059. */
  1060. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1061. /**
  1062. * Returns a string : the upper case translation of the number i to hexadecimal.
  1063. * @param i number
  1064. * @returns the upper case translation of the number i to hexadecimal.
  1065. */
  1066. static ToHex(i: number): string;
  1067. /**
  1068. * Returns -1 if value is negative and +1 is value is positive.
  1069. * @param value the value
  1070. * @returns the value itself if it's equal to zero.
  1071. */
  1072. static Sign(value: number): number;
  1073. /**
  1074. * Returns the value itself if it's between min and max.
  1075. * Returns min if the value is lower than min.
  1076. * Returns max if the value is greater than max.
  1077. * @param value the value to clmap
  1078. * @param min the min value to clamp to (default: 0)
  1079. * @param max the max value to clamp to (default: 1)
  1080. * @returns the clamped value
  1081. */
  1082. static Clamp(value: number, min?: number, max?: number): number;
  1083. /**
  1084. * the log2 of value.
  1085. * @param value the value to compute log2 of
  1086. * @returns the log2 of value.
  1087. */
  1088. static Log2(value: number): number;
  1089. /**
  1090. * Loops the value, so that it is never larger than length and never smaller than 0.
  1091. *
  1092. * This is similar to the modulo operator but it works with floating point numbers.
  1093. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1094. * With t = 5 and length = 2.5, the result would be 0.0.
  1095. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1096. * @param value the value
  1097. * @param length the length
  1098. * @returns the looped value
  1099. */
  1100. static Repeat(value: number, length: number): number;
  1101. /**
  1102. * Normalize the value between 0.0 and 1.0 using min and max values
  1103. * @param value value to normalize
  1104. * @param min max to normalize between
  1105. * @param max min to normalize between
  1106. * @returns the normalized value
  1107. */
  1108. static Normalize(value: number, min: number, max: number): number;
  1109. /**
  1110. * Denormalize the value from 0.0 and 1.0 using min and max values
  1111. * @param normalized value to denormalize
  1112. * @param min max to denormalize between
  1113. * @param max min to denormalize between
  1114. * @returns the denormalized value
  1115. */
  1116. static Denormalize(normalized: number, min: number, max: number): number;
  1117. /**
  1118. * Calculates the shortest difference between two given angles given in degrees.
  1119. * @param current current angle in degrees
  1120. * @param target target angle in degrees
  1121. * @returns the delta
  1122. */
  1123. static DeltaAngle(current: number, target: number): number;
  1124. /**
  1125. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1126. * @param tx value
  1127. * @param length length
  1128. * @returns The returned value will move back and forth between 0 and length
  1129. */
  1130. static PingPong(tx: number, length: number): number;
  1131. /**
  1132. * Interpolates between min and max with smoothing at the limits.
  1133. *
  1134. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1135. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1136. * @param from from
  1137. * @param to to
  1138. * @param tx value
  1139. * @returns the smooth stepped value
  1140. */
  1141. static SmoothStep(from: number, to: number, tx: number): number;
  1142. /**
  1143. * Moves a value current towards target.
  1144. *
  1145. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1146. * Negative values of maxDelta pushes the value away from target.
  1147. * @param current current value
  1148. * @param target target value
  1149. * @param maxDelta max distance to move
  1150. * @returns resulting value
  1151. */
  1152. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1153. /**
  1154. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1155. *
  1156. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1157. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1158. * @param current current value
  1159. * @param target target value
  1160. * @param maxDelta max distance to move
  1161. * @returns resulting angle
  1162. */
  1163. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1164. /**
  1165. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1166. * @param start start value
  1167. * @param end target value
  1168. * @param amount amount to lerp between
  1169. * @returns the lerped value
  1170. */
  1171. static Lerp(start: number, end: number, amount: number): number;
  1172. /**
  1173. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1174. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1175. * @param start start value
  1176. * @param end target value
  1177. * @param amount amount to lerp between
  1178. * @returns the lerped value
  1179. */
  1180. static LerpAngle(start: number, end: number, amount: number): number;
  1181. /**
  1182. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1183. * @param a start value
  1184. * @param b target value
  1185. * @param value value between a and b
  1186. * @returns the inverseLerp value
  1187. */
  1188. static InverseLerp(a: number, b: number, value: number): number;
  1189. /**
  1190. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1191. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1192. * @param value1 spline value
  1193. * @param tangent1 spline value
  1194. * @param value2 spline value
  1195. * @param tangent2 spline value
  1196. * @param amount input value
  1197. * @returns hermite result
  1198. */
  1199. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1200. /**
  1201. * Returns a random float number between and min and max values
  1202. * @param min min value of random
  1203. * @param max max value of random
  1204. * @returns random value
  1205. */
  1206. static RandomRange(min: number, max: number): number;
  1207. /**
  1208. * This function returns percentage of a number in a given range.
  1209. *
  1210. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1211. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1212. * @param number to convert to percentage
  1213. * @param min min range
  1214. * @param max max range
  1215. * @returns the percentage
  1216. */
  1217. static RangeToPercent(number: number, min: number, max: number): number;
  1218. /**
  1219. * This function returns number that corresponds to the percentage in a given range.
  1220. *
  1221. * PercentToRange(0.34,0,100) will return 34.
  1222. * @param percent to convert to number
  1223. * @param min min range
  1224. * @param max max range
  1225. * @returns the number
  1226. */
  1227. static PercentToRange(percent: number, min: number, max: number): number;
  1228. /**
  1229. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1230. * @param angle The angle to normalize in radian.
  1231. * @return The converted angle.
  1232. */
  1233. static NormalizeRadians(angle: number): number;
  1234. }
  1235. }
  1236. declare module "babylonjs/Maths/math.constants" {
  1237. /**
  1238. * Constant used to convert a value to gamma space
  1239. * @ignorenaming
  1240. */
  1241. export const ToGammaSpace: number;
  1242. /**
  1243. * Constant used to convert a value to linear space
  1244. * @ignorenaming
  1245. */
  1246. export const ToLinearSpace = 2.2;
  1247. /**
  1248. * Constant used to define the minimal number value in Babylon.js
  1249. * @ignorenaming
  1250. */
  1251. let Epsilon: number;
  1252. export { Epsilon };
  1253. }
  1254. declare module "babylonjs/Maths/math.viewport" {
  1255. /**
  1256. * Class used to represent a viewport on screen
  1257. */
  1258. export class Viewport {
  1259. /** viewport left coordinate */
  1260. x: number;
  1261. /** viewport top coordinate */
  1262. y: number;
  1263. /**viewport width */
  1264. width: number;
  1265. /** viewport height */
  1266. height: number;
  1267. /**
  1268. * Creates a Viewport object located at (x, y) and sized (width, height)
  1269. * @param x defines viewport left coordinate
  1270. * @param y defines viewport top coordinate
  1271. * @param width defines the viewport width
  1272. * @param height defines the viewport height
  1273. */
  1274. constructor(
  1275. /** viewport left coordinate */
  1276. x: number,
  1277. /** viewport top coordinate */
  1278. y: number,
  1279. /**viewport width */
  1280. width: number,
  1281. /** viewport height */
  1282. height: number);
  1283. /**
  1284. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1285. * @param renderWidth defines the rendering width
  1286. * @param renderHeight defines the rendering height
  1287. * @returns a new Viewport
  1288. */
  1289. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1290. /**
  1291. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1292. * @param renderWidth defines the rendering width
  1293. * @param renderHeight defines the rendering height
  1294. * @param ref defines the target viewport
  1295. * @returns the current viewport
  1296. */
  1297. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1298. /**
  1299. * Returns a new Viewport copied from the current one
  1300. * @returns a new Viewport
  1301. */
  1302. clone(): Viewport;
  1303. }
  1304. }
  1305. declare module "babylonjs/Misc/arrayTools" {
  1306. /**
  1307. * Class containing a set of static utilities functions for arrays.
  1308. */
  1309. export class ArrayTools {
  1310. /**
  1311. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1312. * @param size the number of element to construct and put in the array
  1313. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1314. * @returns a new array filled with new objects
  1315. */
  1316. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1317. }
  1318. }
  1319. declare module "babylonjs/Maths/math.like" {
  1320. import { float, int, DeepImmutable } from "babylonjs/types";
  1321. /**
  1322. * @hidden
  1323. */
  1324. export interface IColor4Like {
  1325. r: float;
  1326. g: float;
  1327. b: float;
  1328. a: float;
  1329. }
  1330. /**
  1331. * @hidden
  1332. */
  1333. export interface IColor3Like {
  1334. r: float;
  1335. g: float;
  1336. b: float;
  1337. }
  1338. /**
  1339. * @hidden
  1340. */
  1341. export interface IVector4Like {
  1342. x: float;
  1343. y: float;
  1344. z: float;
  1345. w: float;
  1346. }
  1347. /**
  1348. * @hidden
  1349. */
  1350. export interface IVector3Like {
  1351. x: float;
  1352. y: float;
  1353. z: float;
  1354. }
  1355. /**
  1356. * @hidden
  1357. */
  1358. export interface IVector2Like {
  1359. x: float;
  1360. y: float;
  1361. }
  1362. /**
  1363. * @hidden
  1364. */
  1365. export interface IMatrixLike {
  1366. toArray(): DeepImmutable<Float32Array>;
  1367. updateFlag: int;
  1368. }
  1369. /**
  1370. * @hidden
  1371. */
  1372. export interface IViewportLike {
  1373. x: float;
  1374. y: float;
  1375. width: float;
  1376. height: float;
  1377. }
  1378. /**
  1379. * @hidden
  1380. */
  1381. export interface IPlaneLike {
  1382. normal: IVector3Like;
  1383. d: float;
  1384. normalize(): void;
  1385. }
  1386. }
  1387. declare module "babylonjs/Maths/math.vector" {
  1388. import { Viewport } from "babylonjs/Maths/math.viewport";
  1389. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1390. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1391. /**
  1392. * Class representing a vector containing 2 coordinates
  1393. */
  1394. export class Vector2 {
  1395. /** defines the first coordinate */
  1396. x: number;
  1397. /** defines the second coordinate */
  1398. y: number;
  1399. /**
  1400. * Creates a new Vector2 from the given x and y coordinates
  1401. * @param x defines the first coordinate
  1402. * @param y defines the second coordinate
  1403. */
  1404. constructor(
  1405. /** defines the first coordinate */
  1406. x?: number,
  1407. /** defines the second coordinate */
  1408. y?: number);
  1409. /**
  1410. * Gets a string with the Vector2 coordinates
  1411. * @returns a string with the Vector2 coordinates
  1412. */
  1413. toString(): string;
  1414. /**
  1415. * Gets class name
  1416. * @returns the string "Vector2"
  1417. */
  1418. getClassName(): string;
  1419. /**
  1420. * Gets current vector hash code
  1421. * @returns the Vector2 hash code as a number
  1422. */
  1423. getHashCode(): number;
  1424. /**
  1425. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1426. * @param array defines the source array
  1427. * @param index defines the offset in source array
  1428. * @returns the current Vector2
  1429. */
  1430. toArray(array: FloatArray, index?: number): Vector2;
  1431. /**
  1432. * Copy the current vector to an array
  1433. * @returns a new array with 2 elements: the Vector2 coordinates.
  1434. */
  1435. asArray(): number[];
  1436. /**
  1437. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1438. * @param source defines the source Vector2
  1439. * @returns the current updated Vector2
  1440. */
  1441. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1442. /**
  1443. * Sets the Vector2 coordinates with the given floats
  1444. * @param x defines the first coordinate
  1445. * @param y defines the second coordinate
  1446. * @returns the current updated Vector2
  1447. */
  1448. copyFromFloats(x: number, y: number): Vector2;
  1449. /**
  1450. * Sets the Vector2 coordinates with the given floats
  1451. * @param x defines the first coordinate
  1452. * @param y defines the second coordinate
  1453. * @returns the current updated Vector2
  1454. */
  1455. set(x: number, y: number): Vector2;
  1456. /**
  1457. * Add another vector with the current one
  1458. * @param otherVector defines the other vector
  1459. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1460. */
  1461. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1462. /**
  1463. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1464. * @param otherVector defines the other vector
  1465. * @param result defines the target vector
  1466. * @returns the unmodified current Vector2
  1467. */
  1468. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1469. /**
  1470. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1471. * @param otherVector defines the other vector
  1472. * @returns the current updated Vector2
  1473. */
  1474. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1475. /**
  1476. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1477. * @param otherVector defines the other vector
  1478. * @returns a new Vector2
  1479. */
  1480. addVector3(otherVector: Vector3): Vector2;
  1481. /**
  1482. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1483. * @param otherVector defines the other vector
  1484. * @returns a new Vector2
  1485. */
  1486. subtract(otherVector: Vector2): Vector2;
  1487. /**
  1488. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1489. * @param otherVector defines the other vector
  1490. * @param result defines the target vector
  1491. * @returns the unmodified current Vector2
  1492. */
  1493. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1494. /**
  1495. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1496. * @param otherVector defines the other vector
  1497. * @returns the current updated Vector2
  1498. */
  1499. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1500. /**
  1501. * Multiplies in place the current Vector2 coordinates by the given ones
  1502. * @param otherVector defines the other vector
  1503. * @returns the current updated Vector2
  1504. */
  1505. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1506. /**
  1507. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1508. * @param otherVector defines the other vector
  1509. * @returns a new Vector2
  1510. */
  1511. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1512. /**
  1513. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1514. * @param otherVector defines the other vector
  1515. * @param result defines the target vector
  1516. * @returns the unmodified current Vector2
  1517. */
  1518. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1519. /**
  1520. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1521. * @param x defines the first coordinate
  1522. * @param y defines the second coordinate
  1523. * @returns a new Vector2
  1524. */
  1525. multiplyByFloats(x: number, y: number): Vector2;
  1526. /**
  1527. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1528. * @param otherVector defines the other vector
  1529. * @returns a new Vector2
  1530. */
  1531. divide(otherVector: Vector2): Vector2;
  1532. /**
  1533. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1534. * @param otherVector defines the other vector
  1535. * @param result defines the target vector
  1536. * @returns the unmodified current Vector2
  1537. */
  1538. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1539. /**
  1540. * Divides the current Vector2 coordinates by the given ones
  1541. * @param otherVector defines the other vector
  1542. * @returns the current updated Vector2
  1543. */
  1544. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1545. /**
  1546. * Gets a new Vector2 with current Vector2 negated coordinates
  1547. * @returns a new Vector2
  1548. */
  1549. negate(): Vector2;
  1550. /**
  1551. * Multiply the Vector2 coordinates by scale
  1552. * @param scale defines the scaling factor
  1553. * @returns the current updated Vector2
  1554. */
  1555. scaleInPlace(scale: number): Vector2;
  1556. /**
  1557. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1558. * @param scale defines the scaling factor
  1559. * @returns a new Vector2
  1560. */
  1561. scale(scale: number): Vector2;
  1562. /**
  1563. * Scale the current Vector2 values by a factor to a given Vector2
  1564. * @param scale defines the scale factor
  1565. * @param result defines the Vector2 object where to store the result
  1566. * @returns the unmodified current Vector2
  1567. */
  1568. scaleToRef(scale: number, result: Vector2): Vector2;
  1569. /**
  1570. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1571. * @param scale defines the scale factor
  1572. * @param result defines the Vector2 object where to store the result
  1573. * @returns the unmodified current Vector2
  1574. */
  1575. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1576. /**
  1577. * Gets a boolean if two vectors are equals
  1578. * @param otherVector defines the other vector
  1579. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1580. */
  1581. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1582. /**
  1583. * Gets a boolean if two vectors are equals (using an epsilon value)
  1584. * @param otherVector defines the other vector
  1585. * @param epsilon defines the minimal distance to consider equality
  1586. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1587. */
  1588. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1589. /**
  1590. * Gets a new Vector2 from current Vector2 floored values
  1591. * @returns a new Vector2
  1592. */
  1593. floor(): Vector2;
  1594. /**
  1595. * Gets a new Vector2 from current Vector2 floored values
  1596. * @returns a new Vector2
  1597. */
  1598. fract(): Vector2;
  1599. /**
  1600. * Gets the length of the vector
  1601. * @returns the vector length (float)
  1602. */
  1603. length(): number;
  1604. /**
  1605. * Gets the vector squared length
  1606. * @returns the vector squared length (float)
  1607. */
  1608. lengthSquared(): number;
  1609. /**
  1610. * Normalize the vector
  1611. * @returns the current updated Vector2
  1612. */
  1613. normalize(): Vector2;
  1614. /**
  1615. * Gets a new Vector2 copied from the Vector2
  1616. * @returns a new Vector2
  1617. */
  1618. clone(): Vector2;
  1619. /**
  1620. * Gets a new Vector2(0, 0)
  1621. * @returns a new Vector2
  1622. */
  1623. static Zero(): Vector2;
  1624. /**
  1625. * Gets a new Vector2(1, 1)
  1626. * @returns a new Vector2
  1627. */
  1628. static One(): Vector2;
  1629. /**
  1630. * Gets a new Vector2 set from the given index element of the given array
  1631. * @param array defines the data source
  1632. * @param offset defines the offset in the data source
  1633. * @returns a new Vector2
  1634. */
  1635. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1636. /**
  1637. * Sets "result" from the given index element of the given array
  1638. * @param array defines the data source
  1639. * @param offset defines the offset in the data source
  1640. * @param result defines the target vector
  1641. */
  1642. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1643. /**
  1644. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1645. * @param value1 defines 1st point of control
  1646. * @param value2 defines 2nd point of control
  1647. * @param value3 defines 3rd point of control
  1648. * @param value4 defines 4th point of control
  1649. * @param amount defines the interpolation factor
  1650. * @returns a new Vector2
  1651. */
  1652. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1653. /**
  1654. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1655. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1656. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1657. * @param value defines the value to clamp
  1658. * @param min defines the lower limit
  1659. * @param max defines the upper limit
  1660. * @returns a new Vector2
  1661. */
  1662. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1663. /**
  1664. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1665. * @param value1 defines the 1st control point
  1666. * @param tangent1 defines the outgoing tangent
  1667. * @param value2 defines the 2nd control point
  1668. * @param tangent2 defines the incoming tangent
  1669. * @param amount defines the interpolation factor
  1670. * @returns a new Vector2
  1671. */
  1672. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1673. /**
  1674. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1675. * @param start defines the start vector
  1676. * @param end defines the end vector
  1677. * @param amount defines the interpolation factor
  1678. * @returns a new Vector2
  1679. */
  1680. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1681. /**
  1682. * Gets the dot product of the vector "left" and the vector "right"
  1683. * @param left defines first vector
  1684. * @param right defines second vector
  1685. * @returns the dot product (float)
  1686. */
  1687. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1688. /**
  1689. * Returns a new Vector2 equal to the normalized given vector
  1690. * @param vector defines the vector to normalize
  1691. * @returns a new Vector2
  1692. */
  1693. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1694. /**
  1695. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1696. * @param left defines 1st vector
  1697. * @param right defines 2nd vector
  1698. * @returns a new Vector2
  1699. */
  1700. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1701. /**
  1702. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1703. * @param left defines 1st vector
  1704. * @param right defines 2nd vector
  1705. * @returns a new Vector2
  1706. */
  1707. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1708. /**
  1709. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1710. * @param vector defines the vector to transform
  1711. * @param transformation defines the matrix to apply
  1712. * @returns a new Vector2
  1713. */
  1714. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1715. /**
  1716. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1717. * @param vector defines the vector to transform
  1718. * @param transformation defines the matrix to apply
  1719. * @param result defines the target vector
  1720. */
  1721. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1722. /**
  1723. * Determines if a given vector is included in a triangle
  1724. * @param p defines the vector to test
  1725. * @param p0 defines 1st triangle point
  1726. * @param p1 defines 2nd triangle point
  1727. * @param p2 defines 3rd triangle point
  1728. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1729. */
  1730. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1731. /**
  1732. * Gets the distance between the vectors "value1" and "value2"
  1733. * @param value1 defines first vector
  1734. * @param value2 defines second vector
  1735. * @returns the distance between vectors
  1736. */
  1737. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1738. /**
  1739. * Returns the squared distance between the vectors "value1" and "value2"
  1740. * @param value1 defines first vector
  1741. * @param value2 defines second vector
  1742. * @returns the squared distance between vectors
  1743. */
  1744. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1745. /**
  1746. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1747. * @param value1 defines first vector
  1748. * @param value2 defines second vector
  1749. * @returns a new Vector2
  1750. */
  1751. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1752. /**
  1753. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1754. * @param p defines the middle point
  1755. * @param segA defines one point of the segment
  1756. * @param segB defines the other point of the segment
  1757. * @returns the shortest distance
  1758. */
  1759. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1760. }
  1761. /**
  1762. * Classed used to store (x,y,z) vector representation
  1763. * A Vector3 is the main object used in 3D geometry
  1764. * It can represent etiher the coordinates of a point the space, either a direction
  1765. * Reminder: js uses a left handed forward facing system
  1766. */
  1767. export class Vector3 {
  1768. /**
  1769. * Defines the first coordinates (on X axis)
  1770. */
  1771. x: number;
  1772. /**
  1773. * Defines the second coordinates (on Y axis)
  1774. */
  1775. y: number;
  1776. /**
  1777. * Defines the third coordinates (on Z axis)
  1778. */
  1779. z: number;
  1780. private static _UpReadOnly;
  1781. private static _ZeroReadOnly;
  1782. /**
  1783. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1784. * @param x defines the first coordinates (on X axis)
  1785. * @param y defines the second coordinates (on Y axis)
  1786. * @param z defines the third coordinates (on Z axis)
  1787. */
  1788. constructor(
  1789. /**
  1790. * Defines the first coordinates (on X axis)
  1791. */
  1792. x?: number,
  1793. /**
  1794. * Defines the second coordinates (on Y axis)
  1795. */
  1796. y?: number,
  1797. /**
  1798. * Defines the third coordinates (on Z axis)
  1799. */
  1800. z?: number);
  1801. /**
  1802. * Creates a string representation of the Vector3
  1803. * @returns a string with the Vector3 coordinates.
  1804. */
  1805. toString(): string;
  1806. /**
  1807. * Gets the class name
  1808. * @returns the string "Vector3"
  1809. */
  1810. getClassName(): string;
  1811. /**
  1812. * Creates the Vector3 hash code
  1813. * @returns a number which tends to be unique between Vector3 instances
  1814. */
  1815. getHashCode(): number;
  1816. /**
  1817. * Creates an array containing three elements : the coordinates of the Vector3
  1818. * @returns a new array of numbers
  1819. */
  1820. asArray(): number[];
  1821. /**
  1822. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1823. * @param array defines the destination array
  1824. * @param index defines the offset in the destination array
  1825. * @returns the current Vector3
  1826. */
  1827. toArray(array: FloatArray, index?: number): Vector3;
  1828. /**
  1829. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1830. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1831. */
  1832. toQuaternion(): Quaternion;
  1833. /**
  1834. * Adds the given vector to the current Vector3
  1835. * @param otherVector defines the second operand
  1836. * @returns the current updated Vector3
  1837. */
  1838. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1839. /**
  1840. * Adds the given coordinates to the current Vector3
  1841. * @param x defines the x coordinate of the operand
  1842. * @param y defines the y coordinate of the operand
  1843. * @param z defines the z coordinate of the operand
  1844. * @returns the current updated Vector3
  1845. */
  1846. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1847. /**
  1848. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1849. * @param otherVector defines the second operand
  1850. * @returns the resulting Vector3
  1851. */
  1852. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1853. /**
  1854. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1855. * @param otherVector defines the second operand
  1856. * @param result defines the Vector3 object where to store the result
  1857. * @returns the current Vector3
  1858. */
  1859. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1860. /**
  1861. * Subtract the given vector from the current Vector3
  1862. * @param otherVector defines the second operand
  1863. * @returns the current updated Vector3
  1864. */
  1865. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1866. /**
  1867. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1868. * @param otherVector defines the second operand
  1869. * @returns the resulting Vector3
  1870. */
  1871. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1872. /**
  1873. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1874. * @param otherVector defines the second operand
  1875. * @param result defines the Vector3 object where to store the result
  1876. * @returns the current Vector3
  1877. */
  1878. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1879. /**
  1880. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1881. * @param x defines the x coordinate of the operand
  1882. * @param y defines the y coordinate of the operand
  1883. * @param z defines the z coordinate of the operand
  1884. * @returns the resulting Vector3
  1885. */
  1886. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1887. /**
  1888. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1889. * @param x defines the x coordinate of the operand
  1890. * @param y defines the y coordinate of the operand
  1891. * @param z defines the z coordinate of the operand
  1892. * @param result defines the Vector3 object where to store the result
  1893. * @returns the current Vector3
  1894. */
  1895. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1896. /**
  1897. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1898. * @returns a new Vector3
  1899. */
  1900. negate(): Vector3;
  1901. /**
  1902. * Multiplies the Vector3 coordinates by the float "scale"
  1903. * @param scale defines the multiplier factor
  1904. * @returns the current updated Vector3
  1905. */
  1906. scaleInPlace(scale: number): Vector3;
  1907. /**
  1908. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1909. * @param scale defines the multiplier factor
  1910. * @returns a new Vector3
  1911. */
  1912. scale(scale: number): Vector3;
  1913. /**
  1914. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1915. * @param scale defines the multiplier factor
  1916. * @param result defines the Vector3 object where to store the result
  1917. * @returns the current Vector3
  1918. */
  1919. scaleToRef(scale: number, result: Vector3): Vector3;
  1920. /**
  1921. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1922. * @param scale defines the scale factor
  1923. * @param result defines the Vector3 object where to store the result
  1924. * @returns the unmodified current Vector3
  1925. */
  1926. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1927. /**
  1928. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1929. * @param otherVector defines the second operand
  1930. * @returns true if both vectors are equals
  1931. */
  1932. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1933. /**
  1934. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1935. * @param otherVector defines the second operand
  1936. * @param epsilon defines the minimal distance to define values as equals
  1937. * @returns true if both vectors are distant less than epsilon
  1938. */
  1939. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1940. /**
  1941. * Returns true if the current Vector3 coordinates equals the given floats
  1942. * @param x defines the x coordinate of the operand
  1943. * @param y defines the y coordinate of the operand
  1944. * @param z defines the z coordinate of the operand
  1945. * @returns true if both vectors are equals
  1946. */
  1947. equalsToFloats(x: number, y: number, z: number): boolean;
  1948. /**
  1949. * Multiplies the current Vector3 coordinates by the given ones
  1950. * @param otherVector defines the second operand
  1951. * @returns the current updated Vector3
  1952. */
  1953. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1954. /**
  1955. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1956. * @param otherVector defines the second operand
  1957. * @returns the new Vector3
  1958. */
  1959. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1960. /**
  1961. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1962. * @param otherVector defines the second operand
  1963. * @param result defines the Vector3 object where to store the result
  1964. * @returns the current Vector3
  1965. */
  1966. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1967. /**
  1968. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1969. * @param x defines the x coordinate of the operand
  1970. * @param y defines the y coordinate of the operand
  1971. * @param z defines the z coordinate of the operand
  1972. * @returns the new Vector3
  1973. */
  1974. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1975. /**
  1976. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1977. * @param otherVector defines the second operand
  1978. * @returns the new Vector3
  1979. */
  1980. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1981. /**
  1982. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1983. * @param otherVector defines the second operand
  1984. * @param result defines the Vector3 object where to store the result
  1985. * @returns the current Vector3
  1986. */
  1987. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1988. /**
  1989. * Divides the current Vector3 coordinates by the given ones.
  1990. * @param otherVector defines the second operand
  1991. * @returns the current updated Vector3
  1992. */
  1993. divideInPlace(otherVector: Vector3): Vector3;
  1994. /**
  1995. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1996. * @param other defines the second operand
  1997. * @returns the current updated Vector3
  1998. */
  1999. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2000. /**
  2001. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2002. * @param other defines the second operand
  2003. * @returns the current updated Vector3
  2004. */
  2005. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2006. /**
  2007. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2008. * @param x defines the x coordinate of the operand
  2009. * @param y defines the y coordinate of the operand
  2010. * @param z defines the z coordinate of the operand
  2011. * @returns the current updated Vector3
  2012. */
  2013. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2014. /**
  2015. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2016. * @param x defines the x coordinate of the operand
  2017. * @param y defines the y coordinate of the operand
  2018. * @param z defines the z coordinate of the operand
  2019. * @returns the current updated Vector3
  2020. */
  2021. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2022. /**
  2023. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2024. * Check if is non uniform within a certain amount of decimal places to account for this
  2025. * @param epsilon the amount the values can differ
  2026. * @returns if the the vector is non uniform to a certain number of decimal places
  2027. */
  2028. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2029. /**
  2030. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2031. */
  2032. readonly isNonUniform: boolean;
  2033. /**
  2034. * Gets a new Vector3 from current Vector3 floored values
  2035. * @returns a new Vector3
  2036. */
  2037. floor(): Vector3;
  2038. /**
  2039. * Gets a new Vector3 from current Vector3 floored values
  2040. * @returns a new Vector3
  2041. */
  2042. fract(): Vector3;
  2043. /**
  2044. * Gets the length of the Vector3
  2045. * @returns the length of the Vector3
  2046. */
  2047. length(): number;
  2048. /**
  2049. * Gets the squared length of the Vector3
  2050. * @returns squared length of the Vector3
  2051. */
  2052. lengthSquared(): number;
  2053. /**
  2054. * Normalize the current Vector3.
  2055. * Please note that this is an in place operation.
  2056. * @returns the current updated Vector3
  2057. */
  2058. normalize(): Vector3;
  2059. /**
  2060. * Reorders the x y z properties of the vector in place
  2061. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2062. * @returns the current updated vector
  2063. */
  2064. reorderInPlace(order: string): this;
  2065. /**
  2066. * Rotates the vector around 0,0,0 by a quaternion
  2067. * @param quaternion the rotation quaternion
  2068. * @param result vector to store the result
  2069. * @returns the resulting vector
  2070. */
  2071. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2072. /**
  2073. * Rotates a vector around a given point
  2074. * @param quaternion the rotation quaternion
  2075. * @param point the point to rotate around
  2076. * @param result vector to store the result
  2077. * @returns the resulting vector
  2078. */
  2079. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2080. /**
  2081. * Normalize the current Vector3 with the given input length.
  2082. * Please note that this is an in place operation.
  2083. * @param len the length of the vector
  2084. * @returns the current updated Vector3
  2085. */
  2086. normalizeFromLength(len: number): Vector3;
  2087. /**
  2088. * Normalize the current Vector3 to a new vector
  2089. * @returns the new Vector3
  2090. */
  2091. normalizeToNew(): Vector3;
  2092. /**
  2093. * Normalize the current Vector3 to the reference
  2094. * @param reference define the Vector3 to update
  2095. * @returns the updated Vector3
  2096. */
  2097. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2098. /**
  2099. * Creates a new Vector3 copied from the current Vector3
  2100. * @returns the new Vector3
  2101. */
  2102. clone(): Vector3;
  2103. /**
  2104. * Copies the given vector coordinates to the current Vector3 ones
  2105. * @param source defines the source Vector3
  2106. * @returns the current updated Vector3
  2107. */
  2108. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2109. /**
  2110. * Copies the given floats to the current Vector3 coordinates
  2111. * @param x defines the x coordinate of the operand
  2112. * @param y defines the y coordinate of the operand
  2113. * @param z defines the z coordinate of the operand
  2114. * @returns the current updated Vector3
  2115. */
  2116. copyFromFloats(x: number, y: number, z: number): Vector3;
  2117. /**
  2118. * Copies the given floats to the current Vector3 coordinates
  2119. * @param x defines the x coordinate of the operand
  2120. * @param y defines the y coordinate of the operand
  2121. * @param z defines the z coordinate of the operand
  2122. * @returns the current updated Vector3
  2123. */
  2124. set(x: number, y: number, z: number): Vector3;
  2125. /**
  2126. * Copies the given float to the current Vector3 coordinates
  2127. * @param v defines the x, y and z coordinates of the operand
  2128. * @returns the current updated Vector3
  2129. */
  2130. setAll(v: number): Vector3;
  2131. /**
  2132. * Get the clip factor between two vectors
  2133. * @param vector0 defines the first operand
  2134. * @param vector1 defines the second operand
  2135. * @param axis defines the axis to use
  2136. * @param size defines the size along the axis
  2137. * @returns the clip factor
  2138. */
  2139. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2140. /**
  2141. * Get angle between two vectors
  2142. * @param vector0 angle between vector0 and vector1
  2143. * @param vector1 angle between vector0 and vector1
  2144. * @param normal direction of the normal
  2145. * @return the angle between vector0 and vector1
  2146. */
  2147. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2148. /**
  2149. * Returns a new Vector3 set from the index "offset" of the given array
  2150. * @param array defines the source array
  2151. * @param offset defines the offset in the source array
  2152. * @returns the new Vector3
  2153. */
  2154. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2155. /**
  2156. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2157. * This function is deprecated. Use FromArray instead
  2158. * @param array defines the source array
  2159. * @param offset defines the offset in the source array
  2160. * @returns the new Vector3
  2161. */
  2162. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2163. /**
  2164. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2165. * @param array defines the source array
  2166. * @param offset defines the offset in the source array
  2167. * @param result defines the Vector3 where to store the result
  2168. */
  2169. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2170. /**
  2171. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2172. * This function is deprecated. Use FromArrayToRef instead.
  2173. * @param array defines the source array
  2174. * @param offset defines the offset in the source array
  2175. * @param result defines the Vector3 where to store the result
  2176. */
  2177. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2178. /**
  2179. * Sets the given vector "result" with the given floats.
  2180. * @param x defines the x coordinate of the source
  2181. * @param y defines the y coordinate of the source
  2182. * @param z defines the z coordinate of the source
  2183. * @param result defines the Vector3 where to store the result
  2184. */
  2185. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2186. /**
  2187. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2188. * @returns a new empty Vector3
  2189. */
  2190. static Zero(): Vector3;
  2191. /**
  2192. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2193. * @returns a new unit Vector3
  2194. */
  2195. static One(): Vector3;
  2196. /**
  2197. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2198. * @returns a new up Vector3
  2199. */
  2200. static Up(): Vector3;
  2201. /**
  2202. * Gets a up Vector3 that must not be updated
  2203. */
  2204. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2205. /**
  2206. * Gets a zero Vector3 that must not be updated
  2207. */
  2208. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2209. /**
  2210. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2211. * @returns a new down Vector3
  2212. */
  2213. static Down(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2216. * @returns a new forward Vector3
  2217. */
  2218. static Forward(): Vector3;
  2219. /**
  2220. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2221. * @returns a new forward Vector3
  2222. */
  2223. static Backward(): Vector3;
  2224. /**
  2225. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2226. * @returns a new right Vector3
  2227. */
  2228. static Right(): Vector3;
  2229. /**
  2230. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2231. * @returns a new left Vector3
  2232. */
  2233. static Left(): Vector3;
  2234. /**
  2235. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2236. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2237. * @param vector defines the Vector3 to transform
  2238. * @param transformation defines the transformation matrix
  2239. * @returns the transformed Vector3
  2240. */
  2241. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2242. /**
  2243. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2244. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2245. * @param vector defines the Vector3 to transform
  2246. * @param transformation defines the transformation matrix
  2247. * @param result defines the Vector3 where to store the result
  2248. */
  2249. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2250. /**
  2251. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2252. * This method computes tranformed coordinates only, not transformed direction vectors
  2253. * @param x define the x coordinate of the source vector
  2254. * @param y define the y coordinate of the source vector
  2255. * @param z define the z coordinate of the source vector
  2256. * @param transformation defines the transformation matrix
  2257. * @param result defines the Vector3 where to store the result
  2258. */
  2259. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2260. /**
  2261. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2262. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2263. * @param vector defines the Vector3 to transform
  2264. * @param transformation defines the transformation matrix
  2265. * @returns the new Vector3
  2266. */
  2267. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2268. /**
  2269. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2270. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2271. * @param vector defines the Vector3 to transform
  2272. * @param transformation defines the transformation matrix
  2273. * @param result defines the Vector3 where to store the result
  2274. */
  2275. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2276. /**
  2277. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2278. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2279. * @param x define the x coordinate of the source vector
  2280. * @param y define the y coordinate of the source vector
  2281. * @param z define the z coordinate of the source vector
  2282. * @param transformation defines the transformation matrix
  2283. * @param result defines the Vector3 where to store the result
  2284. */
  2285. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2286. /**
  2287. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2288. * @param value1 defines the first control point
  2289. * @param value2 defines the second control point
  2290. * @param value3 defines the third control point
  2291. * @param value4 defines the fourth control point
  2292. * @param amount defines the amount on the spline to use
  2293. * @returns the new Vector3
  2294. */
  2295. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2296. /**
  2297. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2298. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2299. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2300. * @param value defines the current value
  2301. * @param min defines the lower range value
  2302. * @param max defines the upper range value
  2303. * @returns the new Vector3
  2304. */
  2305. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2306. /**
  2307. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2308. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2309. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2310. * @param value defines the current value
  2311. * @param min defines the lower range value
  2312. * @param max defines the upper range value
  2313. * @param result defines the Vector3 where to store the result
  2314. */
  2315. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2316. /**
  2317. * Checks if a given vector is inside a specific range
  2318. * @param v defines the vector to test
  2319. * @param min defines the minimum range
  2320. * @param max defines the maximum range
  2321. */
  2322. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2323. /**
  2324. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2325. * @param value1 defines the first control point
  2326. * @param tangent1 defines the first tangent vector
  2327. * @param value2 defines the second control point
  2328. * @param tangent2 defines the second tangent vector
  2329. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2330. * @returns the new Vector3
  2331. */
  2332. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2333. /**
  2334. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2335. * @param start defines the start value
  2336. * @param end defines the end value
  2337. * @param amount max defines amount between both (between 0 and 1)
  2338. * @returns the new Vector3
  2339. */
  2340. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2341. /**
  2342. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2343. * @param start defines the start value
  2344. * @param end defines the end value
  2345. * @param amount max defines amount between both (between 0 and 1)
  2346. * @param result defines the Vector3 where to store the result
  2347. */
  2348. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2349. /**
  2350. * Returns the dot product (float) between the vectors "left" and "right"
  2351. * @param left defines the left operand
  2352. * @param right defines the right operand
  2353. * @returns the dot product
  2354. */
  2355. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2356. /**
  2357. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2358. * The cross product is then orthogonal to both "left" and "right"
  2359. * @param left defines the left operand
  2360. * @param right defines the right operand
  2361. * @returns the cross product
  2362. */
  2363. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2364. /**
  2365. * Sets the given vector "result" with the cross product of "left" and "right"
  2366. * The cross product is then orthogonal to both "left" and "right"
  2367. * @param left defines the left operand
  2368. * @param right defines the right operand
  2369. * @param result defines the Vector3 where to store the result
  2370. */
  2371. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2372. /**
  2373. * Returns a new Vector3 as the normalization of the given vector
  2374. * @param vector defines the Vector3 to normalize
  2375. * @returns the new Vector3
  2376. */
  2377. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2378. /**
  2379. * Sets the given vector "result" with the normalization of the given first vector
  2380. * @param vector defines the Vector3 to normalize
  2381. * @param result defines the Vector3 where to store the result
  2382. */
  2383. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2384. /**
  2385. * Project a Vector3 onto screen space
  2386. * @param vector defines the Vector3 to project
  2387. * @param world defines the world matrix to use
  2388. * @param transform defines the transform (view x projection) matrix to use
  2389. * @param viewport defines the screen viewport to use
  2390. * @returns the new Vector3
  2391. */
  2392. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2393. /** @hidden */
  2394. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2395. /**
  2396. * Unproject from screen space to object space
  2397. * @param source defines the screen space Vector3 to use
  2398. * @param viewportWidth defines the current width of the viewport
  2399. * @param viewportHeight defines the current height of the viewport
  2400. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2401. * @param transform defines the transform (view x projection) matrix to use
  2402. * @returns the new Vector3
  2403. */
  2404. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2405. /**
  2406. * Unproject from screen space to object space
  2407. * @param source defines the screen space Vector3 to use
  2408. * @param viewportWidth defines the current width of the viewport
  2409. * @param viewportHeight defines the current height of the viewport
  2410. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2411. * @param view defines the view matrix to use
  2412. * @param projection defines the projection matrix to use
  2413. * @returns the new Vector3
  2414. */
  2415. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2416. /**
  2417. * Unproject from screen space to object space
  2418. * @param source defines the screen space Vector3 to use
  2419. * @param viewportWidth defines the current width of the viewport
  2420. * @param viewportHeight defines the current height of the viewport
  2421. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2422. * @param view defines the view matrix to use
  2423. * @param projection defines the projection matrix to use
  2424. * @param result defines the Vector3 where to store the result
  2425. */
  2426. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2427. /**
  2428. * Unproject from screen space to object space
  2429. * @param sourceX defines the screen space x coordinate to use
  2430. * @param sourceY defines the screen space y coordinate to use
  2431. * @param sourceZ defines the screen space z coordinate to use
  2432. * @param viewportWidth defines the current width of the viewport
  2433. * @param viewportHeight defines the current height of the viewport
  2434. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2435. * @param view defines the view matrix to use
  2436. * @param projection defines the projection matrix to use
  2437. * @param result defines the Vector3 where to store the result
  2438. */
  2439. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2440. /**
  2441. * Gets the minimal coordinate values between two Vector3
  2442. * @param left defines the first operand
  2443. * @param right defines the second operand
  2444. * @returns the new Vector3
  2445. */
  2446. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2447. /**
  2448. * Gets the maximal coordinate values between two Vector3
  2449. * @param left defines the first operand
  2450. * @param right defines the second operand
  2451. * @returns the new Vector3
  2452. */
  2453. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2454. /**
  2455. * Returns the distance between the vectors "value1" and "value2"
  2456. * @param value1 defines the first operand
  2457. * @param value2 defines the second operand
  2458. * @returns the distance
  2459. */
  2460. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2461. /**
  2462. * Returns the squared distance between the vectors "value1" and "value2"
  2463. * @param value1 defines the first operand
  2464. * @param value2 defines the second operand
  2465. * @returns the squared distance
  2466. */
  2467. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2468. /**
  2469. * Returns a new Vector3 located at the center between "value1" and "value2"
  2470. * @param value1 defines the first operand
  2471. * @param value2 defines the second operand
  2472. * @returns the new Vector3
  2473. */
  2474. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2475. /**
  2476. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2477. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2478. * to something in order to rotate it from its local system to the given target system
  2479. * Note: axis1, axis2 and axis3 are normalized during this operation
  2480. * @param axis1 defines the first axis
  2481. * @param axis2 defines the second axis
  2482. * @param axis3 defines the third axis
  2483. * @returns a new Vector3
  2484. */
  2485. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2486. /**
  2487. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2488. * @param axis1 defines the first axis
  2489. * @param axis2 defines the second axis
  2490. * @param axis3 defines the third axis
  2491. * @param ref defines the Vector3 where to store the result
  2492. */
  2493. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2494. }
  2495. /**
  2496. * Vector4 class created for EulerAngle class conversion to Quaternion
  2497. */
  2498. export class Vector4 {
  2499. /** x value of the vector */
  2500. x: number;
  2501. /** y value of the vector */
  2502. y: number;
  2503. /** z value of the vector */
  2504. z: number;
  2505. /** w value of the vector */
  2506. w: number;
  2507. /**
  2508. * Creates a Vector4 object from the given floats.
  2509. * @param x x value of the vector
  2510. * @param y y value of the vector
  2511. * @param z z value of the vector
  2512. * @param w w value of the vector
  2513. */
  2514. constructor(
  2515. /** x value of the vector */
  2516. x: number,
  2517. /** y value of the vector */
  2518. y: number,
  2519. /** z value of the vector */
  2520. z: number,
  2521. /** w value of the vector */
  2522. w: number);
  2523. /**
  2524. * Returns the string with the Vector4 coordinates.
  2525. * @returns a string containing all the vector values
  2526. */
  2527. toString(): string;
  2528. /**
  2529. * Returns the string "Vector4".
  2530. * @returns "Vector4"
  2531. */
  2532. getClassName(): string;
  2533. /**
  2534. * Returns the Vector4 hash code.
  2535. * @returns a unique hash code
  2536. */
  2537. getHashCode(): number;
  2538. /**
  2539. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2540. * @returns the resulting array
  2541. */
  2542. asArray(): number[];
  2543. /**
  2544. * Populates the given array from the given index with the Vector4 coordinates.
  2545. * @param array array to populate
  2546. * @param index index of the array to start at (default: 0)
  2547. * @returns the Vector4.
  2548. */
  2549. toArray(array: FloatArray, index?: number): Vector4;
  2550. /**
  2551. * Adds the given vector to the current Vector4.
  2552. * @param otherVector the vector to add
  2553. * @returns the updated Vector4.
  2554. */
  2555. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2556. /**
  2557. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2558. * @param otherVector the vector to add
  2559. * @returns the resulting vector
  2560. */
  2561. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2562. /**
  2563. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2564. * @param otherVector the vector to add
  2565. * @param result the vector to store the result
  2566. * @returns the current Vector4.
  2567. */
  2568. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2569. /**
  2570. * Subtract in place the given vector from the current Vector4.
  2571. * @param otherVector the vector to subtract
  2572. * @returns the updated Vector4.
  2573. */
  2574. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2575. /**
  2576. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2577. * @param otherVector the vector to add
  2578. * @returns the new vector with the result
  2579. */
  2580. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2581. /**
  2582. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2583. * @param otherVector the vector to subtract
  2584. * @param result the vector to store the result
  2585. * @returns the current Vector4.
  2586. */
  2587. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2588. /**
  2589. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2590. */
  2591. /**
  2592. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2593. * @param x value to subtract
  2594. * @param y value to subtract
  2595. * @param z value to subtract
  2596. * @param w value to subtract
  2597. * @returns new vector containing the result
  2598. */
  2599. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2600. /**
  2601. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2602. * @param x value to subtract
  2603. * @param y value to subtract
  2604. * @param z value to subtract
  2605. * @param w value to subtract
  2606. * @param result the vector to store the result in
  2607. * @returns the current Vector4.
  2608. */
  2609. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2610. /**
  2611. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2612. * @returns a new vector with the negated values
  2613. */
  2614. negate(): Vector4;
  2615. /**
  2616. * Multiplies the current Vector4 coordinates by scale (float).
  2617. * @param scale the number to scale with
  2618. * @returns the updated Vector4.
  2619. */
  2620. scaleInPlace(scale: number): Vector4;
  2621. /**
  2622. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2623. * @param scale the number to scale with
  2624. * @returns a new vector with the result
  2625. */
  2626. scale(scale: number): Vector4;
  2627. /**
  2628. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2629. * @param scale the number to scale with
  2630. * @param result a vector to store the result in
  2631. * @returns the current Vector4.
  2632. */
  2633. scaleToRef(scale: number, result: Vector4): Vector4;
  2634. /**
  2635. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2636. * @param scale defines the scale factor
  2637. * @param result defines the Vector4 object where to store the result
  2638. * @returns the unmodified current Vector4
  2639. */
  2640. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2641. /**
  2642. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2643. * @param otherVector the vector to compare against
  2644. * @returns true if they are equal
  2645. */
  2646. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2647. /**
  2648. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2649. * @param otherVector vector to compare against
  2650. * @param epsilon (Default: very small number)
  2651. * @returns true if they are equal
  2652. */
  2653. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2654. /**
  2655. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2656. * @param x x value to compare against
  2657. * @param y y value to compare against
  2658. * @param z z value to compare against
  2659. * @param w w value to compare against
  2660. * @returns true if equal
  2661. */
  2662. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2663. /**
  2664. * Multiplies in place the current Vector4 by the given one.
  2665. * @param otherVector vector to multiple with
  2666. * @returns the updated Vector4.
  2667. */
  2668. multiplyInPlace(otherVector: Vector4): Vector4;
  2669. /**
  2670. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2671. * @param otherVector vector to multiple with
  2672. * @returns resulting new vector
  2673. */
  2674. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2675. /**
  2676. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2677. * @param otherVector vector to multiple with
  2678. * @param result vector to store the result
  2679. * @returns the current Vector4.
  2680. */
  2681. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2682. /**
  2683. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2684. * @param x x value multiply with
  2685. * @param y y value multiply with
  2686. * @param z z value multiply with
  2687. * @param w w value multiply with
  2688. * @returns resulting new vector
  2689. */
  2690. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2691. /**
  2692. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2693. * @param otherVector vector to devide with
  2694. * @returns resulting new vector
  2695. */
  2696. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2697. /**
  2698. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2699. * @param otherVector vector to devide with
  2700. * @param result vector to store the result
  2701. * @returns the current Vector4.
  2702. */
  2703. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2704. /**
  2705. * Divides the current Vector3 coordinates by the given ones.
  2706. * @param otherVector vector to devide with
  2707. * @returns the updated Vector3.
  2708. */
  2709. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2710. /**
  2711. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2712. * @param other defines the second operand
  2713. * @returns the current updated Vector4
  2714. */
  2715. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2716. /**
  2717. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2718. * @param other defines the second operand
  2719. * @returns the current updated Vector4
  2720. */
  2721. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2722. /**
  2723. * Gets a new Vector4 from current Vector4 floored values
  2724. * @returns a new Vector4
  2725. */
  2726. floor(): Vector4;
  2727. /**
  2728. * Gets a new Vector4 from current Vector3 floored values
  2729. * @returns a new Vector4
  2730. */
  2731. fract(): Vector4;
  2732. /**
  2733. * Returns the Vector4 length (float).
  2734. * @returns the length
  2735. */
  2736. length(): number;
  2737. /**
  2738. * Returns the Vector4 squared length (float).
  2739. * @returns the length squared
  2740. */
  2741. lengthSquared(): number;
  2742. /**
  2743. * Normalizes in place the Vector4.
  2744. * @returns the updated Vector4.
  2745. */
  2746. normalize(): Vector4;
  2747. /**
  2748. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2749. * @returns this converted to a new vector3
  2750. */
  2751. toVector3(): Vector3;
  2752. /**
  2753. * Returns a new Vector4 copied from the current one.
  2754. * @returns the new cloned vector
  2755. */
  2756. clone(): Vector4;
  2757. /**
  2758. * Updates the current Vector4 with the given one coordinates.
  2759. * @param source the source vector to copy from
  2760. * @returns the updated Vector4.
  2761. */
  2762. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2763. /**
  2764. * Updates the current Vector4 coordinates with the given floats.
  2765. * @param x float to copy from
  2766. * @param y float to copy from
  2767. * @param z float to copy from
  2768. * @param w float to copy from
  2769. * @returns the updated Vector4.
  2770. */
  2771. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2772. /**
  2773. * Updates the current Vector4 coordinates with the given floats.
  2774. * @param x float to set from
  2775. * @param y float to set from
  2776. * @param z float to set from
  2777. * @param w float to set from
  2778. * @returns the updated Vector4.
  2779. */
  2780. set(x: number, y: number, z: number, w: number): Vector4;
  2781. /**
  2782. * Copies the given float to the current Vector3 coordinates
  2783. * @param v defines the x, y, z and w coordinates of the operand
  2784. * @returns the current updated Vector3
  2785. */
  2786. setAll(v: number): Vector4;
  2787. /**
  2788. * Returns a new Vector4 set from the starting index of the given array.
  2789. * @param array the array to pull values from
  2790. * @param offset the offset into the array to start at
  2791. * @returns the new vector
  2792. */
  2793. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2794. /**
  2795. * Updates the given vector "result" from the starting index of the given array.
  2796. * @param array the array to pull values from
  2797. * @param offset the offset into the array to start at
  2798. * @param result the vector to store the result in
  2799. */
  2800. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2801. /**
  2802. * Updates the given vector "result" from the starting index of the given Float32Array.
  2803. * @param array the array to pull values from
  2804. * @param offset the offset into the array to start at
  2805. * @param result the vector to store the result in
  2806. */
  2807. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2808. /**
  2809. * Updates the given vector "result" coordinates from the given floats.
  2810. * @param x float to set from
  2811. * @param y float to set from
  2812. * @param z float to set from
  2813. * @param w float to set from
  2814. * @param result the vector to the floats in
  2815. */
  2816. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2817. /**
  2818. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2819. * @returns the new vector
  2820. */
  2821. static Zero(): Vector4;
  2822. /**
  2823. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2824. * @returns the new vector
  2825. */
  2826. static One(): Vector4;
  2827. /**
  2828. * Returns a new normalized Vector4 from the given one.
  2829. * @param vector the vector to normalize
  2830. * @returns the vector
  2831. */
  2832. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2833. /**
  2834. * Updates the given vector "result" from the normalization of the given one.
  2835. * @param vector the vector to normalize
  2836. * @param result the vector to store the result in
  2837. */
  2838. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2839. /**
  2840. * Returns a vector with the minimum values from the left and right vectors
  2841. * @param left left vector to minimize
  2842. * @param right right vector to minimize
  2843. * @returns a new vector with the minimum of the left and right vector values
  2844. */
  2845. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2846. /**
  2847. * Returns a vector with the maximum values from the left and right vectors
  2848. * @param left left vector to maximize
  2849. * @param right right vector to maximize
  2850. * @returns a new vector with the maximum of the left and right vector values
  2851. */
  2852. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2853. /**
  2854. * Returns the distance (float) between the vectors "value1" and "value2".
  2855. * @param value1 value to calulate the distance between
  2856. * @param value2 value to calulate the distance between
  2857. * @return the distance between the two vectors
  2858. */
  2859. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2860. /**
  2861. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2862. * @param value1 value to calulate the distance between
  2863. * @param value2 value to calulate the distance between
  2864. * @return the distance between the two vectors squared
  2865. */
  2866. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2867. /**
  2868. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2869. * @param value1 value to calulate the center between
  2870. * @param value2 value to calulate the center between
  2871. * @return the center between the two vectors
  2872. */
  2873. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2874. /**
  2875. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2876. * This methods computes transformed normalized direction vectors only.
  2877. * @param vector the vector to transform
  2878. * @param transformation the transformation matrix to apply
  2879. * @returns the new vector
  2880. */
  2881. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2882. /**
  2883. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2884. * This methods computes transformed normalized direction vectors only.
  2885. * @param vector the vector to transform
  2886. * @param transformation the transformation matrix to apply
  2887. * @param result the vector to store the result in
  2888. */
  2889. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2890. /**
  2891. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2892. * This methods computes transformed normalized direction vectors only.
  2893. * @param x value to transform
  2894. * @param y value to transform
  2895. * @param z value to transform
  2896. * @param w value to transform
  2897. * @param transformation the transformation matrix to apply
  2898. * @param result the vector to store the results in
  2899. */
  2900. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2901. /**
  2902. * Creates a new Vector4 from a Vector3
  2903. * @param source defines the source data
  2904. * @param w defines the 4th component (default is 0)
  2905. * @returns a new Vector4
  2906. */
  2907. static FromVector3(source: Vector3, w?: number): Vector4;
  2908. }
  2909. /**
  2910. * Class used to store quaternion data
  2911. * @see https://en.wikipedia.org/wiki/Quaternion
  2912. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2913. */
  2914. export class Quaternion {
  2915. /** defines the first component (0 by default) */
  2916. x: number;
  2917. /** defines the second component (0 by default) */
  2918. y: number;
  2919. /** defines the third component (0 by default) */
  2920. z: number;
  2921. /** defines the fourth component (1.0 by default) */
  2922. w: number;
  2923. /**
  2924. * Creates a new Quaternion from the given floats
  2925. * @param x defines the first component (0 by default)
  2926. * @param y defines the second component (0 by default)
  2927. * @param z defines the third component (0 by default)
  2928. * @param w defines the fourth component (1.0 by default)
  2929. */
  2930. constructor(
  2931. /** defines the first component (0 by default) */
  2932. x?: number,
  2933. /** defines the second component (0 by default) */
  2934. y?: number,
  2935. /** defines the third component (0 by default) */
  2936. z?: number,
  2937. /** defines the fourth component (1.0 by default) */
  2938. w?: number);
  2939. /**
  2940. * Gets a string representation for the current quaternion
  2941. * @returns a string with the Quaternion coordinates
  2942. */
  2943. toString(): string;
  2944. /**
  2945. * Gets the class name of the quaternion
  2946. * @returns the string "Quaternion"
  2947. */
  2948. getClassName(): string;
  2949. /**
  2950. * Gets a hash code for this quaternion
  2951. * @returns the quaternion hash code
  2952. */
  2953. getHashCode(): number;
  2954. /**
  2955. * Copy the quaternion to an array
  2956. * @returns a new array populated with 4 elements from the quaternion coordinates
  2957. */
  2958. asArray(): number[];
  2959. /**
  2960. * Check if two quaternions are equals
  2961. * @param otherQuaternion defines the second operand
  2962. * @return true if the current quaternion and the given one coordinates are strictly equals
  2963. */
  2964. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2965. /**
  2966. * Clone the current quaternion
  2967. * @returns a new quaternion copied from the current one
  2968. */
  2969. clone(): Quaternion;
  2970. /**
  2971. * Copy a quaternion to the current one
  2972. * @param other defines the other quaternion
  2973. * @returns the updated current quaternion
  2974. */
  2975. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2976. /**
  2977. * Updates the current quaternion with the given float coordinates
  2978. * @param x defines the x coordinate
  2979. * @param y defines the y coordinate
  2980. * @param z defines the z coordinate
  2981. * @param w defines the w coordinate
  2982. * @returns the updated current quaternion
  2983. */
  2984. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2985. /**
  2986. * Updates the current quaternion from the given float coordinates
  2987. * @param x defines the x coordinate
  2988. * @param y defines the y coordinate
  2989. * @param z defines the z coordinate
  2990. * @param w defines the w coordinate
  2991. * @returns the updated current quaternion
  2992. */
  2993. set(x: number, y: number, z: number, w: number): Quaternion;
  2994. /**
  2995. * Adds two quaternions
  2996. * @param other defines the second operand
  2997. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2998. */
  2999. add(other: DeepImmutable<Quaternion>): Quaternion;
  3000. /**
  3001. * Add a quaternion to the current one
  3002. * @param other defines the quaternion to add
  3003. * @returns the current quaternion
  3004. */
  3005. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3006. /**
  3007. * Subtract two quaternions
  3008. * @param other defines the second operand
  3009. * @returns a new quaternion as the subtraction result of the given one from the current one
  3010. */
  3011. subtract(other: Quaternion): Quaternion;
  3012. /**
  3013. * Multiplies the current quaternion by a scale factor
  3014. * @param value defines the scale factor
  3015. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3016. */
  3017. scale(value: number): Quaternion;
  3018. /**
  3019. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3020. * @param scale defines the scale factor
  3021. * @param result defines the Quaternion object where to store the result
  3022. * @returns the unmodified current quaternion
  3023. */
  3024. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3025. /**
  3026. * Multiplies in place the current quaternion by a scale factor
  3027. * @param value defines the scale factor
  3028. * @returns the current modified quaternion
  3029. */
  3030. scaleInPlace(value: number): Quaternion;
  3031. /**
  3032. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3033. * @param scale defines the scale factor
  3034. * @param result defines the Quaternion object where to store the result
  3035. * @returns the unmodified current quaternion
  3036. */
  3037. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3038. /**
  3039. * Multiplies two quaternions
  3040. * @param q1 defines the second operand
  3041. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3042. */
  3043. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3044. /**
  3045. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3046. * @param q1 defines the second operand
  3047. * @param result defines the target quaternion
  3048. * @returns the current quaternion
  3049. */
  3050. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3051. /**
  3052. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3053. * @param q1 defines the second operand
  3054. * @returns the currentupdated quaternion
  3055. */
  3056. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3057. /**
  3058. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3059. * @param ref defines the target quaternion
  3060. * @returns the current quaternion
  3061. */
  3062. conjugateToRef(ref: Quaternion): Quaternion;
  3063. /**
  3064. * Conjugates in place (1-q) the current quaternion
  3065. * @returns the current updated quaternion
  3066. */
  3067. conjugateInPlace(): Quaternion;
  3068. /**
  3069. * Conjugates in place (1-q) the current quaternion
  3070. * @returns a new quaternion
  3071. */
  3072. conjugate(): Quaternion;
  3073. /**
  3074. * Gets length of current quaternion
  3075. * @returns the quaternion length (float)
  3076. */
  3077. length(): number;
  3078. /**
  3079. * Normalize in place the current quaternion
  3080. * @returns the current updated quaternion
  3081. */
  3082. normalize(): Quaternion;
  3083. /**
  3084. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3085. * @param order is a reserved parameter and is ignore for now
  3086. * @returns a new Vector3 containing the Euler angles
  3087. */
  3088. toEulerAngles(order?: string): Vector3;
  3089. /**
  3090. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3091. * @param result defines the vector which will be filled with the Euler angles
  3092. * @param order is a reserved parameter and is ignore for now
  3093. * @returns the current unchanged quaternion
  3094. */
  3095. toEulerAnglesToRef(result: Vector3): Quaternion;
  3096. /**
  3097. * Updates the given rotation matrix with the current quaternion values
  3098. * @param result defines the target matrix
  3099. * @returns the current unchanged quaternion
  3100. */
  3101. toRotationMatrix(result: Matrix): Quaternion;
  3102. /**
  3103. * Updates the current quaternion from the given rotation matrix values
  3104. * @param matrix defines the source matrix
  3105. * @returns the current updated quaternion
  3106. */
  3107. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3108. /**
  3109. * Creates a new quaternion from a rotation matrix
  3110. * @param matrix defines the source matrix
  3111. * @returns a new quaternion created from the given rotation matrix values
  3112. */
  3113. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3114. /**
  3115. * Updates the given quaternion with the given rotation matrix values
  3116. * @param matrix defines the source matrix
  3117. * @param result defines the target quaternion
  3118. */
  3119. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3120. /**
  3121. * Returns the dot product (float) between the quaternions "left" and "right"
  3122. * @param left defines the left operand
  3123. * @param right defines the right operand
  3124. * @returns the dot product
  3125. */
  3126. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3127. /**
  3128. * Checks if the two quaternions are close to each other
  3129. * @param quat0 defines the first quaternion to check
  3130. * @param quat1 defines the second quaternion to check
  3131. * @returns true if the two quaternions are close to each other
  3132. */
  3133. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3134. /**
  3135. * Creates an empty quaternion
  3136. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3137. */
  3138. static Zero(): Quaternion;
  3139. /**
  3140. * Inverse a given quaternion
  3141. * @param q defines the source quaternion
  3142. * @returns a new quaternion as the inverted current quaternion
  3143. */
  3144. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3145. /**
  3146. * Inverse a given quaternion
  3147. * @param q defines the source quaternion
  3148. * @param result the quaternion the result will be stored in
  3149. * @returns the result quaternion
  3150. */
  3151. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3152. /**
  3153. * Creates an identity quaternion
  3154. * @returns the identity quaternion
  3155. */
  3156. static Identity(): Quaternion;
  3157. /**
  3158. * Gets a boolean indicating if the given quaternion is identity
  3159. * @param quaternion defines the quaternion to check
  3160. * @returns true if the quaternion is identity
  3161. */
  3162. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3163. /**
  3164. * Creates a quaternion from a rotation around an axis
  3165. * @param axis defines the axis to use
  3166. * @param angle defines the angle to use
  3167. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3168. */
  3169. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3170. /**
  3171. * Creates a rotation around an axis and stores it into the given quaternion
  3172. * @param axis defines the axis to use
  3173. * @param angle defines the angle to use
  3174. * @param result defines the target quaternion
  3175. * @returns the target quaternion
  3176. */
  3177. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3178. /**
  3179. * Creates a new quaternion from data stored into an array
  3180. * @param array defines the data source
  3181. * @param offset defines the offset in the source array where the data starts
  3182. * @returns a new quaternion
  3183. */
  3184. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3185. /**
  3186. * Create a quaternion from Euler rotation angles
  3187. * @param x Pitch
  3188. * @param y Yaw
  3189. * @param z Roll
  3190. * @returns the new Quaternion
  3191. */
  3192. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3193. /**
  3194. * Updates a quaternion from Euler rotation angles
  3195. * @param x Pitch
  3196. * @param y Yaw
  3197. * @param z Roll
  3198. * @param result the quaternion to store the result
  3199. * @returns the updated quaternion
  3200. */
  3201. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3202. /**
  3203. * Create a quaternion from Euler rotation vector
  3204. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3205. * @returns the new Quaternion
  3206. */
  3207. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3208. /**
  3209. * Updates a quaternion from Euler rotation vector
  3210. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3211. * @param result the quaternion to store the result
  3212. * @returns the updated quaternion
  3213. */
  3214. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3215. /**
  3216. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3217. * @param yaw defines the rotation around Y axis
  3218. * @param pitch defines the rotation around X axis
  3219. * @param roll defines the rotation around Z axis
  3220. * @returns the new quaternion
  3221. */
  3222. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3223. /**
  3224. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3225. * @param yaw defines the rotation around Y axis
  3226. * @param pitch defines the rotation around X axis
  3227. * @param roll defines the rotation around Z axis
  3228. * @param result defines the target quaternion
  3229. */
  3230. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3231. /**
  3232. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3233. * @param alpha defines the rotation around first axis
  3234. * @param beta defines the rotation around second axis
  3235. * @param gamma defines the rotation around third axis
  3236. * @returns the new quaternion
  3237. */
  3238. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3239. /**
  3240. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3241. * @param alpha defines the rotation around first axis
  3242. * @param beta defines the rotation around second axis
  3243. * @param gamma defines the rotation around third axis
  3244. * @param result defines the target quaternion
  3245. */
  3246. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3247. /**
  3248. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3249. * @param axis1 defines the first axis
  3250. * @param axis2 defines the second axis
  3251. * @param axis3 defines the third axis
  3252. * @returns the new quaternion
  3253. */
  3254. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3255. /**
  3256. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3257. * @param axis1 defines the first axis
  3258. * @param axis2 defines the second axis
  3259. * @param axis3 defines the third axis
  3260. * @param ref defines the target quaternion
  3261. */
  3262. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3263. /**
  3264. * Interpolates between two quaternions
  3265. * @param left defines first quaternion
  3266. * @param right defines second quaternion
  3267. * @param amount defines the gradient to use
  3268. * @returns the new interpolated quaternion
  3269. */
  3270. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3271. /**
  3272. * Interpolates between two quaternions and stores it into a target quaternion
  3273. * @param left defines first quaternion
  3274. * @param right defines second quaternion
  3275. * @param amount defines the gradient to use
  3276. * @param result defines the target quaternion
  3277. */
  3278. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3279. /**
  3280. * Interpolate between two quaternions using Hermite interpolation
  3281. * @param value1 defines first quaternion
  3282. * @param tangent1 defines the incoming tangent
  3283. * @param value2 defines second quaternion
  3284. * @param tangent2 defines the outgoing tangent
  3285. * @param amount defines the target quaternion
  3286. * @returns the new interpolated quaternion
  3287. */
  3288. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3289. }
  3290. /**
  3291. * Class used to store matrix data (4x4)
  3292. */
  3293. export class Matrix {
  3294. private static _updateFlagSeed;
  3295. private static _identityReadOnly;
  3296. private _isIdentity;
  3297. private _isIdentityDirty;
  3298. private _isIdentity3x2;
  3299. private _isIdentity3x2Dirty;
  3300. /**
  3301. * Gets the update flag of the matrix which is an unique number for the matrix.
  3302. * It will be incremented every time the matrix data change.
  3303. * You can use it to speed the comparison between two versions of the same matrix.
  3304. */
  3305. updateFlag: number;
  3306. private readonly _m;
  3307. /**
  3308. * Gets the internal data of the matrix
  3309. */
  3310. readonly m: DeepImmutable<Float32Array>;
  3311. /** @hidden */
  3312. _markAsUpdated(): void;
  3313. /** @hidden */
  3314. private _updateIdentityStatus;
  3315. /**
  3316. * Creates an empty matrix (filled with zeros)
  3317. */
  3318. constructor();
  3319. /**
  3320. * Check if the current matrix is identity
  3321. * @returns true is the matrix is the identity matrix
  3322. */
  3323. isIdentity(): boolean;
  3324. /**
  3325. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3326. * @returns true is the matrix is the identity matrix
  3327. */
  3328. isIdentityAs3x2(): boolean;
  3329. /**
  3330. * Gets the determinant of the matrix
  3331. * @returns the matrix determinant
  3332. */
  3333. determinant(): number;
  3334. /**
  3335. * Returns the matrix as a Float32Array
  3336. * @returns the matrix underlying array
  3337. */
  3338. toArray(): DeepImmutable<Float32Array>;
  3339. /**
  3340. * Returns the matrix as a Float32Array
  3341. * @returns the matrix underlying array.
  3342. */
  3343. asArray(): DeepImmutable<Float32Array>;
  3344. /**
  3345. * Inverts the current matrix in place
  3346. * @returns the current inverted matrix
  3347. */
  3348. invert(): Matrix;
  3349. /**
  3350. * Sets all the matrix elements to zero
  3351. * @returns the current matrix
  3352. */
  3353. reset(): Matrix;
  3354. /**
  3355. * Adds the current matrix with a second one
  3356. * @param other defines the matrix to add
  3357. * @returns a new matrix as the addition of the current matrix and the given one
  3358. */
  3359. add(other: DeepImmutable<Matrix>): Matrix;
  3360. /**
  3361. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3362. * @param other defines the matrix to add
  3363. * @param result defines the target matrix
  3364. * @returns the current matrix
  3365. */
  3366. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3367. /**
  3368. * Adds in place the given matrix to the current matrix
  3369. * @param other defines the second operand
  3370. * @returns the current updated matrix
  3371. */
  3372. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3373. /**
  3374. * Sets the given matrix to the current inverted Matrix
  3375. * @param other defines the target matrix
  3376. * @returns the unmodified current matrix
  3377. */
  3378. invertToRef(other: Matrix): Matrix;
  3379. /**
  3380. * add a value at the specified position in the current Matrix
  3381. * @param index the index of the value within the matrix. between 0 and 15.
  3382. * @param value the value to be added
  3383. * @returns the current updated matrix
  3384. */
  3385. addAtIndex(index: number, value: number): Matrix;
  3386. /**
  3387. * mutiply the specified position in the current Matrix by a value
  3388. * @param index the index of the value within the matrix. between 0 and 15.
  3389. * @param value the value to be added
  3390. * @returns the current updated matrix
  3391. */
  3392. multiplyAtIndex(index: number, value: number): Matrix;
  3393. /**
  3394. * Inserts the translation vector (using 3 floats) in the current matrix
  3395. * @param x defines the 1st component of the translation
  3396. * @param y defines the 2nd component of the translation
  3397. * @param z defines the 3rd component of the translation
  3398. * @returns the current updated matrix
  3399. */
  3400. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3401. /**
  3402. * Adds the translation vector (using 3 floats) in the current matrix
  3403. * @param x defines the 1st component of the translation
  3404. * @param y defines the 2nd component of the translation
  3405. * @param z defines the 3rd component of the translation
  3406. * @returns the current updated matrix
  3407. */
  3408. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3409. /**
  3410. * Inserts the translation vector in the current matrix
  3411. * @param vector3 defines the translation to insert
  3412. * @returns the current updated matrix
  3413. */
  3414. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3415. /**
  3416. * Gets the translation value of the current matrix
  3417. * @returns a new Vector3 as the extracted translation from the matrix
  3418. */
  3419. getTranslation(): Vector3;
  3420. /**
  3421. * Fill a Vector3 with the extracted translation from the matrix
  3422. * @param result defines the Vector3 where to store the translation
  3423. * @returns the current matrix
  3424. */
  3425. getTranslationToRef(result: Vector3): Matrix;
  3426. /**
  3427. * Remove rotation and scaling part from the matrix
  3428. * @returns the updated matrix
  3429. */
  3430. removeRotationAndScaling(): Matrix;
  3431. /**
  3432. * Multiply two matrices
  3433. * @param other defines the second operand
  3434. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3435. */
  3436. multiply(other: DeepImmutable<Matrix>): Matrix;
  3437. /**
  3438. * Copy the current matrix from the given one
  3439. * @param other defines the source matrix
  3440. * @returns the current updated matrix
  3441. */
  3442. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3443. /**
  3444. * Populates the given array from the starting index with the current matrix values
  3445. * @param array defines the target array
  3446. * @param offset defines the offset in the target array where to start storing values
  3447. * @returns the current matrix
  3448. */
  3449. copyToArray(array: Float32Array, offset?: number): Matrix;
  3450. /**
  3451. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3452. * @param other defines the second operand
  3453. * @param result defines the matrix where to store the multiplication
  3454. * @returns the current matrix
  3455. */
  3456. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3457. /**
  3458. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3459. * @param other defines the second operand
  3460. * @param result defines the array where to store the multiplication
  3461. * @param offset defines the offset in the target array where to start storing values
  3462. * @returns the current matrix
  3463. */
  3464. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3465. /**
  3466. * Check equality between this matrix and a second one
  3467. * @param value defines the second matrix to compare
  3468. * @returns true is the current matrix and the given one values are strictly equal
  3469. */
  3470. equals(value: DeepImmutable<Matrix>): boolean;
  3471. /**
  3472. * Clone the current matrix
  3473. * @returns a new matrix from the current matrix
  3474. */
  3475. clone(): Matrix;
  3476. /**
  3477. * Returns the name of the current matrix class
  3478. * @returns the string "Matrix"
  3479. */
  3480. getClassName(): string;
  3481. /**
  3482. * Gets the hash code of the current matrix
  3483. * @returns the hash code
  3484. */
  3485. getHashCode(): number;
  3486. /**
  3487. * Decomposes the current Matrix into a translation, rotation and scaling components
  3488. * @param scale defines the scale vector3 given as a reference to update
  3489. * @param rotation defines the rotation quaternion given as a reference to update
  3490. * @param translation defines the translation vector3 given as a reference to update
  3491. * @returns true if operation was successful
  3492. */
  3493. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3494. /**
  3495. * Gets specific row of the matrix
  3496. * @param index defines the number of the row to get
  3497. * @returns the index-th row of the current matrix as a new Vector4
  3498. */
  3499. getRow(index: number): Nullable<Vector4>;
  3500. /**
  3501. * Sets the index-th row of the current matrix to the vector4 values
  3502. * @param index defines the number of the row to set
  3503. * @param row defines the target vector4
  3504. * @returns the updated current matrix
  3505. */
  3506. setRow(index: number, row: Vector4): Matrix;
  3507. /**
  3508. * Compute the transpose of the matrix
  3509. * @returns the new transposed matrix
  3510. */
  3511. transpose(): Matrix;
  3512. /**
  3513. * Compute the transpose of the matrix and store it in a given matrix
  3514. * @param result defines the target matrix
  3515. * @returns the current matrix
  3516. */
  3517. transposeToRef(result: Matrix): Matrix;
  3518. /**
  3519. * Sets the index-th row of the current matrix with the given 4 x float values
  3520. * @param index defines the row index
  3521. * @param x defines the x component to set
  3522. * @param y defines the y component to set
  3523. * @param z defines the z component to set
  3524. * @param w defines the w component to set
  3525. * @returns the updated current matrix
  3526. */
  3527. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3528. /**
  3529. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3530. * @param scale defines the scale factor
  3531. * @returns a new matrix
  3532. */
  3533. scale(scale: number): Matrix;
  3534. /**
  3535. * Scale the current matrix values by a factor to a given result matrix
  3536. * @param scale defines the scale factor
  3537. * @param result defines the matrix to store the result
  3538. * @returns the current matrix
  3539. */
  3540. scaleToRef(scale: number, result: Matrix): Matrix;
  3541. /**
  3542. * Scale the current matrix values by a factor and add the result to a given matrix
  3543. * @param scale defines the scale factor
  3544. * @param result defines the Matrix to store the result
  3545. * @returns the current matrix
  3546. */
  3547. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3548. /**
  3549. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3550. * @param ref matrix to store the result
  3551. */
  3552. toNormalMatrix(ref: Matrix): void;
  3553. /**
  3554. * Gets only rotation part of the current matrix
  3555. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3556. */
  3557. getRotationMatrix(): Matrix;
  3558. /**
  3559. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3560. * @param result defines the target matrix to store data to
  3561. * @returns the current matrix
  3562. */
  3563. getRotationMatrixToRef(result: Matrix): Matrix;
  3564. /**
  3565. * Toggles model matrix from being right handed to left handed in place and vice versa
  3566. */
  3567. toggleModelMatrixHandInPlace(): void;
  3568. /**
  3569. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3570. */
  3571. toggleProjectionMatrixHandInPlace(): void;
  3572. /**
  3573. * Creates a matrix from an array
  3574. * @param array defines the source array
  3575. * @param offset defines an offset in the source array
  3576. * @returns a new Matrix set from the starting index of the given array
  3577. */
  3578. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3579. /**
  3580. * Copy the content of an array into a given matrix
  3581. * @param array defines the source array
  3582. * @param offset defines an offset in the source array
  3583. * @param result defines the target matrix
  3584. */
  3585. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3586. /**
  3587. * Stores an array into a matrix after having multiplied each component by a given factor
  3588. * @param array defines the source array
  3589. * @param offset defines the offset in the source array
  3590. * @param scale defines the scaling factor
  3591. * @param result defines the target matrix
  3592. */
  3593. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3594. /**
  3595. * Gets an identity matrix that must not be updated
  3596. */
  3597. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3598. /**
  3599. * Stores a list of values (16) inside a given matrix
  3600. * @param initialM11 defines 1st value of 1st row
  3601. * @param initialM12 defines 2nd value of 1st row
  3602. * @param initialM13 defines 3rd value of 1st row
  3603. * @param initialM14 defines 4th value of 1st row
  3604. * @param initialM21 defines 1st value of 2nd row
  3605. * @param initialM22 defines 2nd value of 2nd row
  3606. * @param initialM23 defines 3rd value of 2nd row
  3607. * @param initialM24 defines 4th value of 2nd row
  3608. * @param initialM31 defines 1st value of 3rd row
  3609. * @param initialM32 defines 2nd value of 3rd row
  3610. * @param initialM33 defines 3rd value of 3rd row
  3611. * @param initialM34 defines 4th value of 3rd row
  3612. * @param initialM41 defines 1st value of 4th row
  3613. * @param initialM42 defines 2nd value of 4th row
  3614. * @param initialM43 defines 3rd value of 4th row
  3615. * @param initialM44 defines 4th value of 4th row
  3616. * @param result defines the target matrix
  3617. */
  3618. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3619. /**
  3620. * Creates new matrix from a list of values (16)
  3621. * @param initialM11 defines 1st value of 1st row
  3622. * @param initialM12 defines 2nd value of 1st row
  3623. * @param initialM13 defines 3rd value of 1st row
  3624. * @param initialM14 defines 4th value of 1st row
  3625. * @param initialM21 defines 1st value of 2nd row
  3626. * @param initialM22 defines 2nd value of 2nd row
  3627. * @param initialM23 defines 3rd value of 2nd row
  3628. * @param initialM24 defines 4th value of 2nd row
  3629. * @param initialM31 defines 1st value of 3rd row
  3630. * @param initialM32 defines 2nd value of 3rd row
  3631. * @param initialM33 defines 3rd value of 3rd row
  3632. * @param initialM34 defines 4th value of 3rd row
  3633. * @param initialM41 defines 1st value of 4th row
  3634. * @param initialM42 defines 2nd value of 4th row
  3635. * @param initialM43 defines 3rd value of 4th row
  3636. * @param initialM44 defines 4th value of 4th row
  3637. * @returns the new matrix
  3638. */
  3639. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3640. /**
  3641. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3642. * @param scale defines the scale vector3
  3643. * @param rotation defines the rotation quaternion
  3644. * @param translation defines the translation vector3
  3645. * @returns a new matrix
  3646. */
  3647. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3648. /**
  3649. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3650. * @param scale defines the scale vector3
  3651. * @param rotation defines the rotation quaternion
  3652. * @param translation defines the translation vector3
  3653. * @param result defines the target matrix
  3654. */
  3655. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3656. /**
  3657. * Creates a new identity matrix
  3658. * @returns a new identity matrix
  3659. */
  3660. static Identity(): Matrix;
  3661. /**
  3662. * Creates a new identity matrix and stores the result in a given matrix
  3663. * @param result defines the target matrix
  3664. */
  3665. static IdentityToRef(result: Matrix): void;
  3666. /**
  3667. * Creates a new zero matrix
  3668. * @returns a new zero matrix
  3669. */
  3670. static Zero(): Matrix;
  3671. /**
  3672. * Creates a new rotation matrix for "angle" radians around the X axis
  3673. * @param angle defines the angle (in radians) to use
  3674. * @return the new matrix
  3675. */
  3676. static RotationX(angle: number): Matrix;
  3677. /**
  3678. * Creates a new matrix as the invert of a given matrix
  3679. * @param source defines the source matrix
  3680. * @returns the new matrix
  3681. */
  3682. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3683. /**
  3684. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3685. * @param angle defines the angle (in radians) to use
  3686. * @param result defines the target matrix
  3687. */
  3688. static RotationXToRef(angle: number, result: Matrix): void;
  3689. /**
  3690. * Creates a new rotation matrix for "angle" radians around the Y axis
  3691. * @param angle defines the angle (in radians) to use
  3692. * @return the new matrix
  3693. */
  3694. static RotationY(angle: number): Matrix;
  3695. /**
  3696. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3697. * @param angle defines the angle (in radians) to use
  3698. * @param result defines the target matrix
  3699. */
  3700. static RotationYToRef(angle: number, result: Matrix): void;
  3701. /**
  3702. * Creates a new rotation matrix for "angle" radians around the Z axis
  3703. * @param angle defines the angle (in radians) to use
  3704. * @return the new matrix
  3705. */
  3706. static RotationZ(angle: number): Matrix;
  3707. /**
  3708. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3709. * @param angle defines the angle (in radians) to use
  3710. * @param result defines the target matrix
  3711. */
  3712. static RotationZToRef(angle: number, result: Matrix): void;
  3713. /**
  3714. * Creates a new rotation matrix for "angle" radians around the given axis
  3715. * @param axis defines the axis to use
  3716. * @param angle defines the angle (in radians) to use
  3717. * @return the new matrix
  3718. */
  3719. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3720. /**
  3721. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3722. * @param axis defines the axis to use
  3723. * @param angle defines the angle (in radians) to use
  3724. * @param result defines the target matrix
  3725. */
  3726. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3727. /**
  3728. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3729. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3730. * @param from defines the vector to align
  3731. * @param to defines the vector to align to
  3732. * @param result defines the target matrix
  3733. */
  3734. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3735. /**
  3736. * Creates a rotation matrix
  3737. * @param yaw defines the yaw angle in radians (Y axis)
  3738. * @param pitch defines the pitch angle in radians (X axis)
  3739. * @param roll defines the roll angle in radians (X axis)
  3740. * @returns the new rotation matrix
  3741. */
  3742. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3743. /**
  3744. * Creates a rotation matrix and stores it in a given matrix
  3745. * @param yaw defines the yaw angle in radians (Y axis)
  3746. * @param pitch defines the pitch angle in radians (X axis)
  3747. * @param roll defines the roll angle in radians (X axis)
  3748. * @param result defines the target matrix
  3749. */
  3750. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3751. /**
  3752. * Creates a scaling matrix
  3753. * @param x defines the scale factor on X axis
  3754. * @param y defines the scale factor on Y axis
  3755. * @param z defines the scale factor on Z axis
  3756. * @returns the new matrix
  3757. */
  3758. static Scaling(x: number, y: number, z: number): Matrix;
  3759. /**
  3760. * Creates a scaling matrix and stores it in a given matrix
  3761. * @param x defines the scale factor on X axis
  3762. * @param y defines the scale factor on Y axis
  3763. * @param z defines the scale factor on Z axis
  3764. * @param result defines the target matrix
  3765. */
  3766. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3767. /**
  3768. * Creates a translation matrix
  3769. * @param x defines the translation on X axis
  3770. * @param y defines the translation on Y axis
  3771. * @param z defines the translationon Z axis
  3772. * @returns the new matrix
  3773. */
  3774. static Translation(x: number, y: number, z: number): Matrix;
  3775. /**
  3776. * Creates a translation matrix and stores it in a given matrix
  3777. * @param x defines the translation on X axis
  3778. * @param y defines the translation on Y axis
  3779. * @param z defines the translationon Z axis
  3780. * @param result defines the target matrix
  3781. */
  3782. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3783. /**
  3784. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3785. * @param startValue defines the start value
  3786. * @param endValue defines the end value
  3787. * @param gradient defines the gradient factor
  3788. * @returns the new matrix
  3789. */
  3790. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3791. /**
  3792. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3793. * @param startValue defines the start value
  3794. * @param endValue defines the end value
  3795. * @param gradient defines the gradient factor
  3796. * @param result defines the Matrix object where to store data
  3797. */
  3798. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3799. /**
  3800. * Builds a new matrix whose values are computed by:
  3801. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3802. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3803. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3804. * @param startValue defines the first matrix
  3805. * @param endValue defines the second matrix
  3806. * @param gradient defines the gradient between the two matrices
  3807. * @returns the new matrix
  3808. */
  3809. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3810. /**
  3811. * Update a matrix to values which are computed by:
  3812. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3813. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3814. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3815. * @param startValue defines the first matrix
  3816. * @param endValue defines the second matrix
  3817. * @param gradient defines the gradient between the two matrices
  3818. * @param result defines the target matrix
  3819. */
  3820. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3821. /**
  3822. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3823. * This function works in left handed mode
  3824. * @param eye defines the final position of the entity
  3825. * @param target defines where the entity should look at
  3826. * @param up defines the up vector for the entity
  3827. * @returns the new matrix
  3828. */
  3829. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3830. /**
  3831. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3832. * This function works in left handed mode
  3833. * @param eye defines the final position of the entity
  3834. * @param target defines where the entity should look at
  3835. * @param up defines the up vector for the entity
  3836. * @param result defines the target matrix
  3837. */
  3838. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3839. /**
  3840. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3841. * This function works in right handed mode
  3842. * @param eye defines the final position of the entity
  3843. * @param target defines where the entity should look at
  3844. * @param up defines the up vector for the entity
  3845. * @returns the new matrix
  3846. */
  3847. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3848. /**
  3849. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3850. * This function works in right handed mode
  3851. * @param eye defines the final position of the entity
  3852. * @param target defines where the entity should look at
  3853. * @param up defines the up vector for the entity
  3854. * @param result defines the target matrix
  3855. */
  3856. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3857. /**
  3858. * Create a left-handed orthographic projection matrix
  3859. * @param width defines the viewport width
  3860. * @param height defines the viewport height
  3861. * @param znear defines the near clip plane
  3862. * @param zfar defines the far clip plane
  3863. * @returns a new matrix as a left-handed orthographic projection matrix
  3864. */
  3865. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3866. /**
  3867. * Store a left-handed orthographic projection to a given matrix
  3868. * @param width defines the viewport width
  3869. * @param height defines the viewport height
  3870. * @param znear defines the near clip plane
  3871. * @param zfar defines the far clip plane
  3872. * @param result defines the target matrix
  3873. */
  3874. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3875. /**
  3876. * Create a left-handed orthographic projection matrix
  3877. * @param left defines the viewport left coordinate
  3878. * @param right defines the viewport right coordinate
  3879. * @param bottom defines the viewport bottom coordinate
  3880. * @param top defines the viewport top coordinate
  3881. * @param znear defines the near clip plane
  3882. * @param zfar defines the far clip plane
  3883. * @returns a new matrix as a left-handed orthographic projection matrix
  3884. */
  3885. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3886. /**
  3887. * Stores a left-handed orthographic projection into a given matrix
  3888. * @param left defines the viewport left coordinate
  3889. * @param right defines the viewport right coordinate
  3890. * @param bottom defines the viewport bottom coordinate
  3891. * @param top defines the viewport top coordinate
  3892. * @param znear defines the near clip plane
  3893. * @param zfar defines the far clip plane
  3894. * @param result defines the target matrix
  3895. */
  3896. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3897. /**
  3898. * Creates a right-handed orthographic projection matrix
  3899. * @param left defines the viewport left coordinate
  3900. * @param right defines the viewport right coordinate
  3901. * @param bottom defines the viewport bottom coordinate
  3902. * @param top defines the viewport top coordinate
  3903. * @param znear defines the near clip plane
  3904. * @param zfar defines the far clip plane
  3905. * @returns a new matrix as a right-handed orthographic projection matrix
  3906. */
  3907. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3908. /**
  3909. * Stores a right-handed orthographic projection into a given matrix
  3910. * @param left defines the viewport left coordinate
  3911. * @param right defines the viewport right coordinate
  3912. * @param bottom defines the viewport bottom coordinate
  3913. * @param top defines the viewport top coordinate
  3914. * @param znear defines the near clip plane
  3915. * @param zfar defines the far clip plane
  3916. * @param result defines the target matrix
  3917. */
  3918. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3919. /**
  3920. * Creates a left-handed perspective projection matrix
  3921. * @param width defines the viewport width
  3922. * @param height defines the viewport height
  3923. * @param znear defines the near clip plane
  3924. * @param zfar defines the far clip plane
  3925. * @returns a new matrix as a left-handed perspective projection matrix
  3926. */
  3927. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3928. /**
  3929. * Creates a left-handed perspective projection matrix
  3930. * @param fov defines the horizontal field of view
  3931. * @param aspect defines the aspect ratio
  3932. * @param znear defines the near clip plane
  3933. * @param zfar defines the far clip plane
  3934. * @returns a new matrix as a left-handed perspective projection matrix
  3935. */
  3936. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3937. /**
  3938. * Stores a left-handed perspective projection into a given matrix
  3939. * @param fov defines the horizontal field of view
  3940. * @param aspect defines the aspect ratio
  3941. * @param znear defines the near clip plane
  3942. * @param zfar defines the far clip plane
  3943. * @param result defines the target matrix
  3944. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3945. */
  3946. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3947. /**
  3948. * Creates a right-handed perspective projection matrix
  3949. * @param fov defines the horizontal field of view
  3950. * @param aspect defines the aspect ratio
  3951. * @param znear defines the near clip plane
  3952. * @param zfar defines the far clip plane
  3953. * @returns a new matrix as a right-handed perspective projection matrix
  3954. */
  3955. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3956. /**
  3957. * Stores a right-handed perspective projection into a given matrix
  3958. * @param fov defines the horizontal field of view
  3959. * @param aspect defines the aspect ratio
  3960. * @param znear defines the near clip plane
  3961. * @param zfar defines the far clip plane
  3962. * @param result defines the target matrix
  3963. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3964. */
  3965. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3966. /**
  3967. * Stores a perspective projection for WebVR info a given matrix
  3968. * @param fov defines the field of view
  3969. * @param znear defines the near clip plane
  3970. * @param zfar defines the far clip plane
  3971. * @param result defines the target matrix
  3972. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3973. */
  3974. static PerspectiveFovWebVRToRef(fov: {
  3975. upDegrees: number;
  3976. downDegrees: number;
  3977. leftDegrees: number;
  3978. rightDegrees: number;
  3979. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3980. /**
  3981. * Computes a complete transformation matrix
  3982. * @param viewport defines the viewport to use
  3983. * @param world defines the world matrix
  3984. * @param view defines the view matrix
  3985. * @param projection defines the projection matrix
  3986. * @param zmin defines the near clip plane
  3987. * @param zmax defines the far clip plane
  3988. * @returns the transformation matrix
  3989. */
  3990. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3991. /**
  3992. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3993. * @param matrix defines the matrix to use
  3994. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3995. */
  3996. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3997. /**
  3998. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3999. * @param matrix defines the matrix to use
  4000. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4001. */
  4002. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4003. /**
  4004. * Compute the transpose of a given matrix
  4005. * @param matrix defines the matrix to transpose
  4006. * @returns the new matrix
  4007. */
  4008. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4009. /**
  4010. * Compute the transpose of a matrix and store it in a target matrix
  4011. * @param matrix defines the matrix to transpose
  4012. * @param result defines the target matrix
  4013. */
  4014. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4015. /**
  4016. * Computes a reflection matrix from a plane
  4017. * @param plane defines the reflection plane
  4018. * @returns a new matrix
  4019. */
  4020. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4021. /**
  4022. * Computes a reflection matrix from a plane
  4023. * @param plane defines the reflection plane
  4024. * @param result defines the target matrix
  4025. */
  4026. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4027. /**
  4028. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4029. * @param xaxis defines the value of the 1st axis
  4030. * @param yaxis defines the value of the 2nd axis
  4031. * @param zaxis defines the value of the 3rd axis
  4032. * @param result defines the target matrix
  4033. */
  4034. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4035. /**
  4036. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4037. * @param quat defines the quaternion to use
  4038. * @param result defines the target matrix
  4039. */
  4040. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4041. }
  4042. /**
  4043. * @hidden
  4044. */
  4045. export class TmpVectors {
  4046. static Vector2: Vector2[];
  4047. static Vector3: Vector3[];
  4048. static Vector4: Vector4[];
  4049. static Quaternion: Quaternion[];
  4050. static Matrix: Matrix[];
  4051. }
  4052. }
  4053. declare module "babylonjs/Engines/constants" {
  4054. /** Defines the cross module used constants to avoid circular dependncies */
  4055. export class Constants {
  4056. /** Defines that alpha blending is disabled */
  4057. static readonly ALPHA_DISABLE: number;
  4058. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4059. static readonly ALPHA_ADD: number;
  4060. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4061. static readonly ALPHA_COMBINE: number;
  4062. /** Defines that alpha blending to DEST - SRC * DEST */
  4063. static readonly ALPHA_SUBTRACT: number;
  4064. /** Defines that alpha blending to SRC * DEST */
  4065. static readonly ALPHA_MULTIPLY: number;
  4066. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4067. static readonly ALPHA_MAXIMIZED: number;
  4068. /** Defines that alpha blending to SRC + DEST */
  4069. static readonly ALPHA_ONEONE: number;
  4070. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4071. static readonly ALPHA_PREMULTIPLIED: number;
  4072. /**
  4073. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4074. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4075. */
  4076. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4077. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4078. static readonly ALPHA_INTERPOLATE: number;
  4079. /**
  4080. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4081. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4082. */
  4083. static readonly ALPHA_SCREENMODE: number;
  4084. /** Defines that the ressource is not delayed*/
  4085. static readonly DELAYLOADSTATE_NONE: number;
  4086. /** Defines that the ressource was successfully delay loaded */
  4087. static readonly DELAYLOADSTATE_LOADED: number;
  4088. /** Defines that the ressource is currently delay loading */
  4089. static readonly DELAYLOADSTATE_LOADING: number;
  4090. /** Defines that the ressource is delayed and has not started loading */
  4091. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4092. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4093. static readonly NEVER: number;
  4094. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4095. static readonly ALWAYS: number;
  4096. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4097. static readonly LESS: number;
  4098. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4099. static readonly EQUAL: number;
  4100. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4101. static readonly LEQUAL: number;
  4102. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4103. static readonly GREATER: number;
  4104. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4105. static readonly GEQUAL: number;
  4106. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4107. static readonly NOTEQUAL: number;
  4108. /** Passed to stencilOperation to specify that stencil value must be kept */
  4109. static readonly KEEP: number;
  4110. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4111. static readonly REPLACE: number;
  4112. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4113. static readonly INCR: number;
  4114. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4115. static readonly DECR: number;
  4116. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4117. static readonly INVERT: number;
  4118. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4119. static readonly INCR_WRAP: number;
  4120. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4121. static readonly DECR_WRAP: number;
  4122. /** Texture is not repeating outside of 0..1 UVs */
  4123. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4124. /** Texture is repeating outside of 0..1 UVs */
  4125. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4126. /** Texture is repeating and mirrored */
  4127. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4128. /** ALPHA */
  4129. static readonly TEXTUREFORMAT_ALPHA: number;
  4130. /** LUMINANCE */
  4131. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4132. /** LUMINANCE_ALPHA */
  4133. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4134. /** RGB */
  4135. static readonly TEXTUREFORMAT_RGB: number;
  4136. /** RGBA */
  4137. static readonly TEXTUREFORMAT_RGBA: number;
  4138. /** RED */
  4139. static readonly TEXTUREFORMAT_RED: number;
  4140. /** RED (2nd reference) */
  4141. static readonly TEXTUREFORMAT_R: number;
  4142. /** RG */
  4143. static readonly TEXTUREFORMAT_RG: number;
  4144. /** RED_INTEGER */
  4145. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4146. /** RED_INTEGER (2nd reference) */
  4147. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4148. /** RG_INTEGER */
  4149. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4150. /** RGB_INTEGER */
  4151. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4152. /** RGBA_INTEGER */
  4153. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4154. /** UNSIGNED_BYTE */
  4155. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4156. /** UNSIGNED_BYTE (2nd reference) */
  4157. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4158. /** FLOAT */
  4159. static readonly TEXTURETYPE_FLOAT: number;
  4160. /** HALF_FLOAT */
  4161. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4162. /** BYTE */
  4163. static readonly TEXTURETYPE_BYTE: number;
  4164. /** SHORT */
  4165. static readonly TEXTURETYPE_SHORT: number;
  4166. /** UNSIGNED_SHORT */
  4167. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4168. /** INT */
  4169. static readonly TEXTURETYPE_INT: number;
  4170. /** UNSIGNED_INT */
  4171. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4172. /** UNSIGNED_SHORT_4_4_4_4 */
  4173. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4174. /** UNSIGNED_SHORT_5_5_5_1 */
  4175. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4176. /** UNSIGNED_SHORT_5_6_5 */
  4177. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4178. /** UNSIGNED_INT_2_10_10_10_REV */
  4179. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4180. /** UNSIGNED_INT_24_8 */
  4181. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4182. /** UNSIGNED_INT_10F_11F_11F_REV */
  4183. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4184. /** UNSIGNED_INT_5_9_9_9_REV */
  4185. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4186. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4187. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4188. /** nearest is mag = nearest and min = nearest and mip = linear */
  4189. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4190. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4191. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4192. /** Trilinear is mag = linear and min = linear and mip = linear */
  4193. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4194. /** nearest is mag = nearest and min = nearest and mip = linear */
  4195. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4196. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4197. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4198. /** Trilinear is mag = linear and min = linear and mip = linear */
  4199. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4200. /** mag = nearest and min = nearest and mip = nearest */
  4201. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4202. /** mag = nearest and min = linear and mip = nearest */
  4203. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4204. /** mag = nearest and min = linear and mip = linear */
  4205. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4206. /** mag = nearest and min = linear and mip = none */
  4207. static readonly TEXTURE_NEAREST_LINEAR: number;
  4208. /** mag = nearest and min = nearest and mip = none */
  4209. static readonly TEXTURE_NEAREST_NEAREST: number;
  4210. /** mag = linear and min = nearest and mip = nearest */
  4211. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4212. /** mag = linear and min = nearest and mip = linear */
  4213. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4214. /** mag = linear and min = linear and mip = none */
  4215. static readonly TEXTURE_LINEAR_LINEAR: number;
  4216. /** mag = linear and min = nearest and mip = none */
  4217. static readonly TEXTURE_LINEAR_NEAREST: number;
  4218. /** Explicit coordinates mode */
  4219. static readonly TEXTURE_EXPLICIT_MODE: number;
  4220. /** Spherical coordinates mode */
  4221. static readonly TEXTURE_SPHERICAL_MODE: number;
  4222. /** Planar coordinates mode */
  4223. static readonly TEXTURE_PLANAR_MODE: number;
  4224. /** Cubic coordinates mode */
  4225. static readonly TEXTURE_CUBIC_MODE: number;
  4226. /** Projection coordinates mode */
  4227. static readonly TEXTURE_PROJECTION_MODE: number;
  4228. /** Skybox coordinates mode */
  4229. static readonly TEXTURE_SKYBOX_MODE: number;
  4230. /** Inverse Cubic coordinates mode */
  4231. static readonly TEXTURE_INVCUBIC_MODE: number;
  4232. /** Equirectangular coordinates mode */
  4233. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4234. /** Equirectangular Fixed coordinates mode */
  4235. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4236. /** Equirectangular Fixed Mirrored coordinates mode */
  4237. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4238. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4239. static readonly SCALEMODE_FLOOR: number;
  4240. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4241. static readonly SCALEMODE_NEAREST: number;
  4242. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4243. static readonly SCALEMODE_CEILING: number;
  4244. /**
  4245. * The dirty texture flag value
  4246. */
  4247. static readonly MATERIAL_TextureDirtyFlag: number;
  4248. /**
  4249. * The dirty light flag value
  4250. */
  4251. static readonly MATERIAL_LightDirtyFlag: number;
  4252. /**
  4253. * The dirty fresnel flag value
  4254. */
  4255. static readonly MATERIAL_FresnelDirtyFlag: number;
  4256. /**
  4257. * The dirty attribute flag value
  4258. */
  4259. static readonly MATERIAL_AttributesDirtyFlag: number;
  4260. /**
  4261. * The dirty misc flag value
  4262. */
  4263. static readonly MATERIAL_MiscDirtyFlag: number;
  4264. /**
  4265. * The all dirty flag value
  4266. */
  4267. static readonly MATERIAL_AllDirtyFlag: number;
  4268. /**
  4269. * Returns the triangle fill mode
  4270. */
  4271. static readonly MATERIAL_TriangleFillMode: number;
  4272. /**
  4273. * Returns the wireframe mode
  4274. */
  4275. static readonly MATERIAL_WireFrameFillMode: number;
  4276. /**
  4277. * Returns the point fill mode
  4278. */
  4279. static readonly MATERIAL_PointFillMode: number;
  4280. /**
  4281. * Returns the point list draw mode
  4282. */
  4283. static readonly MATERIAL_PointListDrawMode: number;
  4284. /**
  4285. * Returns the line list draw mode
  4286. */
  4287. static readonly MATERIAL_LineListDrawMode: number;
  4288. /**
  4289. * Returns the line loop draw mode
  4290. */
  4291. static readonly MATERIAL_LineLoopDrawMode: number;
  4292. /**
  4293. * Returns the line strip draw mode
  4294. */
  4295. static readonly MATERIAL_LineStripDrawMode: number;
  4296. /**
  4297. * Returns the triangle strip draw mode
  4298. */
  4299. static readonly MATERIAL_TriangleStripDrawMode: number;
  4300. /**
  4301. * Returns the triangle fan draw mode
  4302. */
  4303. static readonly MATERIAL_TriangleFanDrawMode: number;
  4304. /**
  4305. * Stores the clock-wise side orientation
  4306. */
  4307. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4308. /**
  4309. * Stores the counter clock-wise side orientation
  4310. */
  4311. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4312. /**
  4313. * Nothing
  4314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4315. */
  4316. static readonly ACTION_NothingTrigger: number;
  4317. /**
  4318. * On pick
  4319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4320. */
  4321. static readonly ACTION_OnPickTrigger: number;
  4322. /**
  4323. * On left pick
  4324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4325. */
  4326. static readonly ACTION_OnLeftPickTrigger: number;
  4327. /**
  4328. * On right pick
  4329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4330. */
  4331. static readonly ACTION_OnRightPickTrigger: number;
  4332. /**
  4333. * On center pick
  4334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4335. */
  4336. static readonly ACTION_OnCenterPickTrigger: number;
  4337. /**
  4338. * On pick down
  4339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4340. */
  4341. static readonly ACTION_OnPickDownTrigger: number;
  4342. /**
  4343. * On double pick
  4344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4345. */
  4346. static readonly ACTION_OnDoublePickTrigger: number;
  4347. /**
  4348. * On pick up
  4349. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4350. */
  4351. static readonly ACTION_OnPickUpTrigger: number;
  4352. /**
  4353. * On pick out.
  4354. * This trigger will only be raised if you also declared a OnPickDown
  4355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4356. */
  4357. static readonly ACTION_OnPickOutTrigger: number;
  4358. /**
  4359. * On long press
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_OnLongPressTrigger: number;
  4363. /**
  4364. * On pointer over
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnPointerOverTrigger: number;
  4368. /**
  4369. * On pointer out
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnPointerOutTrigger: number;
  4373. /**
  4374. * On every frame
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnEveryFrameTrigger: number;
  4378. /**
  4379. * On intersection enter
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4383. /**
  4384. * On intersection exit
  4385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4386. */
  4387. static readonly ACTION_OnIntersectionExitTrigger: number;
  4388. /**
  4389. * On key down
  4390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4391. */
  4392. static readonly ACTION_OnKeyDownTrigger: number;
  4393. /**
  4394. * On key up
  4395. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4396. */
  4397. static readonly ACTION_OnKeyUpTrigger: number;
  4398. /**
  4399. * Billboard mode will only apply to Y axis
  4400. */
  4401. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4402. /**
  4403. * Billboard mode will apply to all axes
  4404. */
  4405. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4406. /**
  4407. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4408. */
  4409. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4410. /**
  4411. * Gets or sets base Assets URL
  4412. */
  4413. static PARTICLES_BaseAssetsUrl: string;
  4414. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4415. * Test order :
  4416. * Is the bounding sphere outside the frustum ?
  4417. * If not, are the bounding box vertices outside the frustum ?
  4418. * It not, then the cullable object is in the frustum.
  4419. */
  4420. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4421. /** Culling strategy : Bounding Sphere Only.
  4422. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4423. * It's also less accurate than the standard because some not visible objects can still be selected.
  4424. * Test : is the bounding sphere outside the frustum ?
  4425. * If not, then the cullable object is in the frustum.
  4426. */
  4427. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4428. /** Culling strategy : Optimistic Inclusion.
  4429. * This in an inclusion test first, then the standard exclusion test.
  4430. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4431. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4432. * Anyway, it's as accurate as the standard strategy.
  4433. * Test :
  4434. * Is the cullable object bounding sphere center in the frustum ?
  4435. * If not, apply the default culling strategy.
  4436. */
  4437. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4438. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4439. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4440. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4441. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4442. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4443. * Test :
  4444. * Is the cullable object bounding sphere center in the frustum ?
  4445. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4446. */
  4447. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4448. /**
  4449. * No logging while loading
  4450. */
  4451. static readonly SCENELOADER_NO_LOGGING: number;
  4452. /**
  4453. * Minimal logging while loading
  4454. */
  4455. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4456. /**
  4457. * Summary logging while loading
  4458. */
  4459. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4460. /**
  4461. * Detailled logging while loading
  4462. */
  4463. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4464. }
  4465. }
  4466. declare module "babylonjs/Engines/IPipelineContext" {
  4467. /**
  4468. * Class used to store and describe the pipeline context associated with an effect
  4469. */
  4470. export interface IPipelineContext {
  4471. /**
  4472. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4473. */
  4474. isAsync: boolean;
  4475. /**
  4476. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4477. */
  4478. isReady: boolean;
  4479. /** @hidden */
  4480. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4481. }
  4482. }
  4483. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4484. /** @hidden */
  4485. export interface IShaderProcessor {
  4486. attributeProcessor?: (attribute: string) => string;
  4487. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4488. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4489. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4490. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4491. lineProcessor?: (line: string, isFragment: boolean) => string;
  4492. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4493. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4494. }
  4495. }
  4496. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4497. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4498. /** @hidden */
  4499. export interface ProcessingOptions {
  4500. defines: string[];
  4501. indexParameters: any;
  4502. isFragment: boolean;
  4503. shouldUseHighPrecisionShader: boolean;
  4504. supportsUniformBuffers: boolean;
  4505. shadersRepository: string;
  4506. includesShadersStore: {
  4507. [key: string]: string;
  4508. };
  4509. processor?: IShaderProcessor;
  4510. version: string;
  4511. platformName: string;
  4512. lookForClosingBracketForUniformBuffer?: boolean;
  4513. }
  4514. }
  4515. declare module "babylonjs/Misc/stringTools" {
  4516. /**
  4517. * Helper to manipulate strings
  4518. */
  4519. export class StringTools {
  4520. /**
  4521. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4522. * @param str Source string
  4523. * @param suffix Suffix to search for in the source string
  4524. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4525. */
  4526. static EndsWith(str: string, suffix: string): boolean;
  4527. /**
  4528. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4529. * @param str Source string
  4530. * @param suffix Suffix to search for in the source string
  4531. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4532. */
  4533. static StartsWith(str: string, suffix: string): boolean;
  4534. }
  4535. }
  4536. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4537. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4538. /** @hidden */
  4539. export class ShaderCodeNode {
  4540. line: string;
  4541. children: ShaderCodeNode[];
  4542. additionalDefineKey?: string;
  4543. additionalDefineValue?: string;
  4544. isValid(preprocessors: {
  4545. [key: string]: string;
  4546. }): boolean;
  4547. process(preprocessors: {
  4548. [key: string]: string;
  4549. }, options: ProcessingOptions): string;
  4550. }
  4551. }
  4552. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4553. /** @hidden */
  4554. export class ShaderCodeCursor {
  4555. private _lines;
  4556. lineIndex: number;
  4557. readonly currentLine: string;
  4558. readonly canRead: boolean;
  4559. lines: string[];
  4560. }
  4561. }
  4562. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4563. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4564. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4565. /** @hidden */
  4566. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4567. process(preprocessors: {
  4568. [key: string]: string;
  4569. }, options: ProcessingOptions): string;
  4570. }
  4571. }
  4572. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4573. /** @hidden */
  4574. export class ShaderDefineExpression {
  4575. isTrue(preprocessors: {
  4576. [key: string]: string;
  4577. }): boolean;
  4578. }
  4579. }
  4580. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4581. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4582. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4583. /** @hidden */
  4584. export class ShaderCodeTestNode extends ShaderCodeNode {
  4585. testExpression: ShaderDefineExpression;
  4586. isValid(preprocessors: {
  4587. [key: string]: string;
  4588. }): boolean;
  4589. }
  4590. }
  4591. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4592. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4593. /** @hidden */
  4594. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4595. define: string;
  4596. not: boolean;
  4597. constructor(define: string, not?: boolean);
  4598. isTrue(preprocessors: {
  4599. [key: string]: string;
  4600. }): boolean;
  4601. }
  4602. }
  4603. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4604. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4605. /** @hidden */
  4606. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4607. leftOperand: ShaderDefineExpression;
  4608. rightOperand: ShaderDefineExpression;
  4609. isTrue(preprocessors: {
  4610. [key: string]: string;
  4611. }): boolean;
  4612. }
  4613. }
  4614. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4615. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4616. /** @hidden */
  4617. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4618. leftOperand: ShaderDefineExpression;
  4619. rightOperand: ShaderDefineExpression;
  4620. isTrue(preprocessors: {
  4621. [key: string]: string;
  4622. }): boolean;
  4623. }
  4624. }
  4625. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  4626. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4627. /** @hidden */
  4628. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4629. define: string;
  4630. operand: string;
  4631. testValue: string;
  4632. constructor(define: string, operand: string, testValue: string);
  4633. isTrue(preprocessors: {
  4634. [key: string]: string;
  4635. }): boolean;
  4636. }
  4637. }
  4638. declare module "babylonjs/Misc/loadFileError" {
  4639. import { WebRequest } from "babylonjs/Misc/webRequest";
  4640. /**
  4641. * @ignore
  4642. * Application error to support additional information when loading a file
  4643. */
  4644. export class LoadFileError extends Error {
  4645. /** defines the optional web request */
  4646. request?: WebRequest | undefined;
  4647. private static _setPrototypeOf;
  4648. /**
  4649. * Creates a new LoadFileError
  4650. * @param message defines the message of the error
  4651. * @param request defines the optional web request
  4652. */
  4653. constructor(message: string,
  4654. /** defines the optional web request */
  4655. request?: WebRequest | undefined);
  4656. }
  4657. }
  4658. declare module "babylonjs/Offline/IOfflineProvider" {
  4659. /**
  4660. * Class used to enable access to offline support
  4661. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4662. */
  4663. export interface IOfflineProvider {
  4664. /**
  4665. * Gets a boolean indicating if scene must be saved in the database
  4666. */
  4667. enableSceneOffline: boolean;
  4668. /**
  4669. * Gets a boolean indicating if textures must be saved in the database
  4670. */
  4671. enableTexturesOffline: boolean;
  4672. /**
  4673. * Open the offline support and make it available
  4674. * @param successCallback defines the callback to call on success
  4675. * @param errorCallback defines the callback to call on error
  4676. */
  4677. open(successCallback: () => void, errorCallback: () => void): void;
  4678. /**
  4679. * Loads an image from the offline support
  4680. * @param url defines the url to load from
  4681. * @param image defines the target DOM image
  4682. */
  4683. loadImage(url: string, image: HTMLImageElement): void;
  4684. /**
  4685. * Loads a file from offline support
  4686. * @param url defines the URL to load from
  4687. * @param sceneLoaded defines a callback to call on success
  4688. * @param progressCallBack defines a callback to call when progress changed
  4689. * @param errorCallback defines a callback to call on error
  4690. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4691. */
  4692. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4693. }
  4694. }
  4695. declare module "babylonjs/Misc/filesInputStore" {
  4696. /**
  4697. * Class used to help managing file picking and drag'n'drop
  4698. * File Storage
  4699. */
  4700. export class FilesInputStore {
  4701. /**
  4702. * List of files ready to be loaded
  4703. */
  4704. static FilesToLoad: {
  4705. [key: string]: File;
  4706. };
  4707. }
  4708. }
  4709. declare module "babylonjs/Misc/retryStrategy" {
  4710. import { WebRequest } from "babylonjs/Misc/webRequest";
  4711. /**
  4712. * Class used to define a retry strategy when error happens while loading assets
  4713. */
  4714. export class RetryStrategy {
  4715. /**
  4716. * Function used to defines an exponential back off strategy
  4717. * @param maxRetries defines the maximum number of retries (3 by default)
  4718. * @param baseInterval defines the interval between retries
  4719. * @returns the strategy function to use
  4720. */
  4721. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4722. }
  4723. }
  4724. declare module "babylonjs/Misc/fileTools" {
  4725. import { WebRequest } from "babylonjs/Misc/webRequest";
  4726. import { Nullable } from "babylonjs/types";
  4727. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  4728. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  4729. /**
  4730. * @hidden
  4731. */
  4732. export class FileTools {
  4733. /**
  4734. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4735. */
  4736. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4737. /**
  4738. * Gets or sets the base URL to use to load assets
  4739. */
  4740. static BaseUrl: string;
  4741. /**
  4742. * Default behaviour for cors in the application.
  4743. * It can be a string if the expected behavior is identical in the entire app.
  4744. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4745. */
  4746. static CorsBehavior: string | ((url: string | string[]) => string);
  4747. /**
  4748. * Gets or sets a function used to pre-process url before using them to load assets
  4749. */
  4750. static PreprocessUrl: (url: string) => string;
  4751. /**
  4752. * Removes unwanted characters from an url
  4753. * @param url defines the url to clean
  4754. * @returns the cleaned url
  4755. */
  4756. private static _CleanUrl;
  4757. /**
  4758. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4759. * @param url define the url we are trying
  4760. * @param element define the dom element where to configure the cors policy
  4761. */
  4762. static SetCorsBehavior(url: string | string[], element: {
  4763. crossOrigin: string | null;
  4764. }): void;
  4765. /**
  4766. * Loads an image as an HTMLImageElement.
  4767. * @param input url string, ArrayBuffer, or Blob to load
  4768. * @param onLoad callback called when the image successfully loads
  4769. * @param onError callback called when the image fails to load
  4770. * @param offlineProvider offline provider for caching
  4771. * @returns the HTMLImageElement of the loaded image
  4772. */
  4773. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4774. /**
  4775. * Loads a file
  4776. * @param fileToLoad defines the file to load
  4777. * @param callback defines the callback to call when data is loaded
  4778. * @param progressCallBack defines the callback to call during loading process
  4779. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4780. * @returns a file request object
  4781. */
  4782. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4783. /**
  4784. * Loads a file
  4785. * @param url url string, ArrayBuffer, or Blob to load
  4786. * @param onSuccess callback called when the file successfully loads
  4787. * @param onProgress callback called while file is loading (if the server supports this mode)
  4788. * @param offlineProvider defines the offline provider for caching
  4789. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4790. * @param onError callback called when the file fails to load
  4791. * @returns a file request object
  4792. */
  4793. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  4794. /**
  4795. * Checks if the loaded document was accessed via `file:`-Protocol.
  4796. * @returns boolean
  4797. */
  4798. static IsFileURL(): boolean;
  4799. }
  4800. }
  4801. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  4802. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4803. /** @hidden */
  4804. export class ShaderProcessor {
  4805. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4806. private static _ProcessPrecision;
  4807. private static _ExtractOperation;
  4808. private static _BuildSubExpression;
  4809. private static _BuildExpression;
  4810. private static _MoveCursorWithinIf;
  4811. private static _MoveCursor;
  4812. private static _EvaluatePreProcessors;
  4813. private static _PreparePreProcessors;
  4814. private static _ProcessShaderConversion;
  4815. private static _ProcessIncludes;
  4816. }
  4817. }
  4818. declare module "babylonjs/Maths/math.color" {
  4819. import { DeepImmutable, FloatArray } from "babylonjs/types";
  4820. /**
  4821. * Class used to hold a RBG color
  4822. */
  4823. export class Color3 {
  4824. /**
  4825. * Defines the red component (between 0 and 1, default is 0)
  4826. */
  4827. r: number;
  4828. /**
  4829. * Defines the green component (between 0 and 1, default is 0)
  4830. */
  4831. g: number;
  4832. /**
  4833. * Defines the blue component (between 0 and 1, default is 0)
  4834. */
  4835. b: number;
  4836. /**
  4837. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4838. * @param r defines the red component (between 0 and 1, default is 0)
  4839. * @param g defines the green component (between 0 and 1, default is 0)
  4840. * @param b defines the blue component (between 0 and 1, default is 0)
  4841. */
  4842. constructor(
  4843. /**
  4844. * Defines the red component (between 0 and 1, default is 0)
  4845. */
  4846. r?: number,
  4847. /**
  4848. * Defines the green component (between 0 and 1, default is 0)
  4849. */
  4850. g?: number,
  4851. /**
  4852. * Defines the blue component (between 0 and 1, default is 0)
  4853. */
  4854. b?: number);
  4855. /**
  4856. * Creates a string with the Color3 current values
  4857. * @returns the string representation of the Color3 object
  4858. */
  4859. toString(): string;
  4860. /**
  4861. * Returns the string "Color3"
  4862. * @returns "Color3"
  4863. */
  4864. getClassName(): string;
  4865. /**
  4866. * Compute the Color3 hash code
  4867. * @returns an unique number that can be used to hash Color3 objects
  4868. */
  4869. getHashCode(): number;
  4870. /**
  4871. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4872. * @param array defines the array where to store the r,g,b components
  4873. * @param index defines an optional index in the target array to define where to start storing values
  4874. * @returns the current Color3 object
  4875. */
  4876. toArray(array: FloatArray, index?: number): Color3;
  4877. /**
  4878. * Returns a new Color4 object from the current Color3 and the given alpha
  4879. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4880. * @returns a new Color4 object
  4881. */
  4882. toColor4(alpha?: number): Color4;
  4883. /**
  4884. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4885. * @returns the new array
  4886. */
  4887. asArray(): number[];
  4888. /**
  4889. * Returns the luminance value
  4890. * @returns a float value
  4891. */
  4892. toLuminance(): number;
  4893. /**
  4894. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4895. * @param otherColor defines the second operand
  4896. * @returns the new Color3 object
  4897. */
  4898. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4899. /**
  4900. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4901. * @param otherColor defines the second operand
  4902. * @param result defines the Color3 object where to store the result
  4903. * @returns the current Color3
  4904. */
  4905. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4906. /**
  4907. * Determines equality between Color3 objects
  4908. * @param otherColor defines the second operand
  4909. * @returns true if the rgb values are equal to the given ones
  4910. */
  4911. equals(otherColor: DeepImmutable<Color3>): boolean;
  4912. /**
  4913. * Determines equality between the current Color3 object and a set of r,b,g values
  4914. * @param r defines the red component to check
  4915. * @param g defines the green component to check
  4916. * @param b defines the blue component to check
  4917. * @returns true if the rgb values are equal to the given ones
  4918. */
  4919. equalsFloats(r: number, g: number, b: number): boolean;
  4920. /**
  4921. * Multiplies in place each rgb value by scale
  4922. * @param scale defines the scaling factor
  4923. * @returns the updated Color3
  4924. */
  4925. scale(scale: number): Color3;
  4926. /**
  4927. * Multiplies the rgb values by scale and stores the result into "result"
  4928. * @param scale defines the scaling factor
  4929. * @param result defines the Color3 object where to store the result
  4930. * @returns the unmodified current Color3
  4931. */
  4932. scaleToRef(scale: number, result: Color3): Color3;
  4933. /**
  4934. * Scale the current Color3 values by a factor and add the result to a given Color3
  4935. * @param scale defines the scale factor
  4936. * @param result defines color to store the result into
  4937. * @returns the unmodified current Color3
  4938. */
  4939. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4940. /**
  4941. * Clamps the rgb values by the min and max values and stores the result into "result"
  4942. * @param min defines minimum clamping value (default is 0)
  4943. * @param max defines maximum clamping value (default is 1)
  4944. * @param result defines color to store the result into
  4945. * @returns the original Color3
  4946. */
  4947. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4948. /**
  4949. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4950. * @param otherColor defines the second operand
  4951. * @returns the new Color3
  4952. */
  4953. add(otherColor: DeepImmutable<Color3>): Color3;
  4954. /**
  4955. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4956. * @param otherColor defines the second operand
  4957. * @param result defines Color3 object to store the result into
  4958. * @returns the unmodified current Color3
  4959. */
  4960. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4961. /**
  4962. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4963. * @param otherColor defines the second operand
  4964. * @returns the new Color3
  4965. */
  4966. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4967. /**
  4968. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4969. * @param otherColor defines the second operand
  4970. * @param result defines Color3 object to store the result into
  4971. * @returns the unmodified current Color3
  4972. */
  4973. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4974. /**
  4975. * Copy the current object
  4976. * @returns a new Color3 copied the current one
  4977. */
  4978. clone(): Color3;
  4979. /**
  4980. * Copies the rgb values from the source in the current Color3
  4981. * @param source defines the source Color3 object
  4982. * @returns the updated Color3 object
  4983. */
  4984. copyFrom(source: DeepImmutable<Color3>): Color3;
  4985. /**
  4986. * Updates the Color3 rgb values from the given floats
  4987. * @param r defines the red component to read from
  4988. * @param g defines the green component to read from
  4989. * @param b defines the blue component to read from
  4990. * @returns the current Color3 object
  4991. */
  4992. copyFromFloats(r: number, g: number, b: number): Color3;
  4993. /**
  4994. * Updates the Color3 rgb values from the given floats
  4995. * @param r defines the red component to read from
  4996. * @param g defines the green component to read from
  4997. * @param b defines the blue component to read from
  4998. * @returns the current Color3 object
  4999. */
  5000. set(r: number, g: number, b: number): Color3;
  5001. /**
  5002. * Compute the Color3 hexadecimal code as a string
  5003. * @returns a string containing the hexadecimal representation of the Color3 object
  5004. */
  5005. toHexString(): string;
  5006. /**
  5007. * Computes a new Color3 converted from the current one to linear space
  5008. * @returns a new Color3 object
  5009. */
  5010. toLinearSpace(): Color3;
  5011. /**
  5012. * Converts current color in rgb space to HSV values
  5013. * @returns a new color3 representing the HSV values
  5014. */
  5015. toHSV(): Color3;
  5016. /**
  5017. * Converts current color in rgb space to HSV values
  5018. * @param result defines the Color3 where to store the HSV values
  5019. */
  5020. toHSVToRef(result: Color3): void;
  5021. /**
  5022. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5023. * @param convertedColor defines the Color3 object where to store the linear space version
  5024. * @returns the unmodified Color3
  5025. */
  5026. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5027. /**
  5028. * Computes a new Color3 converted from the current one to gamma space
  5029. * @returns a new Color3 object
  5030. */
  5031. toGammaSpace(): Color3;
  5032. /**
  5033. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5034. * @param convertedColor defines the Color3 object where to store the gamma space version
  5035. * @returns the unmodified Color3
  5036. */
  5037. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5038. private static _BlackReadOnly;
  5039. /**
  5040. * Convert Hue, saturation and value to a Color3 (RGB)
  5041. * @param hue defines the hue
  5042. * @param saturation defines the saturation
  5043. * @param value defines the value
  5044. * @param result defines the Color3 where to store the RGB values
  5045. */
  5046. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5047. /**
  5048. * Creates a new Color3 from the string containing valid hexadecimal values
  5049. * @param hex defines a string containing valid hexadecimal values
  5050. * @returns a new Color3 object
  5051. */
  5052. static FromHexString(hex: string): Color3;
  5053. /**
  5054. * Creates a new Color3 from the starting index of the given array
  5055. * @param array defines the source array
  5056. * @param offset defines an offset in the source array
  5057. * @returns a new Color3 object
  5058. */
  5059. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5060. /**
  5061. * Creates a new Color3 from integer values (< 256)
  5062. * @param r defines the red component to read from (value between 0 and 255)
  5063. * @param g defines the green component to read from (value between 0 and 255)
  5064. * @param b defines the blue component to read from (value between 0 and 255)
  5065. * @returns a new Color3 object
  5066. */
  5067. static FromInts(r: number, g: number, b: number): Color3;
  5068. /**
  5069. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5070. * @param start defines the start Color3 value
  5071. * @param end defines the end Color3 value
  5072. * @param amount defines the gradient value between start and end
  5073. * @returns a new Color3 object
  5074. */
  5075. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5076. /**
  5077. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5078. * @param left defines the start value
  5079. * @param right defines the end value
  5080. * @param amount defines the gradient factor
  5081. * @param result defines the Color3 object where to store the result
  5082. */
  5083. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5084. /**
  5085. * Returns a Color3 value containing a red color
  5086. * @returns a new Color3 object
  5087. */
  5088. static Red(): Color3;
  5089. /**
  5090. * Returns a Color3 value containing a green color
  5091. * @returns a new Color3 object
  5092. */
  5093. static Green(): Color3;
  5094. /**
  5095. * Returns a Color3 value containing a blue color
  5096. * @returns a new Color3 object
  5097. */
  5098. static Blue(): Color3;
  5099. /**
  5100. * Returns a Color3 value containing a black color
  5101. * @returns a new Color3 object
  5102. */
  5103. static Black(): Color3;
  5104. /**
  5105. * Gets a Color3 value containing a black color that must not be updated
  5106. */
  5107. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5108. /**
  5109. * Returns a Color3 value containing a white color
  5110. * @returns a new Color3 object
  5111. */
  5112. static White(): Color3;
  5113. /**
  5114. * Returns a Color3 value containing a purple color
  5115. * @returns a new Color3 object
  5116. */
  5117. static Purple(): Color3;
  5118. /**
  5119. * Returns a Color3 value containing a magenta color
  5120. * @returns a new Color3 object
  5121. */
  5122. static Magenta(): Color3;
  5123. /**
  5124. * Returns a Color3 value containing a yellow color
  5125. * @returns a new Color3 object
  5126. */
  5127. static Yellow(): Color3;
  5128. /**
  5129. * Returns a Color3 value containing a gray color
  5130. * @returns a new Color3 object
  5131. */
  5132. static Gray(): Color3;
  5133. /**
  5134. * Returns a Color3 value containing a teal color
  5135. * @returns a new Color3 object
  5136. */
  5137. static Teal(): Color3;
  5138. /**
  5139. * Returns a Color3 value containing a random color
  5140. * @returns a new Color3 object
  5141. */
  5142. static Random(): Color3;
  5143. }
  5144. /**
  5145. * Class used to hold a RBGA color
  5146. */
  5147. export class Color4 {
  5148. /**
  5149. * Defines the red component (between 0 and 1, default is 0)
  5150. */
  5151. r: number;
  5152. /**
  5153. * Defines the green component (between 0 and 1, default is 0)
  5154. */
  5155. g: number;
  5156. /**
  5157. * Defines the blue component (between 0 and 1, default is 0)
  5158. */
  5159. b: number;
  5160. /**
  5161. * Defines the alpha component (between 0 and 1, default is 1)
  5162. */
  5163. a: number;
  5164. /**
  5165. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5166. * @param r defines the red component (between 0 and 1, default is 0)
  5167. * @param g defines the green component (between 0 and 1, default is 0)
  5168. * @param b defines the blue component (between 0 and 1, default is 0)
  5169. * @param a defines the alpha component (between 0 and 1, default is 1)
  5170. */
  5171. constructor(
  5172. /**
  5173. * Defines the red component (between 0 and 1, default is 0)
  5174. */
  5175. r?: number,
  5176. /**
  5177. * Defines the green component (between 0 and 1, default is 0)
  5178. */
  5179. g?: number,
  5180. /**
  5181. * Defines the blue component (between 0 and 1, default is 0)
  5182. */
  5183. b?: number,
  5184. /**
  5185. * Defines the alpha component (between 0 and 1, default is 1)
  5186. */
  5187. a?: number);
  5188. /**
  5189. * Adds in place the given Color4 values to the current Color4 object
  5190. * @param right defines the second operand
  5191. * @returns the current updated Color4 object
  5192. */
  5193. addInPlace(right: DeepImmutable<Color4>): Color4;
  5194. /**
  5195. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5196. * @returns the new array
  5197. */
  5198. asArray(): number[];
  5199. /**
  5200. * Stores from the starting index in the given array the Color4 successive values
  5201. * @param array defines the array where to store the r,g,b components
  5202. * @param index defines an optional index in the target array to define where to start storing values
  5203. * @returns the current Color4 object
  5204. */
  5205. toArray(array: number[], index?: number): Color4;
  5206. /**
  5207. * Determines equality between Color4 objects
  5208. * @param otherColor defines the second operand
  5209. * @returns true if the rgba values are equal to the given ones
  5210. */
  5211. equals(otherColor: DeepImmutable<Color4>): boolean;
  5212. /**
  5213. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5214. * @param right defines the second operand
  5215. * @returns a new Color4 object
  5216. */
  5217. add(right: DeepImmutable<Color4>): Color4;
  5218. /**
  5219. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5220. * @param right defines the second operand
  5221. * @returns a new Color4 object
  5222. */
  5223. subtract(right: DeepImmutable<Color4>): Color4;
  5224. /**
  5225. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5226. * @param right defines the second operand
  5227. * @param result defines the Color4 object where to store the result
  5228. * @returns the current Color4 object
  5229. */
  5230. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5231. /**
  5232. * Creates a new Color4 with the current Color4 values multiplied by scale
  5233. * @param scale defines the scaling factor to apply
  5234. * @returns a new Color4 object
  5235. */
  5236. scale(scale: number): Color4;
  5237. /**
  5238. * Multiplies the current Color4 values by scale and stores the result in "result"
  5239. * @param scale defines the scaling factor to apply
  5240. * @param result defines the Color4 object where to store the result
  5241. * @returns the current unmodified Color4
  5242. */
  5243. scaleToRef(scale: number, result: Color4): Color4;
  5244. /**
  5245. * Scale the current Color4 values by a factor and add the result to a given Color4
  5246. * @param scale defines the scale factor
  5247. * @param result defines the Color4 object where to store the result
  5248. * @returns the unmodified current Color4
  5249. */
  5250. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5251. /**
  5252. * Clamps the rgb values by the min and max values and stores the result into "result"
  5253. * @param min defines minimum clamping value (default is 0)
  5254. * @param max defines maximum clamping value (default is 1)
  5255. * @param result defines color to store the result into.
  5256. * @returns the cuurent Color4
  5257. */
  5258. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5259. /**
  5260. * Multipy an Color4 value by another and return a new Color4 object
  5261. * @param color defines the Color4 value to multiply by
  5262. * @returns a new Color4 object
  5263. */
  5264. multiply(color: Color4): Color4;
  5265. /**
  5266. * Multipy a Color4 value by another and push the result in a reference value
  5267. * @param color defines the Color4 value to multiply by
  5268. * @param result defines the Color4 to fill the result in
  5269. * @returns the result Color4
  5270. */
  5271. multiplyToRef(color: Color4, result: Color4): Color4;
  5272. /**
  5273. * Creates a string with the Color4 current values
  5274. * @returns the string representation of the Color4 object
  5275. */
  5276. toString(): string;
  5277. /**
  5278. * Returns the string "Color4"
  5279. * @returns "Color4"
  5280. */
  5281. getClassName(): string;
  5282. /**
  5283. * Compute the Color4 hash code
  5284. * @returns an unique number that can be used to hash Color4 objects
  5285. */
  5286. getHashCode(): number;
  5287. /**
  5288. * Creates a new Color4 copied from the current one
  5289. * @returns a new Color4 object
  5290. */
  5291. clone(): Color4;
  5292. /**
  5293. * Copies the given Color4 values into the current one
  5294. * @param source defines the source Color4 object
  5295. * @returns the current updated Color4 object
  5296. */
  5297. copyFrom(source: Color4): Color4;
  5298. /**
  5299. * Copies the given float values into the current one
  5300. * @param r defines the red component to read from
  5301. * @param g defines the green component to read from
  5302. * @param b defines the blue component to read from
  5303. * @param a defines the alpha component to read from
  5304. * @returns the current updated Color4 object
  5305. */
  5306. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5307. /**
  5308. * Copies the given float values into the current one
  5309. * @param r defines the red component to read from
  5310. * @param g defines the green component to read from
  5311. * @param b defines the blue component to read from
  5312. * @param a defines the alpha component to read from
  5313. * @returns the current updated Color4 object
  5314. */
  5315. set(r: number, g: number, b: number, a: number): Color4;
  5316. /**
  5317. * Compute the Color4 hexadecimal code as a string
  5318. * @returns a string containing the hexadecimal representation of the Color4 object
  5319. */
  5320. toHexString(): string;
  5321. /**
  5322. * Computes a new Color4 converted from the current one to linear space
  5323. * @returns a new Color4 object
  5324. */
  5325. toLinearSpace(): Color4;
  5326. /**
  5327. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5328. * @param convertedColor defines the Color4 object where to store the linear space version
  5329. * @returns the unmodified Color4
  5330. */
  5331. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5332. /**
  5333. * Computes a new Color4 converted from the current one to gamma space
  5334. * @returns a new Color4 object
  5335. */
  5336. toGammaSpace(): Color4;
  5337. /**
  5338. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5339. * @param convertedColor defines the Color4 object where to store the gamma space version
  5340. * @returns the unmodified Color4
  5341. */
  5342. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5343. /**
  5344. * Creates a new Color4 from the string containing valid hexadecimal values
  5345. * @param hex defines a string containing valid hexadecimal values
  5346. * @returns a new Color4 object
  5347. */
  5348. static FromHexString(hex: string): Color4;
  5349. /**
  5350. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5351. * @param left defines the start value
  5352. * @param right defines the end value
  5353. * @param amount defines the gradient factor
  5354. * @returns a new Color4 object
  5355. */
  5356. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5357. /**
  5358. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5359. * @param left defines the start value
  5360. * @param right defines the end value
  5361. * @param amount defines the gradient factor
  5362. * @param result defines the Color4 object where to store data
  5363. */
  5364. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5365. /**
  5366. * Creates a new Color4 from a Color3 and an alpha value
  5367. * @param color3 defines the source Color3 to read from
  5368. * @param alpha defines the alpha component (1.0 by default)
  5369. * @returns a new Color4 object
  5370. */
  5371. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5372. /**
  5373. * Creates a new Color4 from the starting index element of the given array
  5374. * @param array defines the source array to read from
  5375. * @param offset defines the offset in the source array
  5376. * @returns a new Color4 object
  5377. */
  5378. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5379. /**
  5380. * Creates a new Color3 from integer values (< 256)
  5381. * @param r defines the red component to read from (value between 0 and 255)
  5382. * @param g defines the green component to read from (value between 0 and 255)
  5383. * @param b defines the blue component to read from (value between 0 and 255)
  5384. * @param a defines the alpha component to read from (value between 0 and 255)
  5385. * @returns a new Color3 object
  5386. */
  5387. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5388. /**
  5389. * Check the content of a given array and convert it to an array containing RGBA data
  5390. * If the original array was already containing count * 4 values then it is returned directly
  5391. * @param colors defines the array to check
  5392. * @param count defines the number of RGBA data to expect
  5393. * @returns an array containing count * 4 values (RGBA)
  5394. */
  5395. static CheckColors4(colors: number[], count: number): number[];
  5396. }
  5397. /**
  5398. * @hidden
  5399. */
  5400. export class TmpColors {
  5401. static Color3: Color3[];
  5402. static Color4: Color4[];
  5403. }
  5404. }
  5405. declare module "babylonjs/Maths/sphericalPolynomial" {
  5406. import { Vector3 } from "babylonjs/Maths/math.vector";
  5407. import { Color3 } from "babylonjs/Maths/math.color";
  5408. /**
  5409. * Class representing spherical harmonics coefficients to the 3rd degree
  5410. */
  5411. export class SphericalHarmonics {
  5412. /**
  5413. * Defines whether or not the harmonics have been prescaled for rendering.
  5414. */
  5415. preScaled: boolean;
  5416. /**
  5417. * The l0,0 coefficients of the spherical harmonics
  5418. */
  5419. l00: Vector3;
  5420. /**
  5421. * The l1,-1 coefficients of the spherical harmonics
  5422. */
  5423. l1_1: Vector3;
  5424. /**
  5425. * The l1,0 coefficients of the spherical harmonics
  5426. */
  5427. l10: Vector3;
  5428. /**
  5429. * The l1,1 coefficients of the spherical harmonics
  5430. */
  5431. l11: Vector3;
  5432. /**
  5433. * The l2,-2 coefficients of the spherical harmonics
  5434. */
  5435. l2_2: Vector3;
  5436. /**
  5437. * The l2,-1 coefficients of the spherical harmonics
  5438. */
  5439. l2_1: Vector3;
  5440. /**
  5441. * The l2,0 coefficients of the spherical harmonics
  5442. */
  5443. l20: Vector3;
  5444. /**
  5445. * The l2,1 coefficients of the spherical harmonics
  5446. */
  5447. l21: Vector3;
  5448. /**
  5449. * The l2,2 coefficients of the spherical harmonics
  5450. */
  5451. l22: Vector3;
  5452. /**
  5453. * Adds a light to the spherical harmonics
  5454. * @param direction the direction of the light
  5455. * @param color the color of the light
  5456. * @param deltaSolidAngle the delta solid angle of the light
  5457. */
  5458. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5459. /**
  5460. * Scales the spherical harmonics by the given amount
  5461. * @param scale the amount to scale
  5462. */
  5463. scaleInPlace(scale: number): void;
  5464. /**
  5465. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5466. *
  5467. * ```
  5468. * E_lm = A_l * L_lm
  5469. * ```
  5470. *
  5471. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5472. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5473. * the scaling factors are given in equation 9.
  5474. */
  5475. convertIncidentRadianceToIrradiance(): void;
  5476. /**
  5477. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5478. *
  5479. * ```
  5480. * L = (1/pi) * E * rho
  5481. * ```
  5482. *
  5483. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5484. */
  5485. convertIrradianceToLambertianRadiance(): void;
  5486. /**
  5487. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5488. * required operations at run time.
  5489. *
  5490. * This is simply done by scaling back the SH with Ylm constants parameter.
  5491. * The trigonometric part being applied by the shader at run time.
  5492. */
  5493. preScaleForRendering(): void;
  5494. /**
  5495. * Constructs a spherical harmonics from an array.
  5496. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5497. * @returns the spherical harmonics
  5498. */
  5499. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5500. /**
  5501. * Gets the spherical harmonics from polynomial
  5502. * @param polynomial the spherical polynomial
  5503. * @returns the spherical harmonics
  5504. */
  5505. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5506. }
  5507. /**
  5508. * Class representing spherical polynomial coefficients to the 3rd degree
  5509. */
  5510. export class SphericalPolynomial {
  5511. private _harmonics;
  5512. /**
  5513. * The spherical harmonics used to create the polynomials.
  5514. */
  5515. readonly preScaledHarmonics: SphericalHarmonics;
  5516. /**
  5517. * The x coefficients of the spherical polynomial
  5518. */
  5519. x: Vector3;
  5520. /**
  5521. * The y coefficients of the spherical polynomial
  5522. */
  5523. y: Vector3;
  5524. /**
  5525. * The z coefficients of the spherical polynomial
  5526. */
  5527. z: Vector3;
  5528. /**
  5529. * The xx coefficients of the spherical polynomial
  5530. */
  5531. xx: Vector3;
  5532. /**
  5533. * The yy coefficients of the spherical polynomial
  5534. */
  5535. yy: Vector3;
  5536. /**
  5537. * The zz coefficients of the spherical polynomial
  5538. */
  5539. zz: Vector3;
  5540. /**
  5541. * The xy coefficients of the spherical polynomial
  5542. */
  5543. xy: Vector3;
  5544. /**
  5545. * The yz coefficients of the spherical polynomial
  5546. */
  5547. yz: Vector3;
  5548. /**
  5549. * The zx coefficients of the spherical polynomial
  5550. */
  5551. zx: Vector3;
  5552. /**
  5553. * Adds an ambient color to the spherical polynomial
  5554. * @param color the color to add
  5555. */
  5556. addAmbient(color: Color3): void;
  5557. /**
  5558. * Scales the spherical polynomial by the given amount
  5559. * @param scale the amount to scale
  5560. */
  5561. scaleInPlace(scale: number): void;
  5562. /**
  5563. * Gets the spherical polynomial from harmonics
  5564. * @param harmonics the spherical harmonics
  5565. * @returns the spherical polynomial
  5566. */
  5567. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5568. /**
  5569. * Constructs a spherical polynomial from an array.
  5570. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5571. * @returns the spherical polynomial
  5572. */
  5573. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5574. }
  5575. }
  5576. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5577. /**
  5578. * Define options used to create a render target texture
  5579. */
  5580. export class RenderTargetCreationOptions {
  5581. /**
  5582. * Specifies is mipmaps must be generated
  5583. */
  5584. generateMipMaps?: boolean;
  5585. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5586. generateDepthBuffer?: boolean;
  5587. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5588. generateStencilBuffer?: boolean;
  5589. /** Defines texture type (int by default) */
  5590. type?: number;
  5591. /** Defines sampling mode (trilinear by default) */
  5592. samplingMode?: number;
  5593. /** Defines format (RGBA by default) */
  5594. format?: number;
  5595. }
  5596. }
  5597. declare module "babylonjs/States/alphaCullingState" {
  5598. /**
  5599. * @hidden
  5600. **/
  5601. export class _AlphaState {
  5602. private _isAlphaBlendDirty;
  5603. private _isBlendFunctionParametersDirty;
  5604. private _isBlendEquationParametersDirty;
  5605. private _isBlendConstantsDirty;
  5606. private _alphaBlend;
  5607. private _blendFunctionParameters;
  5608. private _blendEquationParameters;
  5609. private _blendConstants;
  5610. /**
  5611. * Initializes the state.
  5612. */
  5613. constructor();
  5614. readonly isDirty: boolean;
  5615. alphaBlend: boolean;
  5616. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5617. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5618. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5619. reset(): void;
  5620. apply(gl: WebGLRenderingContext): void;
  5621. }
  5622. }
  5623. declare module "babylonjs/States/depthCullingState" {
  5624. import { Nullable } from "babylonjs/types";
  5625. /**
  5626. * @hidden
  5627. **/
  5628. export class _DepthCullingState {
  5629. private _isDepthTestDirty;
  5630. private _isDepthMaskDirty;
  5631. private _isDepthFuncDirty;
  5632. private _isCullFaceDirty;
  5633. private _isCullDirty;
  5634. private _isZOffsetDirty;
  5635. private _isFrontFaceDirty;
  5636. private _depthTest;
  5637. private _depthMask;
  5638. private _depthFunc;
  5639. private _cull;
  5640. private _cullFace;
  5641. private _zOffset;
  5642. private _frontFace;
  5643. /**
  5644. * Initializes the state.
  5645. */
  5646. constructor();
  5647. readonly isDirty: boolean;
  5648. zOffset: number;
  5649. cullFace: Nullable<number>;
  5650. cull: Nullable<boolean>;
  5651. depthFunc: Nullable<number>;
  5652. depthMask: boolean;
  5653. depthTest: boolean;
  5654. frontFace: Nullable<number>;
  5655. reset(): void;
  5656. apply(gl: WebGLRenderingContext): void;
  5657. }
  5658. }
  5659. declare module "babylonjs/States/stencilState" {
  5660. /**
  5661. * @hidden
  5662. **/
  5663. export class _StencilState {
  5664. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  5665. static readonly ALWAYS: number;
  5666. /** Passed to stencilOperation to specify that stencil value must be kept */
  5667. static readonly KEEP: number;
  5668. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5669. static readonly REPLACE: number;
  5670. private _isStencilTestDirty;
  5671. private _isStencilMaskDirty;
  5672. private _isStencilFuncDirty;
  5673. private _isStencilOpDirty;
  5674. private _stencilTest;
  5675. private _stencilMask;
  5676. private _stencilFunc;
  5677. private _stencilFuncRef;
  5678. private _stencilFuncMask;
  5679. private _stencilOpStencilFail;
  5680. private _stencilOpDepthFail;
  5681. private _stencilOpStencilDepthPass;
  5682. readonly isDirty: boolean;
  5683. stencilFunc: number;
  5684. stencilFuncRef: number;
  5685. stencilFuncMask: number;
  5686. stencilOpStencilFail: number;
  5687. stencilOpDepthFail: number;
  5688. stencilOpStencilDepthPass: number;
  5689. stencilMask: number;
  5690. stencilTest: boolean;
  5691. constructor();
  5692. reset(): void;
  5693. apply(gl: WebGLRenderingContext): void;
  5694. }
  5695. }
  5696. declare module "babylonjs/States/index" {
  5697. export * from "babylonjs/States/alphaCullingState";
  5698. export * from "babylonjs/States/depthCullingState";
  5699. export * from "babylonjs/States/stencilState";
  5700. }
  5701. declare module "babylonjs/Instrumentation/timeToken" {
  5702. import { Nullable } from "babylonjs/types";
  5703. /**
  5704. * @hidden
  5705. **/
  5706. export class _TimeToken {
  5707. _startTimeQuery: Nullable<WebGLQuery>;
  5708. _endTimeQuery: Nullable<WebGLQuery>;
  5709. _timeElapsedQuery: Nullable<WebGLQuery>;
  5710. _timeElapsedQueryEnded: boolean;
  5711. }
  5712. }
  5713. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5714. /**
  5715. * Class used to evalaute queries containing `and` and `or` operators
  5716. */
  5717. export class AndOrNotEvaluator {
  5718. /**
  5719. * Evaluate a query
  5720. * @param query defines the query to evaluate
  5721. * @param evaluateCallback defines the callback used to filter result
  5722. * @returns true if the query matches
  5723. */
  5724. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5725. private static _HandleParenthesisContent;
  5726. private static _SimplifyNegation;
  5727. }
  5728. }
  5729. declare module "babylonjs/Misc/tags" {
  5730. /**
  5731. * Class used to store custom tags
  5732. */
  5733. export class Tags {
  5734. /**
  5735. * Adds support for tags on the given object
  5736. * @param obj defines the object to use
  5737. */
  5738. static EnableFor(obj: any): void;
  5739. /**
  5740. * Removes tags support
  5741. * @param obj defines the object to use
  5742. */
  5743. static DisableFor(obj: any): void;
  5744. /**
  5745. * Gets a boolean indicating if the given object has tags
  5746. * @param obj defines the object to use
  5747. * @returns a boolean
  5748. */
  5749. static HasTags(obj: any): boolean;
  5750. /**
  5751. * Gets the tags available on a given object
  5752. * @param obj defines the object to use
  5753. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5754. * @returns the tags
  5755. */
  5756. static GetTags(obj: any, asString?: boolean): any;
  5757. /**
  5758. * Adds tags to an object
  5759. * @param obj defines the object to use
  5760. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5761. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5762. */
  5763. static AddTagsTo(obj: any, tagsString: string): void;
  5764. /**
  5765. * @hidden
  5766. */
  5767. static _AddTagTo(obj: any, tag: string): void;
  5768. /**
  5769. * Removes specific tags from a specific object
  5770. * @param obj defines the object to use
  5771. * @param tagsString defines the tags to remove
  5772. */
  5773. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5774. /**
  5775. * @hidden
  5776. */
  5777. static _RemoveTagFrom(obj: any, tag: string): void;
  5778. /**
  5779. * Defines if tags hosted on an object match a given query
  5780. * @param obj defines the object to use
  5781. * @param tagsQuery defines the tag query
  5782. * @returns a boolean
  5783. */
  5784. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5785. }
  5786. }
  5787. declare module "babylonjs/Maths/math.path" {
  5788. import { DeepImmutable, Nullable } from "babylonjs/types";
  5789. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5790. /**
  5791. * Defines potential orientation for back face culling
  5792. */
  5793. export enum Orientation {
  5794. /**
  5795. * Clockwise
  5796. */
  5797. CW = 0,
  5798. /** Counter clockwise */
  5799. CCW = 1
  5800. }
  5801. /** Class used to represent a Bezier curve */
  5802. export class BezierCurve {
  5803. /**
  5804. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5805. * @param t defines the time
  5806. * @param x1 defines the left coordinate on X axis
  5807. * @param y1 defines the left coordinate on Y axis
  5808. * @param x2 defines the right coordinate on X axis
  5809. * @param y2 defines the right coordinate on Y axis
  5810. * @returns the interpolated value
  5811. */
  5812. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5813. }
  5814. /**
  5815. * Defines angle representation
  5816. */
  5817. export class Angle {
  5818. private _radians;
  5819. /**
  5820. * Creates an Angle object of "radians" radians (float).
  5821. * @param radians the angle in radians
  5822. */
  5823. constructor(radians: number);
  5824. /**
  5825. * Get value in degrees
  5826. * @returns the Angle value in degrees (float)
  5827. */
  5828. degrees(): number;
  5829. /**
  5830. * Get value in radians
  5831. * @returns the Angle value in radians (float)
  5832. */
  5833. radians(): number;
  5834. /**
  5835. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5836. * @param a defines first vector
  5837. * @param b defines second vector
  5838. * @returns a new Angle
  5839. */
  5840. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5841. /**
  5842. * Gets a new Angle object from the given float in radians
  5843. * @param radians defines the angle value in radians
  5844. * @returns a new Angle
  5845. */
  5846. static FromRadians(radians: number): Angle;
  5847. /**
  5848. * Gets a new Angle object from the given float in degrees
  5849. * @param degrees defines the angle value in degrees
  5850. * @returns a new Angle
  5851. */
  5852. static FromDegrees(degrees: number): Angle;
  5853. }
  5854. /**
  5855. * This represents an arc in a 2d space.
  5856. */
  5857. export class Arc2 {
  5858. /** Defines the start point of the arc */
  5859. startPoint: Vector2;
  5860. /** Defines the mid point of the arc */
  5861. midPoint: Vector2;
  5862. /** Defines the end point of the arc */
  5863. endPoint: Vector2;
  5864. /**
  5865. * Defines the center point of the arc.
  5866. */
  5867. centerPoint: Vector2;
  5868. /**
  5869. * Defines the radius of the arc.
  5870. */
  5871. radius: number;
  5872. /**
  5873. * Defines the angle of the arc (from mid point to end point).
  5874. */
  5875. angle: Angle;
  5876. /**
  5877. * Defines the start angle of the arc (from start point to middle point).
  5878. */
  5879. startAngle: Angle;
  5880. /**
  5881. * Defines the orientation of the arc (clock wise/counter clock wise).
  5882. */
  5883. orientation: Orientation;
  5884. /**
  5885. * Creates an Arc object from the three given points : start, middle and end.
  5886. * @param startPoint Defines the start point of the arc
  5887. * @param midPoint Defines the midlle point of the arc
  5888. * @param endPoint Defines the end point of the arc
  5889. */
  5890. constructor(
  5891. /** Defines the start point of the arc */
  5892. startPoint: Vector2,
  5893. /** Defines the mid point of the arc */
  5894. midPoint: Vector2,
  5895. /** Defines the end point of the arc */
  5896. endPoint: Vector2);
  5897. }
  5898. /**
  5899. * Represents a 2D path made up of multiple 2D points
  5900. */
  5901. export class Path2 {
  5902. private _points;
  5903. private _length;
  5904. /**
  5905. * If the path start and end point are the same
  5906. */
  5907. closed: boolean;
  5908. /**
  5909. * Creates a Path2 object from the starting 2D coordinates x and y.
  5910. * @param x the starting points x value
  5911. * @param y the starting points y value
  5912. */
  5913. constructor(x: number, y: number);
  5914. /**
  5915. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5916. * @param x the added points x value
  5917. * @param y the added points y value
  5918. * @returns the updated Path2.
  5919. */
  5920. addLineTo(x: number, y: number): Path2;
  5921. /**
  5922. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5923. * @param midX middle point x value
  5924. * @param midY middle point y value
  5925. * @param endX end point x value
  5926. * @param endY end point y value
  5927. * @param numberOfSegments (default: 36)
  5928. * @returns the updated Path2.
  5929. */
  5930. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5931. /**
  5932. * Closes the Path2.
  5933. * @returns the Path2.
  5934. */
  5935. close(): Path2;
  5936. /**
  5937. * Gets the sum of the distance between each sequential point in the path
  5938. * @returns the Path2 total length (float).
  5939. */
  5940. length(): number;
  5941. /**
  5942. * Gets the points which construct the path
  5943. * @returns the Path2 internal array of points.
  5944. */
  5945. getPoints(): Vector2[];
  5946. /**
  5947. * Retreives the point at the distance aways from the starting point
  5948. * @param normalizedLengthPosition the length along the path to retreive the point from
  5949. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5950. */
  5951. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5952. /**
  5953. * Creates a new path starting from an x and y position
  5954. * @param x starting x value
  5955. * @param y starting y value
  5956. * @returns a new Path2 starting at the coordinates (x, y).
  5957. */
  5958. static StartingAt(x: number, y: number): Path2;
  5959. }
  5960. /**
  5961. * Represents a 3D path made up of multiple 3D points
  5962. */
  5963. export class Path3D {
  5964. /**
  5965. * an array of Vector3, the curve axis of the Path3D
  5966. */
  5967. path: Vector3[];
  5968. private _curve;
  5969. private _distances;
  5970. private _tangents;
  5971. private _normals;
  5972. private _binormals;
  5973. private _raw;
  5974. /**
  5975. * new Path3D(path, normal, raw)
  5976. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5977. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5978. * @param path an array of Vector3, the curve axis of the Path3D
  5979. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5980. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5981. */
  5982. constructor(
  5983. /**
  5984. * an array of Vector3, the curve axis of the Path3D
  5985. */
  5986. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5987. /**
  5988. * Returns the Path3D array of successive Vector3 designing its curve.
  5989. * @returns the Path3D array of successive Vector3 designing its curve.
  5990. */
  5991. getCurve(): Vector3[];
  5992. /**
  5993. * Returns an array populated with tangent vectors on each Path3D curve point.
  5994. * @returns an array populated with tangent vectors on each Path3D curve point.
  5995. */
  5996. getTangents(): Vector3[];
  5997. /**
  5998. * Returns an array populated with normal vectors on each Path3D curve point.
  5999. * @returns an array populated with normal vectors on each Path3D curve point.
  6000. */
  6001. getNormals(): Vector3[];
  6002. /**
  6003. * Returns an array populated with binormal vectors on each Path3D curve point.
  6004. * @returns an array populated with binormal vectors on each Path3D curve point.
  6005. */
  6006. getBinormals(): Vector3[];
  6007. /**
  6008. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  6009. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  6010. */
  6011. getDistances(): number[];
  6012. /**
  6013. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  6014. * @param path path which all values are copied into the curves points
  6015. * @param firstNormal which should be projected onto the curve
  6016. * @returns the same object updated.
  6017. */
  6018. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  6019. private _compute;
  6020. private _getFirstNonNullVector;
  6021. private _getLastNonNullVector;
  6022. private _normalVector;
  6023. }
  6024. /**
  6025. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6026. * A Curve3 is designed from a series of successive Vector3.
  6027. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  6028. */
  6029. export class Curve3 {
  6030. private _points;
  6031. private _length;
  6032. /**
  6033. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  6034. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  6035. * @param v1 (Vector3) the control point
  6036. * @param v2 (Vector3) the end point of the Quadratic Bezier
  6037. * @param nbPoints (integer) the wanted number of points in the curve
  6038. * @returns the created Curve3
  6039. */
  6040. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6041. /**
  6042. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  6043. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6044. * @param v1 (Vector3) the first control point
  6045. * @param v2 (Vector3) the second control point
  6046. * @param v3 (Vector3) the end point of the Cubic Bezier
  6047. * @param nbPoints (integer) the wanted number of points in the curve
  6048. * @returns the created Curve3
  6049. */
  6050. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6051. /**
  6052. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6053. * @param p1 (Vector3) the origin point of the Hermite Spline
  6054. * @param t1 (Vector3) the tangent vector at the origin point
  6055. * @param p2 (Vector3) the end point of the Hermite Spline
  6056. * @param t2 (Vector3) the tangent vector at the end point
  6057. * @param nbPoints (integer) the wanted number of points in the curve
  6058. * @returns the created Curve3
  6059. */
  6060. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6061. /**
  6062. * Returns a Curve3 object along a CatmullRom Spline curve :
  6063. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6064. * @param nbPoints (integer) the wanted number of points between each curve control points
  6065. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6066. * @returns the created Curve3
  6067. */
  6068. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6069. /**
  6070. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6071. * A Curve3 is designed from a series of successive Vector3.
  6072. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6073. * @param points points which make up the curve
  6074. */
  6075. constructor(points: Vector3[]);
  6076. /**
  6077. * @returns the Curve3 stored array of successive Vector3
  6078. */
  6079. getPoints(): Vector3[];
  6080. /**
  6081. * @returns the computed length (float) of the curve.
  6082. */
  6083. length(): number;
  6084. /**
  6085. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6086. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6087. * curveA and curveB keep unchanged.
  6088. * @param curve the curve to continue from this curve
  6089. * @returns the newly constructed curve
  6090. */
  6091. continue(curve: DeepImmutable<Curve3>): Curve3;
  6092. private _computeLength;
  6093. }
  6094. }
  6095. declare module "babylonjs/Animations/easing" {
  6096. /**
  6097. * This represents the main contract an easing function should follow.
  6098. * Easing functions are used throughout the animation system.
  6099. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6100. */
  6101. export interface IEasingFunction {
  6102. /**
  6103. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6104. * of the easing function.
  6105. * The link below provides some of the most common examples of easing functions.
  6106. * @see https://easings.net/
  6107. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6108. * @returns the corresponding value on the curve defined by the easing function
  6109. */
  6110. ease(gradient: number): number;
  6111. }
  6112. /**
  6113. * Base class used for every default easing function.
  6114. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6115. */
  6116. export class EasingFunction implements IEasingFunction {
  6117. /**
  6118. * Interpolation follows the mathematical formula associated with the easing function.
  6119. */
  6120. static readonly EASINGMODE_EASEIN: number;
  6121. /**
  6122. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6123. */
  6124. static readonly EASINGMODE_EASEOUT: number;
  6125. /**
  6126. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6127. */
  6128. static readonly EASINGMODE_EASEINOUT: number;
  6129. private _easingMode;
  6130. /**
  6131. * Sets the easing mode of the current function.
  6132. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6133. */
  6134. setEasingMode(easingMode: number): void;
  6135. /**
  6136. * Gets the current easing mode.
  6137. * @returns the easing mode
  6138. */
  6139. getEasingMode(): number;
  6140. /**
  6141. * @hidden
  6142. */
  6143. easeInCore(gradient: number): number;
  6144. /**
  6145. * Given an input gradient between 0 and 1, this returns the corresponding value
  6146. * of the easing function.
  6147. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6148. * @returns the corresponding value on the curve defined by the easing function
  6149. */
  6150. ease(gradient: number): number;
  6151. }
  6152. /**
  6153. * Easing function with a circle shape (see link below).
  6154. * @see https://easings.net/#easeInCirc
  6155. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6156. */
  6157. export class CircleEase extends EasingFunction implements IEasingFunction {
  6158. /** @hidden */
  6159. easeInCore(gradient: number): number;
  6160. }
  6161. /**
  6162. * Easing function with a ease back shape (see link below).
  6163. * @see https://easings.net/#easeInBack
  6164. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6165. */
  6166. export class BackEase extends EasingFunction implements IEasingFunction {
  6167. /** Defines the amplitude of the function */
  6168. amplitude: number;
  6169. /**
  6170. * Instantiates a back ease easing
  6171. * @see https://easings.net/#easeInBack
  6172. * @param amplitude Defines the amplitude of the function
  6173. */
  6174. constructor(
  6175. /** Defines the amplitude of the function */
  6176. amplitude?: number);
  6177. /** @hidden */
  6178. easeInCore(gradient: number): number;
  6179. }
  6180. /**
  6181. * Easing function with a bouncing shape (see link below).
  6182. * @see https://easings.net/#easeInBounce
  6183. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6184. */
  6185. export class BounceEase extends EasingFunction implements IEasingFunction {
  6186. /** Defines the number of bounces */
  6187. bounces: number;
  6188. /** Defines the amplitude of the bounce */
  6189. bounciness: number;
  6190. /**
  6191. * Instantiates a bounce easing
  6192. * @see https://easings.net/#easeInBounce
  6193. * @param bounces Defines the number of bounces
  6194. * @param bounciness Defines the amplitude of the bounce
  6195. */
  6196. constructor(
  6197. /** Defines the number of bounces */
  6198. bounces?: number,
  6199. /** Defines the amplitude of the bounce */
  6200. bounciness?: number);
  6201. /** @hidden */
  6202. easeInCore(gradient: number): number;
  6203. }
  6204. /**
  6205. * Easing function with a power of 3 shape (see link below).
  6206. * @see https://easings.net/#easeInCubic
  6207. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6208. */
  6209. export class CubicEase extends EasingFunction implements IEasingFunction {
  6210. /** @hidden */
  6211. easeInCore(gradient: number): number;
  6212. }
  6213. /**
  6214. * Easing function with an elastic shape (see link below).
  6215. * @see https://easings.net/#easeInElastic
  6216. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6217. */
  6218. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6219. /** Defines the number of oscillations*/
  6220. oscillations: number;
  6221. /** Defines the amplitude of the oscillations*/
  6222. springiness: number;
  6223. /**
  6224. * Instantiates an elastic easing function
  6225. * @see https://easings.net/#easeInElastic
  6226. * @param oscillations Defines the number of oscillations
  6227. * @param springiness Defines the amplitude of the oscillations
  6228. */
  6229. constructor(
  6230. /** Defines the number of oscillations*/
  6231. oscillations?: number,
  6232. /** Defines the amplitude of the oscillations*/
  6233. springiness?: number);
  6234. /** @hidden */
  6235. easeInCore(gradient: number): number;
  6236. }
  6237. /**
  6238. * Easing function with an exponential shape (see link below).
  6239. * @see https://easings.net/#easeInExpo
  6240. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6241. */
  6242. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6243. /** Defines the exponent of the function */
  6244. exponent: number;
  6245. /**
  6246. * Instantiates an exponential easing function
  6247. * @see https://easings.net/#easeInExpo
  6248. * @param exponent Defines the exponent of the function
  6249. */
  6250. constructor(
  6251. /** Defines the exponent of the function */
  6252. exponent?: number);
  6253. /** @hidden */
  6254. easeInCore(gradient: number): number;
  6255. }
  6256. /**
  6257. * Easing function with a power shape (see link below).
  6258. * @see https://easings.net/#easeInQuad
  6259. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6260. */
  6261. export class PowerEase extends EasingFunction implements IEasingFunction {
  6262. /** Defines the power of the function */
  6263. power: number;
  6264. /**
  6265. * Instantiates an power base easing function
  6266. * @see https://easings.net/#easeInQuad
  6267. * @param power Defines the power of the function
  6268. */
  6269. constructor(
  6270. /** Defines the power of the function */
  6271. power?: number);
  6272. /** @hidden */
  6273. easeInCore(gradient: number): number;
  6274. }
  6275. /**
  6276. * Easing function with a power of 2 shape (see link below).
  6277. * @see https://easings.net/#easeInQuad
  6278. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6279. */
  6280. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6281. /** @hidden */
  6282. easeInCore(gradient: number): number;
  6283. }
  6284. /**
  6285. * Easing function with a power of 4 shape (see link below).
  6286. * @see https://easings.net/#easeInQuart
  6287. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6288. */
  6289. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6290. /** @hidden */
  6291. easeInCore(gradient: number): number;
  6292. }
  6293. /**
  6294. * Easing function with a power of 5 shape (see link below).
  6295. * @see https://easings.net/#easeInQuint
  6296. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6297. */
  6298. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6299. /** @hidden */
  6300. easeInCore(gradient: number): number;
  6301. }
  6302. /**
  6303. * Easing function with a sin shape (see link below).
  6304. * @see https://easings.net/#easeInSine
  6305. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6306. */
  6307. export class SineEase extends EasingFunction implements IEasingFunction {
  6308. /** @hidden */
  6309. easeInCore(gradient: number): number;
  6310. }
  6311. /**
  6312. * Easing function with a bezier shape (see link below).
  6313. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6314. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6315. */
  6316. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6317. /** Defines the x component of the start tangent in the bezier curve */
  6318. x1: number;
  6319. /** Defines the y component of the start tangent in the bezier curve */
  6320. y1: number;
  6321. /** Defines the x component of the end tangent in the bezier curve */
  6322. x2: number;
  6323. /** Defines the y component of the end tangent in the bezier curve */
  6324. y2: number;
  6325. /**
  6326. * Instantiates a bezier function
  6327. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6328. * @param x1 Defines the x component of the start tangent in the bezier curve
  6329. * @param y1 Defines the y component of the start tangent in the bezier curve
  6330. * @param x2 Defines the x component of the end tangent in the bezier curve
  6331. * @param y2 Defines the y component of the end tangent in the bezier curve
  6332. */
  6333. constructor(
  6334. /** Defines the x component of the start tangent in the bezier curve */
  6335. x1?: number,
  6336. /** Defines the y component of the start tangent in the bezier curve */
  6337. y1?: number,
  6338. /** Defines the x component of the end tangent in the bezier curve */
  6339. x2?: number,
  6340. /** Defines the y component of the end tangent in the bezier curve */
  6341. y2?: number);
  6342. /** @hidden */
  6343. easeInCore(gradient: number): number;
  6344. }
  6345. }
  6346. declare module "babylonjs/Animations/animationKey" {
  6347. /**
  6348. * Defines an interface which represents an animation key frame
  6349. */
  6350. export interface IAnimationKey {
  6351. /**
  6352. * Frame of the key frame
  6353. */
  6354. frame: number;
  6355. /**
  6356. * Value at the specifies key frame
  6357. */
  6358. value: any;
  6359. /**
  6360. * The input tangent for the cubic hermite spline
  6361. */
  6362. inTangent?: any;
  6363. /**
  6364. * The output tangent for the cubic hermite spline
  6365. */
  6366. outTangent?: any;
  6367. /**
  6368. * The animation interpolation type
  6369. */
  6370. interpolation?: AnimationKeyInterpolation;
  6371. }
  6372. /**
  6373. * Enum for the animation key frame interpolation type
  6374. */
  6375. export enum AnimationKeyInterpolation {
  6376. /**
  6377. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6378. */
  6379. STEP = 1
  6380. }
  6381. }
  6382. declare module "babylonjs/Animations/animationRange" {
  6383. /**
  6384. * Represents the range of an animation
  6385. */
  6386. export class AnimationRange {
  6387. /**The name of the animation range**/
  6388. name: string;
  6389. /**The starting frame of the animation */
  6390. from: number;
  6391. /**The ending frame of the animation*/
  6392. to: number;
  6393. /**
  6394. * Initializes the range of an animation
  6395. * @param name The name of the animation range
  6396. * @param from The starting frame of the animation
  6397. * @param to The ending frame of the animation
  6398. */
  6399. constructor(
  6400. /**The name of the animation range**/
  6401. name: string,
  6402. /**The starting frame of the animation */
  6403. from: number,
  6404. /**The ending frame of the animation*/
  6405. to: number);
  6406. /**
  6407. * Makes a copy of the animation range
  6408. * @returns A copy of the animation range
  6409. */
  6410. clone(): AnimationRange;
  6411. }
  6412. }
  6413. declare module "babylonjs/Animations/animationEvent" {
  6414. /**
  6415. * Composed of a frame, and an action function
  6416. */
  6417. export class AnimationEvent {
  6418. /** The frame for which the event is triggered **/
  6419. frame: number;
  6420. /** The event to perform when triggered **/
  6421. action: (currentFrame: number) => void;
  6422. /** Specifies if the event should be triggered only once**/
  6423. onlyOnce?: boolean | undefined;
  6424. /**
  6425. * Specifies if the animation event is done
  6426. */
  6427. isDone: boolean;
  6428. /**
  6429. * Initializes the animation event
  6430. * @param frame The frame for which the event is triggered
  6431. * @param action The event to perform when triggered
  6432. * @param onlyOnce Specifies if the event should be triggered only once
  6433. */
  6434. constructor(
  6435. /** The frame for which the event is triggered **/
  6436. frame: number,
  6437. /** The event to perform when triggered **/
  6438. action: (currentFrame: number) => void,
  6439. /** Specifies if the event should be triggered only once**/
  6440. onlyOnce?: boolean | undefined);
  6441. /** @hidden */
  6442. _clone(): AnimationEvent;
  6443. }
  6444. }
  6445. declare module "babylonjs/Behaviors/behavior" {
  6446. import { Nullable } from "babylonjs/types";
  6447. /**
  6448. * Interface used to define a behavior
  6449. */
  6450. export interface Behavior<T> {
  6451. /** gets or sets behavior's name */
  6452. name: string;
  6453. /**
  6454. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6455. */
  6456. init(): void;
  6457. /**
  6458. * Called when the behavior is attached to a target
  6459. * @param target defines the target where the behavior is attached to
  6460. */
  6461. attach(target: T): void;
  6462. /**
  6463. * Called when the behavior is detached from its target
  6464. */
  6465. detach(): void;
  6466. }
  6467. /**
  6468. * Interface implemented by classes supporting behaviors
  6469. */
  6470. export interface IBehaviorAware<T> {
  6471. /**
  6472. * Attach a behavior
  6473. * @param behavior defines the behavior to attach
  6474. * @returns the current host
  6475. */
  6476. addBehavior(behavior: Behavior<T>): T;
  6477. /**
  6478. * Remove a behavior from the current object
  6479. * @param behavior defines the behavior to detach
  6480. * @returns the current host
  6481. */
  6482. removeBehavior(behavior: Behavior<T>): T;
  6483. /**
  6484. * Gets a behavior using its name to search
  6485. * @param name defines the name to search
  6486. * @returns the behavior or null if not found
  6487. */
  6488. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6489. }
  6490. }
  6491. declare module "babylonjs/Misc/smartArray" {
  6492. /**
  6493. * Defines an array and its length.
  6494. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6495. */
  6496. export interface ISmartArrayLike<T> {
  6497. /**
  6498. * The data of the array.
  6499. */
  6500. data: Array<T>;
  6501. /**
  6502. * The active length of the array.
  6503. */
  6504. length: number;
  6505. }
  6506. /**
  6507. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6508. */
  6509. export class SmartArray<T> implements ISmartArrayLike<T> {
  6510. /**
  6511. * The full set of data from the array.
  6512. */
  6513. data: Array<T>;
  6514. /**
  6515. * The active length of the array.
  6516. */
  6517. length: number;
  6518. protected _id: number;
  6519. /**
  6520. * Instantiates a Smart Array.
  6521. * @param capacity defines the default capacity of the array.
  6522. */
  6523. constructor(capacity: number);
  6524. /**
  6525. * Pushes a value at the end of the active data.
  6526. * @param value defines the object to push in the array.
  6527. */
  6528. push(value: T): void;
  6529. /**
  6530. * Iterates over the active data and apply the lambda to them.
  6531. * @param func defines the action to apply on each value.
  6532. */
  6533. forEach(func: (content: T) => void): void;
  6534. /**
  6535. * Sorts the full sets of data.
  6536. * @param compareFn defines the comparison function to apply.
  6537. */
  6538. sort(compareFn: (a: T, b: T) => number): void;
  6539. /**
  6540. * Resets the active data to an empty array.
  6541. */
  6542. reset(): void;
  6543. /**
  6544. * Releases all the data from the array as well as the array.
  6545. */
  6546. dispose(): void;
  6547. /**
  6548. * Concats the active data with a given array.
  6549. * @param array defines the data to concatenate with.
  6550. */
  6551. concat(array: any): void;
  6552. /**
  6553. * Returns the position of a value in the active data.
  6554. * @param value defines the value to find the index for
  6555. * @returns the index if found in the active data otherwise -1
  6556. */
  6557. indexOf(value: T): number;
  6558. /**
  6559. * Returns whether an element is part of the active data.
  6560. * @param value defines the value to look for
  6561. * @returns true if found in the active data otherwise false
  6562. */
  6563. contains(value: T): boolean;
  6564. private static _GlobalId;
  6565. }
  6566. /**
  6567. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6568. * The data in this array can only be present once
  6569. */
  6570. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6571. private _duplicateId;
  6572. /**
  6573. * Pushes a value at the end of the active data.
  6574. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6575. * @param value defines the object to push in the array.
  6576. */
  6577. push(value: T): void;
  6578. /**
  6579. * Pushes a value at the end of the active data.
  6580. * If the data is already present, it won t be added again
  6581. * @param value defines the object to push in the array.
  6582. * @returns true if added false if it was already present
  6583. */
  6584. pushNoDuplicate(value: T): boolean;
  6585. /**
  6586. * Resets the active data to an empty array.
  6587. */
  6588. reset(): void;
  6589. /**
  6590. * Concats the active data with a given array.
  6591. * This ensures no dupplicate will be present in the result.
  6592. * @param array defines the data to concatenate with.
  6593. */
  6594. concatWithNoDuplicate(array: any): void;
  6595. }
  6596. }
  6597. declare module "babylonjs/Cameras/cameraInputsManager" {
  6598. import { Nullable } from "babylonjs/types";
  6599. import { Camera } from "babylonjs/Cameras/camera";
  6600. /**
  6601. * @ignore
  6602. * This is a list of all the different input types that are available in the application.
  6603. * Fo instance: ArcRotateCameraGamepadInput...
  6604. */
  6605. export var CameraInputTypes: {};
  6606. /**
  6607. * This is the contract to implement in order to create a new input class.
  6608. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6609. */
  6610. export interface ICameraInput<TCamera extends Camera> {
  6611. /**
  6612. * Defines the camera the input is attached to.
  6613. */
  6614. camera: Nullable<TCamera>;
  6615. /**
  6616. * Gets the class name of the current intput.
  6617. * @returns the class name
  6618. */
  6619. getClassName(): string;
  6620. /**
  6621. * Get the friendly name associated with the input class.
  6622. * @returns the input friendly name
  6623. */
  6624. getSimpleName(): string;
  6625. /**
  6626. * Attach the input controls to a specific dom element to get the input from.
  6627. * @param element Defines the element the controls should be listened from
  6628. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6629. */
  6630. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6631. /**
  6632. * Detach the current controls from the specified dom element.
  6633. * @param element Defines the element to stop listening the inputs from
  6634. */
  6635. detachControl(element: Nullable<HTMLElement>): void;
  6636. /**
  6637. * Update the current camera state depending on the inputs that have been used this frame.
  6638. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6639. */
  6640. checkInputs?: () => void;
  6641. }
  6642. /**
  6643. * Represents a map of input types to input instance or input index to input instance.
  6644. */
  6645. export interface CameraInputsMap<TCamera extends Camera> {
  6646. /**
  6647. * Accessor to the input by input type.
  6648. */
  6649. [name: string]: ICameraInput<TCamera>;
  6650. /**
  6651. * Accessor to the input by input index.
  6652. */
  6653. [idx: number]: ICameraInput<TCamera>;
  6654. }
  6655. /**
  6656. * This represents the input manager used within a camera.
  6657. * It helps dealing with all the different kind of input attached to a camera.
  6658. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6659. */
  6660. export class CameraInputsManager<TCamera extends Camera> {
  6661. /**
  6662. * Defines the list of inputs attahed to the camera.
  6663. */
  6664. attached: CameraInputsMap<TCamera>;
  6665. /**
  6666. * Defines the dom element the camera is collecting inputs from.
  6667. * This is null if the controls have not been attached.
  6668. */
  6669. attachedElement: Nullable<HTMLElement>;
  6670. /**
  6671. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6672. */
  6673. noPreventDefault: boolean;
  6674. /**
  6675. * Defined the camera the input manager belongs to.
  6676. */
  6677. camera: TCamera;
  6678. /**
  6679. * Update the current camera state depending on the inputs that have been used this frame.
  6680. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6681. */
  6682. checkInputs: () => void;
  6683. /**
  6684. * Instantiate a new Camera Input Manager.
  6685. * @param camera Defines the camera the input manager blongs to
  6686. */
  6687. constructor(camera: TCamera);
  6688. /**
  6689. * Add an input method to a camera
  6690. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6691. * @param input camera input method
  6692. */
  6693. add(input: ICameraInput<TCamera>): void;
  6694. /**
  6695. * Remove a specific input method from a camera
  6696. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6697. * @param inputToRemove camera input method
  6698. */
  6699. remove(inputToRemove: ICameraInput<TCamera>): void;
  6700. /**
  6701. * Remove a specific input type from a camera
  6702. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6703. * @param inputType the type of the input to remove
  6704. */
  6705. removeByType(inputType: string): void;
  6706. private _addCheckInputs;
  6707. /**
  6708. * Attach the input controls to the currently attached dom element to listen the events from.
  6709. * @param input Defines the input to attach
  6710. */
  6711. attachInput(input: ICameraInput<TCamera>): void;
  6712. /**
  6713. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6714. * @param element Defines the dom element to collect the events from
  6715. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6716. */
  6717. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6718. /**
  6719. * Detach the current manager inputs controls from a specific dom element.
  6720. * @param element Defines the dom element to collect the events from
  6721. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6722. */
  6723. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6724. /**
  6725. * Rebuild the dynamic inputCheck function from the current list of
  6726. * defined inputs in the manager.
  6727. */
  6728. rebuildInputCheck(): void;
  6729. /**
  6730. * Remove all attached input methods from a camera
  6731. */
  6732. clear(): void;
  6733. /**
  6734. * Serialize the current input manager attached to a camera.
  6735. * This ensures than once parsed,
  6736. * the input associated to the camera will be identical to the current ones
  6737. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6738. */
  6739. serialize(serializedCamera: any): void;
  6740. /**
  6741. * Parses an input manager serialized JSON to restore the previous list of inputs
  6742. * and states associated to a camera.
  6743. * @param parsedCamera Defines the JSON to parse
  6744. */
  6745. parse(parsedCamera: any): void;
  6746. }
  6747. }
  6748. declare module "babylonjs/Collisions/intersectionInfo" {
  6749. import { Nullable } from "babylonjs/types";
  6750. /**
  6751. * @hidden
  6752. */
  6753. export class IntersectionInfo {
  6754. bu: Nullable<number>;
  6755. bv: Nullable<number>;
  6756. distance: number;
  6757. faceId: number;
  6758. subMeshId: number;
  6759. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6760. }
  6761. }
  6762. declare module "babylonjs/Maths/math.plane" {
  6763. import { DeepImmutable } from "babylonjs/types";
  6764. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6765. /**
  6766. * Represens a plane by the equation ax + by + cz + d = 0
  6767. */
  6768. export class Plane {
  6769. private static _TmpMatrix;
  6770. /**
  6771. * Normal of the plane (a,b,c)
  6772. */
  6773. normal: Vector3;
  6774. /**
  6775. * d component of the plane
  6776. */
  6777. d: number;
  6778. /**
  6779. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6780. * @param a a component of the plane
  6781. * @param b b component of the plane
  6782. * @param c c component of the plane
  6783. * @param d d component of the plane
  6784. */
  6785. constructor(a: number, b: number, c: number, d: number);
  6786. /**
  6787. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6788. */
  6789. asArray(): number[];
  6790. /**
  6791. * @returns a new plane copied from the current Plane.
  6792. */
  6793. clone(): Plane;
  6794. /**
  6795. * @returns the string "Plane".
  6796. */
  6797. getClassName(): string;
  6798. /**
  6799. * @returns the Plane hash code.
  6800. */
  6801. getHashCode(): number;
  6802. /**
  6803. * Normalize the current Plane in place.
  6804. * @returns the updated Plane.
  6805. */
  6806. normalize(): Plane;
  6807. /**
  6808. * Applies a transformation the plane and returns the result
  6809. * @param transformation the transformation matrix to be applied to the plane
  6810. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6811. */
  6812. transform(transformation: DeepImmutable<Matrix>): Plane;
  6813. /**
  6814. * Calcualtte the dot product between the point and the plane normal
  6815. * @param point point to calculate the dot product with
  6816. * @returns the dot product (float) of the point coordinates and the plane normal.
  6817. */
  6818. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6819. /**
  6820. * Updates the current Plane from the plane defined by the three given points.
  6821. * @param point1 one of the points used to contruct the plane
  6822. * @param point2 one of the points used to contruct the plane
  6823. * @param point3 one of the points used to contruct the plane
  6824. * @returns the updated Plane.
  6825. */
  6826. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6827. /**
  6828. * Checks if the plane is facing a given direction
  6829. * @param direction the direction to check if the plane is facing
  6830. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6831. * @returns True is the vector "direction" is the same side than the plane normal.
  6832. */
  6833. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6834. /**
  6835. * Calculates the distance to a point
  6836. * @param point point to calculate distance to
  6837. * @returns the signed distance (float) from the given point to the Plane.
  6838. */
  6839. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6840. /**
  6841. * Creates a plane from an array
  6842. * @param array the array to create a plane from
  6843. * @returns a new Plane from the given array.
  6844. */
  6845. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6846. /**
  6847. * Creates a plane from three points
  6848. * @param point1 point used to create the plane
  6849. * @param point2 point used to create the plane
  6850. * @param point3 point used to create the plane
  6851. * @returns a new Plane defined by the three given points.
  6852. */
  6853. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6854. /**
  6855. * Creates a plane from an origin point and a normal
  6856. * @param origin origin of the plane to be constructed
  6857. * @param normal normal of the plane to be constructed
  6858. * @returns a new Plane the normal vector to this plane at the given origin point.
  6859. * Note : the vector "normal" is updated because normalized.
  6860. */
  6861. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6862. /**
  6863. * Calculates the distance from a plane and a point
  6864. * @param origin origin of the plane to be constructed
  6865. * @param normal normal of the plane to be constructed
  6866. * @param point point to calculate distance to
  6867. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6868. */
  6869. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6870. }
  6871. }
  6872. declare module "babylonjs/Culling/boundingSphere" {
  6873. import { DeepImmutable } from "babylonjs/types";
  6874. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6875. import { Plane } from "babylonjs/Maths/math.plane";
  6876. /**
  6877. * Class used to store bounding sphere information
  6878. */
  6879. export class BoundingSphere {
  6880. /**
  6881. * Gets the center of the bounding sphere in local space
  6882. */
  6883. readonly center: Vector3;
  6884. /**
  6885. * Radius of the bounding sphere in local space
  6886. */
  6887. radius: number;
  6888. /**
  6889. * Gets the center of the bounding sphere in world space
  6890. */
  6891. readonly centerWorld: Vector3;
  6892. /**
  6893. * Radius of the bounding sphere in world space
  6894. */
  6895. radiusWorld: number;
  6896. /**
  6897. * Gets the minimum vector in local space
  6898. */
  6899. readonly minimum: Vector3;
  6900. /**
  6901. * Gets the maximum vector in local space
  6902. */
  6903. readonly maximum: Vector3;
  6904. private _worldMatrix;
  6905. private static readonly TmpVector3;
  6906. /**
  6907. * Creates a new bounding sphere
  6908. * @param min defines the minimum vector (in local space)
  6909. * @param max defines the maximum vector (in local space)
  6910. * @param worldMatrix defines the new world matrix
  6911. */
  6912. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6913. /**
  6914. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6915. * @param min defines the new minimum vector (in local space)
  6916. * @param max defines the new maximum vector (in local space)
  6917. * @param worldMatrix defines the new world matrix
  6918. */
  6919. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6920. /**
  6921. * Scale the current bounding sphere by applying a scale factor
  6922. * @param factor defines the scale factor to apply
  6923. * @returns the current bounding box
  6924. */
  6925. scale(factor: number): BoundingSphere;
  6926. /**
  6927. * Gets the world matrix of the bounding box
  6928. * @returns a matrix
  6929. */
  6930. getWorldMatrix(): DeepImmutable<Matrix>;
  6931. /** @hidden */
  6932. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6933. /**
  6934. * Tests if the bounding sphere is intersecting the frustum planes
  6935. * @param frustumPlanes defines the frustum planes to test
  6936. * @returns true if there is an intersection
  6937. */
  6938. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6939. /**
  6940. * Tests if the bounding sphere center is in between the frustum planes.
  6941. * Used for optimistic fast inclusion.
  6942. * @param frustumPlanes defines the frustum planes to test
  6943. * @returns true if the sphere center is in between the frustum planes
  6944. */
  6945. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6946. /**
  6947. * Tests if a point is inside the bounding sphere
  6948. * @param point defines the point to test
  6949. * @returns true if the point is inside the bounding sphere
  6950. */
  6951. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6952. /**
  6953. * Checks if two sphere intersct
  6954. * @param sphere0 sphere 0
  6955. * @param sphere1 sphere 1
  6956. * @returns true if the speres intersect
  6957. */
  6958. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6959. }
  6960. }
  6961. declare module "babylonjs/Culling/boundingBox" {
  6962. import { DeepImmutable } from "babylonjs/types";
  6963. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6964. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6965. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6966. import { Plane } from "babylonjs/Maths/math.plane";
  6967. /**
  6968. * Class used to store bounding box information
  6969. */
  6970. export class BoundingBox implements ICullable {
  6971. /**
  6972. * Gets the 8 vectors representing the bounding box in local space
  6973. */
  6974. readonly vectors: Vector3[];
  6975. /**
  6976. * Gets the center of the bounding box in local space
  6977. */
  6978. readonly center: Vector3;
  6979. /**
  6980. * Gets the center of the bounding box in world space
  6981. */
  6982. readonly centerWorld: Vector3;
  6983. /**
  6984. * Gets the extend size in local space
  6985. */
  6986. readonly extendSize: Vector3;
  6987. /**
  6988. * Gets the extend size in world space
  6989. */
  6990. readonly extendSizeWorld: Vector3;
  6991. /**
  6992. * Gets the OBB (object bounding box) directions
  6993. */
  6994. readonly directions: Vector3[];
  6995. /**
  6996. * Gets the 8 vectors representing the bounding box in world space
  6997. */
  6998. readonly vectorsWorld: Vector3[];
  6999. /**
  7000. * Gets the minimum vector in world space
  7001. */
  7002. readonly minimumWorld: Vector3;
  7003. /**
  7004. * Gets the maximum vector in world space
  7005. */
  7006. readonly maximumWorld: Vector3;
  7007. /**
  7008. * Gets the minimum vector in local space
  7009. */
  7010. readonly minimum: Vector3;
  7011. /**
  7012. * Gets the maximum vector in local space
  7013. */
  7014. readonly maximum: Vector3;
  7015. private _worldMatrix;
  7016. private static readonly TmpVector3;
  7017. /**
  7018. * @hidden
  7019. */
  7020. _tag: number;
  7021. /**
  7022. * Creates a new bounding box
  7023. * @param min defines the minimum vector (in local space)
  7024. * @param max defines the maximum vector (in local space)
  7025. * @param worldMatrix defines the new world matrix
  7026. */
  7027. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7028. /**
  7029. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7030. * @param min defines the new minimum vector (in local space)
  7031. * @param max defines the new maximum vector (in local space)
  7032. * @param worldMatrix defines the new world matrix
  7033. */
  7034. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7035. /**
  7036. * Scale the current bounding box by applying a scale factor
  7037. * @param factor defines the scale factor to apply
  7038. * @returns the current bounding box
  7039. */
  7040. scale(factor: number): BoundingBox;
  7041. /**
  7042. * Gets the world matrix of the bounding box
  7043. * @returns a matrix
  7044. */
  7045. getWorldMatrix(): DeepImmutable<Matrix>;
  7046. /** @hidden */
  7047. _update(world: DeepImmutable<Matrix>): void;
  7048. /**
  7049. * Tests if the bounding box is intersecting the frustum planes
  7050. * @param frustumPlanes defines the frustum planes to test
  7051. * @returns true if there is an intersection
  7052. */
  7053. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7054. /**
  7055. * Tests if the bounding box is entirely inside the frustum planes
  7056. * @param frustumPlanes defines the frustum planes to test
  7057. * @returns true if there is an inclusion
  7058. */
  7059. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7060. /**
  7061. * Tests if a point is inside the bounding box
  7062. * @param point defines the point to test
  7063. * @returns true if the point is inside the bounding box
  7064. */
  7065. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7066. /**
  7067. * Tests if the bounding box intersects with a bounding sphere
  7068. * @param sphere defines the sphere to test
  7069. * @returns true if there is an intersection
  7070. */
  7071. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7072. /**
  7073. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7074. * @param min defines the min vector to use
  7075. * @param max defines the max vector to use
  7076. * @returns true if there is an intersection
  7077. */
  7078. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7079. /**
  7080. * Tests if two bounding boxes are intersections
  7081. * @param box0 defines the first box to test
  7082. * @param box1 defines the second box to test
  7083. * @returns true if there is an intersection
  7084. */
  7085. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7086. /**
  7087. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7088. * @param minPoint defines the minimum vector of the bounding box
  7089. * @param maxPoint defines the maximum vector of the bounding box
  7090. * @param sphereCenter defines the sphere center
  7091. * @param sphereRadius defines the sphere radius
  7092. * @returns true if there is an intersection
  7093. */
  7094. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7095. /**
  7096. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7097. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7098. * @param frustumPlanes defines the frustum planes to test
  7099. * @return true if there is an inclusion
  7100. */
  7101. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7102. /**
  7103. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7104. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7105. * @param frustumPlanes defines the frustum planes to test
  7106. * @return true if there is an intersection
  7107. */
  7108. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7109. }
  7110. }
  7111. declare module "babylonjs/Collisions/collider" {
  7112. import { Nullable, IndicesArray } from "babylonjs/types";
  7113. import { Vector3 } from "babylonjs/Maths/math.vector";
  7114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7115. import { Plane } from "babylonjs/Maths/math.plane";
  7116. /** @hidden */
  7117. export class Collider {
  7118. /** Define if a collision was found */
  7119. collisionFound: boolean;
  7120. /**
  7121. * Define last intersection point in local space
  7122. */
  7123. intersectionPoint: Vector3;
  7124. /**
  7125. * Define last collided mesh
  7126. */
  7127. collidedMesh: Nullable<AbstractMesh>;
  7128. private _collisionPoint;
  7129. private _planeIntersectionPoint;
  7130. private _tempVector;
  7131. private _tempVector2;
  7132. private _tempVector3;
  7133. private _tempVector4;
  7134. private _edge;
  7135. private _baseToVertex;
  7136. private _destinationPoint;
  7137. private _slidePlaneNormal;
  7138. private _displacementVector;
  7139. /** @hidden */
  7140. _radius: Vector3;
  7141. /** @hidden */
  7142. _retry: number;
  7143. private _velocity;
  7144. private _basePoint;
  7145. private _epsilon;
  7146. /** @hidden */
  7147. _velocityWorldLength: number;
  7148. /** @hidden */
  7149. _basePointWorld: Vector3;
  7150. private _velocityWorld;
  7151. private _normalizedVelocity;
  7152. /** @hidden */
  7153. _initialVelocity: Vector3;
  7154. /** @hidden */
  7155. _initialPosition: Vector3;
  7156. private _nearestDistance;
  7157. private _collisionMask;
  7158. collisionMask: number;
  7159. /**
  7160. * Gets the plane normal used to compute the sliding response (in local space)
  7161. */
  7162. readonly slidePlaneNormal: Vector3;
  7163. /** @hidden */
  7164. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7165. /** @hidden */
  7166. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7167. /** @hidden */
  7168. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7169. /** @hidden */
  7170. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7171. /** @hidden */
  7172. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7173. /** @hidden */
  7174. _getResponse(pos: Vector3, vel: Vector3): void;
  7175. }
  7176. }
  7177. declare module "babylonjs/Culling/boundingInfo" {
  7178. import { DeepImmutable } from "babylonjs/types";
  7179. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7180. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7181. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7182. import { Plane } from "babylonjs/Maths/math.plane";
  7183. import { Collider } from "babylonjs/Collisions/collider";
  7184. /**
  7185. * Interface for cullable objects
  7186. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7187. */
  7188. export interface ICullable {
  7189. /**
  7190. * Checks if the object or part of the object is in the frustum
  7191. * @param frustumPlanes Camera near/planes
  7192. * @returns true if the object is in frustum otherwise false
  7193. */
  7194. isInFrustum(frustumPlanes: Plane[]): boolean;
  7195. /**
  7196. * Checks if a cullable object (mesh...) is in the camera frustum
  7197. * Unlike isInFrustum this cheks the full bounding box
  7198. * @param frustumPlanes Camera near/planes
  7199. * @returns true if the object is in frustum otherwise false
  7200. */
  7201. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7202. }
  7203. /**
  7204. * Info for a bounding data of a mesh
  7205. */
  7206. export class BoundingInfo implements ICullable {
  7207. /**
  7208. * Bounding box for the mesh
  7209. */
  7210. readonly boundingBox: BoundingBox;
  7211. /**
  7212. * Bounding sphere for the mesh
  7213. */
  7214. readonly boundingSphere: BoundingSphere;
  7215. private _isLocked;
  7216. private static readonly TmpVector3;
  7217. /**
  7218. * Constructs bounding info
  7219. * @param minimum min vector of the bounding box/sphere
  7220. * @param maximum max vector of the bounding box/sphere
  7221. * @param worldMatrix defines the new world matrix
  7222. */
  7223. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7224. /**
  7225. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7226. * @param min defines the new minimum vector (in local space)
  7227. * @param max defines the new maximum vector (in local space)
  7228. * @param worldMatrix defines the new world matrix
  7229. */
  7230. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7231. /**
  7232. * min vector of the bounding box/sphere
  7233. */
  7234. readonly minimum: Vector3;
  7235. /**
  7236. * max vector of the bounding box/sphere
  7237. */
  7238. readonly maximum: Vector3;
  7239. /**
  7240. * If the info is locked and won't be updated to avoid perf overhead
  7241. */
  7242. isLocked: boolean;
  7243. /**
  7244. * Updates the bounding sphere and box
  7245. * @param world world matrix to be used to update
  7246. */
  7247. update(world: DeepImmutable<Matrix>): void;
  7248. /**
  7249. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7250. * @param center New center of the bounding info
  7251. * @param extend New extend of the bounding info
  7252. * @returns the current bounding info
  7253. */
  7254. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7255. /**
  7256. * Scale the current bounding info by applying a scale factor
  7257. * @param factor defines the scale factor to apply
  7258. * @returns the current bounding info
  7259. */
  7260. scale(factor: number): BoundingInfo;
  7261. /**
  7262. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7263. * @param frustumPlanes defines the frustum to test
  7264. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7265. * @returns true if the bounding info is in the frustum planes
  7266. */
  7267. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7268. /**
  7269. * Gets the world distance between the min and max points of the bounding box
  7270. */
  7271. readonly diagonalLength: number;
  7272. /**
  7273. * Checks if a cullable object (mesh...) is in the camera frustum
  7274. * Unlike isInFrustum this cheks the full bounding box
  7275. * @param frustumPlanes Camera near/planes
  7276. * @returns true if the object is in frustum otherwise false
  7277. */
  7278. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7279. /** @hidden */
  7280. _checkCollision(collider: Collider): boolean;
  7281. /**
  7282. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7283. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7284. * @param point the point to check intersection with
  7285. * @returns if the point intersects
  7286. */
  7287. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7288. /**
  7289. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7290. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7291. * @param boundingInfo the bounding info to check intersection with
  7292. * @param precise if the intersection should be done using OBB
  7293. * @returns if the bounding info intersects
  7294. */
  7295. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7296. }
  7297. }
  7298. declare module "babylonjs/Maths/math.functions" {
  7299. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7300. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7301. /**
  7302. * Extracts minimum and maximum values from a list of indexed positions
  7303. * @param positions defines the positions to use
  7304. * @param indices defines the indices to the positions
  7305. * @param indexStart defines the start index
  7306. * @param indexCount defines the end index
  7307. * @param bias defines bias value to add to the result
  7308. * @return minimum and maximum values
  7309. */
  7310. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7311. minimum: Vector3;
  7312. maximum: Vector3;
  7313. };
  7314. /**
  7315. * Extracts minimum and maximum values from a list of positions
  7316. * @param positions defines the positions to use
  7317. * @param start defines the start index in the positions array
  7318. * @param count defines the number of positions to handle
  7319. * @param bias defines bias value to add to the result
  7320. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7321. * @return minimum and maximum values
  7322. */
  7323. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7324. minimum: Vector3;
  7325. maximum: Vector3;
  7326. };
  7327. }
  7328. declare module "babylonjs/Misc/iInspectable" {
  7329. /**
  7330. * Enum that determines the text-wrapping mode to use.
  7331. */
  7332. export enum InspectableType {
  7333. /**
  7334. * Checkbox for booleans
  7335. */
  7336. Checkbox = 0,
  7337. /**
  7338. * Sliders for numbers
  7339. */
  7340. Slider = 1,
  7341. /**
  7342. * Vector3
  7343. */
  7344. Vector3 = 2,
  7345. /**
  7346. * Quaternions
  7347. */
  7348. Quaternion = 3,
  7349. /**
  7350. * Color3
  7351. */
  7352. Color3 = 4,
  7353. /**
  7354. * String
  7355. */
  7356. String = 5
  7357. }
  7358. /**
  7359. * Interface used to define custom inspectable properties.
  7360. * This interface is used by the inspector to display custom property grids
  7361. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7362. */
  7363. export interface IInspectable {
  7364. /**
  7365. * Gets the label to display
  7366. */
  7367. label: string;
  7368. /**
  7369. * Gets the name of the property to edit
  7370. */
  7371. propertyName: string;
  7372. /**
  7373. * Gets the type of the editor to use
  7374. */
  7375. type: InspectableType;
  7376. /**
  7377. * Gets the minimum value of the property when using in "slider" mode
  7378. */
  7379. min?: number;
  7380. /**
  7381. * Gets the maximum value of the property when using in "slider" mode
  7382. */
  7383. max?: number;
  7384. /**
  7385. * Gets the setp to use when using in "slider" mode
  7386. */
  7387. step?: number;
  7388. }
  7389. }
  7390. declare module "babylonjs/Misc/timingTools" {
  7391. /**
  7392. * Class used to provide helper for timing
  7393. */
  7394. export class TimingTools {
  7395. /**
  7396. * Polyfill for setImmediate
  7397. * @param action defines the action to execute after the current execution block
  7398. */
  7399. static SetImmediate(action: () => void): void;
  7400. }
  7401. }
  7402. declare module "babylonjs/Misc/instantiationTools" {
  7403. /**
  7404. * Class used to enable instatition of objects by class name
  7405. */
  7406. export class InstantiationTools {
  7407. /**
  7408. * Use this object to register external classes like custom textures or material
  7409. * to allow the laoders to instantiate them
  7410. */
  7411. static RegisteredExternalClasses: {
  7412. [key: string]: Object;
  7413. };
  7414. /**
  7415. * Tries to instantiate a new object from a given class name
  7416. * @param className defines the class name to instantiate
  7417. * @returns the new object or null if the system was not able to do the instantiation
  7418. */
  7419. static Instantiate(className: string): any;
  7420. }
  7421. }
  7422. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7423. import { Nullable } from "babylonjs/types";
  7424. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7425. /**
  7426. * This represents the required contract to create a new type of texture loader.
  7427. */
  7428. export interface IInternalTextureLoader {
  7429. /**
  7430. * Defines wether the loader supports cascade loading the different faces.
  7431. */
  7432. supportCascades: boolean;
  7433. /**
  7434. * This returns if the loader support the current file information.
  7435. * @param extension defines the file extension of the file being loaded
  7436. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7437. * @param fallback defines the fallback internal texture if any
  7438. * @param isBase64 defines whether the texture is encoded as a base64
  7439. * @param isBuffer defines whether the texture data are stored as a buffer
  7440. * @returns true if the loader can load the specified file
  7441. */
  7442. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7443. /**
  7444. * Transform the url before loading if required.
  7445. * @param rootUrl the url of the texture
  7446. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7447. * @returns the transformed texture
  7448. */
  7449. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7450. /**
  7451. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7452. * @param rootUrl the url of the texture
  7453. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7454. * @returns the fallback texture
  7455. */
  7456. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7457. /**
  7458. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7459. * @param data contains the texture data
  7460. * @param texture defines the BabylonJS internal texture
  7461. * @param createPolynomials will be true if polynomials have been requested
  7462. * @param onLoad defines the callback to trigger once the texture is ready
  7463. * @param onError defines the callback to trigger in case of error
  7464. */
  7465. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7466. /**
  7467. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7468. * @param data contains the texture data
  7469. * @param texture defines the BabylonJS internal texture
  7470. * @param callback defines the method to call once ready to upload
  7471. */
  7472. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7473. }
  7474. }
  7475. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7476. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7477. import { Nullable } from "babylonjs/types";
  7478. import { Scene } from "babylonjs/scene";
  7479. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7480. module "babylonjs/Engines/engine" {
  7481. interface Engine {
  7482. /**
  7483. * Creates a depth stencil cube texture.
  7484. * This is only available in WebGL 2.
  7485. * @param size The size of face edge in the cube texture.
  7486. * @param options The options defining the cube texture.
  7487. * @returns The cube texture
  7488. */
  7489. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7490. /**
  7491. * Creates a cube texture
  7492. * @param rootUrl defines the url where the files to load is located
  7493. * @param scene defines the current scene
  7494. * @param files defines the list of files to load (1 per face)
  7495. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7496. * @param onLoad defines an optional callback raised when the texture is loaded
  7497. * @param onError defines an optional callback raised if there is an issue to load the texture
  7498. * @param format defines the format of the data
  7499. * @param forcedExtension defines the extension to use to pick the right loader
  7500. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7501. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7502. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7503. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7504. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7505. * @returns the cube texture as an InternalTexture
  7506. */
  7507. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7508. /**
  7509. * Creates a cube texture
  7510. * @param rootUrl defines the url where the files to load is located
  7511. * @param scene defines the current scene
  7512. * @param files defines the list of files to load (1 per face)
  7513. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7514. * @param onLoad defines an optional callback raised when the texture is loaded
  7515. * @param onError defines an optional callback raised if there is an issue to load the texture
  7516. * @param format defines the format of the data
  7517. * @param forcedExtension defines the extension to use to pick the right loader
  7518. * @returns the cube texture as an InternalTexture
  7519. */
  7520. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7521. /**
  7522. * Creates a cube texture
  7523. * @param rootUrl defines the url where the files to load is located
  7524. * @param scene defines the current scene
  7525. * @param files defines the list of files to load (1 per face)
  7526. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7527. * @param onLoad defines an optional callback raised when the texture is loaded
  7528. * @param onError defines an optional callback raised if there is an issue to load the texture
  7529. * @param format defines the format of the data
  7530. * @param forcedExtension defines the extension to use to pick the right loader
  7531. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7532. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7533. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7534. * @returns the cube texture as an InternalTexture
  7535. */
  7536. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7537. /** @hidden */
  7538. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7539. /** @hidden */
  7540. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7541. /** @hidden */
  7542. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7543. /** @hidden */
  7544. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7545. }
  7546. }
  7547. }
  7548. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7549. import { Nullable } from "babylonjs/types";
  7550. import { Scene } from "babylonjs/scene";
  7551. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7552. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7553. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7554. /**
  7555. * Class for creating a cube texture
  7556. */
  7557. export class CubeTexture extends BaseTexture {
  7558. private _delayedOnLoad;
  7559. /**
  7560. * The url of the texture
  7561. */
  7562. url: string;
  7563. /**
  7564. * Gets or sets the center of the bounding box associated with the cube texture.
  7565. * It must define where the camera used to render the texture was set
  7566. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7567. */
  7568. boundingBoxPosition: Vector3;
  7569. private _boundingBoxSize;
  7570. /**
  7571. * Gets or sets the size of the bounding box associated with the cube texture
  7572. * When defined, the cubemap will switch to local mode
  7573. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7574. * @example https://www.babylonjs-playground.com/#RNASML
  7575. */
  7576. /**
  7577. * Returns the bounding box size
  7578. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7579. */
  7580. boundingBoxSize: Vector3;
  7581. protected _rotationY: number;
  7582. /**
  7583. * Sets texture matrix rotation angle around Y axis in radians.
  7584. */
  7585. /**
  7586. * Gets texture matrix rotation angle around Y axis radians.
  7587. */
  7588. rotationY: number;
  7589. /**
  7590. * Are mip maps generated for this texture or not.
  7591. */
  7592. readonly noMipmap: boolean;
  7593. private _noMipmap;
  7594. private _files;
  7595. private _extensions;
  7596. private _textureMatrix;
  7597. private _format;
  7598. private _createPolynomials;
  7599. /** @hidden */
  7600. _prefiltered: boolean;
  7601. /**
  7602. * Creates a cube texture from an array of image urls
  7603. * @param files defines an array of image urls
  7604. * @param scene defines the hosting scene
  7605. * @param noMipmap specifies if mip maps are not used
  7606. * @returns a cube texture
  7607. */
  7608. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7609. /**
  7610. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7611. * @param url defines the url of the prefiltered texture
  7612. * @param scene defines the scene the texture is attached to
  7613. * @param forcedExtension defines the extension of the file if different from the url
  7614. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7615. * @return the prefiltered texture
  7616. */
  7617. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7618. /**
  7619. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7620. * as prefiltered data.
  7621. * @param rootUrl defines the url of the texture or the root name of the six images
  7622. * @param scene defines the scene the texture is attached to
  7623. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7624. * @param noMipmap defines if mipmaps should be created or not
  7625. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7626. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7627. * @param onError defines a callback triggered in case of error during load
  7628. * @param format defines the internal format to use for the texture once loaded
  7629. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7630. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7631. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7632. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7633. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7634. * @return the cube texture
  7635. */
  7636. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7637. /**
  7638. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7639. */
  7640. readonly isPrefiltered: boolean;
  7641. /**
  7642. * Get the current class name of the texture useful for serialization or dynamic coding.
  7643. * @returns "CubeTexture"
  7644. */
  7645. getClassName(): string;
  7646. /**
  7647. * Update the url (and optional buffer) of this texture if url was null during construction.
  7648. * @param url the url of the texture
  7649. * @param forcedExtension defines the extension to use
  7650. * @param onLoad callback called when the texture is loaded (defaults to null)
  7651. */
  7652. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7653. /**
  7654. * Delays loading of the cube texture
  7655. * @param forcedExtension defines the extension to use
  7656. */
  7657. delayLoad(forcedExtension?: string): void;
  7658. /**
  7659. * Returns the reflection texture matrix
  7660. * @returns the reflection texture matrix
  7661. */
  7662. getReflectionTextureMatrix(): Matrix;
  7663. /**
  7664. * Sets the reflection texture matrix
  7665. * @param value Reflection texture matrix
  7666. */
  7667. setReflectionTextureMatrix(value: Matrix): void;
  7668. /**
  7669. * Parses text to create a cube texture
  7670. * @param parsedTexture define the serialized text to read from
  7671. * @param scene defines the hosting scene
  7672. * @param rootUrl defines the root url of the cube texture
  7673. * @returns a cube texture
  7674. */
  7675. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7676. /**
  7677. * Makes a clone, or deep copy, of the cube texture
  7678. * @returns a new cube texture
  7679. */
  7680. clone(): CubeTexture;
  7681. }
  7682. }
  7683. declare module "babylonjs/Materials/materialDefines" {
  7684. /**
  7685. * Manages the defines for the Material
  7686. */
  7687. export class MaterialDefines {
  7688. /** @hidden */
  7689. protected _keys: string[];
  7690. private _isDirty;
  7691. /** @hidden */
  7692. _renderId: number;
  7693. /** @hidden */
  7694. _areLightsDirty: boolean;
  7695. /** @hidden */
  7696. _areLightsDisposed: boolean;
  7697. /** @hidden */
  7698. _areAttributesDirty: boolean;
  7699. /** @hidden */
  7700. _areTexturesDirty: boolean;
  7701. /** @hidden */
  7702. _areFresnelDirty: boolean;
  7703. /** @hidden */
  7704. _areMiscDirty: boolean;
  7705. /** @hidden */
  7706. _areImageProcessingDirty: boolean;
  7707. /** @hidden */
  7708. _normals: boolean;
  7709. /** @hidden */
  7710. _uvs: boolean;
  7711. /** @hidden */
  7712. _needNormals: boolean;
  7713. /** @hidden */
  7714. _needUVs: boolean;
  7715. [id: string]: any;
  7716. /**
  7717. * Specifies if the material needs to be re-calculated
  7718. */
  7719. readonly isDirty: boolean;
  7720. /**
  7721. * Marks the material to indicate that it has been re-calculated
  7722. */
  7723. markAsProcessed(): void;
  7724. /**
  7725. * Marks the material to indicate that it needs to be re-calculated
  7726. */
  7727. markAsUnprocessed(): void;
  7728. /**
  7729. * Marks the material to indicate all of its defines need to be re-calculated
  7730. */
  7731. markAllAsDirty(): void;
  7732. /**
  7733. * Marks the material to indicate that image processing needs to be re-calculated
  7734. */
  7735. markAsImageProcessingDirty(): void;
  7736. /**
  7737. * Marks the material to indicate the lights need to be re-calculated
  7738. * @param disposed Defines whether the light is dirty due to dispose or not
  7739. */
  7740. markAsLightDirty(disposed?: boolean): void;
  7741. /**
  7742. * Marks the attribute state as changed
  7743. */
  7744. markAsAttributesDirty(): void;
  7745. /**
  7746. * Marks the texture state as changed
  7747. */
  7748. markAsTexturesDirty(): void;
  7749. /**
  7750. * Marks the fresnel state as changed
  7751. */
  7752. markAsFresnelDirty(): void;
  7753. /**
  7754. * Marks the misc state as changed
  7755. */
  7756. markAsMiscDirty(): void;
  7757. /**
  7758. * Rebuilds the material defines
  7759. */
  7760. rebuild(): void;
  7761. /**
  7762. * Specifies if two material defines are equal
  7763. * @param other - A material define instance to compare to
  7764. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7765. */
  7766. isEqual(other: MaterialDefines): boolean;
  7767. /**
  7768. * Clones this instance's defines to another instance
  7769. * @param other - material defines to clone values to
  7770. */
  7771. cloneTo(other: MaterialDefines): void;
  7772. /**
  7773. * Resets the material define values
  7774. */
  7775. reset(): void;
  7776. /**
  7777. * Converts the material define values to a string
  7778. * @returns - String of material define information
  7779. */
  7780. toString(): string;
  7781. }
  7782. }
  7783. declare module "babylonjs/Materials/colorCurves" {
  7784. import { Effect } from "babylonjs/Materials/effect";
  7785. /**
  7786. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7787. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7788. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7789. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7790. */
  7791. export class ColorCurves {
  7792. private _dirty;
  7793. private _tempColor;
  7794. private _globalCurve;
  7795. private _highlightsCurve;
  7796. private _midtonesCurve;
  7797. private _shadowsCurve;
  7798. private _positiveCurve;
  7799. private _negativeCurve;
  7800. private _globalHue;
  7801. private _globalDensity;
  7802. private _globalSaturation;
  7803. private _globalExposure;
  7804. /**
  7805. * Gets the global Hue value.
  7806. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7807. */
  7808. /**
  7809. * Sets the global Hue value.
  7810. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7811. */
  7812. globalHue: number;
  7813. /**
  7814. * Gets the global Density value.
  7815. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7816. * Values less than zero provide a filter of opposite hue.
  7817. */
  7818. /**
  7819. * Sets the global Density value.
  7820. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7821. * Values less than zero provide a filter of opposite hue.
  7822. */
  7823. globalDensity: number;
  7824. /**
  7825. * Gets the global Saturation value.
  7826. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7827. */
  7828. /**
  7829. * Sets the global Saturation value.
  7830. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7831. */
  7832. globalSaturation: number;
  7833. /**
  7834. * Gets the global Exposure value.
  7835. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7836. */
  7837. /**
  7838. * Sets the global Exposure value.
  7839. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7840. */
  7841. globalExposure: number;
  7842. private _highlightsHue;
  7843. private _highlightsDensity;
  7844. private _highlightsSaturation;
  7845. private _highlightsExposure;
  7846. /**
  7847. * Gets the highlights Hue value.
  7848. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7849. */
  7850. /**
  7851. * Sets the highlights Hue value.
  7852. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7853. */
  7854. highlightsHue: number;
  7855. /**
  7856. * Gets the highlights Density value.
  7857. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7858. * Values less than zero provide a filter of opposite hue.
  7859. */
  7860. /**
  7861. * Sets the highlights Density value.
  7862. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7863. * Values less than zero provide a filter of opposite hue.
  7864. */
  7865. highlightsDensity: number;
  7866. /**
  7867. * Gets the highlights Saturation value.
  7868. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7869. */
  7870. /**
  7871. * Sets the highlights Saturation value.
  7872. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7873. */
  7874. highlightsSaturation: number;
  7875. /**
  7876. * Gets the highlights Exposure value.
  7877. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7878. */
  7879. /**
  7880. * Sets the highlights Exposure value.
  7881. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7882. */
  7883. highlightsExposure: number;
  7884. private _midtonesHue;
  7885. private _midtonesDensity;
  7886. private _midtonesSaturation;
  7887. private _midtonesExposure;
  7888. /**
  7889. * Gets the midtones Hue value.
  7890. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7891. */
  7892. /**
  7893. * Sets the midtones Hue value.
  7894. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7895. */
  7896. midtonesHue: number;
  7897. /**
  7898. * Gets the midtones Density value.
  7899. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7900. * Values less than zero provide a filter of opposite hue.
  7901. */
  7902. /**
  7903. * Sets the midtones Density value.
  7904. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7905. * Values less than zero provide a filter of opposite hue.
  7906. */
  7907. midtonesDensity: number;
  7908. /**
  7909. * Gets the midtones Saturation value.
  7910. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7911. */
  7912. /**
  7913. * Sets the midtones Saturation value.
  7914. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7915. */
  7916. midtonesSaturation: number;
  7917. /**
  7918. * Gets the midtones Exposure value.
  7919. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7920. */
  7921. /**
  7922. * Sets the midtones Exposure value.
  7923. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7924. */
  7925. midtonesExposure: number;
  7926. private _shadowsHue;
  7927. private _shadowsDensity;
  7928. private _shadowsSaturation;
  7929. private _shadowsExposure;
  7930. /**
  7931. * Gets the shadows Hue value.
  7932. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7933. */
  7934. /**
  7935. * Sets the shadows Hue value.
  7936. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7937. */
  7938. shadowsHue: number;
  7939. /**
  7940. * Gets the shadows Density value.
  7941. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7942. * Values less than zero provide a filter of opposite hue.
  7943. */
  7944. /**
  7945. * Sets the shadows Density value.
  7946. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7947. * Values less than zero provide a filter of opposite hue.
  7948. */
  7949. shadowsDensity: number;
  7950. /**
  7951. * Gets the shadows Saturation value.
  7952. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7953. */
  7954. /**
  7955. * Sets the shadows Saturation value.
  7956. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7957. */
  7958. shadowsSaturation: number;
  7959. /**
  7960. * Gets the shadows Exposure value.
  7961. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7962. */
  7963. /**
  7964. * Sets the shadows Exposure value.
  7965. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7966. */
  7967. shadowsExposure: number;
  7968. /**
  7969. * Returns the class name
  7970. * @returns The class name
  7971. */
  7972. getClassName(): string;
  7973. /**
  7974. * Binds the color curves to the shader.
  7975. * @param colorCurves The color curve to bind
  7976. * @param effect The effect to bind to
  7977. * @param positiveUniform The positive uniform shader parameter
  7978. * @param neutralUniform The neutral uniform shader parameter
  7979. * @param negativeUniform The negative uniform shader parameter
  7980. */
  7981. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7982. /**
  7983. * Prepare the list of uniforms associated with the ColorCurves effects.
  7984. * @param uniformsList The list of uniforms used in the effect
  7985. */
  7986. static PrepareUniforms(uniformsList: string[]): void;
  7987. /**
  7988. * Returns color grading data based on a hue, density, saturation and exposure value.
  7989. * @param filterHue The hue of the color filter.
  7990. * @param filterDensity The density of the color filter.
  7991. * @param saturation The saturation.
  7992. * @param exposure The exposure.
  7993. * @param result The result data container.
  7994. */
  7995. private getColorGradingDataToRef;
  7996. /**
  7997. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7998. * @param value The input slider value in range [-100,100].
  7999. * @returns Adjusted value.
  8000. */
  8001. private static applyColorGradingSliderNonlinear;
  8002. /**
  8003. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8004. * @param hue The hue (H) input.
  8005. * @param saturation The saturation (S) input.
  8006. * @param brightness The brightness (B) input.
  8007. * @result An RGBA color represented as Vector4.
  8008. */
  8009. private static fromHSBToRef;
  8010. /**
  8011. * Returns a value clamped between min and max
  8012. * @param value The value to clamp
  8013. * @param min The minimum of value
  8014. * @param max The maximum of value
  8015. * @returns The clamped value.
  8016. */
  8017. private static clamp;
  8018. /**
  8019. * Clones the current color curve instance.
  8020. * @return The cloned curves
  8021. */
  8022. clone(): ColorCurves;
  8023. /**
  8024. * Serializes the current color curve instance to a json representation.
  8025. * @return a JSON representation
  8026. */
  8027. serialize(): any;
  8028. /**
  8029. * Parses the color curve from a json representation.
  8030. * @param source the JSON source to parse
  8031. * @return The parsed curves
  8032. */
  8033. static Parse(source: any): ColorCurves;
  8034. }
  8035. }
  8036. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8037. import { Observable } from "babylonjs/Misc/observable";
  8038. import { Nullable } from "babylonjs/types";
  8039. import { Color4 } from "babylonjs/Maths/math.color";
  8040. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8041. import { Effect } from "babylonjs/Materials/effect";
  8042. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8043. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8044. /**
  8045. * Interface to follow in your material defines to integrate easily the
  8046. * Image proccessing functions.
  8047. * @hidden
  8048. */
  8049. export interface IImageProcessingConfigurationDefines {
  8050. IMAGEPROCESSING: boolean;
  8051. VIGNETTE: boolean;
  8052. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8053. VIGNETTEBLENDMODEOPAQUE: boolean;
  8054. TONEMAPPING: boolean;
  8055. TONEMAPPING_ACES: boolean;
  8056. CONTRAST: boolean;
  8057. EXPOSURE: boolean;
  8058. COLORCURVES: boolean;
  8059. COLORGRADING: boolean;
  8060. COLORGRADING3D: boolean;
  8061. SAMPLER3DGREENDEPTH: boolean;
  8062. SAMPLER3DBGRMAP: boolean;
  8063. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8064. }
  8065. /**
  8066. * @hidden
  8067. */
  8068. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8069. IMAGEPROCESSING: boolean;
  8070. VIGNETTE: boolean;
  8071. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8072. VIGNETTEBLENDMODEOPAQUE: boolean;
  8073. TONEMAPPING: boolean;
  8074. TONEMAPPING_ACES: boolean;
  8075. CONTRAST: boolean;
  8076. COLORCURVES: boolean;
  8077. COLORGRADING: boolean;
  8078. COLORGRADING3D: boolean;
  8079. SAMPLER3DGREENDEPTH: boolean;
  8080. SAMPLER3DBGRMAP: boolean;
  8081. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8082. EXPOSURE: boolean;
  8083. constructor();
  8084. }
  8085. /**
  8086. * This groups together the common properties used for image processing either in direct forward pass
  8087. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8088. * or not.
  8089. */
  8090. export class ImageProcessingConfiguration {
  8091. /**
  8092. * Default tone mapping applied in BabylonJS.
  8093. */
  8094. static readonly TONEMAPPING_STANDARD: number;
  8095. /**
  8096. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8097. * to other engines rendering to increase portability.
  8098. */
  8099. static readonly TONEMAPPING_ACES: number;
  8100. /**
  8101. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8102. */
  8103. colorCurves: Nullable<ColorCurves>;
  8104. private _colorCurvesEnabled;
  8105. /**
  8106. * Gets wether the color curves effect is enabled.
  8107. */
  8108. /**
  8109. * Sets wether the color curves effect is enabled.
  8110. */
  8111. colorCurvesEnabled: boolean;
  8112. private _colorGradingTexture;
  8113. /**
  8114. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8115. */
  8116. /**
  8117. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8118. */
  8119. colorGradingTexture: Nullable<BaseTexture>;
  8120. private _colorGradingEnabled;
  8121. /**
  8122. * Gets wether the color grading effect is enabled.
  8123. */
  8124. /**
  8125. * Sets wether the color grading effect is enabled.
  8126. */
  8127. colorGradingEnabled: boolean;
  8128. private _colorGradingWithGreenDepth;
  8129. /**
  8130. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8131. */
  8132. /**
  8133. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8134. */
  8135. colorGradingWithGreenDepth: boolean;
  8136. private _colorGradingBGR;
  8137. /**
  8138. * Gets wether the color grading texture contains BGR values.
  8139. */
  8140. /**
  8141. * Sets wether the color grading texture contains BGR values.
  8142. */
  8143. colorGradingBGR: boolean;
  8144. /** @hidden */
  8145. _exposure: number;
  8146. /**
  8147. * Gets the Exposure used in the effect.
  8148. */
  8149. /**
  8150. * Sets the Exposure used in the effect.
  8151. */
  8152. exposure: number;
  8153. private _toneMappingEnabled;
  8154. /**
  8155. * Gets wether the tone mapping effect is enabled.
  8156. */
  8157. /**
  8158. * Sets wether the tone mapping effect is enabled.
  8159. */
  8160. toneMappingEnabled: boolean;
  8161. private _toneMappingType;
  8162. /**
  8163. * Gets the type of tone mapping effect.
  8164. */
  8165. /**
  8166. * Sets the type of tone mapping effect used in BabylonJS.
  8167. */
  8168. toneMappingType: number;
  8169. protected _contrast: number;
  8170. /**
  8171. * Gets the contrast used in the effect.
  8172. */
  8173. /**
  8174. * Sets the contrast used in the effect.
  8175. */
  8176. contrast: number;
  8177. /**
  8178. * Vignette stretch size.
  8179. */
  8180. vignetteStretch: number;
  8181. /**
  8182. * Vignette centre X Offset.
  8183. */
  8184. vignetteCentreX: number;
  8185. /**
  8186. * Vignette centre Y Offset.
  8187. */
  8188. vignetteCentreY: number;
  8189. /**
  8190. * Vignette weight or intensity of the vignette effect.
  8191. */
  8192. vignetteWeight: number;
  8193. /**
  8194. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8195. * if vignetteEnabled is set to true.
  8196. */
  8197. vignetteColor: Color4;
  8198. /**
  8199. * Camera field of view used by the Vignette effect.
  8200. */
  8201. vignetteCameraFov: number;
  8202. private _vignetteBlendMode;
  8203. /**
  8204. * Gets the vignette blend mode allowing different kind of effect.
  8205. */
  8206. /**
  8207. * Sets the vignette blend mode allowing different kind of effect.
  8208. */
  8209. vignetteBlendMode: number;
  8210. private _vignetteEnabled;
  8211. /**
  8212. * Gets wether the vignette effect is enabled.
  8213. */
  8214. /**
  8215. * Sets wether the vignette effect is enabled.
  8216. */
  8217. vignetteEnabled: boolean;
  8218. private _applyByPostProcess;
  8219. /**
  8220. * Gets wether the image processing is applied through a post process or not.
  8221. */
  8222. /**
  8223. * Sets wether the image processing is applied through a post process or not.
  8224. */
  8225. applyByPostProcess: boolean;
  8226. private _isEnabled;
  8227. /**
  8228. * Gets wether the image processing is enabled or not.
  8229. */
  8230. /**
  8231. * Sets wether the image processing is enabled or not.
  8232. */
  8233. isEnabled: boolean;
  8234. /**
  8235. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8236. */
  8237. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8238. /**
  8239. * Method called each time the image processing information changes requires to recompile the effect.
  8240. */
  8241. protected _updateParameters(): void;
  8242. /**
  8243. * Gets the current class name.
  8244. * @return "ImageProcessingConfiguration"
  8245. */
  8246. getClassName(): string;
  8247. /**
  8248. * Prepare the list of uniforms associated with the Image Processing effects.
  8249. * @param uniforms The list of uniforms used in the effect
  8250. * @param defines the list of defines currently in use
  8251. */
  8252. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8253. /**
  8254. * Prepare the list of samplers associated with the Image Processing effects.
  8255. * @param samplersList The list of uniforms used in the effect
  8256. * @param defines the list of defines currently in use
  8257. */
  8258. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8259. /**
  8260. * Prepare the list of defines associated to the shader.
  8261. * @param defines the list of defines to complete
  8262. * @param forPostProcess Define if we are currently in post process mode or not
  8263. */
  8264. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8265. /**
  8266. * Returns true if all the image processing information are ready.
  8267. * @returns True if ready, otherwise, false
  8268. */
  8269. isReady(): boolean;
  8270. /**
  8271. * Binds the image processing to the shader.
  8272. * @param effect The effect to bind to
  8273. * @param aspectRatio Define the current aspect ratio of the effect
  8274. */
  8275. bind(effect: Effect, aspectRatio?: number): void;
  8276. /**
  8277. * Clones the current image processing instance.
  8278. * @return The cloned image processing
  8279. */
  8280. clone(): ImageProcessingConfiguration;
  8281. /**
  8282. * Serializes the current image processing instance to a json representation.
  8283. * @return a JSON representation
  8284. */
  8285. serialize(): any;
  8286. /**
  8287. * Parses the image processing from a json representation.
  8288. * @param source the JSON source to parse
  8289. * @return The parsed image processing
  8290. */
  8291. static Parse(source: any): ImageProcessingConfiguration;
  8292. private static _VIGNETTEMODE_MULTIPLY;
  8293. private static _VIGNETTEMODE_OPAQUE;
  8294. /**
  8295. * Used to apply the vignette as a mix with the pixel color.
  8296. */
  8297. static readonly VIGNETTEMODE_MULTIPLY: number;
  8298. /**
  8299. * Used to apply the vignette as a replacement of the pixel color.
  8300. */
  8301. static readonly VIGNETTEMODE_OPAQUE: number;
  8302. }
  8303. }
  8304. declare module "babylonjs/Shaders/postprocess.vertex" {
  8305. /** @hidden */
  8306. export var postprocessVertexShader: {
  8307. name: string;
  8308. shader: string;
  8309. };
  8310. }
  8311. declare module "babylonjs/Maths/math.axis" {
  8312. import { Vector3 } from "babylonjs/Maths/math.vector";
  8313. /** Defines supported spaces */
  8314. export enum Space {
  8315. /** Local (object) space */
  8316. LOCAL = 0,
  8317. /** World space */
  8318. WORLD = 1,
  8319. /** Bone space */
  8320. BONE = 2
  8321. }
  8322. /** Defines the 3 main axes */
  8323. export class Axis {
  8324. /** X axis */
  8325. static X: Vector3;
  8326. /** Y axis */
  8327. static Y: Vector3;
  8328. /** Z axis */
  8329. static Z: Vector3;
  8330. }
  8331. }
  8332. declare module "babylonjs/Cameras/targetCamera" {
  8333. import { Nullable } from "babylonjs/types";
  8334. import { Camera } from "babylonjs/Cameras/camera";
  8335. import { Scene } from "babylonjs/scene";
  8336. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8337. /**
  8338. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8339. * This is the base of the follow, arc rotate cameras and Free camera
  8340. * @see http://doc.babylonjs.com/features/cameras
  8341. */
  8342. export class TargetCamera extends Camera {
  8343. private static _RigCamTransformMatrix;
  8344. private static _TargetTransformMatrix;
  8345. private static _TargetFocalPoint;
  8346. /**
  8347. * Define the current direction the camera is moving to
  8348. */
  8349. cameraDirection: Vector3;
  8350. /**
  8351. * Define the current rotation the camera is rotating to
  8352. */
  8353. cameraRotation: Vector2;
  8354. /**
  8355. * When set, the up vector of the camera will be updated by the rotation of the camera
  8356. */
  8357. updateUpVectorFromRotation: boolean;
  8358. private _tmpQuaternion;
  8359. /**
  8360. * Define the current rotation of the camera
  8361. */
  8362. rotation: Vector3;
  8363. /**
  8364. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8365. */
  8366. rotationQuaternion: Quaternion;
  8367. /**
  8368. * Define the current speed of the camera
  8369. */
  8370. speed: number;
  8371. /**
  8372. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8373. * around all axis.
  8374. */
  8375. noRotationConstraint: boolean;
  8376. /**
  8377. * Define the current target of the camera as an object or a position.
  8378. */
  8379. lockedTarget: any;
  8380. /** @hidden */
  8381. _currentTarget: Vector3;
  8382. /** @hidden */
  8383. _initialFocalDistance: number;
  8384. /** @hidden */
  8385. _viewMatrix: Matrix;
  8386. /** @hidden */
  8387. _camMatrix: Matrix;
  8388. /** @hidden */
  8389. _cameraTransformMatrix: Matrix;
  8390. /** @hidden */
  8391. _cameraRotationMatrix: Matrix;
  8392. /** @hidden */
  8393. _referencePoint: Vector3;
  8394. /** @hidden */
  8395. _transformedReferencePoint: Vector3;
  8396. protected _globalCurrentTarget: Vector3;
  8397. protected _globalCurrentUpVector: Vector3;
  8398. /** @hidden */
  8399. _reset: () => void;
  8400. private _defaultUp;
  8401. /**
  8402. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8403. * This is the base of the follow, arc rotate cameras and Free camera
  8404. * @see http://doc.babylonjs.com/features/cameras
  8405. * @param name Defines the name of the camera in the scene
  8406. * @param position Defines the start position of the camera in the scene
  8407. * @param scene Defines the scene the camera belongs to
  8408. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8409. */
  8410. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8411. /**
  8412. * Gets the position in front of the camera at a given distance.
  8413. * @param distance The distance from the camera we want the position to be
  8414. * @returns the position
  8415. */
  8416. getFrontPosition(distance: number): Vector3;
  8417. /** @hidden */
  8418. _getLockedTargetPosition(): Nullable<Vector3>;
  8419. private _storedPosition;
  8420. private _storedRotation;
  8421. private _storedRotationQuaternion;
  8422. /**
  8423. * Store current camera state of the camera (fov, position, rotation, etc..)
  8424. * @returns the camera
  8425. */
  8426. storeState(): Camera;
  8427. /**
  8428. * Restored camera state. You must call storeState() first
  8429. * @returns whether it was successful or not
  8430. * @hidden
  8431. */
  8432. _restoreStateValues(): boolean;
  8433. /** @hidden */
  8434. _initCache(): void;
  8435. /** @hidden */
  8436. _updateCache(ignoreParentClass?: boolean): void;
  8437. /** @hidden */
  8438. _isSynchronizedViewMatrix(): boolean;
  8439. /** @hidden */
  8440. _computeLocalCameraSpeed(): number;
  8441. /**
  8442. * Defines the target the camera should look at.
  8443. * @param target Defines the new target as a Vector or a mesh
  8444. */
  8445. setTarget(target: Vector3): void;
  8446. /**
  8447. * Return the current target position of the camera. This value is expressed in local space.
  8448. * @returns the target position
  8449. */
  8450. getTarget(): Vector3;
  8451. /** @hidden */
  8452. _decideIfNeedsToMove(): boolean;
  8453. /** @hidden */
  8454. _updatePosition(): void;
  8455. /** @hidden */
  8456. _checkInputs(): void;
  8457. protected _updateCameraRotationMatrix(): void;
  8458. /**
  8459. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8460. * @returns the current camera
  8461. */
  8462. private _rotateUpVectorWithCameraRotationMatrix;
  8463. private _cachedRotationZ;
  8464. private _cachedQuaternionRotationZ;
  8465. /** @hidden */
  8466. _getViewMatrix(): Matrix;
  8467. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8468. /**
  8469. * @hidden
  8470. */
  8471. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8472. /**
  8473. * @hidden
  8474. */
  8475. _updateRigCameras(): void;
  8476. private _getRigCamPositionAndTarget;
  8477. /**
  8478. * Gets the current object class name.
  8479. * @return the class name
  8480. */
  8481. getClassName(): string;
  8482. }
  8483. }
  8484. declare module "babylonjs/Events/keyboardEvents" {
  8485. /**
  8486. * Gather the list of keyboard event types as constants.
  8487. */
  8488. export class KeyboardEventTypes {
  8489. /**
  8490. * The keydown event is fired when a key becomes active (pressed).
  8491. */
  8492. static readonly KEYDOWN: number;
  8493. /**
  8494. * The keyup event is fired when a key has been released.
  8495. */
  8496. static readonly KEYUP: number;
  8497. }
  8498. /**
  8499. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8500. */
  8501. export class KeyboardInfo {
  8502. /**
  8503. * Defines the type of event (KeyboardEventTypes)
  8504. */
  8505. type: number;
  8506. /**
  8507. * Defines the related dom event
  8508. */
  8509. event: KeyboardEvent;
  8510. /**
  8511. * Instantiates a new keyboard info.
  8512. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8513. * @param type Defines the type of event (KeyboardEventTypes)
  8514. * @param event Defines the related dom event
  8515. */
  8516. constructor(
  8517. /**
  8518. * Defines the type of event (KeyboardEventTypes)
  8519. */
  8520. type: number,
  8521. /**
  8522. * Defines the related dom event
  8523. */
  8524. event: KeyboardEvent);
  8525. }
  8526. /**
  8527. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8528. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8529. */
  8530. export class KeyboardInfoPre extends KeyboardInfo {
  8531. /**
  8532. * Defines the type of event (KeyboardEventTypes)
  8533. */
  8534. type: number;
  8535. /**
  8536. * Defines the related dom event
  8537. */
  8538. event: KeyboardEvent;
  8539. /**
  8540. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8541. */
  8542. skipOnPointerObservable: boolean;
  8543. /**
  8544. * Instantiates a new keyboard pre info.
  8545. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8546. * @param type Defines the type of event (KeyboardEventTypes)
  8547. * @param event Defines the related dom event
  8548. */
  8549. constructor(
  8550. /**
  8551. * Defines the type of event (KeyboardEventTypes)
  8552. */
  8553. type: number,
  8554. /**
  8555. * Defines the related dom event
  8556. */
  8557. event: KeyboardEvent);
  8558. }
  8559. }
  8560. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8561. import { Nullable } from "babylonjs/types";
  8562. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8563. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8564. /**
  8565. * Manage the keyboard inputs to control the movement of a free camera.
  8566. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8567. */
  8568. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8569. /**
  8570. * Defines the camera the input is attached to.
  8571. */
  8572. camera: FreeCamera;
  8573. /**
  8574. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8575. */
  8576. keysUp: number[];
  8577. /**
  8578. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8579. */
  8580. keysDown: number[];
  8581. /**
  8582. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8583. */
  8584. keysLeft: number[];
  8585. /**
  8586. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8587. */
  8588. keysRight: number[];
  8589. private _keys;
  8590. private _onCanvasBlurObserver;
  8591. private _onKeyboardObserver;
  8592. private _engine;
  8593. private _scene;
  8594. /**
  8595. * Attach the input controls to a specific dom element to get the input from.
  8596. * @param element Defines the element the controls should be listened from
  8597. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8598. */
  8599. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8600. /**
  8601. * Detach the current controls from the specified dom element.
  8602. * @param element Defines the element to stop listening the inputs from
  8603. */
  8604. detachControl(element: Nullable<HTMLElement>): void;
  8605. /**
  8606. * Update the current camera state depending on the inputs that have been used this frame.
  8607. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8608. */
  8609. checkInputs(): void;
  8610. /**
  8611. * Gets the class name of the current intput.
  8612. * @returns the class name
  8613. */
  8614. getClassName(): string;
  8615. /** @hidden */
  8616. _onLostFocus(): void;
  8617. /**
  8618. * Get the friendly name associated with the input class.
  8619. * @returns the input friendly name
  8620. */
  8621. getSimpleName(): string;
  8622. }
  8623. }
  8624. declare module "babylonjs/Lights/shadowLight" {
  8625. import { Camera } from "babylonjs/Cameras/camera";
  8626. import { Scene } from "babylonjs/scene";
  8627. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8629. import { Light } from "babylonjs/Lights/light";
  8630. /**
  8631. * Interface describing all the common properties and methods a shadow light needs to implement.
  8632. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8633. * as well as binding the different shadow properties to the effects.
  8634. */
  8635. export interface IShadowLight extends Light {
  8636. /**
  8637. * The light id in the scene (used in scene.findLighById for instance)
  8638. */
  8639. id: string;
  8640. /**
  8641. * The position the shdow will be casted from.
  8642. */
  8643. position: Vector3;
  8644. /**
  8645. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8646. */
  8647. direction: Vector3;
  8648. /**
  8649. * The transformed position. Position of the light in world space taking parenting in account.
  8650. */
  8651. transformedPosition: Vector3;
  8652. /**
  8653. * The transformed direction. Direction of the light in world space taking parenting in account.
  8654. */
  8655. transformedDirection: Vector3;
  8656. /**
  8657. * The friendly name of the light in the scene.
  8658. */
  8659. name: string;
  8660. /**
  8661. * Defines the shadow projection clipping minimum z value.
  8662. */
  8663. shadowMinZ: number;
  8664. /**
  8665. * Defines the shadow projection clipping maximum z value.
  8666. */
  8667. shadowMaxZ: number;
  8668. /**
  8669. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8670. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8671. */
  8672. computeTransformedInformation(): boolean;
  8673. /**
  8674. * Gets the scene the light belongs to.
  8675. * @returns The scene
  8676. */
  8677. getScene(): Scene;
  8678. /**
  8679. * Callback defining a custom Projection Matrix Builder.
  8680. * This can be used to override the default projection matrix computation.
  8681. */
  8682. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8683. /**
  8684. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8685. * @param matrix The materix to updated with the projection information
  8686. * @param viewMatrix The transform matrix of the light
  8687. * @param renderList The list of mesh to render in the map
  8688. * @returns The current light
  8689. */
  8690. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8691. /**
  8692. * Gets the current depth scale used in ESM.
  8693. * @returns The scale
  8694. */
  8695. getDepthScale(): number;
  8696. /**
  8697. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8698. * @returns true if a cube texture needs to be use
  8699. */
  8700. needCube(): boolean;
  8701. /**
  8702. * Detects if the projection matrix requires to be recomputed this frame.
  8703. * @returns true if it requires to be recomputed otherwise, false.
  8704. */
  8705. needProjectionMatrixCompute(): boolean;
  8706. /**
  8707. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8708. */
  8709. forceProjectionMatrixCompute(): void;
  8710. /**
  8711. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8712. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8713. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8714. */
  8715. getShadowDirection(faceIndex?: number): Vector3;
  8716. /**
  8717. * Gets the minZ used for shadow according to both the scene and the light.
  8718. * @param activeCamera The camera we are returning the min for
  8719. * @returns the depth min z
  8720. */
  8721. getDepthMinZ(activeCamera: Camera): number;
  8722. /**
  8723. * Gets the maxZ used for shadow according to both the scene and the light.
  8724. * @param activeCamera The camera we are returning the max for
  8725. * @returns the depth max z
  8726. */
  8727. getDepthMaxZ(activeCamera: Camera): number;
  8728. }
  8729. /**
  8730. * Base implementation IShadowLight
  8731. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8732. */
  8733. export abstract class ShadowLight extends Light implements IShadowLight {
  8734. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8735. protected _position: Vector3;
  8736. protected _setPosition(value: Vector3): void;
  8737. /**
  8738. * Sets the position the shadow will be casted from. Also use as the light position for both
  8739. * point and spot lights.
  8740. */
  8741. /**
  8742. * Sets the position the shadow will be casted from. Also use as the light position for both
  8743. * point and spot lights.
  8744. */
  8745. position: Vector3;
  8746. protected _direction: Vector3;
  8747. protected _setDirection(value: Vector3): void;
  8748. /**
  8749. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8750. * Also use as the light direction on spot and directional lights.
  8751. */
  8752. /**
  8753. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8754. * Also use as the light direction on spot and directional lights.
  8755. */
  8756. direction: Vector3;
  8757. private _shadowMinZ;
  8758. /**
  8759. * Gets the shadow projection clipping minimum z value.
  8760. */
  8761. /**
  8762. * Sets the shadow projection clipping minimum z value.
  8763. */
  8764. shadowMinZ: number;
  8765. private _shadowMaxZ;
  8766. /**
  8767. * Sets the shadow projection clipping maximum z value.
  8768. */
  8769. /**
  8770. * Gets the shadow projection clipping maximum z value.
  8771. */
  8772. shadowMaxZ: number;
  8773. /**
  8774. * Callback defining a custom Projection Matrix Builder.
  8775. * This can be used to override the default projection matrix computation.
  8776. */
  8777. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8778. /**
  8779. * The transformed position. Position of the light in world space taking parenting in account.
  8780. */
  8781. transformedPosition: Vector3;
  8782. /**
  8783. * The transformed direction. Direction of the light in world space taking parenting in account.
  8784. */
  8785. transformedDirection: Vector3;
  8786. private _needProjectionMatrixCompute;
  8787. /**
  8788. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8789. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8790. */
  8791. computeTransformedInformation(): boolean;
  8792. /**
  8793. * Return the depth scale used for the shadow map.
  8794. * @returns the depth scale.
  8795. */
  8796. getDepthScale(): number;
  8797. /**
  8798. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8799. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8800. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8801. */
  8802. getShadowDirection(faceIndex?: number): Vector3;
  8803. /**
  8804. * Returns the ShadowLight absolute position in the World.
  8805. * @returns the position vector in world space
  8806. */
  8807. getAbsolutePosition(): Vector3;
  8808. /**
  8809. * Sets the ShadowLight direction toward the passed target.
  8810. * @param target The point to target in local space
  8811. * @returns the updated ShadowLight direction
  8812. */
  8813. setDirectionToTarget(target: Vector3): Vector3;
  8814. /**
  8815. * Returns the light rotation in euler definition.
  8816. * @returns the x y z rotation in local space.
  8817. */
  8818. getRotation(): Vector3;
  8819. /**
  8820. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8821. * @returns true if a cube texture needs to be use
  8822. */
  8823. needCube(): boolean;
  8824. /**
  8825. * Detects if the projection matrix requires to be recomputed this frame.
  8826. * @returns true if it requires to be recomputed otherwise, false.
  8827. */
  8828. needProjectionMatrixCompute(): boolean;
  8829. /**
  8830. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8831. */
  8832. forceProjectionMatrixCompute(): void;
  8833. /** @hidden */
  8834. _initCache(): void;
  8835. /** @hidden */
  8836. _isSynchronized(): boolean;
  8837. /**
  8838. * Computes the world matrix of the node
  8839. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8840. * @returns the world matrix
  8841. */
  8842. computeWorldMatrix(force?: boolean): Matrix;
  8843. /**
  8844. * Gets the minZ used for shadow according to both the scene and the light.
  8845. * @param activeCamera The camera we are returning the min for
  8846. * @returns the depth min z
  8847. */
  8848. getDepthMinZ(activeCamera: Camera): number;
  8849. /**
  8850. * Gets the maxZ used for shadow according to both the scene and the light.
  8851. * @param activeCamera The camera we are returning the max for
  8852. * @returns the depth max z
  8853. */
  8854. getDepthMaxZ(activeCamera: Camera): number;
  8855. /**
  8856. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8857. * @param matrix The materix to updated with the projection information
  8858. * @param viewMatrix The transform matrix of the light
  8859. * @param renderList The list of mesh to render in the map
  8860. * @returns The current light
  8861. */
  8862. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8863. }
  8864. }
  8865. declare module "babylonjs/Materials/materialHelper" {
  8866. import { Nullable } from "babylonjs/types";
  8867. import { Scene } from "babylonjs/scene";
  8868. import { Engine } from "babylonjs/Engines/engine";
  8869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8870. import { Light } from "babylonjs/Lights/light";
  8871. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8872. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  8873. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8874. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8875. /**
  8876. * "Static Class" containing the most commonly used helper while dealing with material for
  8877. * rendering purpose.
  8878. *
  8879. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8880. *
  8881. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8882. */
  8883. export class MaterialHelper {
  8884. /**
  8885. * Bind the current view position to an effect.
  8886. * @param effect The effect to be bound
  8887. * @param scene The scene the eyes position is used from
  8888. */
  8889. static BindEyePosition(effect: Effect, scene: Scene): void;
  8890. /**
  8891. * Helps preparing the defines values about the UVs in used in the effect.
  8892. * UVs are shared as much as we can accross channels in the shaders.
  8893. * @param texture The texture we are preparing the UVs for
  8894. * @param defines The defines to update
  8895. * @param key The channel key "diffuse", "specular"... used in the shader
  8896. */
  8897. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8898. /**
  8899. * Binds a texture matrix value to its corrsponding uniform
  8900. * @param texture The texture to bind the matrix for
  8901. * @param uniformBuffer The uniform buffer receivin the data
  8902. * @param key The channel key "diffuse", "specular"... used in the shader
  8903. */
  8904. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8905. /**
  8906. * Gets the current status of the fog (should it be enabled?)
  8907. * @param mesh defines the mesh to evaluate for fog support
  8908. * @param scene defines the hosting scene
  8909. * @returns true if fog must be enabled
  8910. */
  8911. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8912. /**
  8913. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8914. * @param mesh defines the current mesh
  8915. * @param scene defines the current scene
  8916. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8917. * @param pointsCloud defines if point cloud rendering has to be turned on
  8918. * @param fogEnabled defines if fog has to be turned on
  8919. * @param alphaTest defines if alpha testing has to be turned on
  8920. * @param defines defines the current list of defines
  8921. */
  8922. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8923. /**
  8924. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8925. * @param scene defines the current scene
  8926. * @param engine defines the current engine
  8927. * @param defines specifies the list of active defines
  8928. * @param useInstances defines if instances have to be turned on
  8929. * @param useClipPlane defines if clip plane have to be turned on
  8930. */
  8931. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8932. /**
  8933. * Prepares the defines for bones
  8934. * @param mesh The mesh containing the geometry data we will draw
  8935. * @param defines The defines to update
  8936. */
  8937. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8938. /**
  8939. * Prepares the defines for morph targets
  8940. * @param mesh The mesh containing the geometry data we will draw
  8941. * @param defines The defines to update
  8942. */
  8943. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8944. /**
  8945. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8946. * @param mesh The mesh containing the geometry data we will draw
  8947. * @param defines The defines to update
  8948. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8949. * @param useBones Precise whether bones should be used or not (override mesh info)
  8950. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8951. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8952. * @returns false if defines are considered not dirty and have not been checked
  8953. */
  8954. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8955. /**
  8956. * Prepares the defines related to multiview
  8957. * @param scene The scene we are intending to draw
  8958. * @param defines The defines to update
  8959. */
  8960. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8961. /**
  8962. * Prepares the defines related to the light information passed in parameter
  8963. * @param scene The scene we are intending to draw
  8964. * @param mesh The mesh the effect is compiling for
  8965. * @param light The light the effect is compiling for
  8966. * @param lightIndex The index of the light
  8967. * @param defines The defines to update
  8968. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8969. * @param state Defines the current state regarding what is needed (normals, etc...)
  8970. */
  8971. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8972. needNormals: boolean;
  8973. needRebuild: boolean;
  8974. shadowEnabled: boolean;
  8975. specularEnabled: boolean;
  8976. lightmapMode: boolean;
  8977. }): void;
  8978. /**
  8979. * Prepares the defines related to the light information passed in parameter
  8980. * @param scene The scene we are intending to draw
  8981. * @param mesh The mesh the effect is compiling for
  8982. * @param defines The defines to update
  8983. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8984. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8985. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8986. * @returns true if normals will be required for the rest of the effect
  8987. */
  8988. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8989. /**
  8990. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8991. * @param lightIndex defines the light index
  8992. * @param uniformsList The uniform list
  8993. * @param samplersList The sampler list
  8994. * @param projectedLightTexture defines if projected texture must be used
  8995. * @param uniformBuffersList defines an optional list of uniform buffers
  8996. */
  8997. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8998. /**
  8999. * Prepares the uniforms and samplers list to be used in the effect
  9000. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9001. * @param samplersList The sampler list
  9002. * @param defines The defines helping in the list generation
  9003. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9004. */
  9005. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9006. /**
  9007. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9008. * @param defines The defines to update while falling back
  9009. * @param fallbacks The authorized effect fallbacks
  9010. * @param maxSimultaneousLights The maximum number of lights allowed
  9011. * @param rank the current rank of the Effect
  9012. * @returns The newly affected rank
  9013. */
  9014. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9015. private static _TmpMorphInfluencers;
  9016. /**
  9017. * Prepares the list of attributes required for morph targets according to the effect defines.
  9018. * @param attribs The current list of supported attribs
  9019. * @param mesh The mesh to prepare the morph targets attributes for
  9020. * @param influencers The number of influencers
  9021. */
  9022. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9023. /**
  9024. * Prepares the list of attributes required for morph targets according to the effect defines.
  9025. * @param attribs The current list of supported attribs
  9026. * @param mesh The mesh to prepare the morph targets attributes for
  9027. * @param defines The current Defines of the effect
  9028. */
  9029. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9030. /**
  9031. * Prepares the list of attributes required for bones according to the effect defines.
  9032. * @param attribs The current list of supported attribs
  9033. * @param mesh The mesh to prepare the bones attributes for
  9034. * @param defines The current Defines of the effect
  9035. * @param fallbacks The current efffect fallback strategy
  9036. */
  9037. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9038. /**
  9039. * Check and prepare the list of attributes required for instances according to the effect defines.
  9040. * @param attribs The current list of supported attribs
  9041. * @param defines The current MaterialDefines of the effect
  9042. */
  9043. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9044. /**
  9045. * Add the list of attributes required for instances to the attribs array.
  9046. * @param attribs The current list of supported attribs
  9047. */
  9048. static PushAttributesForInstances(attribs: string[]): void;
  9049. /**
  9050. * Binds the light shadow information to the effect for the given mesh.
  9051. * @param light The light containing the generator
  9052. * @param scene The scene the lights belongs to
  9053. * @param mesh The mesh we are binding the information to render
  9054. * @param lightIndex The light index in the effect used to render the mesh
  9055. * @param effect The effect we are binding the data to
  9056. */
  9057. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9058. /**
  9059. * Binds the light information to the effect.
  9060. * @param light The light containing the generator
  9061. * @param effect The effect we are binding the data to
  9062. * @param lightIndex The light index in the effect used to render
  9063. */
  9064. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9065. /**
  9066. * Binds the lights information from the scene to the effect for the given mesh.
  9067. * @param light Light to bind
  9068. * @param lightIndex Light index
  9069. * @param scene The scene where the light belongs to
  9070. * @param mesh The mesh we are binding the information to render
  9071. * @param effect The effect we are binding the data to
  9072. * @param useSpecular Defines if specular is supported
  9073. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9074. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9075. */
  9076. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9077. /**
  9078. * Binds the lights information from the scene to the effect for the given mesh.
  9079. * @param scene The scene the lights belongs to
  9080. * @param mesh The mesh we are binding the information to render
  9081. * @param effect The effect we are binding the data to
  9082. * @param defines The generated defines for the effect
  9083. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9084. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9085. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9086. */
  9087. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9088. private static _tempFogColor;
  9089. /**
  9090. * Binds the fog information from the scene to the effect for the given mesh.
  9091. * @param scene The scene the lights belongs to
  9092. * @param mesh The mesh we are binding the information to render
  9093. * @param effect The effect we are binding the data to
  9094. * @param linearSpace Defines if the fog effect is applied in linear space
  9095. */
  9096. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9097. /**
  9098. * Binds the bones information from the mesh to the effect.
  9099. * @param mesh The mesh we are binding the information to render
  9100. * @param effect The effect we are binding the data to
  9101. */
  9102. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9103. /**
  9104. * Binds the morph targets information from the mesh to the effect.
  9105. * @param abstractMesh The mesh we are binding the information to render
  9106. * @param effect The effect we are binding the data to
  9107. */
  9108. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9109. /**
  9110. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9111. * @param defines The generated defines used in the effect
  9112. * @param effect The effect we are binding the data to
  9113. * @param scene The scene we are willing to render with logarithmic scale for
  9114. */
  9115. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9116. /**
  9117. * Binds the clip plane information from the scene to the effect.
  9118. * @param scene The scene the clip plane information are extracted from
  9119. * @param effect The effect we are binding the data to
  9120. */
  9121. static BindClipPlane(effect: Effect, scene: Scene): void;
  9122. }
  9123. }
  9124. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9125. /** @hidden */
  9126. export var packingFunctions: {
  9127. name: string;
  9128. shader: string;
  9129. };
  9130. }
  9131. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9132. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9133. /** @hidden */
  9134. export var shadowMapPixelShader: {
  9135. name: string;
  9136. shader: string;
  9137. };
  9138. }
  9139. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9140. /** @hidden */
  9141. export var bonesDeclaration: {
  9142. name: string;
  9143. shader: string;
  9144. };
  9145. }
  9146. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9147. /** @hidden */
  9148. export var morphTargetsVertexGlobalDeclaration: {
  9149. name: string;
  9150. shader: string;
  9151. };
  9152. }
  9153. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9154. /** @hidden */
  9155. export var morphTargetsVertexDeclaration: {
  9156. name: string;
  9157. shader: string;
  9158. };
  9159. }
  9160. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9161. /** @hidden */
  9162. export var instancesDeclaration: {
  9163. name: string;
  9164. shader: string;
  9165. };
  9166. }
  9167. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9168. /** @hidden */
  9169. export var helperFunctions: {
  9170. name: string;
  9171. shader: string;
  9172. };
  9173. }
  9174. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9175. /** @hidden */
  9176. export var morphTargetsVertex: {
  9177. name: string;
  9178. shader: string;
  9179. };
  9180. }
  9181. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9182. /** @hidden */
  9183. export var instancesVertex: {
  9184. name: string;
  9185. shader: string;
  9186. };
  9187. }
  9188. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9189. /** @hidden */
  9190. export var bonesVertex: {
  9191. name: string;
  9192. shader: string;
  9193. };
  9194. }
  9195. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9196. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9197. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9198. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9199. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9200. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9201. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9202. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9203. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9204. /** @hidden */
  9205. export var shadowMapVertexShader: {
  9206. name: string;
  9207. shader: string;
  9208. };
  9209. }
  9210. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9211. /** @hidden */
  9212. export var depthBoxBlurPixelShader: {
  9213. name: string;
  9214. shader: string;
  9215. };
  9216. }
  9217. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9218. import { Nullable } from "babylonjs/types";
  9219. import { Scene } from "babylonjs/scene";
  9220. import { Matrix } from "babylonjs/Maths/math.vector";
  9221. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9223. import { Mesh } from "babylonjs/Meshes/mesh";
  9224. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9225. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9226. import { Effect } from "babylonjs/Materials/effect";
  9227. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9228. import "babylonjs/Shaders/shadowMap.fragment";
  9229. import "babylonjs/Shaders/shadowMap.vertex";
  9230. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9231. import { Observable } from "babylonjs/Misc/observable";
  9232. /**
  9233. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9234. */
  9235. export interface ICustomShaderOptions {
  9236. /**
  9237. * Gets or sets the custom shader name to use
  9238. */
  9239. shaderName: string;
  9240. /**
  9241. * The list of attribute names used in the shader
  9242. */
  9243. attributes?: string[];
  9244. /**
  9245. * The list of unifrom names used in the shader
  9246. */
  9247. uniforms?: string[];
  9248. /**
  9249. * The list of sampler names used in the shader
  9250. */
  9251. samplers?: string[];
  9252. /**
  9253. * The list of defines used in the shader
  9254. */
  9255. defines?: string[];
  9256. }
  9257. /**
  9258. * Interface to implement to create a shadow generator compatible with BJS.
  9259. */
  9260. export interface IShadowGenerator {
  9261. /**
  9262. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9263. * @returns The render target texture if present otherwise, null
  9264. */
  9265. getShadowMap(): Nullable<RenderTargetTexture>;
  9266. /**
  9267. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9268. * @returns The render target texture if the shadow map is present otherwise, null
  9269. */
  9270. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9271. /**
  9272. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9273. * @param subMesh The submesh we want to render in the shadow map
  9274. * @param useInstances Defines wether will draw in the map using instances
  9275. * @returns true if ready otherwise, false
  9276. */
  9277. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9278. /**
  9279. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9280. * @param defines Defines of the material we want to update
  9281. * @param lightIndex Index of the light in the enabled light list of the material
  9282. */
  9283. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9284. /**
  9285. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9286. * defined in the generator but impacting the effect).
  9287. * It implies the unifroms available on the materials are the standard BJS ones.
  9288. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9289. * @param effect The effect we are binfing the information for
  9290. */
  9291. bindShadowLight(lightIndex: string, effect: Effect): void;
  9292. /**
  9293. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9294. * (eq to shadow prjection matrix * light transform matrix)
  9295. * @returns The transform matrix used to create the shadow map
  9296. */
  9297. getTransformMatrix(): Matrix;
  9298. /**
  9299. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9300. * Cube and 2D textures for instance.
  9301. */
  9302. recreateShadowMap(): void;
  9303. /**
  9304. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9305. * @param onCompiled Callback triggered at the and of the effects compilation
  9306. * @param options Sets of optional options forcing the compilation with different modes
  9307. */
  9308. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9309. useInstances: boolean;
  9310. }>): void;
  9311. /**
  9312. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9313. * @param options Sets of optional options forcing the compilation with different modes
  9314. * @returns A promise that resolves when the compilation completes
  9315. */
  9316. forceCompilationAsync(options?: Partial<{
  9317. useInstances: boolean;
  9318. }>): Promise<void>;
  9319. /**
  9320. * Serializes the shadow generator setup to a json object.
  9321. * @returns The serialized JSON object
  9322. */
  9323. serialize(): any;
  9324. /**
  9325. * Disposes the Shadow map and related Textures and effects.
  9326. */
  9327. dispose(): void;
  9328. }
  9329. /**
  9330. * Default implementation IShadowGenerator.
  9331. * This is the main object responsible of generating shadows in the framework.
  9332. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9333. */
  9334. export class ShadowGenerator implements IShadowGenerator {
  9335. /**
  9336. * Shadow generator mode None: no filtering applied.
  9337. */
  9338. static readonly FILTER_NONE: number;
  9339. /**
  9340. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9341. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9342. */
  9343. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9344. /**
  9345. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9346. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9347. */
  9348. static readonly FILTER_POISSONSAMPLING: number;
  9349. /**
  9350. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9351. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9352. */
  9353. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9354. /**
  9355. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9356. * edge artifacts on steep falloff.
  9357. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9358. */
  9359. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9360. /**
  9361. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9362. * edge artifacts on steep falloff.
  9363. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9364. */
  9365. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9366. /**
  9367. * Shadow generator mode PCF: Percentage Closer Filtering
  9368. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9369. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9370. */
  9371. static readonly FILTER_PCF: number;
  9372. /**
  9373. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9374. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9375. * Contact Hardening
  9376. */
  9377. static readonly FILTER_PCSS: number;
  9378. /**
  9379. * Reserved for PCF and PCSS
  9380. * Highest Quality.
  9381. *
  9382. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9383. *
  9384. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9385. */
  9386. static readonly QUALITY_HIGH: number;
  9387. /**
  9388. * Reserved for PCF and PCSS
  9389. * Good tradeoff for quality/perf cross devices
  9390. *
  9391. * Execute PCF on a 3*3 kernel.
  9392. *
  9393. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9394. */
  9395. static readonly QUALITY_MEDIUM: number;
  9396. /**
  9397. * Reserved for PCF and PCSS
  9398. * The lowest quality but the fastest.
  9399. *
  9400. * Execute PCF on a 1*1 kernel.
  9401. *
  9402. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9403. */
  9404. static readonly QUALITY_LOW: number;
  9405. /** Gets or sets the custom shader name to use */
  9406. customShaderOptions: ICustomShaderOptions;
  9407. /**
  9408. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9409. */
  9410. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9411. /**
  9412. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9413. */
  9414. onAfterShadowMapRenderObservable: Observable<Effect>;
  9415. /**
  9416. * Observable triggered before a mesh is rendered in the shadow map.
  9417. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9418. */
  9419. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9420. /**
  9421. * Observable triggered after a mesh is rendered in the shadow map.
  9422. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9423. */
  9424. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9425. private _bias;
  9426. /**
  9427. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9428. */
  9429. /**
  9430. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9431. */
  9432. bias: number;
  9433. private _normalBias;
  9434. /**
  9435. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9436. */
  9437. /**
  9438. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9439. */
  9440. normalBias: number;
  9441. private _blurBoxOffset;
  9442. /**
  9443. * Gets the blur box offset: offset applied during the blur pass.
  9444. * Only useful if useKernelBlur = false
  9445. */
  9446. /**
  9447. * Sets the blur box offset: offset applied during the blur pass.
  9448. * Only useful if useKernelBlur = false
  9449. */
  9450. blurBoxOffset: number;
  9451. private _blurScale;
  9452. /**
  9453. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9454. * 2 means half of the size.
  9455. */
  9456. /**
  9457. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9458. * 2 means half of the size.
  9459. */
  9460. blurScale: number;
  9461. private _blurKernel;
  9462. /**
  9463. * Gets the blur kernel: kernel size of the blur pass.
  9464. * Only useful if useKernelBlur = true
  9465. */
  9466. /**
  9467. * Sets the blur kernel: kernel size of the blur pass.
  9468. * Only useful if useKernelBlur = true
  9469. */
  9470. blurKernel: number;
  9471. private _useKernelBlur;
  9472. /**
  9473. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9474. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9475. */
  9476. /**
  9477. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9478. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9479. */
  9480. useKernelBlur: boolean;
  9481. private _depthScale;
  9482. /**
  9483. * Gets the depth scale used in ESM mode.
  9484. */
  9485. /**
  9486. * Sets the depth scale used in ESM mode.
  9487. * This can override the scale stored on the light.
  9488. */
  9489. depthScale: number;
  9490. private _filter;
  9491. /**
  9492. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9493. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9494. */
  9495. /**
  9496. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9497. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9498. */
  9499. filter: number;
  9500. /**
  9501. * Gets if the current filter is set to Poisson Sampling.
  9502. */
  9503. /**
  9504. * Sets the current filter to Poisson Sampling.
  9505. */
  9506. usePoissonSampling: boolean;
  9507. /**
  9508. * Gets if the current filter is set to ESM.
  9509. */
  9510. /**
  9511. * Sets the current filter is to ESM.
  9512. */
  9513. useExponentialShadowMap: boolean;
  9514. /**
  9515. * Gets if the current filter is set to filtered ESM.
  9516. */
  9517. /**
  9518. * Gets if the current filter is set to filtered ESM.
  9519. */
  9520. useBlurExponentialShadowMap: boolean;
  9521. /**
  9522. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9523. * exponential to prevent steep falloff artifacts).
  9524. */
  9525. /**
  9526. * Sets the current filter to "close ESM" (using the inverse of the
  9527. * exponential to prevent steep falloff artifacts).
  9528. */
  9529. useCloseExponentialShadowMap: boolean;
  9530. /**
  9531. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9532. * exponential to prevent steep falloff artifacts).
  9533. */
  9534. /**
  9535. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9536. * exponential to prevent steep falloff artifacts).
  9537. */
  9538. useBlurCloseExponentialShadowMap: boolean;
  9539. /**
  9540. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9541. */
  9542. /**
  9543. * Sets the current filter to "PCF" (percentage closer filtering).
  9544. */
  9545. usePercentageCloserFiltering: boolean;
  9546. private _filteringQuality;
  9547. /**
  9548. * Gets the PCF or PCSS Quality.
  9549. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9550. */
  9551. /**
  9552. * Sets the PCF or PCSS Quality.
  9553. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9554. */
  9555. filteringQuality: number;
  9556. /**
  9557. * Gets if the current filter is set to "PCSS" (contact hardening).
  9558. */
  9559. /**
  9560. * Sets the current filter to "PCSS" (contact hardening).
  9561. */
  9562. useContactHardeningShadow: boolean;
  9563. private _contactHardeningLightSizeUVRatio;
  9564. /**
  9565. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9566. * Using a ratio helps keeping shape stability independently of the map size.
  9567. *
  9568. * It does not account for the light projection as it was having too much
  9569. * instability during the light setup or during light position changes.
  9570. *
  9571. * Only valid if useContactHardeningShadow is true.
  9572. */
  9573. /**
  9574. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9575. * Using a ratio helps keeping shape stability independently of the map size.
  9576. *
  9577. * It does not account for the light projection as it was having too much
  9578. * instability during the light setup or during light position changes.
  9579. *
  9580. * Only valid if useContactHardeningShadow is true.
  9581. */
  9582. contactHardeningLightSizeUVRatio: number;
  9583. private _darkness;
  9584. /** Gets or sets the actual darkness of a shadow */
  9585. darkness: number;
  9586. /**
  9587. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9588. * 0 means strongest and 1 would means no shadow.
  9589. * @returns the darkness.
  9590. */
  9591. getDarkness(): number;
  9592. /**
  9593. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9594. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9595. * @returns the shadow generator allowing fluent coding.
  9596. */
  9597. setDarkness(darkness: number): ShadowGenerator;
  9598. private _transparencyShadow;
  9599. /** Gets or sets the ability to have transparent shadow */
  9600. transparencyShadow: boolean;
  9601. /**
  9602. * Sets the ability to have transparent shadow (boolean).
  9603. * @param transparent True if transparent else False
  9604. * @returns the shadow generator allowing fluent coding
  9605. */
  9606. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9607. private _shadowMap;
  9608. private _shadowMap2;
  9609. /**
  9610. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9611. * @returns The render target texture if present otherwise, null
  9612. */
  9613. getShadowMap(): Nullable<RenderTargetTexture>;
  9614. /**
  9615. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9616. * @returns The render target texture if the shadow map is present otherwise, null
  9617. */
  9618. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9619. /**
  9620. * Gets the class name of that object
  9621. * @returns "ShadowGenerator"
  9622. */
  9623. getClassName(): string;
  9624. /**
  9625. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9626. * @param mesh Mesh to add
  9627. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9628. * @returns the Shadow Generator itself
  9629. */
  9630. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9631. /**
  9632. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9633. * @param mesh Mesh to remove
  9634. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9635. * @returns the Shadow Generator itself
  9636. */
  9637. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9638. /**
  9639. * Controls the extent to which the shadows fade out at the edge of the frustum
  9640. * Used only by directionals and spots
  9641. */
  9642. frustumEdgeFalloff: number;
  9643. private _light;
  9644. /**
  9645. * Returns the associated light object.
  9646. * @returns the light generating the shadow
  9647. */
  9648. getLight(): IShadowLight;
  9649. /**
  9650. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9651. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9652. * It might on the other hand introduce peter panning.
  9653. */
  9654. forceBackFacesOnly: boolean;
  9655. private _scene;
  9656. private _lightDirection;
  9657. private _effect;
  9658. private _viewMatrix;
  9659. private _projectionMatrix;
  9660. private _transformMatrix;
  9661. private _cachedPosition;
  9662. private _cachedDirection;
  9663. private _cachedDefines;
  9664. private _currentRenderID;
  9665. private _boxBlurPostprocess;
  9666. private _kernelBlurXPostprocess;
  9667. private _kernelBlurYPostprocess;
  9668. private _blurPostProcesses;
  9669. private _mapSize;
  9670. private _currentFaceIndex;
  9671. private _currentFaceIndexCache;
  9672. private _textureType;
  9673. private _defaultTextureMatrix;
  9674. /** @hidden */
  9675. static _SceneComponentInitialization: (scene: Scene) => void;
  9676. /**
  9677. * Creates a ShadowGenerator object.
  9678. * A ShadowGenerator is the required tool to use the shadows.
  9679. * Each light casting shadows needs to use its own ShadowGenerator.
  9680. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9681. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9682. * @param light The light object generating the shadows.
  9683. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  9684. */
  9685. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9686. private _initializeGenerator;
  9687. private _initializeShadowMap;
  9688. private _initializeBlurRTTAndPostProcesses;
  9689. private _renderForShadowMap;
  9690. private _renderSubMeshForShadowMap;
  9691. private _applyFilterValues;
  9692. /**
  9693. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9694. * @param onCompiled Callback triggered at the and of the effects compilation
  9695. * @param options Sets of optional options forcing the compilation with different modes
  9696. */
  9697. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9698. useInstances: boolean;
  9699. }>): void;
  9700. /**
  9701. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9702. * @param options Sets of optional options forcing the compilation with different modes
  9703. * @returns A promise that resolves when the compilation completes
  9704. */
  9705. forceCompilationAsync(options?: Partial<{
  9706. useInstances: boolean;
  9707. }>): Promise<void>;
  9708. /**
  9709. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9710. * @param subMesh The submesh we want to render in the shadow map
  9711. * @param useInstances Defines wether will draw in the map using instances
  9712. * @returns true if ready otherwise, false
  9713. */
  9714. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9715. /**
  9716. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9717. * @param defines Defines of the material we want to update
  9718. * @param lightIndex Index of the light in the enabled light list of the material
  9719. */
  9720. prepareDefines(defines: any, lightIndex: number): void;
  9721. /**
  9722. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9723. * defined in the generator but impacting the effect).
  9724. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9725. * @param effect The effect we are binfing the information for
  9726. */
  9727. bindShadowLight(lightIndex: string, effect: Effect): void;
  9728. /**
  9729. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9730. * (eq to shadow prjection matrix * light transform matrix)
  9731. * @returns The transform matrix used to create the shadow map
  9732. */
  9733. getTransformMatrix(): Matrix;
  9734. /**
  9735. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9736. * Cube and 2D textures for instance.
  9737. */
  9738. recreateShadowMap(): void;
  9739. private _disposeBlurPostProcesses;
  9740. private _disposeRTTandPostProcesses;
  9741. /**
  9742. * Disposes the ShadowGenerator.
  9743. * Returns nothing.
  9744. */
  9745. dispose(): void;
  9746. /**
  9747. * Serializes the shadow generator setup to a json object.
  9748. * @returns The serialized JSON object
  9749. */
  9750. serialize(): any;
  9751. /**
  9752. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9753. * @param parsedShadowGenerator The JSON object to parse
  9754. * @param scene The scene to create the shadow map for
  9755. * @returns The parsed shadow generator
  9756. */
  9757. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9758. }
  9759. }
  9760. declare module "babylonjs/Lights/light" {
  9761. import { Nullable } from "babylonjs/types";
  9762. import { Scene } from "babylonjs/scene";
  9763. import { Vector3 } from "babylonjs/Maths/math.vector";
  9764. import { Color3 } from "babylonjs/Maths/math.color";
  9765. import { Node } from "babylonjs/node";
  9766. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9767. import { Effect } from "babylonjs/Materials/effect";
  9768. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9769. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9770. /**
  9771. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9772. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9773. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  9774. */
  9775. export abstract class Light extends Node {
  9776. /**
  9777. * Falloff Default: light is falling off following the material specification:
  9778. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9779. */
  9780. static readonly FALLOFF_DEFAULT: number;
  9781. /**
  9782. * Falloff Physical: light is falling off following the inverse squared distance law.
  9783. */
  9784. static readonly FALLOFF_PHYSICAL: number;
  9785. /**
  9786. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9787. * to enhance interoperability with other engines.
  9788. */
  9789. static readonly FALLOFF_GLTF: number;
  9790. /**
  9791. * Falloff Standard: light is falling off like in the standard material
  9792. * to enhance interoperability with other materials.
  9793. */
  9794. static readonly FALLOFF_STANDARD: number;
  9795. /**
  9796. * If every light affecting the material is in this lightmapMode,
  9797. * material.lightmapTexture adds or multiplies
  9798. * (depends on material.useLightmapAsShadowmap)
  9799. * after every other light calculations.
  9800. */
  9801. static readonly LIGHTMAP_DEFAULT: number;
  9802. /**
  9803. * material.lightmapTexture as only diffuse lighting from this light
  9804. * adds only specular lighting from this light
  9805. * adds dynamic shadows
  9806. */
  9807. static readonly LIGHTMAP_SPECULAR: number;
  9808. /**
  9809. * material.lightmapTexture as only lighting
  9810. * no light calculation from this light
  9811. * only adds dynamic shadows from this light
  9812. */
  9813. static readonly LIGHTMAP_SHADOWSONLY: number;
  9814. /**
  9815. * Each light type uses the default quantity according to its type:
  9816. * point/spot lights use luminous intensity
  9817. * directional lights use illuminance
  9818. */
  9819. static readonly INTENSITYMODE_AUTOMATIC: number;
  9820. /**
  9821. * lumen (lm)
  9822. */
  9823. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9824. /**
  9825. * candela (lm/sr)
  9826. */
  9827. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9828. /**
  9829. * lux (lm/m^2)
  9830. */
  9831. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9832. /**
  9833. * nit (cd/m^2)
  9834. */
  9835. static readonly INTENSITYMODE_LUMINANCE: number;
  9836. /**
  9837. * Light type const id of the point light.
  9838. */
  9839. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9840. /**
  9841. * Light type const id of the directional light.
  9842. */
  9843. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9844. /**
  9845. * Light type const id of the spot light.
  9846. */
  9847. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9848. /**
  9849. * Light type const id of the hemispheric light.
  9850. */
  9851. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9852. /**
  9853. * Diffuse gives the basic color to an object.
  9854. */
  9855. diffuse: Color3;
  9856. /**
  9857. * Specular produces a highlight color on an object.
  9858. * Note: This is note affecting PBR materials.
  9859. */
  9860. specular: Color3;
  9861. /**
  9862. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9863. * falling off base on range or angle.
  9864. * This can be set to any values in Light.FALLOFF_x.
  9865. *
  9866. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9867. * other types of materials.
  9868. */
  9869. falloffType: number;
  9870. /**
  9871. * Strength of the light.
  9872. * Note: By default it is define in the framework own unit.
  9873. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9874. */
  9875. intensity: number;
  9876. private _range;
  9877. protected _inverseSquaredRange: number;
  9878. /**
  9879. * Defines how far from the source the light is impacting in scene units.
  9880. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9881. */
  9882. /**
  9883. * Defines how far from the source the light is impacting in scene units.
  9884. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9885. */
  9886. range: number;
  9887. /**
  9888. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9889. * of light.
  9890. */
  9891. private _photometricScale;
  9892. private _intensityMode;
  9893. /**
  9894. * Gets the photometric scale used to interpret the intensity.
  9895. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9896. */
  9897. /**
  9898. * Sets the photometric scale used to interpret the intensity.
  9899. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9900. */
  9901. intensityMode: number;
  9902. private _radius;
  9903. /**
  9904. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9905. */
  9906. /**
  9907. * sets the light radius used by PBR Materials to simulate soft area lights.
  9908. */
  9909. radius: number;
  9910. private _renderPriority;
  9911. /**
  9912. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9913. * exceeding the number allowed of the materials.
  9914. */
  9915. renderPriority: number;
  9916. private _shadowEnabled;
  9917. /**
  9918. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9919. * the current shadow generator.
  9920. */
  9921. /**
  9922. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9923. * the current shadow generator.
  9924. */
  9925. shadowEnabled: boolean;
  9926. private _includedOnlyMeshes;
  9927. /**
  9928. * Gets the only meshes impacted by this light.
  9929. */
  9930. /**
  9931. * Sets the only meshes impacted by this light.
  9932. */
  9933. includedOnlyMeshes: AbstractMesh[];
  9934. private _excludedMeshes;
  9935. /**
  9936. * Gets the meshes not impacted by this light.
  9937. */
  9938. /**
  9939. * Sets the meshes not impacted by this light.
  9940. */
  9941. excludedMeshes: AbstractMesh[];
  9942. private _excludeWithLayerMask;
  9943. /**
  9944. * Gets the layer id use to find what meshes are not impacted by the light.
  9945. * Inactive if 0
  9946. */
  9947. /**
  9948. * Sets the layer id use to find what meshes are not impacted by the light.
  9949. * Inactive if 0
  9950. */
  9951. excludeWithLayerMask: number;
  9952. private _includeOnlyWithLayerMask;
  9953. /**
  9954. * Gets the layer id use to find what meshes are impacted by the light.
  9955. * Inactive if 0
  9956. */
  9957. /**
  9958. * Sets the layer id use to find what meshes are impacted by the light.
  9959. * Inactive if 0
  9960. */
  9961. includeOnlyWithLayerMask: number;
  9962. private _lightmapMode;
  9963. /**
  9964. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9965. */
  9966. /**
  9967. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9968. */
  9969. lightmapMode: number;
  9970. /**
  9971. * Shadow generator associted to the light.
  9972. * @hidden Internal use only.
  9973. */
  9974. _shadowGenerator: Nullable<IShadowGenerator>;
  9975. /**
  9976. * @hidden Internal use only.
  9977. */
  9978. _excludedMeshesIds: string[];
  9979. /**
  9980. * @hidden Internal use only.
  9981. */
  9982. _includedOnlyMeshesIds: string[];
  9983. /**
  9984. * The current light unifom buffer.
  9985. * @hidden Internal use only.
  9986. */
  9987. _uniformBuffer: UniformBuffer;
  9988. /**
  9989. * Creates a Light object in the scene.
  9990. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9991. * @param name The firendly name of the light
  9992. * @param scene The scene the light belongs too
  9993. */
  9994. constructor(name: string, scene: Scene);
  9995. protected abstract _buildUniformLayout(): void;
  9996. /**
  9997. * Sets the passed Effect "effect" with the Light information.
  9998. * @param effect The effect to update
  9999. * @param lightIndex The index of the light in the effect to update
  10000. * @returns The light
  10001. */
  10002. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10003. /**
  10004. * Sets the passed Effect "effect" with the Light information.
  10005. * @param effect The effect to update
  10006. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10007. * @returns The light
  10008. */
  10009. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10010. /**
  10011. * Returns the string "Light".
  10012. * @returns the class name
  10013. */
  10014. getClassName(): string;
  10015. /** @hidden */
  10016. readonly _isLight: boolean;
  10017. /**
  10018. * Converts the light information to a readable string for debug purpose.
  10019. * @param fullDetails Supports for multiple levels of logging within scene loading
  10020. * @returns the human readable light info
  10021. */
  10022. toString(fullDetails?: boolean): string;
  10023. /** @hidden */
  10024. protected _syncParentEnabledState(): void;
  10025. /**
  10026. * Set the enabled state of this node.
  10027. * @param value - the new enabled state
  10028. */
  10029. setEnabled(value: boolean): void;
  10030. /**
  10031. * Returns the Light associated shadow generator if any.
  10032. * @return the associated shadow generator.
  10033. */
  10034. getShadowGenerator(): Nullable<IShadowGenerator>;
  10035. /**
  10036. * Returns a Vector3, the absolute light position in the World.
  10037. * @returns the world space position of the light
  10038. */
  10039. getAbsolutePosition(): Vector3;
  10040. /**
  10041. * Specifies if the light will affect the passed mesh.
  10042. * @param mesh The mesh to test against the light
  10043. * @return true the mesh is affected otherwise, false.
  10044. */
  10045. canAffectMesh(mesh: AbstractMesh): boolean;
  10046. /**
  10047. * Sort function to order lights for rendering.
  10048. * @param a First Light object to compare to second.
  10049. * @param b Second Light object to compare first.
  10050. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10051. */
  10052. static CompareLightsPriority(a: Light, b: Light): number;
  10053. /**
  10054. * Releases resources associated with this node.
  10055. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10056. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10057. */
  10058. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10059. /**
  10060. * Returns the light type ID (integer).
  10061. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10062. */
  10063. getTypeID(): number;
  10064. /**
  10065. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10066. * @returns the scaled intensity in intensity mode unit
  10067. */
  10068. getScaledIntensity(): number;
  10069. /**
  10070. * Returns a new Light object, named "name", from the current one.
  10071. * @param name The name of the cloned light
  10072. * @returns the new created light
  10073. */
  10074. clone(name: string): Nullable<Light>;
  10075. /**
  10076. * Serializes the current light into a Serialization object.
  10077. * @returns the serialized object.
  10078. */
  10079. serialize(): any;
  10080. /**
  10081. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10082. * This new light is named "name" and added to the passed scene.
  10083. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10084. * @param name The friendly name of the light
  10085. * @param scene The scene the new light will belong to
  10086. * @returns the constructor function
  10087. */
  10088. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10089. /**
  10090. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10091. * @param parsedLight The JSON representation of the light
  10092. * @param scene The scene to create the parsed light in
  10093. * @returns the created light after parsing
  10094. */
  10095. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10096. private _hookArrayForExcluded;
  10097. private _hookArrayForIncludedOnly;
  10098. private _resyncMeshes;
  10099. /**
  10100. * Forces the meshes to update their light related information in their rendering used effects
  10101. * @hidden Internal Use Only
  10102. */
  10103. _markMeshesAsLightDirty(): void;
  10104. /**
  10105. * Recomputes the cached photometric scale if needed.
  10106. */
  10107. private _computePhotometricScale;
  10108. /**
  10109. * Returns the Photometric Scale according to the light type and intensity mode.
  10110. */
  10111. private _getPhotometricScale;
  10112. /**
  10113. * Reorder the light in the scene according to their defined priority.
  10114. * @hidden Internal Use Only
  10115. */
  10116. _reorderLightsInScene(): void;
  10117. /**
  10118. * Prepares the list of defines specific to the light type.
  10119. * @param defines the list of defines
  10120. * @param lightIndex defines the index of the light for the effect
  10121. */
  10122. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10123. }
  10124. }
  10125. declare module "babylonjs/Actions/action" {
  10126. import { Observable } from "babylonjs/Misc/observable";
  10127. import { Condition } from "babylonjs/Actions/condition";
  10128. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10129. import { ActionManager } from "babylonjs/Actions/actionManager";
  10130. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10131. /**
  10132. * Interface used to define Action
  10133. */
  10134. export interface IAction {
  10135. /**
  10136. * Trigger for the action
  10137. */
  10138. trigger: number;
  10139. /** Options of the trigger */
  10140. triggerOptions: any;
  10141. /**
  10142. * Gets the trigger parameters
  10143. * @returns the trigger parameters
  10144. */
  10145. getTriggerParameter(): any;
  10146. /**
  10147. * Internal only - executes current action event
  10148. * @hidden
  10149. */
  10150. _executeCurrent(evt?: ActionEvent): void;
  10151. /**
  10152. * Serialize placeholder for child classes
  10153. * @param parent of child
  10154. * @returns the serialized object
  10155. */
  10156. serialize(parent: any): any;
  10157. /**
  10158. * Internal only
  10159. * @hidden
  10160. */
  10161. _prepare(): void;
  10162. /**
  10163. * Internal only - manager for action
  10164. * @hidden
  10165. */
  10166. _actionManager: AbstractActionManager;
  10167. /**
  10168. * Adds action to chain of actions, may be a DoNothingAction
  10169. * @param action defines the next action to execute
  10170. * @returns The action passed in
  10171. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10172. */
  10173. then(action: IAction): IAction;
  10174. }
  10175. /**
  10176. * The action to be carried out following a trigger
  10177. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10178. */
  10179. export class Action implements IAction {
  10180. /** the trigger, with or without parameters, for the action */
  10181. triggerOptions: any;
  10182. /**
  10183. * Trigger for the action
  10184. */
  10185. trigger: number;
  10186. /**
  10187. * Internal only - manager for action
  10188. * @hidden
  10189. */
  10190. _actionManager: ActionManager;
  10191. private _nextActiveAction;
  10192. private _child;
  10193. private _condition?;
  10194. private _triggerParameter;
  10195. /**
  10196. * An event triggered prior to action being executed.
  10197. */
  10198. onBeforeExecuteObservable: Observable<Action>;
  10199. /**
  10200. * Creates a new Action
  10201. * @param triggerOptions the trigger, with or without parameters, for the action
  10202. * @param condition an optional determinant of action
  10203. */
  10204. constructor(
  10205. /** the trigger, with or without parameters, for the action */
  10206. triggerOptions: any, condition?: Condition);
  10207. /**
  10208. * Internal only
  10209. * @hidden
  10210. */
  10211. _prepare(): void;
  10212. /**
  10213. * Gets the trigger parameters
  10214. * @returns the trigger parameters
  10215. */
  10216. getTriggerParameter(): any;
  10217. /**
  10218. * Internal only - executes current action event
  10219. * @hidden
  10220. */
  10221. _executeCurrent(evt?: ActionEvent): void;
  10222. /**
  10223. * Execute placeholder for child classes
  10224. * @param evt optional action event
  10225. */
  10226. execute(evt?: ActionEvent): void;
  10227. /**
  10228. * Skips to next active action
  10229. */
  10230. skipToNextActiveAction(): void;
  10231. /**
  10232. * Adds action to chain of actions, may be a DoNothingAction
  10233. * @param action defines the next action to execute
  10234. * @returns The action passed in
  10235. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10236. */
  10237. then(action: Action): Action;
  10238. /**
  10239. * Internal only
  10240. * @hidden
  10241. */
  10242. _getProperty(propertyPath: string): string;
  10243. /**
  10244. * Internal only
  10245. * @hidden
  10246. */
  10247. _getEffectiveTarget(target: any, propertyPath: string): any;
  10248. /**
  10249. * Serialize placeholder for child classes
  10250. * @param parent of child
  10251. * @returns the serialized object
  10252. */
  10253. serialize(parent: any): any;
  10254. /**
  10255. * Internal only called by serialize
  10256. * @hidden
  10257. */
  10258. protected _serialize(serializedAction: any, parent?: any): any;
  10259. /**
  10260. * Internal only
  10261. * @hidden
  10262. */
  10263. static _SerializeValueAsString: (value: any) => string;
  10264. /**
  10265. * Internal only
  10266. * @hidden
  10267. */
  10268. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10269. name: string;
  10270. targetType: string;
  10271. value: string;
  10272. };
  10273. }
  10274. }
  10275. declare module "babylonjs/Actions/condition" {
  10276. import { ActionManager } from "babylonjs/Actions/actionManager";
  10277. /**
  10278. * A Condition applied to an Action
  10279. */
  10280. export class Condition {
  10281. /**
  10282. * Internal only - manager for action
  10283. * @hidden
  10284. */
  10285. _actionManager: ActionManager;
  10286. /**
  10287. * Internal only
  10288. * @hidden
  10289. */
  10290. _evaluationId: number;
  10291. /**
  10292. * Internal only
  10293. * @hidden
  10294. */
  10295. _currentResult: boolean;
  10296. /**
  10297. * Creates a new Condition
  10298. * @param actionManager the manager of the action the condition is applied to
  10299. */
  10300. constructor(actionManager: ActionManager);
  10301. /**
  10302. * Check if the current condition is valid
  10303. * @returns a boolean
  10304. */
  10305. isValid(): boolean;
  10306. /**
  10307. * Internal only
  10308. * @hidden
  10309. */
  10310. _getProperty(propertyPath: string): string;
  10311. /**
  10312. * Internal only
  10313. * @hidden
  10314. */
  10315. _getEffectiveTarget(target: any, propertyPath: string): any;
  10316. /**
  10317. * Serialize placeholder for child classes
  10318. * @returns the serialized object
  10319. */
  10320. serialize(): any;
  10321. /**
  10322. * Internal only
  10323. * @hidden
  10324. */
  10325. protected _serialize(serializedCondition: any): any;
  10326. }
  10327. /**
  10328. * Defines specific conditional operators as extensions of Condition
  10329. */
  10330. export class ValueCondition extends Condition {
  10331. /** path to specify the property of the target the conditional operator uses */
  10332. propertyPath: string;
  10333. /** the value compared by the conditional operator against the current value of the property */
  10334. value: any;
  10335. /** the conditional operator, default ValueCondition.IsEqual */
  10336. operator: number;
  10337. /**
  10338. * Internal only
  10339. * @hidden
  10340. */
  10341. private static _IsEqual;
  10342. /**
  10343. * Internal only
  10344. * @hidden
  10345. */
  10346. private static _IsDifferent;
  10347. /**
  10348. * Internal only
  10349. * @hidden
  10350. */
  10351. private static _IsGreater;
  10352. /**
  10353. * Internal only
  10354. * @hidden
  10355. */
  10356. private static _IsLesser;
  10357. /**
  10358. * returns the number for IsEqual
  10359. */
  10360. static readonly IsEqual: number;
  10361. /**
  10362. * Returns the number for IsDifferent
  10363. */
  10364. static readonly IsDifferent: number;
  10365. /**
  10366. * Returns the number for IsGreater
  10367. */
  10368. static readonly IsGreater: number;
  10369. /**
  10370. * Returns the number for IsLesser
  10371. */
  10372. static readonly IsLesser: number;
  10373. /**
  10374. * Internal only The action manager for the condition
  10375. * @hidden
  10376. */
  10377. _actionManager: ActionManager;
  10378. /**
  10379. * Internal only
  10380. * @hidden
  10381. */
  10382. private _target;
  10383. /**
  10384. * Internal only
  10385. * @hidden
  10386. */
  10387. private _effectiveTarget;
  10388. /**
  10389. * Internal only
  10390. * @hidden
  10391. */
  10392. private _property;
  10393. /**
  10394. * Creates a new ValueCondition
  10395. * @param actionManager manager for the action the condition applies to
  10396. * @param target for the action
  10397. * @param propertyPath path to specify the property of the target the conditional operator uses
  10398. * @param value the value compared by the conditional operator against the current value of the property
  10399. * @param operator the conditional operator, default ValueCondition.IsEqual
  10400. */
  10401. constructor(actionManager: ActionManager, target: any,
  10402. /** path to specify the property of the target the conditional operator uses */
  10403. propertyPath: string,
  10404. /** the value compared by the conditional operator against the current value of the property */
  10405. value: any,
  10406. /** the conditional operator, default ValueCondition.IsEqual */
  10407. operator?: number);
  10408. /**
  10409. * Compares the given value with the property value for the specified conditional operator
  10410. * @returns the result of the comparison
  10411. */
  10412. isValid(): boolean;
  10413. /**
  10414. * Serialize the ValueCondition into a JSON compatible object
  10415. * @returns serialization object
  10416. */
  10417. serialize(): any;
  10418. /**
  10419. * Gets the name of the conditional operator for the ValueCondition
  10420. * @param operator the conditional operator
  10421. * @returns the name
  10422. */
  10423. static GetOperatorName(operator: number): string;
  10424. }
  10425. /**
  10426. * Defines a predicate condition as an extension of Condition
  10427. */
  10428. export class PredicateCondition extends Condition {
  10429. /** defines the predicate function used to validate the condition */
  10430. predicate: () => boolean;
  10431. /**
  10432. * Internal only - manager for action
  10433. * @hidden
  10434. */
  10435. _actionManager: ActionManager;
  10436. /**
  10437. * Creates a new PredicateCondition
  10438. * @param actionManager manager for the action the condition applies to
  10439. * @param predicate defines the predicate function used to validate the condition
  10440. */
  10441. constructor(actionManager: ActionManager,
  10442. /** defines the predicate function used to validate the condition */
  10443. predicate: () => boolean);
  10444. /**
  10445. * @returns the validity of the predicate condition
  10446. */
  10447. isValid(): boolean;
  10448. }
  10449. /**
  10450. * Defines a state condition as an extension of Condition
  10451. */
  10452. export class StateCondition extends Condition {
  10453. /** Value to compare with target state */
  10454. value: string;
  10455. /**
  10456. * Internal only - manager for action
  10457. * @hidden
  10458. */
  10459. _actionManager: ActionManager;
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */
  10464. private _target;
  10465. /**
  10466. * Creates a new StateCondition
  10467. * @param actionManager manager for the action the condition applies to
  10468. * @param target of the condition
  10469. * @param value to compare with target state
  10470. */
  10471. constructor(actionManager: ActionManager, target: any,
  10472. /** Value to compare with target state */
  10473. value: string);
  10474. /**
  10475. * Gets a boolean indicating if the current condition is met
  10476. * @returns the validity of the state
  10477. */
  10478. isValid(): boolean;
  10479. /**
  10480. * Serialize the StateCondition into a JSON compatible object
  10481. * @returns serialization object
  10482. */
  10483. serialize(): any;
  10484. }
  10485. }
  10486. declare module "babylonjs/Actions/directActions" {
  10487. import { Action } from "babylonjs/Actions/action";
  10488. import { Condition } from "babylonjs/Actions/condition";
  10489. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10490. /**
  10491. * This defines an action responsible to toggle a boolean once triggered.
  10492. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10493. */
  10494. export class SwitchBooleanAction extends Action {
  10495. /**
  10496. * The path to the boolean property in the target object
  10497. */
  10498. propertyPath: string;
  10499. private _target;
  10500. private _effectiveTarget;
  10501. private _property;
  10502. /**
  10503. * Instantiate the action
  10504. * @param triggerOptions defines the trigger options
  10505. * @param target defines the object containing the boolean
  10506. * @param propertyPath defines the path to the boolean property in the target object
  10507. * @param condition defines the trigger related conditions
  10508. */
  10509. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10510. /** @hidden */
  10511. _prepare(): void;
  10512. /**
  10513. * Execute the action toggle the boolean value.
  10514. */
  10515. execute(): void;
  10516. /**
  10517. * Serializes the actions and its related information.
  10518. * @param parent defines the object to serialize in
  10519. * @returns the serialized object
  10520. */
  10521. serialize(parent: any): any;
  10522. }
  10523. /**
  10524. * This defines an action responsible to set a the state field of the target
  10525. * to a desired value once triggered.
  10526. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10527. */
  10528. export class SetStateAction extends Action {
  10529. /**
  10530. * The value to store in the state field.
  10531. */
  10532. value: string;
  10533. private _target;
  10534. /**
  10535. * Instantiate the action
  10536. * @param triggerOptions defines the trigger options
  10537. * @param target defines the object containing the state property
  10538. * @param value defines the value to store in the state field
  10539. * @param condition defines the trigger related conditions
  10540. */
  10541. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10542. /**
  10543. * Execute the action and store the value on the target state property.
  10544. */
  10545. execute(): void;
  10546. /**
  10547. * Serializes the actions and its related information.
  10548. * @param parent defines the object to serialize in
  10549. * @returns the serialized object
  10550. */
  10551. serialize(parent: any): any;
  10552. }
  10553. /**
  10554. * This defines an action responsible to set a property of the target
  10555. * to a desired value once triggered.
  10556. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10557. */
  10558. export class SetValueAction extends Action {
  10559. /**
  10560. * The path of the property to set in the target.
  10561. */
  10562. propertyPath: string;
  10563. /**
  10564. * The value to set in the property
  10565. */
  10566. value: any;
  10567. private _target;
  10568. private _effectiveTarget;
  10569. private _property;
  10570. /**
  10571. * Instantiate the action
  10572. * @param triggerOptions defines the trigger options
  10573. * @param target defines the object containing the property
  10574. * @param propertyPath defines the path of the property to set in the target
  10575. * @param value defines the value to set in the property
  10576. * @param condition defines the trigger related conditions
  10577. */
  10578. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10579. /** @hidden */
  10580. _prepare(): void;
  10581. /**
  10582. * Execute the action and set the targetted property to the desired value.
  10583. */
  10584. execute(): void;
  10585. /**
  10586. * Serializes the actions and its related information.
  10587. * @param parent defines the object to serialize in
  10588. * @returns the serialized object
  10589. */
  10590. serialize(parent: any): any;
  10591. }
  10592. /**
  10593. * This defines an action responsible to increment the target value
  10594. * to a desired value once triggered.
  10595. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10596. */
  10597. export class IncrementValueAction extends Action {
  10598. /**
  10599. * The path of the property to increment in the target.
  10600. */
  10601. propertyPath: string;
  10602. /**
  10603. * The value we should increment the property by.
  10604. */
  10605. value: any;
  10606. private _target;
  10607. private _effectiveTarget;
  10608. private _property;
  10609. /**
  10610. * Instantiate the action
  10611. * @param triggerOptions defines the trigger options
  10612. * @param target defines the object containing the property
  10613. * @param propertyPath defines the path of the property to increment in the target
  10614. * @param value defines the value value we should increment the property by
  10615. * @param condition defines the trigger related conditions
  10616. */
  10617. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10618. /** @hidden */
  10619. _prepare(): void;
  10620. /**
  10621. * Execute the action and increment the target of the value amount.
  10622. */
  10623. execute(): void;
  10624. /**
  10625. * Serializes the actions and its related information.
  10626. * @param parent defines the object to serialize in
  10627. * @returns the serialized object
  10628. */
  10629. serialize(parent: any): any;
  10630. }
  10631. /**
  10632. * This defines an action responsible to start an animation once triggered.
  10633. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10634. */
  10635. export class PlayAnimationAction extends Action {
  10636. /**
  10637. * Where the animation should start (animation frame)
  10638. */
  10639. from: number;
  10640. /**
  10641. * Where the animation should stop (animation frame)
  10642. */
  10643. to: number;
  10644. /**
  10645. * Define if the animation should loop or stop after the first play.
  10646. */
  10647. loop?: boolean;
  10648. private _target;
  10649. /**
  10650. * Instantiate the action
  10651. * @param triggerOptions defines the trigger options
  10652. * @param target defines the target animation or animation name
  10653. * @param from defines from where the animation should start (animation frame)
  10654. * @param end defines where the animation should stop (animation frame)
  10655. * @param loop defines if the animation should loop or stop after the first play
  10656. * @param condition defines the trigger related conditions
  10657. */
  10658. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10659. /** @hidden */
  10660. _prepare(): void;
  10661. /**
  10662. * Execute the action and play the animation.
  10663. */
  10664. execute(): void;
  10665. /**
  10666. * Serializes the actions and its related information.
  10667. * @param parent defines the object to serialize in
  10668. * @returns the serialized object
  10669. */
  10670. serialize(parent: any): any;
  10671. }
  10672. /**
  10673. * This defines an action responsible to stop an animation once triggered.
  10674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10675. */
  10676. export class StopAnimationAction extends Action {
  10677. private _target;
  10678. /**
  10679. * Instantiate the action
  10680. * @param triggerOptions defines the trigger options
  10681. * @param target defines the target animation or animation name
  10682. * @param condition defines the trigger related conditions
  10683. */
  10684. constructor(triggerOptions: any, target: any, condition?: Condition);
  10685. /** @hidden */
  10686. _prepare(): void;
  10687. /**
  10688. * Execute the action and stop the animation.
  10689. */
  10690. execute(): void;
  10691. /**
  10692. * Serializes the actions and its related information.
  10693. * @param parent defines the object to serialize in
  10694. * @returns the serialized object
  10695. */
  10696. serialize(parent: any): any;
  10697. }
  10698. /**
  10699. * This defines an action responsible that does nothing once triggered.
  10700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10701. */
  10702. export class DoNothingAction extends Action {
  10703. /**
  10704. * Instantiate the action
  10705. * @param triggerOptions defines the trigger options
  10706. * @param condition defines the trigger related conditions
  10707. */
  10708. constructor(triggerOptions?: any, condition?: Condition);
  10709. /**
  10710. * Execute the action and do nothing.
  10711. */
  10712. execute(): void;
  10713. /**
  10714. * Serializes the actions and its related information.
  10715. * @param parent defines the object to serialize in
  10716. * @returns the serialized object
  10717. */
  10718. serialize(parent: any): any;
  10719. }
  10720. /**
  10721. * This defines an action responsible to trigger several actions once triggered.
  10722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10723. */
  10724. export class CombineAction extends Action {
  10725. /**
  10726. * The list of aggregated animations to run.
  10727. */
  10728. children: Action[];
  10729. /**
  10730. * Instantiate the action
  10731. * @param triggerOptions defines the trigger options
  10732. * @param children defines the list of aggregated animations to run
  10733. * @param condition defines the trigger related conditions
  10734. */
  10735. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10736. /** @hidden */
  10737. _prepare(): void;
  10738. /**
  10739. * Execute the action and executes all the aggregated actions.
  10740. */
  10741. execute(evt: ActionEvent): void;
  10742. /**
  10743. * Serializes the actions and its related information.
  10744. * @param parent defines the object to serialize in
  10745. * @returns the serialized object
  10746. */
  10747. serialize(parent: any): any;
  10748. }
  10749. /**
  10750. * This defines an action responsible to run code (external event) once triggered.
  10751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10752. */
  10753. export class ExecuteCodeAction extends Action {
  10754. /**
  10755. * The callback function to run.
  10756. */
  10757. func: (evt: ActionEvent) => void;
  10758. /**
  10759. * Instantiate the action
  10760. * @param triggerOptions defines the trigger options
  10761. * @param func defines the callback function to run
  10762. * @param condition defines the trigger related conditions
  10763. */
  10764. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10765. /**
  10766. * Execute the action and run the attached code.
  10767. */
  10768. execute(evt: ActionEvent): void;
  10769. }
  10770. /**
  10771. * This defines an action responsible to set the parent property of the target once triggered.
  10772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10773. */
  10774. export class SetParentAction extends Action {
  10775. private _parent;
  10776. private _target;
  10777. /**
  10778. * Instantiate the action
  10779. * @param triggerOptions defines the trigger options
  10780. * @param target defines the target containing the parent property
  10781. * @param parent defines from where the animation should start (animation frame)
  10782. * @param condition defines the trigger related conditions
  10783. */
  10784. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10785. /** @hidden */
  10786. _prepare(): void;
  10787. /**
  10788. * Execute the action and set the parent property.
  10789. */
  10790. execute(): void;
  10791. /**
  10792. * Serializes the actions and its related information.
  10793. * @param parent defines the object to serialize in
  10794. * @returns the serialized object
  10795. */
  10796. serialize(parent: any): any;
  10797. }
  10798. }
  10799. declare module "babylonjs/Actions/actionManager" {
  10800. import { Nullable } from "babylonjs/types";
  10801. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10802. import { Scene } from "babylonjs/scene";
  10803. import { IAction } from "babylonjs/Actions/action";
  10804. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10805. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10806. /**
  10807. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10808. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10810. */
  10811. export class ActionManager extends AbstractActionManager {
  10812. /**
  10813. * Nothing
  10814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10815. */
  10816. static readonly NothingTrigger: number;
  10817. /**
  10818. * On pick
  10819. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10820. */
  10821. static readonly OnPickTrigger: number;
  10822. /**
  10823. * On left pick
  10824. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10825. */
  10826. static readonly OnLeftPickTrigger: number;
  10827. /**
  10828. * On right pick
  10829. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10830. */
  10831. static readonly OnRightPickTrigger: number;
  10832. /**
  10833. * On center pick
  10834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10835. */
  10836. static readonly OnCenterPickTrigger: number;
  10837. /**
  10838. * On pick down
  10839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10840. */
  10841. static readonly OnPickDownTrigger: number;
  10842. /**
  10843. * On double pick
  10844. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10845. */
  10846. static readonly OnDoublePickTrigger: number;
  10847. /**
  10848. * On pick up
  10849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10850. */
  10851. static readonly OnPickUpTrigger: number;
  10852. /**
  10853. * On pick out.
  10854. * This trigger will only be raised if you also declared a OnPickDown
  10855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10856. */
  10857. static readonly OnPickOutTrigger: number;
  10858. /**
  10859. * On long press
  10860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10861. */
  10862. static readonly OnLongPressTrigger: number;
  10863. /**
  10864. * On pointer over
  10865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10866. */
  10867. static readonly OnPointerOverTrigger: number;
  10868. /**
  10869. * On pointer out
  10870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10871. */
  10872. static readonly OnPointerOutTrigger: number;
  10873. /**
  10874. * On every frame
  10875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10876. */
  10877. static readonly OnEveryFrameTrigger: number;
  10878. /**
  10879. * On intersection enter
  10880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10881. */
  10882. static readonly OnIntersectionEnterTrigger: number;
  10883. /**
  10884. * On intersection exit
  10885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10886. */
  10887. static readonly OnIntersectionExitTrigger: number;
  10888. /**
  10889. * On key down
  10890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10891. */
  10892. static readonly OnKeyDownTrigger: number;
  10893. /**
  10894. * On key up
  10895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10896. */
  10897. static readonly OnKeyUpTrigger: number;
  10898. private _scene;
  10899. /**
  10900. * Creates a new action manager
  10901. * @param scene defines the hosting scene
  10902. */
  10903. constructor(scene: Scene);
  10904. /**
  10905. * Releases all associated resources
  10906. */
  10907. dispose(): void;
  10908. /**
  10909. * Gets hosting scene
  10910. * @returns the hosting scene
  10911. */
  10912. getScene(): Scene;
  10913. /**
  10914. * Does this action manager handles actions of any of the given triggers
  10915. * @param triggers defines the triggers to be tested
  10916. * @return a boolean indicating whether one (or more) of the triggers is handled
  10917. */
  10918. hasSpecificTriggers(triggers: number[]): boolean;
  10919. /**
  10920. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10921. * speed.
  10922. * @param triggerA defines the trigger to be tested
  10923. * @param triggerB defines the trigger to be tested
  10924. * @return a boolean indicating whether one (or more) of the triggers is handled
  10925. */
  10926. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10927. /**
  10928. * Does this action manager handles actions of a given trigger
  10929. * @param trigger defines the trigger to be tested
  10930. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10931. * @return whether the trigger is handled
  10932. */
  10933. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10934. /**
  10935. * Does this action manager has pointer triggers
  10936. */
  10937. readonly hasPointerTriggers: boolean;
  10938. /**
  10939. * Does this action manager has pick triggers
  10940. */
  10941. readonly hasPickTriggers: boolean;
  10942. /**
  10943. * Registers an action to this action manager
  10944. * @param action defines the action to be registered
  10945. * @return the action amended (prepared) after registration
  10946. */
  10947. registerAction(action: IAction): Nullable<IAction>;
  10948. /**
  10949. * Unregisters an action to this action manager
  10950. * @param action defines the action to be unregistered
  10951. * @return a boolean indicating whether the action has been unregistered
  10952. */
  10953. unregisterAction(action: IAction): Boolean;
  10954. /**
  10955. * Process a specific trigger
  10956. * @param trigger defines the trigger to process
  10957. * @param evt defines the event details to be processed
  10958. */
  10959. processTrigger(trigger: number, evt?: IActionEvent): void;
  10960. /** @hidden */
  10961. _getEffectiveTarget(target: any, propertyPath: string): any;
  10962. /** @hidden */
  10963. _getProperty(propertyPath: string): string;
  10964. /**
  10965. * Serialize this manager to a JSON object
  10966. * @param name defines the property name to store this manager
  10967. * @returns a JSON representation of this manager
  10968. */
  10969. serialize(name: string): any;
  10970. /**
  10971. * Creates a new ActionManager from a JSON data
  10972. * @param parsedActions defines the JSON data to read from
  10973. * @param object defines the hosting mesh
  10974. * @param scene defines the hosting scene
  10975. */
  10976. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10977. /**
  10978. * Get a trigger name by index
  10979. * @param trigger defines the trigger index
  10980. * @returns a trigger name
  10981. */
  10982. static GetTriggerName(trigger: number): string;
  10983. }
  10984. }
  10985. declare module "babylonjs/Culling/ray" {
  10986. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10987. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10989. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10990. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10991. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10992. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10993. import { Plane } from "babylonjs/Maths/math.plane";
  10994. /**
  10995. * Class representing a ray with position and direction
  10996. */
  10997. export class Ray {
  10998. /** origin point */
  10999. origin: Vector3;
  11000. /** direction */
  11001. direction: Vector3;
  11002. /** length of the ray */
  11003. length: number;
  11004. private static readonly TmpVector3;
  11005. private _tmpRay;
  11006. /**
  11007. * Creates a new ray
  11008. * @param origin origin point
  11009. * @param direction direction
  11010. * @param length length of the ray
  11011. */
  11012. constructor(
  11013. /** origin point */
  11014. origin: Vector3,
  11015. /** direction */
  11016. direction: Vector3,
  11017. /** length of the ray */
  11018. length?: number);
  11019. /**
  11020. * Checks if the ray intersects a box
  11021. * @param minimum bound of the box
  11022. * @param maximum bound of the box
  11023. * @param intersectionTreshold extra extend to be added to the box in all direction
  11024. * @returns if the box was hit
  11025. */
  11026. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11027. /**
  11028. * Checks if the ray intersects a box
  11029. * @param box the bounding box to check
  11030. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11031. * @returns if the box was hit
  11032. */
  11033. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11034. /**
  11035. * If the ray hits a sphere
  11036. * @param sphere the bounding sphere to check
  11037. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11038. * @returns true if it hits the sphere
  11039. */
  11040. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11041. /**
  11042. * If the ray hits a triange
  11043. * @param vertex0 triangle vertex
  11044. * @param vertex1 triangle vertex
  11045. * @param vertex2 triangle vertex
  11046. * @returns intersection information if hit
  11047. */
  11048. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11049. /**
  11050. * Checks if ray intersects a plane
  11051. * @param plane the plane to check
  11052. * @returns the distance away it was hit
  11053. */
  11054. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11055. /**
  11056. * Calculate the intercept of a ray on a given axis
  11057. * @param axis to check 'x' | 'y' | 'z'
  11058. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11059. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11060. */
  11061. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11062. /**
  11063. * Checks if ray intersects a mesh
  11064. * @param mesh the mesh to check
  11065. * @param fastCheck if only the bounding box should checked
  11066. * @returns picking info of the intersecton
  11067. */
  11068. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11069. /**
  11070. * Checks if ray intersects a mesh
  11071. * @param meshes the meshes to check
  11072. * @param fastCheck if only the bounding box should checked
  11073. * @param results array to store result in
  11074. * @returns Array of picking infos
  11075. */
  11076. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11077. private _comparePickingInfo;
  11078. private static smallnum;
  11079. private static rayl;
  11080. /**
  11081. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11082. * @param sega the first point of the segment to test the intersection against
  11083. * @param segb the second point of the segment to test the intersection against
  11084. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11085. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11086. */
  11087. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11088. /**
  11089. * Update the ray from viewport position
  11090. * @param x position
  11091. * @param y y position
  11092. * @param viewportWidth viewport width
  11093. * @param viewportHeight viewport height
  11094. * @param world world matrix
  11095. * @param view view matrix
  11096. * @param projection projection matrix
  11097. * @returns this ray updated
  11098. */
  11099. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11100. /**
  11101. * Creates a ray with origin and direction of 0,0,0
  11102. * @returns the new ray
  11103. */
  11104. static Zero(): Ray;
  11105. /**
  11106. * Creates a new ray from screen space and viewport
  11107. * @param x position
  11108. * @param y y position
  11109. * @param viewportWidth viewport width
  11110. * @param viewportHeight viewport height
  11111. * @param world world matrix
  11112. * @param view view matrix
  11113. * @param projection projection matrix
  11114. * @returns new ray
  11115. */
  11116. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11117. /**
  11118. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  11119. * transformed to the given world matrix.
  11120. * @param origin The origin point
  11121. * @param end The end point
  11122. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11123. * @returns the new ray
  11124. */
  11125. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11126. /**
  11127. * Transforms a ray by a matrix
  11128. * @param ray ray to transform
  11129. * @param matrix matrix to apply
  11130. * @returns the resulting new ray
  11131. */
  11132. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11133. /**
  11134. * Transforms a ray by a matrix
  11135. * @param ray ray to transform
  11136. * @param matrix matrix to apply
  11137. * @param result ray to store result in
  11138. */
  11139. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11140. /**
  11141. * Unproject a ray from screen space to object space
  11142. * @param sourceX defines the screen space x coordinate to use
  11143. * @param sourceY defines the screen space y coordinate to use
  11144. * @param viewportWidth defines the current width of the viewport
  11145. * @param viewportHeight defines the current height of the viewport
  11146. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11147. * @param view defines the view matrix to use
  11148. * @param projection defines the projection matrix to use
  11149. */
  11150. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11151. }
  11152. /**
  11153. * Type used to define predicate used to select faces when a mesh intersection is detected
  11154. */
  11155. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11156. module "babylonjs/scene" {
  11157. interface Scene {
  11158. /** @hidden */
  11159. _tempPickingRay: Nullable<Ray>;
  11160. /** @hidden */
  11161. _cachedRayForTransform: Ray;
  11162. /** @hidden */
  11163. _pickWithRayInverseMatrix: Matrix;
  11164. /** @hidden */
  11165. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11166. /** @hidden */
  11167. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11168. }
  11169. }
  11170. }
  11171. declare module "babylonjs/sceneComponent" {
  11172. import { Scene } from "babylonjs/scene";
  11173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11174. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11175. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11176. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11177. import { Nullable } from "babylonjs/types";
  11178. import { Camera } from "babylonjs/Cameras/camera";
  11179. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11180. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11181. import { AbstractScene } from "babylonjs/abstractScene";
  11182. /**
  11183. * Groups all the scene component constants in one place to ease maintenance.
  11184. * @hidden
  11185. */
  11186. export class SceneComponentConstants {
  11187. static readonly NAME_EFFECTLAYER: string;
  11188. static readonly NAME_LAYER: string;
  11189. static readonly NAME_LENSFLARESYSTEM: string;
  11190. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11191. static readonly NAME_PARTICLESYSTEM: string;
  11192. static readonly NAME_GAMEPAD: string;
  11193. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11194. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11195. static readonly NAME_DEPTHRENDERER: string;
  11196. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11197. static readonly NAME_SPRITE: string;
  11198. static readonly NAME_OUTLINERENDERER: string;
  11199. static readonly NAME_PROCEDURALTEXTURE: string;
  11200. static readonly NAME_SHADOWGENERATOR: string;
  11201. static readonly NAME_OCTREE: string;
  11202. static readonly NAME_PHYSICSENGINE: string;
  11203. static readonly NAME_AUDIO: string;
  11204. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11205. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11206. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11207. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11208. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11209. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11210. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11211. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11212. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11213. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11214. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11215. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11216. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11217. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11218. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11219. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11220. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11221. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11222. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11223. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11224. static readonly STEP_AFTERRENDER_AUDIO: number;
  11225. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11226. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11227. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11228. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11229. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11230. static readonly STEP_POINTERMOVE_SPRITE: number;
  11231. static readonly STEP_POINTERDOWN_SPRITE: number;
  11232. static readonly STEP_POINTERUP_SPRITE: number;
  11233. }
  11234. /**
  11235. * This represents a scene component.
  11236. *
  11237. * This is used to decouple the dependency the scene is having on the different workloads like
  11238. * layers, post processes...
  11239. */
  11240. export interface ISceneComponent {
  11241. /**
  11242. * The name of the component. Each component must have a unique name.
  11243. */
  11244. name: string;
  11245. /**
  11246. * The scene the component belongs to.
  11247. */
  11248. scene: Scene;
  11249. /**
  11250. * Register the component to one instance of a scene.
  11251. */
  11252. register(): void;
  11253. /**
  11254. * Rebuilds the elements related to this component in case of
  11255. * context lost for instance.
  11256. */
  11257. rebuild(): void;
  11258. /**
  11259. * Disposes the component and the associated ressources.
  11260. */
  11261. dispose(): void;
  11262. }
  11263. /**
  11264. * This represents a SERIALIZABLE scene component.
  11265. *
  11266. * This extends Scene Component to add Serialization methods on top.
  11267. */
  11268. export interface ISceneSerializableComponent extends ISceneComponent {
  11269. /**
  11270. * Adds all the elements from the container to the scene
  11271. * @param container the container holding the elements
  11272. */
  11273. addFromContainer(container: AbstractScene): void;
  11274. /**
  11275. * Removes all the elements in the container from the scene
  11276. * @param container contains the elements to remove
  11277. * @param dispose if the removed element should be disposed (default: false)
  11278. */
  11279. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11280. /**
  11281. * Serializes the component data to the specified json object
  11282. * @param serializationObject The object to serialize to
  11283. */
  11284. serialize(serializationObject: any): void;
  11285. }
  11286. /**
  11287. * Strong typing of a Mesh related stage step action
  11288. */
  11289. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11290. /**
  11291. * Strong typing of a Evaluate Sub Mesh related stage step action
  11292. */
  11293. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11294. /**
  11295. * Strong typing of a Active Mesh related stage step action
  11296. */
  11297. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11298. /**
  11299. * Strong typing of a Camera related stage step action
  11300. */
  11301. export type CameraStageAction = (camera: Camera) => void;
  11302. /**
  11303. * Strong typing of a Camera Frame buffer related stage step action
  11304. */
  11305. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11306. /**
  11307. * Strong typing of a Render Target related stage step action
  11308. */
  11309. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11310. /**
  11311. * Strong typing of a RenderingGroup related stage step action
  11312. */
  11313. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11314. /**
  11315. * Strong typing of a Mesh Render related stage step action
  11316. */
  11317. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11318. /**
  11319. * Strong typing of a simple stage step action
  11320. */
  11321. export type SimpleStageAction = () => void;
  11322. /**
  11323. * Strong typing of a render target action.
  11324. */
  11325. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11326. /**
  11327. * Strong typing of a pointer move action.
  11328. */
  11329. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11330. /**
  11331. * Strong typing of a pointer up/down action.
  11332. */
  11333. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11334. /**
  11335. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11336. * @hidden
  11337. */
  11338. export class Stage<T extends Function> extends Array<{
  11339. index: number;
  11340. component: ISceneComponent;
  11341. action: T;
  11342. }> {
  11343. /**
  11344. * Hide ctor from the rest of the world.
  11345. * @param items The items to add.
  11346. */
  11347. private constructor();
  11348. /**
  11349. * Creates a new Stage.
  11350. * @returns A new instance of a Stage
  11351. */
  11352. static Create<T extends Function>(): Stage<T>;
  11353. /**
  11354. * Registers a step in an ordered way in the targeted stage.
  11355. * @param index Defines the position to register the step in
  11356. * @param component Defines the component attached to the step
  11357. * @param action Defines the action to launch during the step
  11358. */
  11359. registerStep(index: number, component: ISceneComponent, action: T): void;
  11360. /**
  11361. * Clears all the steps from the stage.
  11362. */
  11363. clear(): void;
  11364. }
  11365. }
  11366. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11367. import { Nullable } from "babylonjs/types";
  11368. import { Observable } from "babylonjs/Misc/observable";
  11369. import { Scene } from "babylonjs/scene";
  11370. import { Sprite } from "babylonjs/Sprites/sprite";
  11371. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11372. import { Ray } from "babylonjs/Culling/ray";
  11373. import { Camera } from "babylonjs/Cameras/camera";
  11374. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11375. import { ISceneComponent } from "babylonjs/sceneComponent";
  11376. module "babylonjs/scene" {
  11377. interface Scene {
  11378. /** @hidden */
  11379. _pointerOverSprite: Nullable<Sprite>;
  11380. /** @hidden */
  11381. _pickedDownSprite: Nullable<Sprite>;
  11382. /** @hidden */
  11383. _tempSpritePickingRay: Nullable<Ray>;
  11384. /**
  11385. * All of the sprite managers added to this scene
  11386. * @see http://doc.babylonjs.com/babylon101/sprites
  11387. */
  11388. spriteManagers: Array<ISpriteManager>;
  11389. /**
  11390. * An event triggered when sprites rendering is about to start
  11391. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11392. */
  11393. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11394. /**
  11395. * An event triggered when sprites rendering is done
  11396. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11397. */
  11398. onAfterSpritesRenderingObservable: Observable<Scene>;
  11399. /** @hidden */
  11400. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11401. /** Launch a ray to try to pick a sprite in the scene
  11402. * @param x position on screen
  11403. * @param y position on screen
  11404. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11405. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11406. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11407. * @returns a PickingInfo
  11408. */
  11409. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11410. /** Use the given ray to pick a sprite in the scene
  11411. * @param ray The ray (in world space) to use to pick meshes
  11412. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11413. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11414. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11415. * @returns a PickingInfo
  11416. */
  11417. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11418. /** @hidden */
  11419. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11420. /** Launch a ray to try to pick sprites in the scene
  11421. * @param x position on screen
  11422. * @param y position on screen
  11423. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11424. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11425. * @returns a PickingInfo array
  11426. */
  11427. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11428. /** Use the given ray to pick sprites in the scene
  11429. * @param ray The ray (in world space) to use to pick meshes
  11430. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11431. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11432. * @returns a PickingInfo array
  11433. */
  11434. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11435. /**
  11436. * Force the sprite under the pointer
  11437. * @param sprite defines the sprite to use
  11438. */
  11439. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11440. /**
  11441. * Gets the sprite under the pointer
  11442. * @returns a Sprite or null if no sprite is under the pointer
  11443. */
  11444. getPointerOverSprite(): Nullable<Sprite>;
  11445. }
  11446. }
  11447. /**
  11448. * Defines the sprite scene component responsible to manage sprites
  11449. * in a given scene.
  11450. */
  11451. export class SpriteSceneComponent implements ISceneComponent {
  11452. /**
  11453. * The component name helpfull to identify the component in the list of scene components.
  11454. */
  11455. readonly name: string;
  11456. /**
  11457. * The scene the component belongs to.
  11458. */
  11459. scene: Scene;
  11460. /** @hidden */
  11461. private _spritePredicate;
  11462. /**
  11463. * Creates a new instance of the component for the given scene
  11464. * @param scene Defines the scene to register the component in
  11465. */
  11466. constructor(scene: Scene);
  11467. /**
  11468. * Registers the component in a given scene
  11469. */
  11470. register(): void;
  11471. /**
  11472. * Rebuilds the elements related to this component in case of
  11473. * context lost for instance.
  11474. */
  11475. rebuild(): void;
  11476. /**
  11477. * Disposes the component and the associated ressources.
  11478. */
  11479. dispose(): void;
  11480. private _pickSpriteButKeepRay;
  11481. private _pointerMove;
  11482. private _pointerDown;
  11483. private _pointerUp;
  11484. }
  11485. }
  11486. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11487. /** @hidden */
  11488. export var fogFragmentDeclaration: {
  11489. name: string;
  11490. shader: string;
  11491. };
  11492. }
  11493. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11494. /** @hidden */
  11495. export var fogFragment: {
  11496. name: string;
  11497. shader: string;
  11498. };
  11499. }
  11500. declare module "babylonjs/Shaders/sprites.fragment" {
  11501. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11502. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11503. /** @hidden */
  11504. export var spritesPixelShader: {
  11505. name: string;
  11506. shader: string;
  11507. };
  11508. }
  11509. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11510. /** @hidden */
  11511. export var fogVertexDeclaration: {
  11512. name: string;
  11513. shader: string;
  11514. };
  11515. }
  11516. declare module "babylonjs/Shaders/sprites.vertex" {
  11517. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11518. /** @hidden */
  11519. export var spritesVertexShader: {
  11520. name: string;
  11521. shader: string;
  11522. };
  11523. }
  11524. declare module "babylonjs/Sprites/spriteManager" {
  11525. import { IDisposable, Scene } from "babylonjs/scene";
  11526. import { Nullable } from "babylonjs/types";
  11527. import { Observable } from "babylonjs/Misc/observable";
  11528. import { Sprite } from "babylonjs/Sprites/sprite";
  11529. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11530. import { Camera } from "babylonjs/Cameras/camera";
  11531. import { Texture } from "babylonjs/Materials/Textures/texture";
  11532. import "babylonjs/Shaders/sprites.fragment";
  11533. import "babylonjs/Shaders/sprites.vertex";
  11534. import { Ray } from "babylonjs/Culling/ray";
  11535. /**
  11536. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11537. */
  11538. export interface ISpriteManager extends IDisposable {
  11539. /**
  11540. * Restricts the camera to viewing objects with the same layerMask.
  11541. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11542. */
  11543. layerMask: number;
  11544. /**
  11545. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11546. */
  11547. isPickable: boolean;
  11548. /**
  11549. * Specifies the rendering group id for this mesh (0 by default)
  11550. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11551. */
  11552. renderingGroupId: number;
  11553. /**
  11554. * Defines the list of sprites managed by the manager.
  11555. */
  11556. sprites: Array<Sprite>;
  11557. /**
  11558. * Tests the intersection of a sprite with a specific ray.
  11559. * @param ray The ray we are sending to test the collision
  11560. * @param camera The camera space we are sending rays in
  11561. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11562. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11563. * @returns picking info or null.
  11564. */
  11565. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11566. /**
  11567. * Intersects the sprites with a ray
  11568. * @param ray defines the ray to intersect with
  11569. * @param camera defines the current active camera
  11570. * @param predicate defines a predicate used to select candidate sprites
  11571. * @returns null if no hit or a PickingInfo array
  11572. */
  11573. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11574. /**
  11575. * Renders the list of sprites on screen.
  11576. */
  11577. render(): void;
  11578. }
  11579. /**
  11580. * Class used to manage multiple sprites on the same spritesheet
  11581. * @see http://doc.babylonjs.com/babylon101/sprites
  11582. */
  11583. export class SpriteManager implements ISpriteManager {
  11584. /** defines the manager's name */
  11585. name: string;
  11586. /** Gets the list of sprites */
  11587. sprites: Sprite[];
  11588. /** Gets or sets the rendering group id (0 by default) */
  11589. renderingGroupId: number;
  11590. /** Gets or sets camera layer mask */
  11591. layerMask: number;
  11592. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11593. fogEnabled: boolean;
  11594. /** Gets or sets a boolean indicating if the sprites are pickable */
  11595. isPickable: boolean;
  11596. /** Defines the default width of a cell in the spritesheet */
  11597. cellWidth: number;
  11598. /** Defines the default height of a cell in the spritesheet */
  11599. cellHeight: number;
  11600. /** Associative array from JSON sprite data file */
  11601. private _cellData;
  11602. /** Array of sprite names from JSON sprite data file */
  11603. private _spriteMap;
  11604. /** True when packed cell data from JSON file is ready*/
  11605. private _packedAndReady;
  11606. /**
  11607. * An event triggered when the manager is disposed.
  11608. */
  11609. onDisposeObservable: Observable<SpriteManager>;
  11610. private _onDisposeObserver;
  11611. /**
  11612. * Callback called when the manager is disposed
  11613. */
  11614. onDispose: () => void;
  11615. private _capacity;
  11616. private _fromPacked;
  11617. private _spriteTexture;
  11618. private _epsilon;
  11619. private _scene;
  11620. private _vertexData;
  11621. private _buffer;
  11622. private _vertexBuffers;
  11623. private _indexBuffer;
  11624. private _effectBase;
  11625. private _effectFog;
  11626. /**
  11627. * Gets or sets the spritesheet texture
  11628. */
  11629. texture: Texture;
  11630. /**
  11631. * Creates a new sprite manager
  11632. * @param name defines the manager's name
  11633. * @param imgUrl defines the sprite sheet url
  11634. * @param capacity defines the maximum allowed number of sprites
  11635. * @param cellSize defines the size of a sprite cell
  11636. * @param scene defines the hosting scene
  11637. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11638. * @param samplingMode defines the smapling mode to use with spritesheet
  11639. * @param fromPacked set to false; do not alter
  11640. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11641. */
  11642. constructor(
  11643. /** defines the manager's name */
  11644. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11645. private _makePacked;
  11646. private _appendSpriteVertex;
  11647. /**
  11648. * Intersects the sprites with a ray
  11649. * @param ray defines the ray to intersect with
  11650. * @param camera defines the current active camera
  11651. * @param predicate defines a predicate used to select candidate sprites
  11652. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11653. * @returns null if no hit or a PickingInfo
  11654. */
  11655. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11656. /**
  11657. * Intersects the sprites with a ray
  11658. * @param ray defines the ray to intersect with
  11659. * @param camera defines the current active camera
  11660. * @param predicate defines a predicate used to select candidate sprites
  11661. * @returns null if no hit or a PickingInfo array
  11662. */
  11663. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11664. /**
  11665. * Render all child sprites
  11666. */
  11667. render(): void;
  11668. /**
  11669. * Release associated resources
  11670. */
  11671. dispose(): void;
  11672. }
  11673. }
  11674. declare module "babylonjs/Sprites/sprite" {
  11675. import { Vector3 } from "babylonjs/Maths/math.vector";
  11676. import { Nullable } from "babylonjs/types";
  11677. import { ActionManager } from "babylonjs/Actions/actionManager";
  11678. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11679. import { Color4 } from "babylonjs/Maths/math.color";
  11680. /**
  11681. * Class used to represent a sprite
  11682. * @see http://doc.babylonjs.com/babylon101/sprites
  11683. */
  11684. export class Sprite {
  11685. /** defines the name */
  11686. name: string;
  11687. /** Gets or sets the current world position */
  11688. position: Vector3;
  11689. /** Gets or sets the main color */
  11690. color: Color4;
  11691. /** Gets or sets the width */
  11692. width: number;
  11693. /** Gets or sets the height */
  11694. height: number;
  11695. /** Gets or sets rotation angle */
  11696. angle: number;
  11697. /** Gets or sets the cell index in the sprite sheet */
  11698. cellIndex: number;
  11699. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11700. cellRef: string;
  11701. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11702. invertU: number;
  11703. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11704. invertV: number;
  11705. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11706. disposeWhenFinishedAnimating: boolean;
  11707. /** Gets the list of attached animations */
  11708. animations: Animation[];
  11709. /** Gets or sets a boolean indicating if the sprite can be picked */
  11710. isPickable: boolean;
  11711. /**
  11712. * Gets or sets the associated action manager
  11713. */
  11714. actionManager: Nullable<ActionManager>;
  11715. private _animationStarted;
  11716. private _loopAnimation;
  11717. private _fromIndex;
  11718. private _toIndex;
  11719. private _delay;
  11720. private _direction;
  11721. private _manager;
  11722. private _time;
  11723. private _onAnimationEnd;
  11724. /**
  11725. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11726. */
  11727. isVisible: boolean;
  11728. /**
  11729. * Gets or sets the sprite size
  11730. */
  11731. size: number;
  11732. /**
  11733. * Creates a new Sprite
  11734. * @param name defines the name
  11735. * @param manager defines the manager
  11736. */
  11737. constructor(
  11738. /** defines the name */
  11739. name: string, manager: ISpriteManager);
  11740. /**
  11741. * Starts an animation
  11742. * @param from defines the initial key
  11743. * @param to defines the end key
  11744. * @param loop defines if the animation must loop
  11745. * @param delay defines the start delay (in ms)
  11746. * @param onAnimationEnd defines a callback to call when animation ends
  11747. */
  11748. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11749. /** Stops current animation (if any) */
  11750. stopAnimation(): void;
  11751. /** @hidden */
  11752. _animate(deltaTime: number): void;
  11753. /** Release associated resources */
  11754. dispose(): void;
  11755. }
  11756. }
  11757. declare module "babylonjs/Collisions/pickingInfo" {
  11758. import { Nullable } from "babylonjs/types";
  11759. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11760. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11761. import { Sprite } from "babylonjs/Sprites/sprite";
  11762. import { Ray } from "babylonjs/Culling/ray";
  11763. /**
  11764. * Information about the result of picking within a scene
  11765. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11766. */
  11767. export class PickingInfo {
  11768. /** @hidden */
  11769. _pickingUnavailable: boolean;
  11770. /**
  11771. * If the pick collided with an object
  11772. */
  11773. hit: boolean;
  11774. /**
  11775. * Distance away where the pick collided
  11776. */
  11777. distance: number;
  11778. /**
  11779. * The location of pick collision
  11780. */
  11781. pickedPoint: Nullable<Vector3>;
  11782. /**
  11783. * The mesh corresponding the the pick collision
  11784. */
  11785. pickedMesh: Nullable<AbstractMesh>;
  11786. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11787. bu: number;
  11788. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11789. bv: number;
  11790. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11791. faceId: number;
  11792. /** Id of the the submesh that was picked */
  11793. subMeshId: number;
  11794. /** If a sprite was picked, this will be the sprite the pick collided with */
  11795. pickedSprite: Nullable<Sprite>;
  11796. /**
  11797. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11798. */
  11799. originMesh: Nullable<AbstractMesh>;
  11800. /**
  11801. * The ray that was used to perform the picking.
  11802. */
  11803. ray: Nullable<Ray>;
  11804. /**
  11805. * Gets the normal correspodning to the face the pick collided with
  11806. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11807. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11808. * @returns The normal correspodning to the face the pick collided with
  11809. */
  11810. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11811. /**
  11812. * Gets the texture coordinates of where the pick occured
  11813. * @returns the vector containing the coordnates of the texture
  11814. */
  11815. getTextureCoordinates(): Nullable<Vector2>;
  11816. }
  11817. }
  11818. declare module "babylonjs/Events/pointerEvents" {
  11819. import { Nullable } from "babylonjs/types";
  11820. import { Vector2 } from "babylonjs/Maths/math.vector";
  11821. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11822. import { Ray } from "babylonjs/Culling/ray";
  11823. /**
  11824. * Gather the list of pointer event types as constants.
  11825. */
  11826. export class PointerEventTypes {
  11827. /**
  11828. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  11829. */
  11830. static readonly POINTERDOWN: number;
  11831. /**
  11832. * The pointerup event is fired when a pointer is no longer active.
  11833. */
  11834. static readonly POINTERUP: number;
  11835. /**
  11836. * The pointermove event is fired when a pointer changes coordinates.
  11837. */
  11838. static readonly POINTERMOVE: number;
  11839. /**
  11840. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11841. */
  11842. static readonly POINTERWHEEL: number;
  11843. /**
  11844. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11845. */
  11846. static readonly POINTERPICK: number;
  11847. /**
  11848. * The pointertap event is fired when a the object has been touched and released without drag.
  11849. */
  11850. static readonly POINTERTAP: number;
  11851. /**
  11852. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11853. */
  11854. static readonly POINTERDOUBLETAP: number;
  11855. }
  11856. /**
  11857. * Base class of pointer info types.
  11858. */
  11859. export class PointerInfoBase {
  11860. /**
  11861. * Defines the type of event (PointerEventTypes)
  11862. */
  11863. type: number;
  11864. /**
  11865. * Defines the related dom event
  11866. */
  11867. event: PointerEvent | MouseWheelEvent;
  11868. /**
  11869. * Instantiates the base class of pointers info.
  11870. * @param type Defines the type of event (PointerEventTypes)
  11871. * @param event Defines the related dom event
  11872. */
  11873. constructor(
  11874. /**
  11875. * Defines the type of event (PointerEventTypes)
  11876. */
  11877. type: number,
  11878. /**
  11879. * Defines the related dom event
  11880. */
  11881. event: PointerEvent | MouseWheelEvent);
  11882. }
  11883. /**
  11884. * This class is used to store pointer related info for the onPrePointerObservable event.
  11885. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11886. */
  11887. export class PointerInfoPre extends PointerInfoBase {
  11888. /**
  11889. * Ray from a pointer if availible (eg. 6dof controller)
  11890. */
  11891. ray: Nullable<Ray>;
  11892. /**
  11893. * Defines the local position of the pointer on the canvas.
  11894. */
  11895. localPosition: Vector2;
  11896. /**
  11897. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11898. */
  11899. skipOnPointerObservable: boolean;
  11900. /**
  11901. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11902. * @param type Defines the type of event (PointerEventTypes)
  11903. * @param event Defines the related dom event
  11904. * @param localX Defines the local x coordinates of the pointer when the event occured
  11905. * @param localY Defines the local y coordinates of the pointer when the event occured
  11906. */
  11907. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11908. }
  11909. /**
  11910. * This type contains all the data related to a pointer event in Babylon.js.
  11911. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  11912. */
  11913. export class PointerInfo extends PointerInfoBase {
  11914. /**
  11915. * Defines the picking info associated to the info (if any)\
  11916. */
  11917. pickInfo: Nullable<PickingInfo>;
  11918. /**
  11919. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11920. * @param type Defines the type of event (PointerEventTypes)
  11921. * @param event Defines the related dom event
  11922. * @param pickInfo Defines the picking info associated to the info (if any)\
  11923. */
  11924. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11925. /**
  11926. * Defines the picking info associated to the info (if any)\
  11927. */
  11928. pickInfo: Nullable<PickingInfo>);
  11929. }
  11930. /**
  11931. * Data relating to a touch event on the screen.
  11932. */
  11933. export interface PointerTouch {
  11934. /**
  11935. * X coordinate of touch.
  11936. */
  11937. x: number;
  11938. /**
  11939. * Y coordinate of touch.
  11940. */
  11941. y: number;
  11942. /**
  11943. * Id of touch. Unique for each finger.
  11944. */
  11945. pointerId: number;
  11946. /**
  11947. * Event type passed from DOM.
  11948. */
  11949. type: any;
  11950. }
  11951. }
  11952. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11953. import { Observable } from "babylonjs/Misc/observable";
  11954. import { Nullable } from "babylonjs/types";
  11955. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11956. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11957. /**
  11958. * Manage the mouse inputs to control the movement of a free camera.
  11959. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11960. */
  11961. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11962. /**
  11963. * Define if touch is enabled in the mouse input
  11964. */
  11965. touchEnabled: boolean;
  11966. /**
  11967. * Defines the camera the input is attached to.
  11968. */
  11969. camera: FreeCamera;
  11970. /**
  11971. * Defines the buttons associated with the input to handle camera move.
  11972. */
  11973. buttons: number[];
  11974. /**
  11975. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11976. */
  11977. angularSensibility: number;
  11978. private _pointerInput;
  11979. private _onMouseMove;
  11980. private _observer;
  11981. private previousPosition;
  11982. /**
  11983. * Observable for when a pointer move event occurs containing the move offset
  11984. */
  11985. onPointerMovedObservable: Observable<{
  11986. offsetX: number;
  11987. offsetY: number;
  11988. }>;
  11989. /**
  11990. * @hidden
  11991. * If the camera should be rotated automatically based on pointer movement
  11992. */
  11993. _allowCameraRotation: boolean;
  11994. /**
  11995. * Manage the mouse inputs to control the movement of a free camera.
  11996. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11997. * @param touchEnabled Defines if touch is enabled or not
  11998. */
  11999. constructor(
  12000. /**
  12001. * Define if touch is enabled in the mouse input
  12002. */
  12003. touchEnabled?: boolean);
  12004. /**
  12005. * Attach the input controls to a specific dom element to get the input from.
  12006. * @param element Defines the element the controls should be listened from
  12007. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12008. */
  12009. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12010. /**
  12011. * Called on JS contextmenu event.
  12012. * Override this method to provide functionality.
  12013. */
  12014. protected onContextMenu(evt: PointerEvent): void;
  12015. /**
  12016. * Detach the current controls from the specified dom element.
  12017. * @param element Defines the element to stop listening the inputs from
  12018. */
  12019. detachControl(element: Nullable<HTMLElement>): void;
  12020. /**
  12021. * Gets the class name of the current intput.
  12022. * @returns the class name
  12023. */
  12024. getClassName(): string;
  12025. /**
  12026. * Get the friendly name associated with the input class.
  12027. * @returns the input friendly name
  12028. */
  12029. getSimpleName(): string;
  12030. }
  12031. }
  12032. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12033. import { Nullable } from "babylonjs/types";
  12034. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12035. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12036. /**
  12037. * Manage the touch inputs to control the movement of a free camera.
  12038. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12039. */
  12040. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12041. /**
  12042. * Defines the camera the input is attached to.
  12043. */
  12044. camera: FreeCamera;
  12045. /**
  12046. * Defines the touch sensibility for rotation.
  12047. * The higher the faster.
  12048. */
  12049. touchAngularSensibility: number;
  12050. /**
  12051. * Defines the touch sensibility for move.
  12052. * The higher the faster.
  12053. */
  12054. touchMoveSensibility: number;
  12055. private _offsetX;
  12056. private _offsetY;
  12057. private _pointerPressed;
  12058. private _pointerInput;
  12059. private _observer;
  12060. private _onLostFocus;
  12061. /**
  12062. * Attach the input controls to a specific dom element to get the input from.
  12063. * @param element Defines the element the controls should be listened from
  12064. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12065. */
  12066. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12067. /**
  12068. * Detach the current controls from the specified dom element.
  12069. * @param element Defines the element to stop listening the inputs from
  12070. */
  12071. detachControl(element: Nullable<HTMLElement>): void;
  12072. /**
  12073. * Update the current camera state depending on the inputs that have been used this frame.
  12074. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12075. */
  12076. checkInputs(): void;
  12077. /**
  12078. * Gets the class name of the current intput.
  12079. * @returns the class name
  12080. */
  12081. getClassName(): string;
  12082. /**
  12083. * Get the friendly name associated with the input class.
  12084. * @returns the input friendly name
  12085. */
  12086. getSimpleName(): string;
  12087. }
  12088. }
  12089. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12090. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12091. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12092. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12093. import { Nullable } from "babylonjs/types";
  12094. /**
  12095. * Default Inputs manager for the FreeCamera.
  12096. * It groups all the default supported inputs for ease of use.
  12097. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12098. */
  12099. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12100. /**
  12101. * @hidden
  12102. */
  12103. _mouseInput: Nullable<FreeCameraMouseInput>;
  12104. /**
  12105. * Instantiates a new FreeCameraInputsManager.
  12106. * @param camera Defines the camera the inputs belong to
  12107. */
  12108. constructor(camera: FreeCamera);
  12109. /**
  12110. * Add keyboard input support to the input manager.
  12111. * @returns the current input manager
  12112. */
  12113. addKeyboard(): FreeCameraInputsManager;
  12114. /**
  12115. * Add mouse input support to the input manager.
  12116. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12117. * @returns the current input manager
  12118. */
  12119. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12120. /**
  12121. * Removes the mouse input support from the manager
  12122. * @returns the current input manager
  12123. */
  12124. removeMouse(): FreeCameraInputsManager;
  12125. /**
  12126. * Add touch input support to the input manager.
  12127. * @returns the current input manager
  12128. */
  12129. addTouch(): FreeCameraInputsManager;
  12130. /**
  12131. * Remove all attached input methods from a camera
  12132. */
  12133. clear(): void;
  12134. }
  12135. }
  12136. declare module "babylonjs/Cameras/freeCamera" {
  12137. import { Vector3 } from "babylonjs/Maths/math.vector";
  12138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12139. import { Scene } from "babylonjs/scene";
  12140. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12141. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12142. /**
  12143. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12144. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12145. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12146. */
  12147. export class FreeCamera extends TargetCamera {
  12148. /**
  12149. * Define the collision ellipsoid of the camera.
  12150. * This is helpful to simulate a camera body like the player body around the camera
  12151. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12152. */
  12153. ellipsoid: Vector3;
  12154. /**
  12155. * Define an offset for the position of the ellipsoid around the camera.
  12156. * This can be helpful to determine the center of the body near the gravity center of the body
  12157. * instead of its head.
  12158. */
  12159. ellipsoidOffset: Vector3;
  12160. /**
  12161. * Enable or disable collisions of the camera with the rest of the scene objects.
  12162. */
  12163. checkCollisions: boolean;
  12164. /**
  12165. * Enable or disable gravity on the camera.
  12166. */
  12167. applyGravity: boolean;
  12168. /**
  12169. * Define the input manager associated to the camera.
  12170. */
  12171. inputs: FreeCameraInputsManager;
  12172. /**
  12173. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12174. * Higher values reduce sensitivity.
  12175. */
  12176. /**
  12177. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12178. * Higher values reduce sensitivity.
  12179. */
  12180. angularSensibility: number;
  12181. /**
  12182. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12183. */
  12184. keysUp: number[];
  12185. /**
  12186. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12187. */
  12188. keysDown: number[];
  12189. /**
  12190. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12191. */
  12192. keysLeft: number[];
  12193. /**
  12194. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12195. */
  12196. keysRight: number[];
  12197. /**
  12198. * Event raised when the camera collide with a mesh in the scene.
  12199. */
  12200. onCollide: (collidedMesh: AbstractMesh) => void;
  12201. private _collider;
  12202. private _needMoveForGravity;
  12203. private _oldPosition;
  12204. private _diffPosition;
  12205. private _newPosition;
  12206. /** @hidden */
  12207. _localDirection: Vector3;
  12208. /** @hidden */
  12209. _transformedDirection: Vector3;
  12210. /**
  12211. * Instantiates a Free Camera.
  12212. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12213. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12214. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12215. * @param name Define the name of the camera in the scene
  12216. * @param position Define the start position of the camera in the scene
  12217. * @param scene Define the scene the camera belongs to
  12218. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12219. */
  12220. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12221. /**
  12222. * Attached controls to the current camera.
  12223. * @param element Defines the element the controls should be listened from
  12224. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12225. */
  12226. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12227. /**
  12228. * Detach the current controls from the camera.
  12229. * The camera will stop reacting to inputs.
  12230. * @param element Defines the element to stop listening the inputs from
  12231. */
  12232. detachControl(element: HTMLElement): void;
  12233. private _collisionMask;
  12234. /**
  12235. * Define a collision mask to limit the list of object the camera can collide with
  12236. */
  12237. collisionMask: number;
  12238. /** @hidden */
  12239. _collideWithWorld(displacement: Vector3): void;
  12240. private _onCollisionPositionChange;
  12241. /** @hidden */
  12242. _checkInputs(): void;
  12243. /** @hidden */
  12244. _decideIfNeedsToMove(): boolean;
  12245. /** @hidden */
  12246. _updatePosition(): void;
  12247. /**
  12248. * Destroy the camera and release the current resources hold by it.
  12249. */
  12250. dispose(): void;
  12251. /**
  12252. * Gets the current object class name.
  12253. * @return the class name
  12254. */
  12255. getClassName(): string;
  12256. }
  12257. }
  12258. declare module "babylonjs/Gamepads/gamepad" {
  12259. import { Observable } from "babylonjs/Misc/observable";
  12260. /**
  12261. * Represents a gamepad control stick position
  12262. */
  12263. export class StickValues {
  12264. /**
  12265. * The x component of the control stick
  12266. */
  12267. x: number;
  12268. /**
  12269. * The y component of the control stick
  12270. */
  12271. y: number;
  12272. /**
  12273. * Initializes the gamepad x and y control stick values
  12274. * @param x The x component of the gamepad control stick value
  12275. * @param y The y component of the gamepad control stick value
  12276. */
  12277. constructor(
  12278. /**
  12279. * The x component of the control stick
  12280. */
  12281. x: number,
  12282. /**
  12283. * The y component of the control stick
  12284. */
  12285. y: number);
  12286. }
  12287. /**
  12288. * An interface which manages callbacks for gamepad button changes
  12289. */
  12290. export interface GamepadButtonChanges {
  12291. /**
  12292. * Called when a gamepad has been changed
  12293. */
  12294. changed: boolean;
  12295. /**
  12296. * Called when a gamepad press event has been triggered
  12297. */
  12298. pressChanged: boolean;
  12299. /**
  12300. * Called when a touch event has been triggered
  12301. */
  12302. touchChanged: boolean;
  12303. /**
  12304. * Called when a value has changed
  12305. */
  12306. valueChanged: boolean;
  12307. }
  12308. /**
  12309. * Represents a gamepad
  12310. */
  12311. export class Gamepad {
  12312. /**
  12313. * The id of the gamepad
  12314. */
  12315. id: string;
  12316. /**
  12317. * The index of the gamepad
  12318. */
  12319. index: number;
  12320. /**
  12321. * The browser gamepad
  12322. */
  12323. browserGamepad: any;
  12324. /**
  12325. * Specifies what type of gamepad this represents
  12326. */
  12327. type: number;
  12328. private _leftStick;
  12329. private _rightStick;
  12330. /** @hidden */
  12331. _isConnected: boolean;
  12332. private _leftStickAxisX;
  12333. private _leftStickAxisY;
  12334. private _rightStickAxisX;
  12335. private _rightStickAxisY;
  12336. /**
  12337. * Triggered when the left control stick has been changed
  12338. */
  12339. private _onleftstickchanged;
  12340. /**
  12341. * Triggered when the right control stick has been changed
  12342. */
  12343. private _onrightstickchanged;
  12344. /**
  12345. * Represents a gamepad controller
  12346. */
  12347. static GAMEPAD: number;
  12348. /**
  12349. * Represents a generic controller
  12350. */
  12351. static GENERIC: number;
  12352. /**
  12353. * Represents an XBox controller
  12354. */
  12355. static XBOX: number;
  12356. /**
  12357. * Represents a pose-enabled controller
  12358. */
  12359. static POSE_ENABLED: number;
  12360. /**
  12361. * Represents an Dual Shock controller
  12362. */
  12363. static DUALSHOCK: number;
  12364. /**
  12365. * Specifies whether the left control stick should be Y-inverted
  12366. */
  12367. protected _invertLeftStickY: boolean;
  12368. /**
  12369. * Specifies if the gamepad has been connected
  12370. */
  12371. readonly isConnected: boolean;
  12372. /**
  12373. * Initializes the gamepad
  12374. * @param id The id of the gamepad
  12375. * @param index The index of the gamepad
  12376. * @param browserGamepad The browser gamepad
  12377. * @param leftStickX The x component of the left joystick
  12378. * @param leftStickY The y component of the left joystick
  12379. * @param rightStickX The x component of the right joystick
  12380. * @param rightStickY The y component of the right joystick
  12381. */
  12382. constructor(
  12383. /**
  12384. * The id of the gamepad
  12385. */
  12386. id: string,
  12387. /**
  12388. * The index of the gamepad
  12389. */
  12390. index: number,
  12391. /**
  12392. * The browser gamepad
  12393. */
  12394. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12395. /**
  12396. * Callback triggered when the left joystick has changed
  12397. * @param callback
  12398. */
  12399. onleftstickchanged(callback: (values: StickValues) => void): void;
  12400. /**
  12401. * Callback triggered when the right joystick has changed
  12402. * @param callback
  12403. */
  12404. onrightstickchanged(callback: (values: StickValues) => void): void;
  12405. /**
  12406. * Gets the left joystick
  12407. */
  12408. /**
  12409. * Sets the left joystick values
  12410. */
  12411. leftStick: StickValues;
  12412. /**
  12413. * Gets the right joystick
  12414. */
  12415. /**
  12416. * Sets the right joystick value
  12417. */
  12418. rightStick: StickValues;
  12419. /**
  12420. * Updates the gamepad joystick positions
  12421. */
  12422. update(): void;
  12423. /**
  12424. * Disposes the gamepad
  12425. */
  12426. dispose(): void;
  12427. }
  12428. /**
  12429. * Represents a generic gamepad
  12430. */
  12431. export class GenericPad extends Gamepad {
  12432. private _buttons;
  12433. private _onbuttondown;
  12434. private _onbuttonup;
  12435. /**
  12436. * Observable triggered when a button has been pressed
  12437. */
  12438. onButtonDownObservable: Observable<number>;
  12439. /**
  12440. * Observable triggered when a button has been released
  12441. */
  12442. onButtonUpObservable: Observable<number>;
  12443. /**
  12444. * Callback triggered when a button has been pressed
  12445. * @param callback Called when a button has been pressed
  12446. */
  12447. onbuttondown(callback: (buttonPressed: number) => void): void;
  12448. /**
  12449. * Callback triggered when a button has been released
  12450. * @param callback Called when a button has been released
  12451. */
  12452. onbuttonup(callback: (buttonReleased: number) => void): void;
  12453. /**
  12454. * Initializes the generic gamepad
  12455. * @param id The id of the generic gamepad
  12456. * @param index The index of the generic gamepad
  12457. * @param browserGamepad The browser gamepad
  12458. */
  12459. constructor(id: string, index: number, browserGamepad: any);
  12460. private _setButtonValue;
  12461. /**
  12462. * Updates the generic gamepad
  12463. */
  12464. update(): void;
  12465. /**
  12466. * Disposes the generic gamepad
  12467. */
  12468. dispose(): void;
  12469. }
  12470. }
  12471. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12472. import { Nullable } from "babylonjs/types";
  12473. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12474. import { Scene } from "babylonjs/scene";
  12475. module "babylonjs/Engines/engine" {
  12476. interface Engine {
  12477. /**
  12478. * Creates a raw texture
  12479. * @param data defines the data to store in the texture
  12480. * @param width defines the width of the texture
  12481. * @param height defines the height of the texture
  12482. * @param format defines the format of the data
  12483. * @param generateMipMaps defines if the engine should generate the mip levels
  12484. * @param invertY defines if data must be stored with Y axis inverted
  12485. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12486. * @param compression defines the compression used (null by default)
  12487. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12488. * @returns the raw texture inside an InternalTexture
  12489. */
  12490. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12491. /**
  12492. * Update a raw texture
  12493. * @param texture defines the texture to update
  12494. * @param data defines the data to store in the texture
  12495. * @param format defines the format of the data
  12496. * @param invertY defines if data must be stored with Y axis inverted
  12497. */
  12498. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12499. /**
  12500. * Update a raw texture
  12501. * @param texture defines the texture to update
  12502. * @param data defines the data to store in the texture
  12503. * @param format defines the format of the data
  12504. * @param invertY defines if data must be stored with Y axis inverted
  12505. * @param compression defines the compression used (null by default)
  12506. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12507. */
  12508. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12509. /**
  12510. * Creates a new raw cube texture
  12511. * @param data defines the array of data to use to create each face
  12512. * @param size defines the size of the textures
  12513. * @param format defines the format of the data
  12514. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12515. * @param generateMipMaps defines if the engine should generate the mip levels
  12516. * @param invertY defines if data must be stored with Y axis inverted
  12517. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12518. * @param compression defines the compression used (null by default)
  12519. * @returns the cube texture as an InternalTexture
  12520. */
  12521. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12522. /**
  12523. * Update a raw cube texture
  12524. * @param texture defines the texture to udpdate
  12525. * @param data defines the data to store
  12526. * @param format defines the data format
  12527. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12528. * @param invertY defines if data must be stored with Y axis inverted
  12529. */
  12530. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12531. /**
  12532. * Update a raw cube texture
  12533. * @param texture defines the texture to udpdate
  12534. * @param data defines the data to store
  12535. * @param format defines the data format
  12536. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12537. * @param invertY defines if data must be stored with Y axis inverted
  12538. * @param compression defines the compression used (null by default)
  12539. */
  12540. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12541. /**
  12542. * Update a raw cube texture
  12543. * @param texture defines the texture to udpdate
  12544. * @param data defines the data to store
  12545. * @param format defines the data format
  12546. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12547. * @param invertY defines if data must be stored with Y axis inverted
  12548. * @param compression defines the compression used (null by default)
  12549. * @param level defines which level of the texture to update
  12550. */
  12551. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12552. /**
  12553. * Creates a new raw cube texture from a specified url
  12554. * @param url defines the url where the data is located
  12555. * @param scene defines the current scene
  12556. * @param size defines the size of the textures
  12557. * @param format defines the format of the data
  12558. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12559. * @param noMipmap defines if the engine should avoid generating the mip levels
  12560. * @param callback defines a callback used to extract texture data from loaded data
  12561. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12562. * @param onLoad defines a callback called when texture is loaded
  12563. * @param onError defines a callback called if there is an error
  12564. * @returns the cube texture as an InternalTexture
  12565. */
  12566. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  12567. /**
  12568. * Creates a new raw cube texture from a specified url
  12569. * @param url defines the url where the data is located
  12570. * @param scene defines the current scene
  12571. * @param size defines the size of the textures
  12572. * @param format defines the format of the data
  12573. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12574. * @param noMipmap defines if the engine should avoid generating the mip levels
  12575. * @param callback defines a callback used to extract texture data from loaded data
  12576. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12577. * @param onLoad defines a callback called when texture is loaded
  12578. * @param onError defines a callback called if there is an error
  12579. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12580. * @param invertY defines if data must be stored with Y axis inverted
  12581. * @returns the cube texture as an InternalTexture
  12582. */
  12583. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  12584. /**
  12585. * Creates a new raw 3D texture
  12586. * @param data defines the data used to create the texture
  12587. * @param width defines the width of the texture
  12588. * @param height defines the height of the texture
  12589. * @param depth defines the depth of the texture
  12590. * @param format defines the format of the texture
  12591. * @param generateMipMaps defines if the engine must generate mip levels
  12592. * @param invertY defines if data must be stored with Y axis inverted
  12593. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12594. * @param compression defines the compressed used (can be null)
  12595. * @param textureType defines the compressed used (can be null)
  12596. * @returns a new raw 3D texture (stored in an InternalTexture)
  12597. */
  12598. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12599. /**
  12600. * Update a raw 3D texture
  12601. * @param texture defines the texture to update
  12602. * @param data defines the data to store
  12603. * @param format defines the data format
  12604. * @param invertY defines if data must be stored with Y axis inverted
  12605. */
  12606. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12607. /**
  12608. * Update a raw 3D texture
  12609. * @param texture defines the texture to update
  12610. * @param data defines the data to store
  12611. * @param format defines the data format
  12612. * @param invertY defines if data must be stored with Y axis inverted
  12613. * @param compression defines the used compression (can be null)
  12614. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12615. */
  12616. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12617. }
  12618. }
  12619. }
  12620. declare module "babylonjs/Materials/Textures/rawTexture" {
  12621. import { Scene } from "babylonjs/scene";
  12622. import { Texture } from "babylonjs/Materials/Textures/texture";
  12623. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12624. /**
  12625. * Raw texture can help creating a texture directly from an array of data.
  12626. * This can be super useful if you either get the data from an uncompressed source or
  12627. * if you wish to create your texture pixel by pixel.
  12628. */
  12629. export class RawTexture extends Texture {
  12630. /**
  12631. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12632. */
  12633. format: number;
  12634. private _engine;
  12635. /**
  12636. * Instantiates a new RawTexture.
  12637. * Raw texture can help creating a texture directly from an array of data.
  12638. * This can be super useful if you either get the data from an uncompressed source or
  12639. * if you wish to create your texture pixel by pixel.
  12640. * @param data define the array of data to use to create the texture
  12641. * @param width define the width of the texture
  12642. * @param height define the height of the texture
  12643. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12644. * @param scene define the scene the texture belongs to
  12645. * @param generateMipMaps define whether mip maps should be generated or not
  12646. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12647. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12648. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12649. */
  12650. constructor(data: ArrayBufferView, width: number, height: number,
  12651. /**
  12652. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12653. */
  12654. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12655. /**
  12656. * Updates the texture underlying data.
  12657. * @param data Define the new data of the texture
  12658. */
  12659. update(data: ArrayBufferView): void;
  12660. /**
  12661. * Creates a luminance texture from some data.
  12662. * @param data Define the texture data
  12663. * @param width Define the width of the texture
  12664. * @param height Define the height of the texture
  12665. * @param scene Define the scene the texture belongs to
  12666. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12667. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12668. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12669. * @returns the luminance texture
  12670. */
  12671. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12672. /**
  12673. * Creates a luminance alpha texture from some data.
  12674. * @param data Define the texture data
  12675. * @param width Define the width of the texture
  12676. * @param height Define the height of the texture
  12677. * @param scene Define the scene the texture belongs to
  12678. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12679. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12680. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12681. * @returns the luminance alpha texture
  12682. */
  12683. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12684. /**
  12685. * Creates an alpha texture from some data.
  12686. * @param data Define the texture data
  12687. * @param width Define the width of the texture
  12688. * @param height Define the height of the texture
  12689. * @param scene Define the scene the texture belongs to
  12690. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12691. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12692. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12693. * @returns the alpha texture
  12694. */
  12695. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12696. /**
  12697. * Creates a RGB texture from some data.
  12698. * @param data Define the texture data
  12699. * @param width Define the width of the texture
  12700. * @param height Define the height of the texture
  12701. * @param scene Define the scene the texture belongs to
  12702. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12703. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12704. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12705. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12706. * @returns the RGB alpha texture
  12707. */
  12708. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12709. /**
  12710. * Creates a RGBA texture from some data.
  12711. * @param data Define the texture data
  12712. * @param width Define the width of the texture
  12713. * @param height Define the height of the texture
  12714. * @param scene Define the scene the texture belongs to
  12715. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12716. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12717. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12718. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12719. * @returns the RGBA texture
  12720. */
  12721. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12722. /**
  12723. * Creates a R texture from some data.
  12724. * @param data Define the texture data
  12725. * @param width Define the width of the texture
  12726. * @param height Define the height of the texture
  12727. * @param scene Define the scene the texture belongs to
  12728. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12729. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12730. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12731. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12732. * @returns the R texture
  12733. */
  12734. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12735. }
  12736. }
  12737. declare module "babylonjs/Maths/math.size" {
  12738. /**
  12739. * Interface for the size containing width and height
  12740. */
  12741. export interface ISize {
  12742. /**
  12743. * Width
  12744. */
  12745. width: number;
  12746. /**
  12747. * Heighht
  12748. */
  12749. height: number;
  12750. }
  12751. /**
  12752. * Size containing widht and height
  12753. */
  12754. export class Size implements ISize {
  12755. /**
  12756. * Width
  12757. */
  12758. width: number;
  12759. /**
  12760. * Height
  12761. */
  12762. height: number;
  12763. /**
  12764. * Creates a Size object from the given width and height (floats).
  12765. * @param width width of the new size
  12766. * @param height height of the new size
  12767. */
  12768. constructor(width: number, height: number);
  12769. /**
  12770. * Returns a string with the Size width and height
  12771. * @returns a string with the Size width and height
  12772. */
  12773. toString(): string;
  12774. /**
  12775. * "Size"
  12776. * @returns the string "Size"
  12777. */
  12778. getClassName(): string;
  12779. /**
  12780. * Returns the Size hash code.
  12781. * @returns a hash code for a unique width and height
  12782. */
  12783. getHashCode(): number;
  12784. /**
  12785. * Updates the current size from the given one.
  12786. * @param src the given size
  12787. */
  12788. copyFrom(src: Size): void;
  12789. /**
  12790. * Updates in place the current Size from the given floats.
  12791. * @param width width of the new size
  12792. * @param height height of the new size
  12793. * @returns the updated Size.
  12794. */
  12795. copyFromFloats(width: number, height: number): Size;
  12796. /**
  12797. * Updates in place the current Size from the given floats.
  12798. * @param width width to set
  12799. * @param height height to set
  12800. * @returns the updated Size.
  12801. */
  12802. set(width: number, height: number): Size;
  12803. /**
  12804. * Multiplies the width and height by numbers
  12805. * @param w factor to multiple the width by
  12806. * @param h factor to multiple the height by
  12807. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12808. */
  12809. multiplyByFloats(w: number, h: number): Size;
  12810. /**
  12811. * Clones the size
  12812. * @returns a new Size copied from the given one.
  12813. */
  12814. clone(): Size;
  12815. /**
  12816. * True if the current Size and the given one width and height are strictly equal.
  12817. * @param other the other size to compare against
  12818. * @returns True if the current Size and the given one width and height are strictly equal.
  12819. */
  12820. equals(other: Size): boolean;
  12821. /**
  12822. * The surface of the Size : width * height (float).
  12823. */
  12824. readonly surface: number;
  12825. /**
  12826. * Create a new size of zero
  12827. * @returns a new Size set to (0.0, 0.0)
  12828. */
  12829. static Zero(): Size;
  12830. /**
  12831. * Sums the width and height of two sizes
  12832. * @param otherSize size to add to this size
  12833. * @returns a new Size set as the addition result of the current Size and the given one.
  12834. */
  12835. add(otherSize: Size): Size;
  12836. /**
  12837. * Subtracts the width and height of two
  12838. * @param otherSize size to subtract to this size
  12839. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12840. */
  12841. subtract(otherSize: Size): Size;
  12842. /**
  12843. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12844. * @param start starting size to lerp between
  12845. * @param end end size to lerp between
  12846. * @param amount amount to lerp between the start and end values
  12847. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12848. */
  12849. static Lerp(start: Size, end: Size, amount: number): Size;
  12850. }
  12851. }
  12852. declare module "babylonjs/Animations/runtimeAnimation" {
  12853. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12854. import { Animatable } from "babylonjs/Animations/animatable";
  12855. import { Scene } from "babylonjs/scene";
  12856. /**
  12857. * Defines a runtime animation
  12858. */
  12859. export class RuntimeAnimation {
  12860. private _events;
  12861. /**
  12862. * The current frame of the runtime animation
  12863. */
  12864. private _currentFrame;
  12865. /**
  12866. * The animation used by the runtime animation
  12867. */
  12868. private _animation;
  12869. /**
  12870. * The target of the runtime animation
  12871. */
  12872. private _target;
  12873. /**
  12874. * The initiating animatable
  12875. */
  12876. private _host;
  12877. /**
  12878. * The original value of the runtime animation
  12879. */
  12880. private _originalValue;
  12881. /**
  12882. * The original blend value of the runtime animation
  12883. */
  12884. private _originalBlendValue;
  12885. /**
  12886. * The offsets cache of the runtime animation
  12887. */
  12888. private _offsetsCache;
  12889. /**
  12890. * The high limits cache of the runtime animation
  12891. */
  12892. private _highLimitsCache;
  12893. /**
  12894. * Specifies if the runtime animation has been stopped
  12895. */
  12896. private _stopped;
  12897. /**
  12898. * The blending factor of the runtime animation
  12899. */
  12900. private _blendingFactor;
  12901. /**
  12902. * The BabylonJS scene
  12903. */
  12904. private _scene;
  12905. /**
  12906. * The current value of the runtime animation
  12907. */
  12908. private _currentValue;
  12909. /** @hidden */
  12910. _animationState: _IAnimationState;
  12911. /**
  12912. * The active target of the runtime animation
  12913. */
  12914. private _activeTargets;
  12915. private _currentActiveTarget;
  12916. private _directTarget;
  12917. /**
  12918. * The target path of the runtime animation
  12919. */
  12920. private _targetPath;
  12921. /**
  12922. * The weight of the runtime animation
  12923. */
  12924. private _weight;
  12925. /**
  12926. * The ratio offset of the runtime animation
  12927. */
  12928. private _ratioOffset;
  12929. /**
  12930. * The previous delay of the runtime animation
  12931. */
  12932. private _previousDelay;
  12933. /**
  12934. * The previous ratio of the runtime animation
  12935. */
  12936. private _previousRatio;
  12937. private _enableBlending;
  12938. private _keys;
  12939. private _minFrame;
  12940. private _maxFrame;
  12941. private _minValue;
  12942. private _maxValue;
  12943. private _targetIsArray;
  12944. /**
  12945. * Gets the current frame of the runtime animation
  12946. */
  12947. readonly currentFrame: number;
  12948. /**
  12949. * Gets the weight of the runtime animation
  12950. */
  12951. readonly weight: number;
  12952. /**
  12953. * Gets the current value of the runtime animation
  12954. */
  12955. readonly currentValue: any;
  12956. /**
  12957. * Gets the target path of the runtime animation
  12958. */
  12959. readonly targetPath: string;
  12960. /**
  12961. * Gets the actual target of the runtime animation
  12962. */
  12963. readonly target: any;
  12964. /** @hidden */
  12965. _onLoop: () => void;
  12966. /**
  12967. * Create a new RuntimeAnimation object
  12968. * @param target defines the target of the animation
  12969. * @param animation defines the source animation object
  12970. * @param scene defines the hosting scene
  12971. * @param host defines the initiating Animatable
  12972. */
  12973. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12974. private _preparePath;
  12975. /**
  12976. * Gets the animation from the runtime animation
  12977. */
  12978. readonly animation: Animation;
  12979. /**
  12980. * Resets the runtime animation to the beginning
  12981. * @param restoreOriginal defines whether to restore the target property to the original value
  12982. */
  12983. reset(restoreOriginal?: boolean): void;
  12984. /**
  12985. * Specifies if the runtime animation is stopped
  12986. * @returns Boolean specifying if the runtime animation is stopped
  12987. */
  12988. isStopped(): boolean;
  12989. /**
  12990. * Disposes of the runtime animation
  12991. */
  12992. dispose(): void;
  12993. /**
  12994. * Apply the interpolated value to the target
  12995. * @param currentValue defines the value computed by the animation
  12996. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12997. */
  12998. setValue(currentValue: any, weight: number): void;
  12999. private _getOriginalValues;
  13000. private _setValue;
  13001. /**
  13002. * Gets the loop pmode of the runtime animation
  13003. * @returns Loop Mode
  13004. */
  13005. private _getCorrectLoopMode;
  13006. /**
  13007. * Move the current animation to a given frame
  13008. * @param frame defines the frame to move to
  13009. */
  13010. goToFrame(frame: number): void;
  13011. /**
  13012. * @hidden Internal use only
  13013. */
  13014. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13015. /**
  13016. * Execute the current animation
  13017. * @param delay defines the delay to add to the current frame
  13018. * @param from defines the lower bound of the animation range
  13019. * @param to defines the upper bound of the animation range
  13020. * @param loop defines if the current animation must loop
  13021. * @param speedRatio defines the current speed ratio
  13022. * @param weight defines the weight of the animation (default is -1 so no weight)
  13023. * @param onLoop optional callback called when animation loops
  13024. * @returns a boolean indicating if the animation is running
  13025. */
  13026. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13027. }
  13028. }
  13029. declare module "babylonjs/Animations/animatable" {
  13030. import { Animation } from "babylonjs/Animations/animation";
  13031. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13032. import { Nullable } from "babylonjs/types";
  13033. import { Observable } from "babylonjs/Misc/observable";
  13034. import { Scene } from "babylonjs/scene";
  13035. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13036. import { Node } from "babylonjs/node";
  13037. /**
  13038. * Class used to store an actual running animation
  13039. */
  13040. export class Animatable {
  13041. /** defines the target object */
  13042. target: any;
  13043. /** defines the starting frame number (default is 0) */
  13044. fromFrame: number;
  13045. /** defines the ending frame number (default is 100) */
  13046. toFrame: number;
  13047. /** defines if the animation must loop (default is false) */
  13048. loopAnimation: boolean;
  13049. /** defines a callback to call when animation ends if it is not looping */
  13050. onAnimationEnd?: (() => void) | null | undefined;
  13051. /** defines a callback to call when animation loops */
  13052. onAnimationLoop?: (() => void) | null | undefined;
  13053. private _localDelayOffset;
  13054. private _pausedDelay;
  13055. private _runtimeAnimations;
  13056. private _paused;
  13057. private _scene;
  13058. private _speedRatio;
  13059. private _weight;
  13060. private _syncRoot;
  13061. /**
  13062. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13063. * This will only apply for non looping animation (default is true)
  13064. */
  13065. disposeOnEnd: boolean;
  13066. /**
  13067. * Gets a boolean indicating if the animation has started
  13068. */
  13069. animationStarted: boolean;
  13070. /**
  13071. * Observer raised when the animation ends
  13072. */
  13073. onAnimationEndObservable: Observable<Animatable>;
  13074. /**
  13075. * Observer raised when the animation loops
  13076. */
  13077. onAnimationLoopObservable: Observable<Animatable>;
  13078. /**
  13079. * Gets the root Animatable used to synchronize and normalize animations
  13080. */
  13081. readonly syncRoot: Nullable<Animatable>;
  13082. /**
  13083. * Gets the current frame of the first RuntimeAnimation
  13084. * Used to synchronize Animatables
  13085. */
  13086. readonly masterFrame: number;
  13087. /**
  13088. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13089. */
  13090. weight: number;
  13091. /**
  13092. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13093. */
  13094. speedRatio: number;
  13095. /**
  13096. * Creates a new Animatable
  13097. * @param scene defines the hosting scene
  13098. * @param target defines the target object
  13099. * @param fromFrame defines the starting frame number (default is 0)
  13100. * @param toFrame defines the ending frame number (default is 100)
  13101. * @param loopAnimation defines if the animation must loop (default is false)
  13102. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13103. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13104. * @param animations defines a group of animation to add to the new Animatable
  13105. * @param onAnimationLoop defines a callback to call when animation loops
  13106. */
  13107. constructor(scene: Scene,
  13108. /** defines the target object */
  13109. target: any,
  13110. /** defines the starting frame number (default is 0) */
  13111. fromFrame?: number,
  13112. /** defines the ending frame number (default is 100) */
  13113. toFrame?: number,
  13114. /** defines if the animation must loop (default is false) */
  13115. loopAnimation?: boolean, speedRatio?: number,
  13116. /** defines a callback to call when animation ends if it is not looping */
  13117. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13118. /** defines a callback to call when animation loops */
  13119. onAnimationLoop?: (() => void) | null | undefined);
  13120. /**
  13121. * Synchronize and normalize current Animatable with a source Animatable
  13122. * This is useful when using animation weights and when animations are not of the same length
  13123. * @param root defines the root Animatable to synchronize with
  13124. * @returns the current Animatable
  13125. */
  13126. syncWith(root: Animatable): Animatable;
  13127. /**
  13128. * Gets the list of runtime animations
  13129. * @returns an array of RuntimeAnimation
  13130. */
  13131. getAnimations(): RuntimeAnimation[];
  13132. /**
  13133. * Adds more animations to the current animatable
  13134. * @param target defines the target of the animations
  13135. * @param animations defines the new animations to add
  13136. */
  13137. appendAnimations(target: any, animations: Animation[]): void;
  13138. /**
  13139. * Gets the source animation for a specific property
  13140. * @param property defines the propertyu to look for
  13141. * @returns null or the source animation for the given property
  13142. */
  13143. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13144. /**
  13145. * Gets the runtime animation for a specific property
  13146. * @param property defines the propertyu to look for
  13147. * @returns null or the runtime animation for the given property
  13148. */
  13149. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13150. /**
  13151. * Resets the animatable to its original state
  13152. */
  13153. reset(): void;
  13154. /**
  13155. * Allows the animatable to blend with current running animations
  13156. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13157. * @param blendingSpeed defines the blending speed to use
  13158. */
  13159. enableBlending(blendingSpeed: number): void;
  13160. /**
  13161. * Disable animation blending
  13162. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13163. */
  13164. disableBlending(): void;
  13165. /**
  13166. * Jump directly to a given frame
  13167. * @param frame defines the frame to jump to
  13168. */
  13169. goToFrame(frame: number): void;
  13170. /**
  13171. * Pause the animation
  13172. */
  13173. pause(): void;
  13174. /**
  13175. * Restart the animation
  13176. */
  13177. restart(): void;
  13178. private _raiseOnAnimationEnd;
  13179. /**
  13180. * Stop and delete the current animation
  13181. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13182. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  13183. */
  13184. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13185. /**
  13186. * Wait asynchronously for the animation to end
  13187. * @returns a promise which will be fullfilled when the animation ends
  13188. */
  13189. waitAsync(): Promise<Animatable>;
  13190. /** @hidden */
  13191. _animate(delay: number): boolean;
  13192. }
  13193. module "babylonjs/scene" {
  13194. interface Scene {
  13195. /** @hidden */
  13196. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13197. /** @hidden */
  13198. _processLateAnimationBindingsForMatrices(holder: {
  13199. totalWeight: number;
  13200. animations: RuntimeAnimation[];
  13201. originalValue: Matrix;
  13202. }): any;
  13203. /** @hidden */
  13204. _processLateAnimationBindingsForQuaternions(holder: {
  13205. totalWeight: number;
  13206. animations: RuntimeAnimation[];
  13207. originalValue: Quaternion;
  13208. }, refQuaternion: Quaternion): Quaternion;
  13209. /** @hidden */
  13210. _processLateAnimationBindings(): void;
  13211. /**
  13212. * Will start the animation sequence of a given target
  13213. * @param target defines the target
  13214. * @param from defines from which frame should animation start
  13215. * @param to defines until which frame should animation run.
  13216. * @param weight defines the weight to apply to the animation (1.0 by default)
  13217. * @param loop defines if the animation loops
  13218. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13219. * @param onAnimationEnd defines the function to be executed when the animation ends
  13220. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13221. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13222. * @param onAnimationLoop defines the callback to call when an animation loops
  13223. * @returns the animatable object created for this animation
  13224. */
  13225. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13226. /**
  13227. * Will start the animation sequence of a given target
  13228. * @param target defines the target
  13229. * @param from defines from which frame should animation start
  13230. * @param to defines until which frame should animation run.
  13231. * @param loop defines if the animation loops
  13232. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13233. * @param onAnimationEnd defines the function to be executed when the animation ends
  13234. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13235. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13236. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13237. * @param onAnimationLoop defines the callback to call when an animation loops
  13238. * @returns the animatable object created for this animation
  13239. */
  13240. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13241. /**
  13242. * Will start the animation sequence of a given target and its hierarchy
  13243. * @param target defines the target
  13244. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  13245. * @param from defines from which frame should animation start
  13246. * @param to defines until which frame should animation run.
  13247. * @param loop defines if the animation loops
  13248. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13249. * @param onAnimationEnd defines the function to be executed when the animation ends
  13250. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13251. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13252. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13253. * @param onAnimationLoop defines the callback to call when an animation loops
  13254. * @returns the list of created animatables
  13255. */
  13256. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  13257. /**
  13258. * Begin a new animation on a given node
  13259. * @param target defines the target where the animation will take place
  13260. * @param animations defines the list of animations to start
  13261. * @param from defines the initial value
  13262. * @param to defines the final value
  13263. * @param loop defines if you want animation to loop (off by default)
  13264. * @param speedRatio defines the speed ratio to apply to all animations
  13265. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13266. * @param onAnimationLoop defines the callback to call when an animation loops
  13267. * @returns the list of created animatables
  13268. */
  13269. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13270. /**
  13271. * Begin a new animation on a given node and its hierarchy
  13272. * @param target defines the root node where the animation will take place
  13273. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  13274. * @param animations defines the list of animations to start
  13275. * @param from defines the initial value
  13276. * @param to defines the final value
  13277. * @param loop defines if you want animation to loop (off by default)
  13278. * @param speedRatio defines the speed ratio to apply to all animations
  13279. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13280. * @param onAnimationLoop defines the callback to call when an animation loops
  13281. * @returns the list of animatables created for all nodes
  13282. */
  13283. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13284. /**
  13285. * Gets the animatable associated with a specific target
  13286. * @param target defines the target of the animatable
  13287. * @returns the required animatable if found
  13288. */
  13289. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13290. /**
  13291. * Gets all animatables associated with a given target
  13292. * @param target defines the target to look animatables for
  13293. * @returns an array of Animatables
  13294. */
  13295. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13296. /**
  13297. * Stops and removes all animations that have been applied to the scene
  13298. */
  13299. stopAllAnimations(): void;
  13300. }
  13301. }
  13302. module "babylonjs/Bones/bone" {
  13303. interface Bone {
  13304. /**
  13305. * Copy an animation range from another bone
  13306. * @param source defines the source bone
  13307. * @param rangeName defines the range name to copy
  13308. * @param frameOffset defines the frame offset
  13309. * @param rescaleAsRequired defines if rescaling must be applied if required
  13310. * @param skelDimensionsRatio defines the scaling ratio
  13311. * @returns true if operation was successful
  13312. */
  13313. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13314. }
  13315. }
  13316. }
  13317. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13318. /**
  13319. * Class used to override all child animations of a given target
  13320. */
  13321. export class AnimationPropertiesOverride {
  13322. /**
  13323. * Gets or sets a value indicating if animation blending must be used
  13324. */
  13325. enableBlending: boolean;
  13326. /**
  13327. * Gets or sets the blending speed to use when enableBlending is true
  13328. */
  13329. blendingSpeed: number;
  13330. /**
  13331. * Gets or sets the default loop mode to use
  13332. */
  13333. loopMode: number;
  13334. }
  13335. }
  13336. declare module "babylonjs/Bones/skeleton" {
  13337. import { Bone } from "babylonjs/Bones/bone";
  13338. import { Observable } from "babylonjs/Misc/observable";
  13339. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13340. import { Scene } from "babylonjs/scene";
  13341. import { Nullable } from "babylonjs/types";
  13342. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13343. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13344. import { Animatable } from "babylonjs/Animations/animatable";
  13345. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13346. import { Animation } from "babylonjs/Animations/animation";
  13347. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13348. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13349. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13350. /**
  13351. * Class used to handle skinning animations
  13352. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13353. */
  13354. export class Skeleton implements IAnimatable {
  13355. /** defines the skeleton name */
  13356. name: string;
  13357. /** defines the skeleton Id */
  13358. id: string;
  13359. /**
  13360. * Defines the list of child bones
  13361. */
  13362. bones: Bone[];
  13363. /**
  13364. * Defines an estimate of the dimension of the skeleton at rest
  13365. */
  13366. dimensionsAtRest: Vector3;
  13367. /**
  13368. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13369. */
  13370. needInitialSkinMatrix: boolean;
  13371. /**
  13372. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13373. */
  13374. overrideMesh: Nullable<AbstractMesh>;
  13375. /**
  13376. * Gets the list of animations attached to this skeleton
  13377. */
  13378. animations: Array<Animation>;
  13379. private _scene;
  13380. private _isDirty;
  13381. private _transformMatrices;
  13382. private _transformMatrixTexture;
  13383. private _meshesWithPoseMatrix;
  13384. private _animatables;
  13385. private _identity;
  13386. private _synchronizedWithMesh;
  13387. private _ranges;
  13388. private _lastAbsoluteTransformsUpdateId;
  13389. private _canUseTextureForBones;
  13390. private _uniqueId;
  13391. /** @hidden */
  13392. _numBonesWithLinkedTransformNode: number;
  13393. /** @hidden */
  13394. _hasWaitingData: Nullable<boolean>;
  13395. /**
  13396. * Specifies if the skeleton should be serialized
  13397. */
  13398. doNotSerialize: boolean;
  13399. private _useTextureToStoreBoneMatrices;
  13400. /**
  13401. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13402. * Please note that this option is not available if the hardware does not support it
  13403. */
  13404. useTextureToStoreBoneMatrices: boolean;
  13405. private _animationPropertiesOverride;
  13406. /**
  13407. * Gets or sets the animation properties override
  13408. */
  13409. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13410. /**
  13411. * List of inspectable custom properties (used by the Inspector)
  13412. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13413. */
  13414. inspectableCustomProperties: IInspectable[];
  13415. /**
  13416. * An observable triggered before computing the skeleton's matrices
  13417. */
  13418. onBeforeComputeObservable: Observable<Skeleton>;
  13419. /**
  13420. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13421. */
  13422. readonly isUsingTextureForMatrices: boolean;
  13423. /**
  13424. * Gets the unique ID of this skeleton
  13425. */
  13426. readonly uniqueId: number;
  13427. /**
  13428. * Creates a new skeleton
  13429. * @param name defines the skeleton name
  13430. * @param id defines the skeleton Id
  13431. * @param scene defines the hosting scene
  13432. */
  13433. constructor(
  13434. /** defines the skeleton name */
  13435. name: string,
  13436. /** defines the skeleton Id */
  13437. id: string, scene: Scene);
  13438. /**
  13439. * Gets the current object class name.
  13440. * @return the class name
  13441. */
  13442. getClassName(): string;
  13443. /**
  13444. * Returns an array containing the root bones
  13445. * @returns an array containing the root bones
  13446. */
  13447. getChildren(): Array<Bone>;
  13448. /**
  13449. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13450. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13451. * @returns a Float32Array containing matrices data
  13452. */
  13453. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13454. /**
  13455. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13456. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13457. * @returns a raw texture containing the data
  13458. */
  13459. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13460. /**
  13461. * Gets the current hosting scene
  13462. * @returns a scene object
  13463. */
  13464. getScene(): Scene;
  13465. /**
  13466. * Gets a string representing the current skeleton data
  13467. * @param fullDetails defines a boolean indicating if we want a verbose version
  13468. * @returns a string representing the current skeleton data
  13469. */
  13470. toString(fullDetails?: boolean): string;
  13471. /**
  13472. * Get bone's index searching by name
  13473. * @param name defines bone's name to search for
  13474. * @return the indice of the bone. Returns -1 if not found
  13475. */
  13476. getBoneIndexByName(name: string): number;
  13477. /**
  13478. * Creater a new animation range
  13479. * @param name defines the name of the range
  13480. * @param from defines the start key
  13481. * @param to defines the end key
  13482. */
  13483. createAnimationRange(name: string, from: number, to: number): void;
  13484. /**
  13485. * Delete a specific animation range
  13486. * @param name defines the name of the range
  13487. * @param deleteFrames defines if frames must be removed as well
  13488. */
  13489. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13490. /**
  13491. * Gets a specific animation range
  13492. * @param name defines the name of the range to look for
  13493. * @returns the requested animation range or null if not found
  13494. */
  13495. getAnimationRange(name: string): Nullable<AnimationRange>;
  13496. /**
  13497. * Gets the list of all animation ranges defined on this skeleton
  13498. * @returns an array
  13499. */
  13500. getAnimationRanges(): Nullable<AnimationRange>[];
  13501. /**
  13502. * Copy animation range from a source skeleton.
  13503. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13504. * @param source defines the source skeleton
  13505. * @param name defines the name of the range to copy
  13506. * @param rescaleAsRequired defines if rescaling must be applied if required
  13507. * @returns true if operation was successful
  13508. */
  13509. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13510. /**
  13511. * Forces the skeleton to go to rest pose
  13512. */
  13513. returnToRest(): void;
  13514. private _getHighestAnimationFrame;
  13515. /**
  13516. * Begin a specific animation range
  13517. * @param name defines the name of the range to start
  13518. * @param loop defines if looping must be turned on (false by default)
  13519. * @param speedRatio defines the speed ratio to apply (1 by default)
  13520. * @param onAnimationEnd defines a callback which will be called when animation will end
  13521. * @returns a new animatable
  13522. */
  13523. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13524. /** @hidden */
  13525. _markAsDirty(): void;
  13526. /** @hidden */
  13527. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13528. /** @hidden */
  13529. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13530. private _computeTransformMatrices;
  13531. /**
  13532. * Build all resources required to render a skeleton
  13533. */
  13534. prepare(): void;
  13535. /**
  13536. * Gets the list of animatables currently running for this skeleton
  13537. * @returns an array of animatables
  13538. */
  13539. getAnimatables(): IAnimatable[];
  13540. /**
  13541. * Clone the current skeleton
  13542. * @param name defines the name of the new skeleton
  13543. * @param id defines the id of the new skeleton
  13544. * @returns the new skeleton
  13545. */
  13546. clone(name: string, id: string): Skeleton;
  13547. /**
  13548. * Enable animation blending for this skeleton
  13549. * @param blendingSpeed defines the blending speed to apply
  13550. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13551. */
  13552. enableBlending(blendingSpeed?: number): void;
  13553. /**
  13554. * Releases all resources associated with the current skeleton
  13555. */
  13556. dispose(): void;
  13557. /**
  13558. * Serialize the skeleton in a JSON object
  13559. * @returns a JSON object
  13560. */
  13561. serialize(): any;
  13562. /**
  13563. * Creates a new skeleton from serialized data
  13564. * @param parsedSkeleton defines the serialized data
  13565. * @param scene defines the hosting scene
  13566. * @returns a new skeleton
  13567. */
  13568. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13569. /**
  13570. * Compute all node absolute transforms
  13571. * @param forceUpdate defines if computation must be done even if cache is up to date
  13572. */
  13573. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13574. /**
  13575. * Gets the root pose matrix
  13576. * @returns a matrix
  13577. */
  13578. getPoseMatrix(): Nullable<Matrix>;
  13579. /**
  13580. * Sorts bones per internal index
  13581. */
  13582. sortBones(): void;
  13583. private _sortBones;
  13584. }
  13585. }
  13586. declare module "babylonjs/Bones/bone" {
  13587. import { Skeleton } from "babylonjs/Bones/skeleton";
  13588. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13589. import { Nullable } from "babylonjs/types";
  13590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13591. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13592. import { Node } from "babylonjs/node";
  13593. import { Space } from "babylonjs/Maths/math.axis";
  13594. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13595. /**
  13596. * Class used to store bone information
  13597. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13598. */
  13599. export class Bone extends Node {
  13600. /**
  13601. * defines the bone name
  13602. */
  13603. name: string;
  13604. private static _tmpVecs;
  13605. private static _tmpQuat;
  13606. private static _tmpMats;
  13607. /**
  13608. * Gets the list of child bones
  13609. */
  13610. children: Bone[];
  13611. /** Gets the animations associated with this bone */
  13612. animations: import("babylonjs/Animations/animation").Animation[];
  13613. /**
  13614. * Gets or sets bone length
  13615. */
  13616. length: number;
  13617. /**
  13618. * @hidden Internal only
  13619. * Set this value to map this bone to a different index in the transform matrices
  13620. * Set this value to -1 to exclude the bone from the transform matrices
  13621. */
  13622. _index: Nullable<number>;
  13623. private _skeleton;
  13624. private _localMatrix;
  13625. private _restPose;
  13626. private _baseMatrix;
  13627. private _absoluteTransform;
  13628. private _invertedAbsoluteTransform;
  13629. private _parent;
  13630. private _scalingDeterminant;
  13631. private _worldTransform;
  13632. private _localScaling;
  13633. private _localRotation;
  13634. private _localPosition;
  13635. private _needToDecompose;
  13636. private _needToCompose;
  13637. /** @hidden */
  13638. _linkedTransformNode: Nullable<TransformNode>;
  13639. /** @hidden */
  13640. _waitingTransformNodeId: Nullable<string>;
  13641. /** @hidden */
  13642. /** @hidden */
  13643. _matrix: Matrix;
  13644. /**
  13645. * Create a new bone
  13646. * @param name defines the bone name
  13647. * @param skeleton defines the parent skeleton
  13648. * @param parentBone defines the parent (can be null if the bone is the root)
  13649. * @param localMatrix defines the local matrix
  13650. * @param restPose defines the rest pose matrix
  13651. * @param baseMatrix defines the base matrix
  13652. * @param index defines index of the bone in the hiearchy
  13653. */
  13654. constructor(
  13655. /**
  13656. * defines the bone name
  13657. */
  13658. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13659. /**
  13660. * Gets the current object class name.
  13661. * @return the class name
  13662. */
  13663. getClassName(): string;
  13664. /**
  13665. * Gets the parent skeleton
  13666. * @returns a skeleton
  13667. */
  13668. getSkeleton(): Skeleton;
  13669. /**
  13670. * Gets parent bone
  13671. * @returns a bone or null if the bone is the root of the bone hierarchy
  13672. */
  13673. getParent(): Nullable<Bone>;
  13674. /**
  13675. * Returns an array containing the root bones
  13676. * @returns an array containing the root bones
  13677. */
  13678. getChildren(): Array<Bone>;
  13679. /**
  13680. * Sets the parent bone
  13681. * @param parent defines the parent (can be null if the bone is the root)
  13682. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13683. */
  13684. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13685. /**
  13686. * Gets the local matrix
  13687. * @returns a matrix
  13688. */
  13689. getLocalMatrix(): Matrix;
  13690. /**
  13691. * Gets the base matrix (initial matrix which remains unchanged)
  13692. * @returns a matrix
  13693. */
  13694. getBaseMatrix(): Matrix;
  13695. /**
  13696. * Gets the rest pose matrix
  13697. * @returns a matrix
  13698. */
  13699. getRestPose(): Matrix;
  13700. /**
  13701. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13702. */
  13703. getWorldMatrix(): Matrix;
  13704. /**
  13705. * Sets the local matrix to rest pose matrix
  13706. */
  13707. returnToRest(): void;
  13708. /**
  13709. * Gets the inverse of the absolute transform matrix.
  13710. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13711. * @returns a matrix
  13712. */
  13713. getInvertedAbsoluteTransform(): Matrix;
  13714. /**
  13715. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13716. * @returns a matrix
  13717. */
  13718. getAbsoluteTransform(): Matrix;
  13719. /**
  13720. * Links with the given transform node.
  13721. * The local matrix of this bone is copied from the transform node every frame.
  13722. * @param transformNode defines the transform node to link to
  13723. */
  13724. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13725. /**
  13726. * Gets the node used to drive the bone's transformation
  13727. * @returns a transform node or null
  13728. */
  13729. getTransformNode(): Nullable<TransformNode>;
  13730. /** Gets or sets current position (in local space) */
  13731. position: Vector3;
  13732. /** Gets or sets current rotation (in local space) */
  13733. rotation: Vector3;
  13734. /** Gets or sets current rotation quaternion (in local space) */
  13735. rotationQuaternion: Quaternion;
  13736. /** Gets or sets current scaling (in local space) */
  13737. scaling: Vector3;
  13738. /**
  13739. * Gets the animation properties override
  13740. */
  13741. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13742. private _decompose;
  13743. private _compose;
  13744. /**
  13745. * Update the base and local matrices
  13746. * @param matrix defines the new base or local matrix
  13747. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13748. * @param updateLocalMatrix defines if the local matrix should be updated
  13749. */
  13750. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13751. /** @hidden */
  13752. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13753. /**
  13754. * Flag the bone as dirty (Forcing it to update everything)
  13755. */
  13756. markAsDirty(): void;
  13757. /** @hidden */
  13758. _markAsDirtyAndCompose(): void;
  13759. private _markAsDirtyAndDecompose;
  13760. /**
  13761. * Translate the bone in local or world space
  13762. * @param vec The amount to translate the bone
  13763. * @param space The space that the translation is in
  13764. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13765. */
  13766. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13767. /**
  13768. * Set the postion of the bone in local or world space
  13769. * @param position The position to set the bone
  13770. * @param space The space that the position is in
  13771. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13772. */
  13773. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13774. /**
  13775. * Set the absolute position of the bone (world space)
  13776. * @param position The position to set the bone
  13777. * @param mesh The mesh that this bone is attached to
  13778. */
  13779. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13780. /**
  13781. * Scale the bone on the x, y and z axes (in local space)
  13782. * @param x The amount to scale the bone on the x axis
  13783. * @param y The amount to scale the bone on the y axis
  13784. * @param z The amount to scale the bone on the z axis
  13785. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13786. */
  13787. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13788. /**
  13789. * Set the bone scaling in local space
  13790. * @param scale defines the scaling vector
  13791. */
  13792. setScale(scale: Vector3): void;
  13793. /**
  13794. * Gets the current scaling in local space
  13795. * @returns the current scaling vector
  13796. */
  13797. getScale(): Vector3;
  13798. /**
  13799. * Gets the current scaling in local space and stores it in a target vector
  13800. * @param result defines the target vector
  13801. */
  13802. getScaleToRef(result: Vector3): void;
  13803. /**
  13804. * Set the yaw, pitch, and roll of the bone in local or world space
  13805. * @param yaw The rotation of the bone on the y axis
  13806. * @param pitch The rotation of the bone on the x axis
  13807. * @param roll The rotation of the bone on the z axis
  13808. * @param space The space that the axes of rotation are in
  13809. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13810. */
  13811. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13812. /**
  13813. * Add a rotation to the bone on an axis in local or world space
  13814. * @param axis The axis to rotate the bone on
  13815. * @param amount The amount to rotate the bone
  13816. * @param space The space that the axis is in
  13817. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13818. */
  13819. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13820. /**
  13821. * Set the rotation of the bone to a particular axis angle in local or world space
  13822. * @param axis The axis to rotate the bone on
  13823. * @param angle The angle that the bone should be rotated to
  13824. * @param space The space that the axis is in
  13825. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13826. */
  13827. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13828. /**
  13829. * Set the euler rotation of the bone in local of world space
  13830. * @param rotation The euler rotation that the bone should be set to
  13831. * @param space The space that the rotation is in
  13832. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13833. */
  13834. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13835. /**
  13836. * Set the quaternion rotation of the bone in local of world space
  13837. * @param quat The quaternion rotation that the bone should be set to
  13838. * @param space The space that the rotation is in
  13839. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13840. */
  13841. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13842. /**
  13843. * Set the rotation matrix of the bone in local of world space
  13844. * @param rotMat The rotation matrix that the bone should be set to
  13845. * @param space The space that the rotation is in
  13846. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13847. */
  13848. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13849. private _rotateWithMatrix;
  13850. private _getNegativeRotationToRef;
  13851. /**
  13852. * Get the position of the bone in local or world space
  13853. * @param space The space that the returned position is in
  13854. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13855. * @returns The position of the bone
  13856. */
  13857. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13858. /**
  13859. * Copy the position of the bone to a vector3 in local or world space
  13860. * @param space The space that the returned position is in
  13861. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13862. * @param result The vector3 to copy the position to
  13863. */
  13864. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13865. /**
  13866. * Get the absolute position of the bone (world space)
  13867. * @param mesh The mesh that this bone is attached to
  13868. * @returns The absolute position of the bone
  13869. */
  13870. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13871. /**
  13872. * Copy the absolute position of the bone (world space) to the result param
  13873. * @param mesh The mesh that this bone is attached to
  13874. * @param result The vector3 to copy the absolute position to
  13875. */
  13876. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13877. /**
  13878. * Compute the absolute transforms of this bone and its children
  13879. */
  13880. computeAbsoluteTransforms(): void;
  13881. /**
  13882. * Get the world direction from an axis that is in the local space of the bone
  13883. * @param localAxis The local direction that is used to compute the world direction
  13884. * @param mesh The mesh that this bone is attached to
  13885. * @returns The world direction
  13886. */
  13887. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13888. /**
  13889. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13890. * @param localAxis The local direction that is used to compute the world direction
  13891. * @param mesh The mesh that this bone is attached to
  13892. * @param result The vector3 that the world direction will be copied to
  13893. */
  13894. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13895. /**
  13896. * Get the euler rotation of the bone in local or world space
  13897. * @param space The space that the rotation should be in
  13898. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13899. * @returns The euler rotation
  13900. */
  13901. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13902. /**
  13903. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13904. * @param space The space that the rotation should be in
  13905. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13906. * @param result The vector3 that the rotation should be copied to
  13907. */
  13908. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13909. /**
  13910. * Get the quaternion rotation of the bone in either local or world space
  13911. * @param space The space that the rotation should be in
  13912. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13913. * @returns The quaternion rotation
  13914. */
  13915. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13916. /**
  13917. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13918. * @param space The space that the rotation should be in
  13919. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13920. * @param result The quaternion that the rotation should be copied to
  13921. */
  13922. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13923. /**
  13924. * Get the rotation matrix of the bone in local or world space
  13925. * @param space The space that the rotation should be in
  13926. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13927. * @returns The rotation matrix
  13928. */
  13929. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13930. /**
  13931. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13932. * @param space The space that the rotation should be in
  13933. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13934. * @param result The quaternion that the rotation should be copied to
  13935. */
  13936. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13937. /**
  13938. * Get the world position of a point that is in the local space of the bone
  13939. * @param position The local position
  13940. * @param mesh The mesh that this bone is attached to
  13941. * @returns The world position
  13942. */
  13943. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13944. /**
  13945. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13946. * @param position The local position
  13947. * @param mesh The mesh that this bone is attached to
  13948. * @param result The vector3 that the world position should be copied to
  13949. */
  13950. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13951. /**
  13952. * Get the local position of a point that is in world space
  13953. * @param position The world position
  13954. * @param mesh The mesh that this bone is attached to
  13955. * @returns The local position
  13956. */
  13957. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13958. /**
  13959. * Get the local position of a point that is in world space and copy it to the result param
  13960. * @param position The world position
  13961. * @param mesh The mesh that this bone is attached to
  13962. * @param result The vector3 that the local position should be copied to
  13963. */
  13964. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13965. }
  13966. }
  13967. declare module "babylonjs/Meshes/transformNode" {
  13968. import { DeepImmutable } from "babylonjs/types";
  13969. import { Observable } from "babylonjs/Misc/observable";
  13970. import { Nullable } from "babylonjs/types";
  13971. import { Camera } from "babylonjs/Cameras/camera";
  13972. import { Scene } from "babylonjs/scene";
  13973. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13974. import { Node } from "babylonjs/node";
  13975. import { Bone } from "babylonjs/Bones/bone";
  13976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13977. import { Space } from "babylonjs/Maths/math.axis";
  13978. /**
  13979. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  13980. * @see https://doc.babylonjs.com/how_to/transformnode
  13981. */
  13982. export class TransformNode extends Node {
  13983. /**
  13984. * Object will not rotate to face the camera
  13985. */
  13986. static BILLBOARDMODE_NONE: number;
  13987. /**
  13988. * Object will rotate to face the camera but only on the x axis
  13989. */
  13990. static BILLBOARDMODE_X: number;
  13991. /**
  13992. * Object will rotate to face the camera but only on the y axis
  13993. */
  13994. static BILLBOARDMODE_Y: number;
  13995. /**
  13996. * Object will rotate to face the camera but only on the z axis
  13997. */
  13998. static BILLBOARDMODE_Z: number;
  13999. /**
  14000. * Object will rotate to face the camera
  14001. */
  14002. static BILLBOARDMODE_ALL: number;
  14003. /**
  14004. * Object will rotate to face the camera's position instead of orientation
  14005. */
  14006. static BILLBOARDMODE_USE_POSITION: number;
  14007. private _forward;
  14008. private _forwardInverted;
  14009. private _up;
  14010. private _right;
  14011. private _rightInverted;
  14012. private _position;
  14013. private _rotation;
  14014. private _rotationQuaternion;
  14015. protected _scaling: Vector3;
  14016. protected _isDirty: boolean;
  14017. private _transformToBoneReferal;
  14018. private _isAbsoluteSynced;
  14019. private _billboardMode;
  14020. /**
  14021. * Gets or sets the billboard mode. Default is 0.
  14022. *
  14023. * | Value | Type | Description |
  14024. * | --- | --- | --- |
  14025. * | 0 | BILLBOARDMODE_NONE | |
  14026. * | 1 | BILLBOARDMODE_X | |
  14027. * | 2 | BILLBOARDMODE_Y | |
  14028. * | 4 | BILLBOARDMODE_Z | |
  14029. * | 7 | BILLBOARDMODE_ALL | |
  14030. *
  14031. */
  14032. billboardMode: number;
  14033. private _preserveParentRotationForBillboard;
  14034. /**
  14035. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14036. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14037. */
  14038. preserveParentRotationForBillboard: boolean;
  14039. /**
  14040. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  14041. */
  14042. scalingDeterminant: number;
  14043. private _infiniteDistance;
  14044. /**
  14045. * Gets or sets the distance of the object to max, often used by skybox
  14046. */
  14047. infiniteDistance: boolean;
  14048. /**
  14049. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14050. * By default the system will update normals to compensate
  14051. */
  14052. ignoreNonUniformScaling: boolean;
  14053. /**
  14054. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  14055. */
  14056. reIntegrateRotationIntoRotationQuaternion: boolean;
  14057. /** @hidden */
  14058. _poseMatrix: Nullable<Matrix>;
  14059. /** @hidden */
  14060. _localMatrix: Matrix;
  14061. private _usePivotMatrix;
  14062. private _absolutePosition;
  14063. private _absoluteScaling;
  14064. private _absoluteRotationQuaternion;
  14065. private _pivotMatrix;
  14066. private _pivotMatrixInverse;
  14067. protected _postMultiplyPivotMatrix: boolean;
  14068. protected _isWorldMatrixFrozen: boolean;
  14069. /** @hidden */
  14070. _indexInSceneTransformNodesArray: number;
  14071. /**
  14072. * An event triggered after the world matrix is updated
  14073. */
  14074. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14075. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14076. /**
  14077. * Gets a string identifying the name of the class
  14078. * @returns "TransformNode" string
  14079. */
  14080. getClassName(): string;
  14081. /**
  14082. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14083. */
  14084. position: Vector3;
  14085. /**
  14086. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14087. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14088. */
  14089. rotation: Vector3;
  14090. /**
  14091. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14092. */
  14093. scaling: Vector3;
  14094. /**
  14095. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  14096. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14097. */
  14098. rotationQuaternion: Nullable<Quaternion>;
  14099. /**
  14100. * The forward direction of that transform in world space.
  14101. */
  14102. readonly forward: Vector3;
  14103. /**
  14104. * The up direction of that transform in world space.
  14105. */
  14106. readonly up: Vector3;
  14107. /**
  14108. * The right direction of that transform in world space.
  14109. */
  14110. readonly right: Vector3;
  14111. /**
  14112. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14113. * @param matrix the matrix to copy the pose from
  14114. * @returns this TransformNode.
  14115. */
  14116. updatePoseMatrix(matrix: Matrix): TransformNode;
  14117. /**
  14118. * Returns the mesh Pose matrix.
  14119. * @returns the pose matrix
  14120. */
  14121. getPoseMatrix(): Matrix;
  14122. /** @hidden */
  14123. _isSynchronized(): boolean;
  14124. /** @hidden */
  14125. _initCache(): void;
  14126. /**
  14127. * Flag the transform node as dirty (Forcing it to update everything)
  14128. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14129. * @returns this transform node
  14130. */
  14131. markAsDirty(property: string): TransformNode;
  14132. /**
  14133. * Returns the current mesh absolute position.
  14134. * Returns a Vector3.
  14135. */
  14136. readonly absolutePosition: Vector3;
  14137. /**
  14138. * Returns the current mesh absolute scaling.
  14139. * Returns a Vector3.
  14140. */
  14141. readonly absoluteScaling: Vector3;
  14142. /**
  14143. * Returns the current mesh absolute rotation.
  14144. * Returns a Quaternion.
  14145. */
  14146. readonly absoluteRotationQuaternion: Quaternion;
  14147. /**
  14148. * Sets a new matrix to apply before all other transformation
  14149. * @param matrix defines the transform matrix
  14150. * @returns the current TransformNode
  14151. */
  14152. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14153. /**
  14154. * Sets a new pivot matrix to the current node
  14155. * @param matrix defines the new pivot matrix to use
  14156. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  14157. * @returns the current TransformNode
  14158. */
  14159. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14160. /**
  14161. * Returns the mesh pivot matrix.
  14162. * Default : Identity.
  14163. * @returns the matrix
  14164. */
  14165. getPivotMatrix(): Matrix;
  14166. /**
  14167. * Instantiate (when possible) or clone that node with its hierarchy
  14168. * @param newParent defines the new parent to use for the instance (or clone)
  14169. * @returns an instance (or a clone) of the current node with its hiearchy
  14170. */
  14171. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14172. /**
  14173. * Prevents the World matrix to be computed any longer
  14174. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14175. * @returns the TransformNode.
  14176. */
  14177. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14178. /**
  14179. * Allows back the World matrix computation.
  14180. * @returns the TransformNode.
  14181. */
  14182. unfreezeWorldMatrix(): this;
  14183. /**
  14184. * True if the World matrix has been frozen.
  14185. */
  14186. readonly isWorldMatrixFrozen: boolean;
  14187. /**
  14188. * Retuns the mesh absolute position in the World.
  14189. * @returns a Vector3.
  14190. */
  14191. getAbsolutePosition(): Vector3;
  14192. /**
  14193. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14194. * @param absolutePosition the absolute position to set
  14195. * @returns the TransformNode.
  14196. */
  14197. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14198. /**
  14199. * Sets the mesh position in its local space.
  14200. * @param vector3 the position to set in localspace
  14201. * @returns the TransformNode.
  14202. */
  14203. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14204. /**
  14205. * Returns the mesh position in the local space from the current World matrix values.
  14206. * @returns a new Vector3.
  14207. */
  14208. getPositionExpressedInLocalSpace(): Vector3;
  14209. /**
  14210. * Translates the mesh along the passed Vector3 in its local space.
  14211. * @param vector3 the distance to translate in localspace
  14212. * @returns the TransformNode.
  14213. */
  14214. locallyTranslate(vector3: Vector3): TransformNode;
  14215. private static _lookAtVectorCache;
  14216. /**
  14217. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14218. * @param targetPoint the position (must be in same space as current mesh) to look at
  14219. * @param yawCor optional yaw (y-axis) correction in radians
  14220. * @param pitchCor optional pitch (x-axis) correction in radians
  14221. * @param rollCor optional roll (z-axis) correction in radians
  14222. * @param space the choosen space of the target
  14223. * @returns the TransformNode.
  14224. */
  14225. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14226. /**
  14227. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14228. * This Vector3 is expressed in the World space.
  14229. * @param localAxis axis to rotate
  14230. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14231. */
  14232. getDirection(localAxis: Vector3): Vector3;
  14233. /**
  14234. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14235. * localAxis is expressed in the mesh local space.
  14236. * result is computed in the Wordl space from the mesh World matrix.
  14237. * @param localAxis axis to rotate
  14238. * @param result the resulting transformnode
  14239. * @returns this TransformNode.
  14240. */
  14241. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14242. /**
  14243. * Sets this transform node rotation to the given local axis.
  14244. * @param localAxis the axis in local space
  14245. * @param yawCor optional yaw (y-axis) correction in radians
  14246. * @param pitchCor optional pitch (x-axis) correction in radians
  14247. * @param rollCor optional roll (z-axis) correction in radians
  14248. * @returns this TransformNode
  14249. */
  14250. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14251. /**
  14252. * Sets a new pivot point to the current node
  14253. * @param point defines the new pivot point to use
  14254. * @param space defines if the point is in world or local space (local by default)
  14255. * @returns the current TransformNode
  14256. */
  14257. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14258. /**
  14259. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14260. * @returns the pivot point
  14261. */
  14262. getPivotPoint(): Vector3;
  14263. /**
  14264. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14265. * @param result the vector3 to store the result
  14266. * @returns this TransformNode.
  14267. */
  14268. getPivotPointToRef(result: Vector3): TransformNode;
  14269. /**
  14270. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14271. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14272. */
  14273. getAbsolutePivotPoint(): Vector3;
  14274. /**
  14275. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14276. * @param result vector3 to store the result
  14277. * @returns this TransformNode.
  14278. */
  14279. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14280. /**
  14281. * Defines the passed node as the parent of the current node.
  14282. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14283. * @see https://doc.babylonjs.com/how_to/parenting
  14284. * @param node the node ot set as the parent
  14285. * @returns this TransformNode.
  14286. */
  14287. setParent(node: Nullable<Node>): TransformNode;
  14288. private _nonUniformScaling;
  14289. /**
  14290. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14291. */
  14292. readonly nonUniformScaling: boolean;
  14293. /** @hidden */
  14294. _updateNonUniformScalingState(value: boolean): boolean;
  14295. /**
  14296. * Attach the current TransformNode to another TransformNode associated with a bone
  14297. * @param bone Bone affecting the TransformNode
  14298. * @param affectedTransformNode TransformNode associated with the bone
  14299. * @returns this object
  14300. */
  14301. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14302. /**
  14303. * Detach the transform node if its associated with a bone
  14304. * @returns this object
  14305. */
  14306. detachFromBone(): TransformNode;
  14307. private static _rotationAxisCache;
  14308. /**
  14309. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14310. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14311. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14312. * The passed axis is also normalized.
  14313. * @param axis the axis to rotate around
  14314. * @param amount the amount to rotate in radians
  14315. * @param space Space to rotate in (Default: local)
  14316. * @returns the TransformNode.
  14317. */
  14318. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14319. /**
  14320. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14321. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14322. * The passed axis is also normalized. .
  14323. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14324. * @param point the point to rotate around
  14325. * @param axis the axis to rotate around
  14326. * @param amount the amount to rotate in radians
  14327. * @returns the TransformNode
  14328. */
  14329. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14330. /**
  14331. * Translates the mesh along the axis vector for the passed distance in the given space.
  14332. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14333. * @param axis the axis to translate in
  14334. * @param distance the distance to translate
  14335. * @param space Space to rotate in (Default: local)
  14336. * @returns the TransformNode.
  14337. */
  14338. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14339. /**
  14340. * Adds a rotation step to the mesh current rotation.
  14341. * x, y, z are Euler angles expressed in radians.
  14342. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14343. * This means this rotation is made in the mesh local space only.
  14344. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14345. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14346. * ```javascript
  14347. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14348. * ```
  14349. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14350. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  14351. * @param x Rotation to add
  14352. * @param y Rotation to add
  14353. * @param z Rotation to add
  14354. * @returns the TransformNode.
  14355. */
  14356. addRotation(x: number, y: number, z: number): TransformNode;
  14357. /**
  14358. * @hidden
  14359. */
  14360. protected _getEffectiveParent(): Nullable<Node>;
  14361. /**
  14362. * Computes the world matrix of the node
  14363. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14364. * @returns the world matrix
  14365. */
  14366. computeWorldMatrix(force?: boolean): Matrix;
  14367. protected _afterComputeWorldMatrix(): void;
  14368. /**
  14369. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14370. * @param func callback function to add
  14371. *
  14372. * @returns the TransformNode.
  14373. */
  14374. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14375. /**
  14376. * Removes a registered callback function.
  14377. * @param func callback function to remove
  14378. * @returns the TransformNode.
  14379. */
  14380. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14381. /**
  14382. * Gets the position of the current mesh in camera space
  14383. * @param camera defines the camera to use
  14384. * @returns a position
  14385. */
  14386. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14387. /**
  14388. * Returns the distance from the mesh to the active camera
  14389. * @param camera defines the camera to use
  14390. * @returns the distance
  14391. */
  14392. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14393. /**
  14394. * Clone the current transform node
  14395. * @param name Name of the new clone
  14396. * @param newParent New parent for the clone
  14397. * @param doNotCloneChildren Do not clone children hierarchy
  14398. * @returns the new transform node
  14399. */
  14400. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14401. /**
  14402. * Serializes the objects information.
  14403. * @param currentSerializationObject defines the object to serialize in
  14404. * @returns the serialized object
  14405. */
  14406. serialize(currentSerializationObject?: any): any;
  14407. /**
  14408. * Returns a new TransformNode object parsed from the source provided.
  14409. * @param parsedTransformNode is the source.
  14410. * @param scene the scne the object belongs to
  14411. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14412. * @returns a new TransformNode object parsed from the source provided.
  14413. */
  14414. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14415. /**
  14416. * Get all child-transformNodes of this node
  14417. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  14418. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  14419. * @returns an array of TransformNode
  14420. */
  14421. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14422. /**
  14423. * Releases resources associated with this transform node.
  14424. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14425. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14426. */
  14427. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14428. /**
  14429. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14430. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14431. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14432. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14433. * @returns the current mesh
  14434. */
  14435. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14436. private _syncAbsoluteScalingAndRotation;
  14437. }
  14438. }
  14439. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14440. import { Observable } from "babylonjs/Misc/observable";
  14441. import { Nullable } from "babylonjs/types";
  14442. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14443. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14444. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14445. import { Ray } from "babylonjs/Culling/ray";
  14446. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14447. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14448. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14449. /**
  14450. * Defines the types of pose enabled controllers that are supported
  14451. */
  14452. export enum PoseEnabledControllerType {
  14453. /**
  14454. * HTC Vive
  14455. */
  14456. VIVE = 0,
  14457. /**
  14458. * Oculus Rift
  14459. */
  14460. OCULUS = 1,
  14461. /**
  14462. * Windows mixed reality
  14463. */
  14464. WINDOWS = 2,
  14465. /**
  14466. * Samsung gear VR
  14467. */
  14468. GEAR_VR = 3,
  14469. /**
  14470. * Google Daydream
  14471. */
  14472. DAYDREAM = 4,
  14473. /**
  14474. * Generic
  14475. */
  14476. GENERIC = 5
  14477. }
  14478. /**
  14479. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14480. */
  14481. export interface MutableGamepadButton {
  14482. /**
  14483. * Value of the button/trigger
  14484. */
  14485. value: number;
  14486. /**
  14487. * If the button/trigger is currently touched
  14488. */
  14489. touched: boolean;
  14490. /**
  14491. * If the button/trigger is currently pressed
  14492. */
  14493. pressed: boolean;
  14494. }
  14495. /**
  14496. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14497. * @hidden
  14498. */
  14499. export interface ExtendedGamepadButton extends GamepadButton {
  14500. /**
  14501. * If the button/trigger is currently pressed
  14502. */
  14503. readonly pressed: boolean;
  14504. /**
  14505. * If the button/trigger is currently touched
  14506. */
  14507. readonly touched: boolean;
  14508. /**
  14509. * Value of the button/trigger
  14510. */
  14511. readonly value: number;
  14512. }
  14513. /** @hidden */
  14514. export interface _GamePadFactory {
  14515. /**
  14516. * Returns wether or not the current gamepad can be created for this type of controller.
  14517. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14518. * @returns true if it can be created, otherwise false
  14519. */
  14520. canCreate(gamepadInfo: any): boolean;
  14521. /**
  14522. * Creates a new instance of the Gamepad.
  14523. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14524. * @returns the new gamepad instance
  14525. */
  14526. create(gamepadInfo: any): Gamepad;
  14527. }
  14528. /**
  14529. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14530. */
  14531. export class PoseEnabledControllerHelper {
  14532. /** @hidden */
  14533. static _ControllerFactories: _GamePadFactory[];
  14534. /** @hidden */
  14535. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14536. /**
  14537. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14538. * @param vrGamepad the gamepad to initialized
  14539. * @returns a vr controller of the type the gamepad identified as
  14540. */
  14541. static InitiateController(vrGamepad: any): Gamepad;
  14542. }
  14543. /**
  14544. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14545. */
  14546. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14547. /**
  14548. * If the controller is used in a webXR session
  14549. */
  14550. isXR: boolean;
  14551. private _deviceRoomPosition;
  14552. private _deviceRoomRotationQuaternion;
  14553. /**
  14554. * The device position in babylon space
  14555. */
  14556. devicePosition: Vector3;
  14557. /**
  14558. * The device rotation in babylon space
  14559. */
  14560. deviceRotationQuaternion: Quaternion;
  14561. /**
  14562. * The scale factor of the device in babylon space
  14563. */
  14564. deviceScaleFactor: number;
  14565. /**
  14566. * (Likely devicePosition should be used instead) The device position in its room space
  14567. */
  14568. position: Vector3;
  14569. /**
  14570. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14571. */
  14572. rotationQuaternion: Quaternion;
  14573. /**
  14574. * The type of controller (Eg. Windows mixed reality)
  14575. */
  14576. controllerType: PoseEnabledControllerType;
  14577. protected _calculatedPosition: Vector3;
  14578. private _calculatedRotation;
  14579. /**
  14580. * The raw pose from the device
  14581. */
  14582. rawPose: DevicePose;
  14583. private _trackPosition;
  14584. private _maxRotationDistFromHeadset;
  14585. private _draggedRoomRotation;
  14586. /**
  14587. * @hidden
  14588. */
  14589. _disableTrackPosition(fixedPosition: Vector3): void;
  14590. /**
  14591. * Internal, the mesh attached to the controller
  14592. * @hidden
  14593. */
  14594. _mesh: Nullable<AbstractMesh>;
  14595. private _poseControlledCamera;
  14596. private _leftHandSystemQuaternion;
  14597. /**
  14598. * Internal, matrix used to convert room space to babylon space
  14599. * @hidden
  14600. */
  14601. _deviceToWorld: Matrix;
  14602. /**
  14603. * Node to be used when casting a ray from the controller
  14604. * @hidden
  14605. */
  14606. _pointingPoseNode: Nullable<TransformNode>;
  14607. /**
  14608. * Name of the child mesh that can be used to cast a ray from the controller
  14609. */
  14610. static readonly POINTING_POSE: string;
  14611. /**
  14612. * Creates a new PoseEnabledController from a gamepad
  14613. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14614. */
  14615. constructor(browserGamepad: any);
  14616. private _workingMatrix;
  14617. /**
  14618. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14619. */
  14620. update(): void;
  14621. /**
  14622. * Updates only the pose device and mesh without doing any button event checking
  14623. */
  14624. protected _updatePoseAndMesh(): void;
  14625. /**
  14626. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14627. * @param poseData raw pose fromthe device
  14628. */
  14629. updateFromDevice(poseData: DevicePose): void;
  14630. /**
  14631. * @hidden
  14632. */
  14633. _meshAttachedObservable: Observable<AbstractMesh>;
  14634. /**
  14635. * Attaches a mesh to the controller
  14636. * @param mesh the mesh to be attached
  14637. */
  14638. attachToMesh(mesh: AbstractMesh): void;
  14639. /**
  14640. * Attaches the controllers mesh to a camera
  14641. * @param camera the camera the mesh should be attached to
  14642. */
  14643. attachToPoseControlledCamera(camera: TargetCamera): void;
  14644. /**
  14645. * Disposes of the controller
  14646. */
  14647. dispose(): void;
  14648. /**
  14649. * The mesh that is attached to the controller
  14650. */
  14651. readonly mesh: Nullable<AbstractMesh>;
  14652. /**
  14653. * Gets the ray of the controller in the direction the controller is pointing
  14654. * @param length the length the resulting ray should be
  14655. * @returns a ray in the direction the controller is pointing
  14656. */
  14657. getForwardRay(length?: number): Ray;
  14658. }
  14659. }
  14660. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14661. import { Observable } from "babylonjs/Misc/observable";
  14662. import { Scene } from "babylonjs/scene";
  14663. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14664. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14665. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14666. /**
  14667. * Defines the WebVRController object that represents controllers tracked in 3D space
  14668. */
  14669. export abstract class WebVRController extends PoseEnabledController {
  14670. /**
  14671. * Internal, the default controller model for the controller
  14672. */
  14673. protected _defaultModel: AbstractMesh;
  14674. /**
  14675. * Fired when the trigger state has changed
  14676. */
  14677. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14678. /**
  14679. * Fired when the main button state has changed
  14680. */
  14681. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14682. /**
  14683. * Fired when the secondary button state has changed
  14684. */
  14685. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14686. /**
  14687. * Fired when the pad state has changed
  14688. */
  14689. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14690. /**
  14691. * Fired when controllers stick values have changed
  14692. */
  14693. onPadValuesChangedObservable: Observable<StickValues>;
  14694. /**
  14695. * Array of button availible on the controller
  14696. */
  14697. protected _buttons: Array<MutableGamepadButton>;
  14698. private _onButtonStateChange;
  14699. /**
  14700. * Fired when a controller button's state has changed
  14701. * @param callback the callback containing the button that was modified
  14702. */
  14703. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14704. /**
  14705. * X and Y axis corresponding to the controllers joystick
  14706. */
  14707. pad: StickValues;
  14708. /**
  14709. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14710. */
  14711. hand: string;
  14712. /**
  14713. * The default controller model for the controller
  14714. */
  14715. readonly defaultModel: AbstractMesh;
  14716. /**
  14717. * Creates a new WebVRController from a gamepad
  14718. * @param vrGamepad the gamepad that the WebVRController should be created from
  14719. */
  14720. constructor(vrGamepad: any);
  14721. /**
  14722. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14723. */
  14724. update(): void;
  14725. /**
  14726. * Function to be called when a button is modified
  14727. */
  14728. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14729. /**
  14730. * Loads a mesh and attaches it to the controller
  14731. * @param scene the scene the mesh should be added to
  14732. * @param meshLoaded callback for when the mesh has been loaded
  14733. */
  14734. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14735. private _setButtonValue;
  14736. private _changes;
  14737. private _checkChanges;
  14738. /**
  14739. * Disposes of th webVRCOntroller
  14740. */
  14741. dispose(): void;
  14742. }
  14743. }
  14744. declare module "babylonjs/Lights/hemisphericLight" {
  14745. import { Nullable } from "babylonjs/types";
  14746. import { Scene } from "babylonjs/scene";
  14747. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14748. import { Color3 } from "babylonjs/Maths/math.color";
  14749. import { Effect } from "babylonjs/Materials/effect";
  14750. import { Light } from "babylonjs/Lights/light";
  14751. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14752. /**
  14753. * The HemisphericLight simulates the ambient environment light,
  14754. * so the passed direction is the light reflection direction, not the incoming direction.
  14755. */
  14756. export class HemisphericLight extends Light {
  14757. /**
  14758. * The groundColor is the light in the opposite direction to the one specified during creation.
  14759. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  14760. */
  14761. groundColor: Color3;
  14762. /**
  14763. * The light reflection direction, not the incoming direction.
  14764. */
  14765. direction: Vector3;
  14766. /**
  14767. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14768. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14769. * The HemisphericLight can't cast shadows.
  14770. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14771. * @param name The friendly name of the light
  14772. * @param direction The direction of the light reflection
  14773. * @param scene The scene the light belongs to
  14774. */
  14775. constructor(name: string, direction: Vector3, scene: Scene);
  14776. protected _buildUniformLayout(): void;
  14777. /**
  14778. * Returns the string "HemisphericLight".
  14779. * @return The class name
  14780. */
  14781. getClassName(): string;
  14782. /**
  14783. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14784. * Returns the updated direction.
  14785. * @param target The target the direction should point to
  14786. * @return The computed direction
  14787. */
  14788. setDirectionToTarget(target: Vector3): Vector3;
  14789. /**
  14790. * Returns the shadow generator associated to the light.
  14791. * @returns Always null for hemispheric lights because it does not support shadows.
  14792. */
  14793. getShadowGenerator(): Nullable<IShadowGenerator>;
  14794. /**
  14795. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14796. * @param effect The effect to update
  14797. * @param lightIndex The index of the light in the effect to update
  14798. * @returns The hemispheric light
  14799. */
  14800. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14801. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14802. /**
  14803. * Computes the world matrix of the node
  14804. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14805. * @param useWasUpdatedFlag defines a reserved property
  14806. * @returns the world matrix
  14807. */
  14808. computeWorldMatrix(): Matrix;
  14809. /**
  14810. * Returns the integer 3.
  14811. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14812. */
  14813. getTypeID(): number;
  14814. /**
  14815. * Prepares the list of defines specific to the light type.
  14816. * @param defines the list of defines
  14817. * @param lightIndex defines the index of the light for the effect
  14818. */
  14819. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14820. }
  14821. }
  14822. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14823. /** @hidden */
  14824. export var vrMultiviewToSingleviewPixelShader: {
  14825. name: string;
  14826. shader: string;
  14827. };
  14828. }
  14829. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14830. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14831. import { Scene } from "babylonjs/scene";
  14832. /**
  14833. * Renders to multiple views with a single draw call
  14834. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14835. */
  14836. export class MultiviewRenderTarget extends RenderTargetTexture {
  14837. /**
  14838. * Creates a multiview render target
  14839. * @param scene scene used with the render target
  14840. * @param size the size of the render target (used for each view)
  14841. */
  14842. constructor(scene: Scene, size?: number | {
  14843. width: number;
  14844. height: number;
  14845. } | {
  14846. ratio: number;
  14847. });
  14848. /**
  14849. * @hidden
  14850. * @param faceIndex the face index, if its a cube texture
  14851. */
  14852. _bindFrameBuffer(faceIndex?: number): void;
  14853. /**
  14854. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14855. * @returns the view count
  14856. */
  14857. getViewCount(): number;
  14858. }
  14859. }
  14860. declare module "babylonjs/Maths/math.frustum" {
  14861. import { Matrix } from "babylonjs/Maths/math.vector";
  14862. import { DeepImmutable } from "babylonjs/types";
  14863. import { Plane } from "babylonjs/Maths/math.plane";
  14864. /**
  14865. * Represents a camera frustum
  14866. */
  14867. export class Frustum {
  14868. /**
  14869. * Gets the planes representing the frustum
  14870. * @param transform matrix to be applied to the returned planes
  14871. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14872. */
  14873. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14874. /**
  14875. * Gets the near frustum plane transformed by the transform matrix
  14876. * @param transform transformation matrix to be applied to the resulting frustum plane
  14877. * @param frustumPlane the resuling frustum plane
  14878. */
  14879. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14880. /**
  14881. * Gets the far frustum plane transformed by the transform matrix
  14882. * @param transform transformation matrix to be applied to the resulting frustum plane
  14883. * @param frustumPlane the resuling frustum plane
  14884. */
  14885. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14886. /**
  14887. * Gets the left frustum plane transformed by the transform matrix
  14888. * @param transform transformation matrix to be applied to the resulting frustum plane
  14889. * @param frustumPlane the resuling frustum plane
  14890. */
  14891. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14892. /**
  14893. * Gets the right frustum plane transformed by the transform matrix
  14894. * @param transform transformation matrix to be applied to the resulting frustum plane
  14895. * @param frustumPlane the resuling frustum plane
  14896. */
  14897. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14898. /**
  14899. * Gets the top frustum plane transformed by the transform matrix
  14900. * @param transform transformation matrix to be applied to the resulting frustum plane
  14901. * @param frustumPlane the resuling frustum plane
  14902. */
  14903. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14904. /**
  14905. * Gets the bottom frustum plane transformed by the transform matrix
  14906. * @param transform transformation matrix to be applied to the resulting frustum plane
  14907. * @param frustumPlane the resuling frustum plane
  14908. */
  14909. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14910. /**
  14911. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14912. * @param transform transformation matrix to be applied to the resulting frustum planes
  14913. * @param frustumPlanes the resuling frustum planes
  14914. */
  14915. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14916. }
  14917. }
  14918. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14919. import { Camera } from "babylonjs/Cameras/camera";
  14920. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14921. import { Nullable } from "babylonjs/types";
  14922. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14923. import { Matrix } from "babylonjs/Maths/math.vector";
  14924. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14925. module "babylonjs/Engines/engine" {
  14926. interface Engine {
  14927. /**
  14928. * Creates a new multiview render target
  14929. * @param width defines the width of the texture
  14930. * @param height defines the height of the texture
  14931. * @returns the created multiview texture
  14932. */
  14933. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14934. /**
  14935. * Binds a multiview framebuffer to be drawn to
  14936. * @param multiviewTexture texture to bind
  14937. */
  14938. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14939. }
  14940. }
  14941. module "babylonjs/Cameras/camera" {
  14942. interface Camera {
  14943. /**
  14944. * @hidden
  14945. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  14946. */
  14947. _useMultiviewToSingleView: boolean;
  14948. /**
  14949. * @hidden
  14950. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  14951. */
  14952. _multiviewTexture: Nullable<RenderTargetTexture>;
  14953. /**
  14954. * @hidden
  14955. * ensures the multiview texture of the camera exists and has the specified width/height
  14956. * @param width height to set on the multiview texture
  14957. * @param height width to set on the multiview texture
  14958. */
  14959. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14960. }
  14961. }
  14962. module "babylonjs/scene" {
  14963. interface Scene {
  14964. /** @hidden */
  14965. _transformMatrixR: Matrix;
  14966. /** @hidden */
  14967. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14968. /** @hidden */
  14969. _createMultiviewUbo(): void;
  14970. /** @hidden */
  14971. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14972. /** @hidden */
  14973. _renderMultiviewToSingleView(camera: Camera): void;
  14974. }
  14975. }
  14976. }
  14977. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  14978. import { Camera } from "babylonjs/Cameras/camera";
  14979. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14980. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  14981. import "babylonjs/Engines/Extensions/engine.multiview";
  14982. /**
  14983. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14984. * This will not be used for webXR as it supports displaying texture arrays directly
  14985. */
  14986. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14987. /**
  14988. * Initializes a VRMultiviewToSingleview
  14989. * @param name name of the post process
  14990. * @param camera camera to be applied to
  14991. * @param scaleFactor scaling factor to the size of the output texture
  14992. */
  14993. constructor(name: string, camera: Camera, scaleFactor: number);
  14994. }
  14995. }
  14996. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  14997. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  14998. import { Nullable } from "babylonjs/types";
  14999. import { Size } from "babylonjs/Maths/math.size";
  15000. import { Observable } from "babylonjs/Misc/observable";
  15001. module "babylonjs/Engines/engine" {
  15002. interface Engine {
  15003. /** @hidden */
  15004. _vrDisplay: any;
  15005. /** @hidden */
  15006. _vrSupported: boolean;
  15007. /** @hidden */
  15008. _oldSize: Size;
  15009. /** @hidden */
  15010. _oldHardwareScaleFactor: number;
  15011. /** @hidden */
  15012. _vrExclusivePointerMode: boolean;
  15013. /** @hidden */
  15014. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15015. /** @hidden */
  15016. _onVRDisplayPointerRestricted: () => void;
  15017. /** @hidden */
  15018. _onVRDisplayPointerUnrestricted: () => void;
  15019. /** @hidden */
  15020. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15021. /** @hidden */
  15022. _onVrDisplayDisconnect: Nullable<() => void>;
  15023. /** @hidden */
  15024. _onVrDisplayPresentChange: Nullable<() => void>;
  15025. /**
  15026. * Observable signaled when VR display mode changes
  15027. */
  15028. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15029. /**
  15030. * Observable signaled when VR request present is complete
  15031. */
  15032. onVRRequestPresentComplete: Observable<boolean>;
  15033. /**
  15034. * Observable signaled when VR request present starts
  15035. */
  15036. onVRRequestPresentStart: Observable<Engine>;
  15037. /**
  15038. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15039. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15040. */
  15041. isInVRExclusivePointerMode: boolean;
  15042. /**
  15043. * Gets a boolean indicating if a webVR device was detected
  15044. * @returns true if a webVR device was detected
  15045. */
  15046. isVRDevicePresent(): boolean;
  15047. /**
  15048. * Gets the current webVR device
  15049. * @returns the current webVR device (or null)
  15050. */
  15051. getVRDevice(): any;
  15052. /**
  15053. * Initializes a webVR display and starts listening to display change events
  15054. * The onVRDisplayChangedObservable will be notified upon these changes
  15055. * @returns A promise containing a VRDisplay and if vr is supported
  15056. */
  15057. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15058. /** @hidden */
  15059. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15060. /**
  15061. * Call this function to switch to webVR mode
  15062. * Will do nothing if webVR is not supported or if there is no webVR device
  15063. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15064. */
  15065. enableVR(): void;
  15066. /** @hidden */
  15067. _onVRFullScreenTriggered(): void;
  15068. }
  15069. }
  15070. }
  15071. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15072. import { Nullable } from "babylonjs/types";
  15073. import { Observable } from "babylonjs/Misc/observable";
  15074. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15075. import { Scene } from "babylonjs/scene";
  15076. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15077. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15078. import { Node } from "babylonjs/node";
  15079. import { Ray } from "babylonjs/Culling/ray";
  15080. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15081. import "babylonjs/Engines/Extensions/engine.webVR";
  15082. /**
  15083. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15084. * IMPORTANT!! The data is right-hand data.
  15085. * @export
  15086. * @interface DevicePose
  15087. */
  15088. export interface DevicePose {
  15089. /**
  15090. * The position of the device, values in array are [x,y,z].
  15091. */
  15092. readonly position: Nullable<Float32Array>;
  15093. /**
  15094. * The linearVelocity of the device, values in array are [x,y,z].
  15095. */
  15096. readonly linearVelocity: Nullable<Float32Array>;
  15097. /**
  15098. * The linearAcceleration of the device, values in array are [x,y,z].
  15099. */
  15100. readonly linearAcceleration: Nullable<Float32Array>;
  15101. /**
  15102. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15103. */
  15104. readonly orientation: Nullable<Float32Array>;
  15105. /**
  15106. * The angularVelocity of the device, values in array are [x,y,z].
  15107. */
  15108. readonly angularVelocity: Nullable<Float32Array>;
  15109. /**
  15110. * The angularAcceleration of the device, values in array are [x,y,z].
  15111. */
  15112. readonly angularAcceleration: Nullable<Float32Array>;
  15113. }
  15114. /**
  15115. * Interface representing a pose controlled object in Babylon.
  15116. * A pose controlled object has both regular pose values as well as pose values
  15117. * from an external device such as a VR head mounted display
  15118. */
  15119. export interface PoseControlled {
  15120. /**
  15121. * The position of the object in babylon space.
  15122. */
  15123. position: Vector3;
  15124. /**
  15125. * The rotation quaternion of the object in babylon space.
  15126. */
  15127. rotationQuaternion: Quaternion;
  15128. /**
  15129. * The position of the device in babylon space.
  15130. */
  15131. devicePosition?: Vector3;
  15132. /**
  15133. * The rotation quaternion of the device in babylon space.
  15134. */
  15135. deviceRotationQuaternion: Quaternion;
  15136. /**
  15137. * The raw pose coming from the device.
  15138. */
  15139. rawPose: Nullable<DevicePose>;
  15140. /**
  15141. * The scale of the device to be used when translating from device space to babylon space.
  15142. */
  15143. deviceScaleFactor: number;
  15144. /**
  15145. * Updates the poseControlled values based on the input device pose.
  15146. * @param poseData the pose data to update the object with
  15147. */
  15148. updateFromDevice(poseData: DevicePose): void;
  15149. }
  15150. /**
  15151. * Set of options to customize the webVRCamera
  15152. */
  15153. export interface WebVROptions {
  15154. /**
  15155. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15156. */
  15157. trackPosition?: boolean;
  15158. /**
  15159. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15160. */
  15161. positionScale?: number;
  15162. /**
  15163. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15164. */
  15165. displayName?: string;
  15166. /**
  15167. * Should the native controller meshes be initialized. (default: true)
  15168. */
  15169. controllerMeshes?: boolean;
  15170. /**
  15171. * Creating a default HemiLight only on controllers. (default: true)
  15172. */
  15173. defaultLightingOnControllers?: boolean;
  15174. /**
  15175. * If you don't want to use the default VR button of the helper. (default: false)
  15176. */
  15177. useCustomVRButton?: boolean;
  15178. /**
  15179. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15180. */
  15181. customVRButton?: HTMLButtonElement;
  15182. /**
  15183. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15184. */
  15185. rayLength?: number;
  15186. /**
  15187. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15188. */
  15189. defaultHeight?: number;
  15190. /**
  15191. * If multiview should be used if availible (default: false)
  15192. */
  15193. useMultiview?: boolean;
  15194. }
  15195. /**
  15196. * This represents a WebVR camera.
  15197. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15198. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15199. */
  15200. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15201. private webVROptions;
  15202. /**
  15203. * @hidden
  15204. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15205. */
  15206. _vrDevice: any;
  15207. /**
  15208. * The rawPose of the vrDevice.
  15209. */
  15210. rawPose: Nullable<DevicePose>;
  15211. private _onVREnabled;
  15212. private _specsVersion;
  15213. private _attached;
  15214. private _frameData;
  15215. protected _descendants: Array<Node>;
  15216. private _deviceRoomPosition;
  15217. /** @hidden */
  15218. _deviceRoomRotationQuaternion: Quaternion;
  15219. private _standingMatrix;
  15220. /**
  15221. * Represents device position in babylon space.
  15222. */
  15223. devicePosition: Vector3;
  15224. /**
  15225. * Represents device rotation in babylon space.
  15226. */
  15227. deviceRotationQuaternion: Quaternion;
  15228. /**
  15229. * The scale of the device to be used when translating from device space to babylon space.
  15230. */
  15231. deviceScaleFactor: number;
  15232. private _deviceToWorld;
  15233. private _worldToDevice;
  15234. /**
  15235. * References to the webVR controllers for the vrDevice.
  15236. */
  15237. controllers: Array<WebVRController>;
  15238. /**
  15239. * Emits an event when a controller is attached.
  15240. */
  15241. onControllersAttachedObservable: Observable<WebVRController[]>;
  15242. /**
  15243. * Emits an event when a controller's mesh has been loaded;
  15244. */
  15245. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15246. /**
  15247. * Emits an event when the HMD's pose has been updated.
  15248. */
  15249. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15250. private _poseSet;
  15251. /**
  15252. * If the rig cameras be used as parent instead of this camera.
  15253. */
  15254. rigParenting: boolean;
  15255. private _lightOnControllers;
  15256. private _defaultHeight?;
  15257. /**
  15258. * Instantiates a WebVRFreeCamera.
  15259. * @param name The name of the WebVRFreeCamera
  15260. * @param position The starting anchor position for the camera
  15261. * @param scene The scene the camera belongs to
  15262. * @param webVROptions a set of customizable options for the webVRCamera
  15263. */
  15264. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15265. /**
  15266. * Gets the device distance from the ground in meters.
  15267. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  15268. */
  15269. deviceDistanceToRoomGround(): number;
  15270. /**
  15271. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15272. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15273. */
  15274. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15275. /**
  15276. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15277. * @returns A promise with a boolean set to if the standing matrix is supported.
  15278. */
  15279. useStandingMatrixAsync(): Promise<boolean>;
  15280. /**
  15281. * Disposes the camera
  15282. */
  15283. dispose(): void;
  15284. /**
  15285. * Gets a vrController by name.
  15286. * @param name The name of the controller to retreive
  15287. * @returns the controller matching the name specified or null if not found
  15288. */
  15289. getControllerByName(name: string): Nullable<WebVRController>;
  15290. private _leftController;
  15291. /**
  15292. * The controller corresponding to the users left hand.
  15293. */
  15294. readonly leftController: Nullable<WebVRController>;
  15295. private _rightController;
  15296. /**
  15297. * The controller corresponding to the users right hand.
  15298. */
  15299. readonly rightController: Nullable<WebVRController>;
  15300. /**
  15301. * Casts a ray forward from the vrCamera's gaze.
  15302. * @param length Length of the ray (default: 100)
  15303. * @returns the ray corresponding to the gaze
  15304. */
  15305. getForwardRay(length?: number): Ray;
  15306. /**
  15307. * @hidden
  15308. * Updates the camera based on device's frame data
  15309. */
  15310. _checkInputs(): void;
  15311. /**
  15312. * Updates the poseControlled values based on the input device pose.
  15313. * @param poseData Pose coming from the device
  15314. */
  15315. updateFromDevice(poseData: DevicePose): void;
  15316. private _htmlElementAttached;
  15317. private _detachIfAttached;
  15318. /**
  15319. * WebVR's attach control will start broadcasting frames to the device.
  15320. * Note that in certain browsers (chrome for example) this function must be called
  15321. * within a user-interaction callback. Example:
  15322. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15323. *
  15324. * @param element html element to attach the vrDevice to
  15325. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15326. */
  15327. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15328. /**
  15329. * Detaches the camera from the html element and disables VR
  15330. *
  15331. * @param element html element to detach from
  15332. */
  15333. detachControl(element: HTMLElement): void;
  15334. /**
  15335. * @returns the name of this class
  15336. */
  15337. getClassName(): string;
  15338. /**
  15339. * Calls resetPose on the vrDisplay
  15340. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15341. */
  15342. resetToCurrentRotation(): void;
  15343. /**
  15344. * @hidden
  15345. * Updates the rig cameras (left and right eye)
  15346. */
  15347. _updateRigCameras(): void;
  15348. private _workingVector;
  15349. private _oneVector;
  15350. private _workingMatrix;
  15351. private updateCacheCalled;
  15352. private _correctPositionIfNotTrackPosition;
  15353. /**
  15354. * @hidden
  15355. * Updates the cached values of the camera
  15356. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15357. */
  15358. _updateCache(ignoreParentClass?: boolean): void;
  15359. /**
  15360. * @hidden
  15361. * Get current device position in babylon world
  15362. */
  15363. _computeDevicePosition(): void;
  15364. /**
  15365. * Updates the current device position and rotation in the babylon world
  15366. */
  15367. update(): void;
  15368. /**
  15369. * @hidden
  15370. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15371. * @returns an identity matrix
  15372. */
  15373. _getViewMatrix(): Matrix;
  15374. private _tmpMatrix;
  15375. /**
  15376. * This function is called by the two RIG cameras.
  15377. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15378. * @hidden
  15379. */
  15380. _getWebVRViewMatrix(): Matrix;
  15381. /** @hidden */
  15382. _getWebVRProjectionMatrix(): Matrix;
  15383. private _onGamepadConnectedObserver;
  15384. private _onGamepadDisconnectedObserver;
  15385. private _updateCacheWhenTrackingDisabledObserver;
  15386. /**
  15387. * Initializes the controllers and their meshes
  15388. */
  15389. initControllers(): void;
  15390. }
  15391. }
  15392. declare module "babylonjs/PostProcesses/postProcess" {
  15393. import { Nullable } from "babylonjs/types";
  15394. import { SmartArray } from "babylonjs/Misc/smartArray";
  15395. import { Observable } from "babylonjs/Misc/observable";
  15396. import { Vector2 } from "babylonjs/Maths/math.vector";
  15397. import { Camera } from "babylonjs/Cameras/camera";
  15398. import { Effect } from "babylonjs/Materials/effect";
  15399. import "babylonjs/Shaders/postprocess.vertex";
  15400. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15401. import { Engine } from "babylonjs/Engines/engine";
  15402. import { Color4 } from "babylonjs/Maths/math.color";
  15403. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15404. /**
  15405. * Size options for a post process
  15406. */
  15407. export type PostProcessOptions = {
  15408. width: number;
  15409. height: number;
  15410. };
  15411. /**
  15412. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15413. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15414. */
  15415. export class PostProcess {
  15416. /** Name of the PostProcess. */
  15417. name: string;
  15418. /**
  15419. * Gets or sets the unique id of the post process
  15420. */
  15421. uniqueId: number;
  15422. /**
  15423. * Width of the texture to apply the post process on
  15424. */
  15425. width: number;
  15426. /**
  15427. * Height of the texture to apply the post process on
  15428. */
  15429. height: number;
  15430. /**
  15431. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15432. * @hidden
  15433. */
  15434. _outputTexture: Nullable<InternalTexture>;
  15435. /**
  15436. * Sampling mode used by the shader
  15437. * See https://doc.babylonjs.com/classes/3.1/texture
  15438. */
  15439. renderTargetSamplingMode: number;
  15440. /**
  15441. * Clear color to use when screen clearing
  15442. */
  15443. clearColor: Color4;
  15444. /**
  15445. * If the buffer needs to be cleared before applying the post process. (default: true)
  15446. * Should be set to false if shader will overwrite all previous pixels.
  15447. */
  15448. autoClear: boolean;
  15449. /**
  15450. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15451. */
  15452. alphaMode: number;
  15453. /**
  15454. * Sets the setAlphaBlendConstants of the babylon engine
  15455. */
  15456. alphaConstants: Color4;
  15457. /**
  15458. * Animations to be used for the post processing
  15459. */
  15460. animations: import("babylonjs/Animations/animation").Animation[];
  15461. /**
  15462. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15463. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15464. */
  15465. enablePixelPerfectMode: boolean;
  15466. /**
  15467. * Force the postprocess to be applied without taking in account viewport
  15468. */
  15469. forceFullscreenViewport: boolean;
  15470. /**
  15471. * List of inspectable custom properties (used by the Inspector)
  15472. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15473. */
  15474. inspectableCustomProperties: IInspectable[];
  15475. /**
  15476. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15477. *
  15478. * | Value | Type | Description |
  15479. * | ----- | ----------------------------------- | ----------- |
  15480. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15481. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15482. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15483. *
  15484. */
  15485. scaleMode: number;
  15486. /**
  15487. * Force textures to be a power of two (default: false)
  15488. */
  15489. alwaysForcePOT: boolean;
  15490. private _samples;
  15491. /**
  15492. * Number of sample textures (default: 1)
  15493. */
  15494. samples: number;
  15495. /**
  15496. * Modify the scale of the post process to be the same as the viewport (default: false)
  15497. */
  15498. adaptScaleToCurrentViewport: boolean;
  15499. private _camera;
  15500. private _scene;
  15501. private _engine;
  15502. private _options;
  15503. private _reusable;
  15504. private _textureType;
  15505. /**
  15506. * Smart array of input and output textures for the post process.
  15507. * @hidden
  15508. */
  15509. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15510. /**
  15511. * The index in _textures that corresponds to the output texture.
  15512. * @hidden
  15513. */
  15514. _currentRenderTextureInd: number;
  15515. private _effect;
  15516. private _samplers;
  15517. private _fragmentUrl;
  15518. private _vertexUrl;
  15519. private _parameters;
  15520. private _scaleRatio;
  15521. protected _indexParameters: any;
  15522. private _shareOutputWithPostProcess;
  15523. private _texelSize;
  15524. private _forcedOutputTexture;
  15525. /**
  15526. * Returns the fragment url or shader name used in the post process.
  15527. * @returns the fragment url or name in the shader store.
  15528. */
  15529. getEffectName(): string;
  15530. /**
  15531. * An event triggered when the postprocess is activated.
  15532. */
  15533. onActivateObservable: Observable<Camera>;
  15534. private _onActivateObserver;
  15535. /**
  15536. * A function that is added to the onActivateObservable
  15537. */
  15538. onActivate: Nullable<(camera: Camera) => void>;
  15539. /**
  15540. * An event triggered when the postprocess changes its size.
  15541. */
  15542. onSizeChangedObservable: Observable<PostProcess>;
  15543. private _onSizeChangedObserver;
  15544. /**
  15545. * A function that is added to the onSizeChangedObservable
  15546. */
  15547. onSizeChanged: (postProcess: PostProcess) => void;
  15548. /**
  15549. * An event triggered when the postprocess applies its effect.
  15550. */
  15551. onApplyObservable: Observable<Effect>;
  15552. private _onApplyObserver;
  15553. /**
  15554. * A function that is added to the onApplyObservable
  15555. */
  15556. onApply: (effect: Effect) => void;
  15557. /**
  15558. * An event triggered before rendering the postprocess
  15559. */
  15560. onBeforeRenderObservable: Observable<Effect>;
  15561. private _onBeforeRenderObserver;
  15562. /**
  15563. * A function that is added to the onBeforeRenderObservable
  15564. */
  15565. onBeforeRender: (effect: Effect) => void;
  15566. /**
  15567. * An event triggered after rendering the postprocess
  15568. */
  15569. onAfterRenderObservable: Observable<Effect>;
  15570. private _onAfterRenderObserver;
  15571. /**
  15572. * A function that is added to the onAfterRenderObservable
  15573. */
  15574. onAfterRender: (efect: Effect) => void;
  15575. /**
  15576. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  15577. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15578. */
  15579. inputTexture: InternalTexture;
  15580. /**
  15581. * Gets the camera which post process is applied to.
  15582. * @returns The camera the post process is applied to.
  15583. */
  15584. getCamera(): Camera;
  15585. /**
  15586. * Gets the texel size of the postprocess.
  15587. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15588. */
  15589. readonly texelSize: Vector2;
  15590. /**
  15591. * Creates a new instance PostProcess
  15592. * @param name The name of the PostProcess.
  15593. * @param fragmentUrl The url of the fragment shader to be used.
  15594. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15595. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15596. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15597. * @param camera The camera to apply the render pass to.
  15598. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15599. * @param engine The engine which the post process will be applied. (default: current engine)
  15600. * @param reusable If the post process can be reused on the same frame. (default: false)
  15601. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15602. * @param textureType Type of textures used when performing the post process. (default: 0)
  15603. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15604. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15605. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15606. */
  15607. constructor(
  15608. /** Name of the PostProcess. */
  15609. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean);
  15610. /**
  15611. * Gets a string idenfifying the name of the class
  15612. * @returns "PostProcess" string
  15613. */
  15614. getClassName(): string;
  15615. /**
  15616. * Gets the engine which this post process belongs to.
  15617. * @returns The engine the post process was enabled with.
  15618. */
  15619. getEngine(): Engine;
  15620. /**
  15621. * The effect that is created when initializing the post process.
  15622. * @returns The created effect corresponding the the postprocess.
  15623. */
  15624. getEffect(): Effect;
  15625. /**
  15626. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15627. * @param postProcess The post process to share the output with.
  15628. * @returns This post process.
  15629. */
  15630. shareOutputWith(postProcess: PostProcess): PostProcess;
  15631. /**
  15632. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15633. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15634. */
  15635. useOwnOutput(): void;
  15636. /**
  15637. * Updates the effect with the current post process compile time values and recompiles the shader.
  15638. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15639. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15640. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15641. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15642. * @param onCompiled Called when the shader has been compiled.
  15643. * @param onError Called if there is an error when compiling a shader.
  15644. */
  15645. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15646. /**
  15647. * The post process is reusable if it can be used multiple times within one frame.
  15648. * @returns If the post process is reusable
  15649. */
  15650. isReusable(): boolean;
  15651. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15652. markTextureDirty(): void;
  15653. /**
  15654. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15655. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  15656. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15657. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15658. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15659. * @returns The target texture that was bound to be written to.
  15660. */
  15661. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15662. /**
  15663. * If the post process is supported.
  15664. */
  15665. readonly isSupported: boolean;
  15666. /**
  15667. * The aspect ratio of the output texture.
  15668. */
  15669. readonly aspectRatio: number;
  15670. /**
  15671. * Get a value indicating if the post-process is ready to be used
  15672. * @returns true if the post-process is ready (shader is compiled)
  15673. */
  15674. isReady(): boolean;
  15675. /**
  15676. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15677. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15678. */
  15679. apply(): Nullable<Effect>;
  15680. private _disposeTextures;
  15681. /**
  15682. * Disposes the post process.
  15683. * @param camera The camera to dispose the post process on.
  15684. */
  15685. dispose(camera?: Camera): void;
  15686. }
  15687. }
  15688. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15689. /** @hidden */
  15690. export var kernelBlurVaryingDeclaration: {
  15691. name: string;
  15692. shader: string;
  15693. };
  15694. }
  15695. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15696. /** @hidden */
  15697. export var kernelBlurFragment: {
  15698. name: string;
  15699. shader: string;
  15700. };
  15701. }
  15702. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15703. /** @hidden */
  15704. export var kernelBlurFragment2: {
  15705. name: string;
  15706. shader: string;
  15707. };
  15708. }
  15709. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15710. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15711. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15712. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15713. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15714. /** @hidden */
  15715. export var kernelBlurPixelShader: {
  15716. name: string;
  15717. shader: string;
  15718. };
  15719. }
  15720. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15721. /** @hidden */
  15722. export var kernelBlurVertex: {
  15723. name: string;
  15724. shader: string;
  15725. };
  15726. }
  15727. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15728. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15729. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15730. /** @hidden */
  15731. export var kernelBlurVertexShader: {
  15732. name: string;
  15733. shader: string;
  15734. };
  15735. }
  15736. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15737. import { Vector2 } from "babylonjs/Maths/math.vector";
  15738. import { Nullable } from "babylonjs/types";
  15739. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15740. import { Camera } from "babylonjs/Cameras/camera";
  15741. import { Effect } from "babylonjs/Materials/effect";
  15742. import { Engine } from "babylonjs/Engines/engine";
  15743. import "babylonjs/Shaders/kernelBlur.fragment";
  15744. import "babylonjs/Shaders/kernelBlur.vertex";
  15745. /**
  15746. * The Blur Post Process which blurs an image based on a kernel and direction.
  15747. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15748. */
  15749. export class BlurPostProcess extends PostProcess {
  15750. /** The direction in which to blur the image. */
  15751. direction: Vector2;
  15752. private blockCompilation;
  15753. protected _kernel: number;
  15754. protected _idealKernel: number;
  15755. protected _packedFloat: boolean;
  15756. private _staticDefines;
  15757. /**
  15758. * Sets the length in pixels of the blur sample region
  15759. */
  15760. /**
  15761. * Gets the length in pixels of the blur sample region
  15762. */
  15763. kernel: number;
  15764. /**
  15765. * Sets wether or not the blur needs to unpack/repack floats
  15766. */
  15767. /**
  15768. * Gets wether or not the blur is unpacking/repacking floats
  15769. */
  15770. packedFloat: boolean;
  15771. /**
  15772. * Creates a new instance BlurPostProcess
  15773. * @param name The name of the effect.
  15774. * @param direction The direction in which to blur the image.
  15775. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  15776. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15777. * @param camera The camera to apply the render pass to.
  15778. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15779. * @param engine The engine which the post process will be applied. (default: current engine)
  15780. * @param reusable If the post process can be reused on the same frame. (default: false)
  15781. * @param textureType Type of textures used when performing the post process. (default: 0)
  15782. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  15783. */
  15784. constructor(name: string,
  15785. /** The direction in which to blur the image. */
  15786. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15787. /**
  15788. * Updates the effect with the current post process compile time values and recompiles the shader.
  15789. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15790. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15791. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15792. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15793. * @param onCompiled Called when the shader has been compiled.
  15794. * @param onError Called if there is an error when compiling a shader.
  15795. */
  15796. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15797. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15798. /**
  15799. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15800. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15801. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15802. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15803. * The gaps between physical kernels are compensated for in the weighting of the samples
  15804. * @param idealKernel Ideal blur kernel.
  15805. * @return Nearest best kernel.
  15806. */
  15807. protected _nearestBestKernel(idealKernel: number): number;
  15808. /**
  15809. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15810. * @param x The point on the Gaussian distribution to sample.
  15811. * @return the value of the Gaussian function at x.
  15812. */
  15813. protected _gaussianWeight(x: number): number;
  15814. /**
  15815. * Generates a string that can be used as a floating point number in GLSL.
  15816. * @param x Value to print.
  15817. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15818. * @return GLSL float string.
  15819. */
  15820. protected _glslFloat(x: number, decimalFigures?: number): string;
  15821. }
  15822. }
  15823. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15824. import { Scene } from "babylonjs/scene";
  15825. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15826. import { Plane } from "babylonjs/Maths/math.plane";
  15827. /**
  15828. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15829. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15830. * You can then easily use it as a reflectionTexture on a flat surface.
  15831. * In case the surface is not a plane, please consider relying on reflection probes.
  15832. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15833. */
  15834. export class MirrorTexture extends RenderTargetTexture {
  15835. private scene;
  15836. /**
  15837. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15838. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  15839. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15840. */
  15841. mirrorPlane: Plane;
  15842. /**
  15843. * Define the blur ratio used to blur the reflection if needed.
  15844. */
  15845. blurRatio: number;
  15846. /**
  15847. * Define the adaptive blur kernel used to blur the reflection if needed.
  15848. * This will autocompute the closest best match for the `blurKernel`
  15849. */
  15850. adaptiveBlurKernel: number;
  15851. /**
  15852. * Define the blur kernel used to blur the reflection if needed.
  15853. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15854. */
  15855. blurKernel: number;
  15856. /**
  15857. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15858. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15859. */
  15860. blurKernelX: number;
  15861. /**
  15862. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15863. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15864. */
  15865. blurKernelY: number;
  15866. private _autoComputeBlurKernel;
  15867. protected _onRatioRescale(): void;
  15868. private _updateGammaSpace;
  15869. private _imageProcessingConfigChangeObserver;
  15870. private _transformMatrix;
  15871. private _mirrorMatrix;
  15872. private _savedViewMatrix;
  15873. private _blurX;
  15874. private _blurY;
  15875. private _adaptiveBlurKernel;
  15876. private _blurKernelX;
  15877. private _blurKernelY;
  15878. private _blurRatio;
  15879. /**
  15880. * Instantiates a Mirror Texture.
  15881. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15882. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15883. * You can then easily use it as a reflectionTexture on a flat surface.
  15884. * In case the surface is not a plane, please consider relying on reflection probes.
  15885. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15886. * @param name
  15887. * @param size
  15888. * @param scene
  15889. * @param generateMipMaps
  15890. * @param type
  15891. * @param samplingMode
  15892. * @param generateDepthBuffer
  15893. */
  15894. constructor(name: string, size: number | {
  15895. width: number;
  15896. height: number;
  15897. } | {
  15898. ratio: number;
  15899. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15900. private _preparePostProcesses;
  15901. /**
  15902. * Clone the mirror texture.
  15903. * @returns the cloned texture
  15904. */
  15905. clone(): MirrorTexture;
  15906. /**
  15907. * Serialize the texture to a JSON representation you could use in Parse later on
  15908. * @returns the serialized JSON representation
  15909. */
  15910. serialize(): any;
  15911. /**
  15912. * Dispose the texture and release its associated resources.
  15913. */
  15914. dispose(): void;
  15915. }
  15916. }
  15917. declare module "babylonjs/Materials/Textures/texture" {
  15918. import { Observable } from "babylonjs/Misc/observable";
  15919. import { Nullable } from "babylonjs/types";
  15920. import { Scene } from "babylonjs/scene";
  15921. import { Matrix } from "babylonjs/Maths/math.vector";
  15922. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15923. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15924. import { Engine } from "babylonjs/Engines/engine";
  15925. /**
  15926. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15927. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15928. */
  15929. export class Texture extends BaseTexture {
  15930. /**
  15931. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15932. */
  15933. static SerializeBuffers: boolean;
  15934. /** @hidden */
  15935. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15936. /** @hidden */
  15937. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15938. /** @hidden */
  15939. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15940. /** nearest is mag = nearest and min = nearest and mip = linear */
  15941. static readonly NEAREST_SAMPLINGMODE: number;
  15942. /** nearest is mag = nearest and min = nearest and mip = linear */
  15943. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15944. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15945. static readonly BILINEAR_SAMPLINGMODE: number;
  15946. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15947. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15948. /** Trilinear is mag = linear and min = linear and mip = linear */
  15949. static readonly TRILINEAR_SAMPLINGMODE: number;
  15950. /** Trilinear is mag = linear and min = linear and mip = linear */
  15951. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15952. /** mag = nearest and min = nearest and mip = nearest */
  15953. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15954. /** mag = nearest and min = linear and mip = nearest */
  15955. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15956. /** mag = nearest and min = linear and mip = linear */
  15957. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15958. /** mag = nearest and min = linear and mip = none */
  15959. static readonly NEAREST_LINEAR: number;
  15960. /** mag = nearest and min = nearest and mip = none */
  15961. static readonly NEAREST_NEAREST: number;
  15962. /** mag = linear and min = nearest and mip = nearest */
  15963. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15964. /** mag = linear and min = nearest and mip = linear */
  15965. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15966. /** mag = linear and min = linear and mip = none */
  15967. static readonly LINEAR_LINEAR: number;
  15968. /** mag = linear and min = nearest and mip = none */
  15969. static readonly LINEAR_NEAREST: number;
  15970. /** Explicit coordinates mode */
  15971. static readonly EXPLICIT_MODE: number;
  15972. /** Spherical coordinates mode */
  15973. static readonly SPHERICAL_MODE: number;
  15974. /** Planar coordinates mode */
  15975. static readonly PLANAR_MODE: number;
  15976. /** Cubic coordinates mode */
  15977. static readonly CUBIC_MODE: number;
  15978. /** Projection coordinates mode */
  15979. static readonly PROJECTION_MODE: number;
  15980. /** Inverse Cubic coordinates mode */
  15981. static readonly SKYBOX_MODE: number;
  15982. /** Inverse Cubic coordinates mode */
  15983. static readonly INVCUBIC_MODE: number;
  15984. /** Equirectangular coordinates mode */
  15985. static readonly EQUIRECTANGULAR_MODE: number;
  15986. /** Equirectangular Fixed coordinates mode */
  15987. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15988. /** Equirectangular Fixed Mirrored coordinates mode */
  15989. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15990. /** Texture is not repeating outside of 0..1 UVs */
  15991. static readonly CLAMP_ADDRESSMODE: number;
  15992. /** Texture is repeating outside of 0..1 UVs */
  15993. static readonly WRAP_ADDRESSMODE: number;
  15994. /** Texture is repeating and mirrored */
  15995. static readonly MIRROR_ADDRESSMODE: number;
  15996. /**
  15997. * 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
  15998. */
  15999. static UseSerializedUrlIfAny: boolean;
  16000. /**
  16001. * Define the url of the texture.
  16002. */
  16003. url: Nullable<string>;
  16004. /**
  16005. * Define an offset on the texture to offset the u coordinates of the UVs
  16006. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16007. */
  16008. uOffset: number;
  16009. /**
  16010. * Define an offset on the texture to offset the v coordinates of the UVs
  16011. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16012. */
  16013. vOffset: number;
  16014. /**
  16015. * Define an offset on the texture to scale the u coordinates of the UVs
  16016. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16017. */
  16018. uScale: number;
  16019. /**
  16020. * Define an offset on the texture to scale the v coordinates of the UVs
  16021. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16022. */
  16023. vScale: number;
  16024. /**
  16025. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16026. * @see http://doc.babylonjs.com/how_to/more_materials
  16027. */
  16028. uAng: number;
  16029. /**
  16030. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16031. * @see http://doc.babylonjs.com/how_to/more_materials
  16032. */
  16033. vAng: number;
  16034. /**
  16035. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16036. * @see http://doc.babylonjs.com/how_to/more_materials
  16037. */
  16038. wAng: number;
  16039. /**
  16040. * Defines the center of rotation (U)
  16041. */
  16042. uRotationCenter: number;
  16043. /**
  16044. * Defines the center of rotation (V)
  16045. */
  16046. vRotationCenter: number;
  16047. /**
  16048. * Defines the center of rotation (W)
  16049. */
  16050. wRotationCenter: number;
  16051. /**
  16052. * Are mip maps generated for this texture or not.
  16053. */
  16054. readonly noMipmap: boolean;
  16055. /**
  16056. * List of inspectable custom properties (used by the Inspector)
  16057. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16058. */
  16059. inspectableCustomProperties: Nullable<IInspectable[]>;
  16060. private _noMipmap;
  16061. /** @hidden */
  16062. _invertY: boolean;
  16063. private _rowGenerationMatrix;
  16064. private _cachedTextureMatrix;
  16065. private _projectionModeMatrix;
  16066. private _t0;
  16067. private _t1;
  16068. private _t2;
  16069. private _cachedUOffset;
  16070. private _cachedVOffset;
  16071. private _cachedUScale;
  16072. private _cachedVScale;
  16073. private _cachedUAng;
  16074. private _cachedVAng;
  16075. private _cachedWAng;
  16076. private _cachedProjectionMatrixId;
  16077. private _cachedCoordinatesMode;
  16078. /** @hidden */
  16079. protected _initialSamplingMode: number;
  16080. /** @hidden */
  16081. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  16082. private _deleteBuffer;
  16083. protected _format: Nullable<number>;
  16084. private _delayedOnLoad;
  16085. private _delayedOnError;
  16086. /**
  16087. * Observable triggered once the texture has been loaded.
  16088. */
  16089. onLoadObservable: Observable<Texture>;
  16090. protected _isBlocking: boolean;
  16091. /**
  16092. * Is the texture preventing material to render while loading.
  16093. * If false, a default texture will be used instead of the loading one during the preparation step.
  16094. */
  16095. isBlocking: boolean;
  16096. /**
  16097. * Get the current sampling mode associated with the texture.
  16098. */
  16099. readonly samplingMode: number;
  16100. /**
  16101. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16102. */
  16103. readonly invertY: boolean;
  16104. /**
  16105. * Instantiates a new texture.
  16106. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16107. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16108. * @param url define the url of the picture to load as a texture
  16109. * @param scene define the scene or engine the texture will belong to
  16110. * @param noMipmap define if the texture will require mip maps or not
  16111. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16112. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16113. * @param onLoad define a callback triggered when the texture has been loaded
  16114. * @param onError define a callback triggered when an error occurred during the loading session
  16115. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16116. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16117. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16118. */
  16119. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  16120. /**
  16121. * Update the url (and optional buffer) of this texture if url was null during construction.
  16122. * @param url the url of the texture
  16123. * @param buffer the buffer of the texture (defaults to null)
  16124. * @param onLoad callback called when the texture is loaded (defaults to null)
  16125. */
  16126. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16127. /**
  16128. * Finish the loading sequence of a texture flagged as delayed load.
  16129. * @hidden
  16130. */
  16131. delayLoad(): void;
  16132. private _prepareRowForTextureGeneration;
  16133. /**
  16134. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16135. * @returns the transform matrix of the texture.
  16136. */
  16137. getTextureMatrix(): Matrix;
  16138. /**
  16139. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16140. * @returns The reflection texture transform
  16141. */
  16142. getReflectionTextureMatrix(): Matrix;
  16143. /**
  16144. * Clones the texture.
  16145. * @returns the cloned texture
  16146. */
  16147. clone(): Texture;
  16148. /**
  16149. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16150. * @returns The JSON representation of the texture
  16151. */
  16152. serialize(): any;
  16153. /**
  16154. * Get the current class name of the texture useful for serialization or dynamic coding.
  16155. * @returns "Texture"
  16156. */
  16157. getClassName(): string;
  16158. /**
  16159. * Dispose the texture and release its associated resources.
  16160. */
  16161. dispose(): void;
  16162. /**
  16163. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16164. * @param parsedTexture Define the JSON representation of the texture
  16165. * @param scene Define the scene the parsed texture should be instantiated in
  16166. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16167. * @returns The parsed texture if successful
  16168. */
  16169. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16170. /**
  16171. * Creates a texture from its base 64 representation.
  16172. * @param data Define the base64 payload without the data: prefix
  16173. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16174. * @param scene Define the scene the texture should belong to
  16175. * @param noMipmap Forces the texture to not create mip map information if true
  16176. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16177. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16178. * @param onLoad define a callback triggered when the texture has been loaded
  16179. * @param onError define a callback triggered when an error occurred during the loading session
  16180. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16181. * @returns the created texture
  16182. */
  16183. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16184. /**
  16185. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16186. * @param data Define the base64 payload without the data: prefix
  16187. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16188. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16189. * @param scene Define the scene the texture should belong to
  16190. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16191. * @param noMipmap Forces the texture to not create mip map information if true
  16192. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16193. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16194. * @param onLoad define a callback triggered when the texture has been loaded
  16195. * @param onError define a callback triggered when an error occurred during the loading session
  16196. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16197. * @returns the created texture
  16198. */
  16199. 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;
  16200. }
  16201. }
  16202. declare module "babylonjs/PostProcesses/postProcessManager" {
  16203. import { Nullable } from "babylonjs/types";
  16204. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16205. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16206. import { Scene } from "babylonjs/scene";
  16207. /**
  16208. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16209. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16210. */
  16211. export class PostProcessManager {
  16212. private _scene;
  16213. private _indexBuffer;
  16214. private _vertexBuffers;
  16215. /**
  16216. * Creates a new instance PostProcess
  16217. * @param scene The scene that the post process is associated with.
  16218. */
  16219. constructor(scene: Scene);
  16220. private _prepareBuffers;
  16221. private _buildIndexBuffer;
  16222. /**
  16223. * Rebuilds the vertex buffers of the manager.
  16224. * @hidden
  16225. */
  16226. _rebuild(): void;
  16227. /**
  16228. * Prepares a frame to be run through a post process.
  16229. * @param sourceTexture The input texture to the post procesess. (default: null)
  16230. * @param postProcesses An array of post processes to be run. (default: null)
  16231. * @returns True if the post processes were able to be run.
  16232. * @hidden
  16233. */
  16234. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16235. /**
  16236. * Manually render a set of post processes to a texture.
  16237. * @param postProcesses An array of post processes to be run.
  16238. * @param targetTexture The target texture to render to.
  16239. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16240. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16241. * @param lodLevel defines which lod of the texture to render to
  16242. */
  16243. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16244. /**
  16245. * Finalize the result of the output of the postprocesses.
  16246. * @param doNotPresent If true the result will not be displayed to the screen.
  16247. * @param targetTexture The target texture to render to.
  16248. * @param faceIndex The index of the face to bind the target texture to.
  16249. * @param postProcesses The array of post processes to render.
  16250. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16251. * @hidden
  16252. */
  16253. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16254. /**
  16255. * Disposes of the post process manager.
  16256. */
  16257. dispose(): void;
  16258. }
  16259. }
  16260. declare module "babylonjs/Misc/gradients" {
  16261. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16262. /** Interface used by value gradients (color, factor, ...) */
  16263. export interface IValueGradient {
  16264. /**
  16265. * Gets or sets the gradient value (between 0 and 1)
  16266. */
  16267. gradient: number;
  16268. }
  16269. /** Class used to store color4 gradient */
  16270. export class ColorGradient implements IValueGradient {
  16271. /**
  16272. * Gets or sets the gradient value (between 0 and 1)
  16273. */
  16274. gradient: number;
  16275. /**
  16276. * Gets or sets first associated color
  16277. */
  16278. color1: Color4;
  16279. /**
  16280. * Gets or sets second associated color
  16281. */
  16282. color2?: Color4;
  16283. /**
  16284. * Will get a color picked randomly between color1 and color2.
  16285. * If color2 is undefined then color1 will be used
  16286. * @param result defines the target Color4 to store the result in
  16287. */
  16288. getColorToRef(result: Color4): void;
  16289. }
  16290. /** Class used to store color 3 gradient */
  16291. export class Color3Gradient implements IValueGradient {
  16292. /**
  16293. * Gets or sets the gradient value (between 0 and 1)
  16294. */
  16295. gradient: number;
  16296. /**
  16297. * Gets or sets the associated color
  16298. */
  16299. color: Color3;
  16300. }
  16301. /** Class used to store factor gradient */
  16302. export class FactorGradient implements IValueGradient {
  16303. /**
  16304. * Gets or sets the gradient value (between 0 and 1)
  16305. */
  16306. gradient: number;
  16307. /**
  16308. * Gets or sets first associated factor
  16309. */
  16310. factor1: number;
  16311. /**
  16312. * Gets or sets second associated factor
  16313. */
  16314. factor2?: number;
  16315. /**
  16316. * Will get a number picked randomly between factor1 and factor2.
  16317. * If factor2 is undefined then factor1 will be used
  16318. * @returns the picked number
  16319. */
  16320. getFactor(): number;
  16321. }
  16322. /**
  16323. * Helper used to simplify some generic gradient tasks
  16324. */
  16325. export class GradientHelper {
  16326. /**
  16327. * Gets the current gradient from an array of IValueGradient
  16328. * @param ratio defines the current ratio to get
  16329. * @param gradients defines the array of IValueGradient
  16330. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16331. */
  16332. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16333. }
  16334. }
  16335. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16336. import { Scene } from "babylonjs/scene";
  16337. import { ISceneComponent } from "babylonjs/sceneComponent";
  16338. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16339. module "babylonjs/abstractScene" {
  16340. interface AbstractScene {
  16341. /**
  16342. * The list of procedural textures added to the scene
  16343. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16344. */
  16345. proceduralTextures: Array<ProceduralTexture>;
  16346. }
  16347. }
  16348. /**
  16349. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16350. * in a given scene.
  16351. */
  16352. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16353. /**
  16354. * The component name helpfull to identify the component in the list of scene components.
  16355. */
  16356. readonly name: string;
  16357. /**
  16358. * The scene the component belongs to.
  16359. */
  16360. scene: Scene;
  16361. /**
  16362. * Creates a new instance of the component for the given scene
  16363. * @param scene Defines the scene to register the component in
  16364. */
  16365. constructor(scene: Scene);
  16366. /**
  16367. * Registers the component in a given scene
  16368. */
  16369. register(): void;
  16370. /**
  16371. * Rebuilds the elements related to this component in case of
  16372. * context lost for instance.
  16373. */
  16374. rebuild(): void;
  16375. /**
  16376. * Disposes the component and the associated ressources.
  16377. */
  16378. dispose(): void;
  16379. private _beforeClear;
  16380. }
  16381. }
  16382. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16383. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16384. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16385. module "babylonjs/Engines/engine" {
  16386. interface Engine {
  16387. /**
  16388. * Creates a new render target cube texture
  16389. * @param size defines the size of the texture
  16390. * @param options defines the options used to create the texture
  16391. * @returns a new render target cube texture stored in an InternalTexture
  16392. */
  16393. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16394. }
  16395. }
  16396. }
  16397. declare module "babylonjs/Shaders/procedural.vertex" {
  16398. /** @hidden */
  16399. export var proceduralVertexShader: {
  16400. name: string;
  16401. shader: string;
  16402. };
  16403. }
  16404. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16405. import { Observable } from "babylonjs/Misc/observable";
  16406. import { Nullable } from "babylonjs/types";
  16407. import { Scene } from "babylonjs/scene";
  16408. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16409. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16410. import { Effect } from "babylonjs/Materials/effect";
  16411. import { Texture } from "babylonjs/Materials/Textures/texture";
  16412. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16413. import "babylonjs/Shaders/procedural.vertex";
  16414. /**
  16415. * 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.
  16416. * This is the base class of any Procedural texture and contains most of the shareable code.
  16417. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16418. */
  16419. export class ProceduralTexture extends Texture {
  16420. isCube: boolean;
  16421. /**
  16422. * Define if the texture is enabled or not (disabled texture will not render)
  16423. */
  16424. isEnabled: boolean;
  16425. /**
  16426. * Define if the texture must be cleared before rendering (default is true)
  16427. */
  16428. autoClear: boolean;
  16429. /**
  16430. * Callback called when the texture is generated
  16431. */
  16432. onGenerated: () => void;
  16433. /**
  16434. * Event raised when the texture is generated
  16435. */
  16436. onGeneratedObservable: Observable<ProceduralTexture>;
  16437. /** @hidden */
  16438. _generateMipMaps: boolean;
  16439. /** @hidden **/
  16440. _effect: Effect;
  16441. /** @hidden */
  16442. _textures: {
  16443. [key: string]: Texture;
  16444. };
  16445. private _size;
  16446. private _currentRefreshId;
  16447. private _refreshRate;
  16448. private _vertexBuffers;
  16449. private _indexBuffer;
  16450. private _uniforms;
  16451. private _samplers;
  16452. private _fragment;
  16453. private _floats;
  16454. private _ints;
  16455. private _floatsArrays;
  16456. private _colors3;
  16457. private _colors4;
  16458. private _vectors2;
  16459. private _vectors3;
  16460. private _matrices;
  16461. private _fallbackTexture;
  16462. private _fallbackTextureUsed;
  16463. private _engine;
  16464. private _cachedDefines;
  16465. private _contentUpdateId;
  16466. private _contentData;
  16467. /**
  16468. * Instantiates a new procedural texture.
  16469. * 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.
  16470. * This is the base class of any Procedural texture and contains most of the shareable code.
  16471. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16472. * @param name Define the name of the texture
  16473. * @param size Define the size of the texture to create
  16474. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16475. * @param scene Define the scene the texture belongs to
  16476. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16477. * @param generateMipMaps Define if the texture should creates mip maps or not
  16478. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16479. */
  16480. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16481. /**
  16482. * The effect that is created when initializing the post process.
  16483. * @returns The created effect corresponding the the postprocess.
  16484. */
  16485. getEffect(): Effect;
  16486. /**
  16487. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16488. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16489. */
  16490. getContent(): Nullable<ArrayBufferView>;
  16491. private _createIndexBuffer;
  16492. /** @hidden */
  16493. _rebuild(): void;
  16494. /**
  16495. * Resets the texture in order to recreate its associated resources.
  16496. * This can be called in case of context loss
  16497. */
  16498. reset(): void;
  16499. protected _getDefines(): string;
  16500. /**
  16501. * Is the texture ready to be used ? (rendered at least once)
  16502. * @returns true if ready, otherwise, false.
  16503. */
  16504. isReady(): boolean;
  16505. /**
  16506. * Resets the refresh counter of the texture and start bak from scratch.
  16507. * Could be useful to regenerate the texture if it is setup to render only once.
  16508. */
  16509. resetRefreshCounter(): void;
  16510. /**
  16511. * Set the fragment shader to use in order to render the texture.
  16512. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16513. */
  16514. setFragment(fragment: any): void;
  16515. /**
  16516. * Define the refresh rate of the texture or the rendering frequency.
  16517. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16518. */
  16519. refreshRate: number;
  16520. /** @hidden */
  16521. _shouldRender(): boolean;
  16522. /**
  16523. * Get the size the texture is rendering at.
  16524. * @returns the size (texture is always squared)
  16525. */
  16526. getRenderSize(): number;
  16527. /**
  16528. * Resize the texture to new value.
  16529. * @param size Define the new size the texture should have
  16530. * @param generateMipMaps Define whether the new texture should create mip maps
  16531. */
  16532. resize(size: number, generateMipMaps: boolean): void;
  16533. private _checkUniform;
  16534. /**
  16535. * Set a texture in the shader program used to render.
  16536. * @param name Define the name of the uniform samplers as defined in the shader
  16537. * @param texture Define the texture to bind to this sampler
  16538. * @return the texture itself allowing "fluent" like uniform updates
  16539. */
  16540. setTexture(name: string, texture: Texture): ProceduralTexture;
  16541. /**
  16542. * Set a float in the shader.
  16543. * @param name Define the name of the uniform as defined in the shader
  16544. * @param value Define the value to give to the uniform
  16545. * @return the texture itself allowing "fluent" like uniform updates
  16546. */
  16547. setFloat(name: string, value: number): ProceduralTexture;
  16548. /**
  16549. * Set a int in the shader.
  16550. * @param name Define the name of the uniform as defined in the shader
  16551. * @param value Define the value to give to the uniform
  16552. * @return the texture itself allowing "fluent" like uniform updates
  16553. */
  16554. setInt(name: string, value: number): ProceduralTexture;
  16555. /**
  16556. * Set an array of floats in the shader.
  16557. * @param name Define the name of the uniform as defined in the shader
  16558. * @param value Define the value to give to the uniform
  16559. * @return the texture itself allowing "fluent" like uniform updates
  16560. */
  16561. setFloats(name: string, value: number[]): ProceduralTexture;
  16562. /**
  16563. * Set a vec3 in the shader from a Color3.
  16564. * @param name Define the name of the uniform as defined in the shader
  16565. * @param value Define the value to give to the uniform
  16566. * @return the texture itself allowing "fluent" like uniform updates
  16567. */
  16568. setColor3(name: string, value: Color3): ProceduralTexture;
  16569. /**
  16570. * Set a vec4 in the shader from a Color4.
  16571. * @param name Define the name of the uniform as defined in the shader
  16572. * @param value Define the value to give to the uniform
  16573. * @return the texture itself allowing "fluent" like uniform updates
  16574. */
  16575. setColor4(name: string, value: Color4): ProceduralTexture;
  16576. /**
  16577. * Set a vec2 in the shader from a Vector2.
  16578. * @param name Define the name of the uniform as defined in the shader
  16579. * @param value Define the value to give to the uniform
  16580. * @return the texture itself allowing "fluent" like uniform updates
  16581. */
  16582. setVector2(name: string, value: Vector2): ProceduralTexture;
  16583. /**
  16584. * Set a vec3 in the shader from a Vector3.
  16585. * @param name Define the name of the uniform as defined in the shader
  16586. * @param value Define the value to give to the uniform
  16587. * @return the texture itself allowing "fluent" like uniform updates
  16588. */
  16589. setVector3(name: string, value: Vector3): ProceduralTexture;
  16590. /**
  16591. * Set a mat4 in the shader from a MAtrix.
  16592. * @param name Define the name of the uniform as defined in the shader
  16593. * @param value Define the value to give to the uniform
  16594. * @return the texture itself allowing "fluent" like uniform updates
  16595. */
  16596. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16597. /**
  16598. * Render the texture to its associated render target.
  16599. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16600. */
  16601. render(useCameraPostProcess?: boolean): void;
  16602. /**
  16603. * Clone the texture.
  16604. * @returns the cloned texture
  16605. */
  16606. clone(): ProceduralTexture;
  16607. /**
  16608. * Dispose the texture and release its asoociated resources.
  16609. */
  16610. dispose(): void;
  16611. }
  16612. }
  16613. declare module "babylonjs/Particles/baseParticleSystem" {
  16614. import { Nullable } from "babylonjs/types";
  16615. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16616. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16617. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16618. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16619. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16620. import { Scene } from "babylonjs/scene";
  16621. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16622. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16623. import { Texture } from "babylonjs/Materials/Textures/texture";
  16624. import { Color4 } from "babylonjs/Maths/math.color";
  16625. import { Animation } from "babylonjs/Animations/animation";
  16626. /**
  16627. * This represents the base class for particle system in Babylon.
  16628. * 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.
  16629. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16630. * @example https://doc.babylonjs.com/babylon101/particles
  16631. */
  16632. export class BaseParticleSystem {
  16633. /**
  16634. * Source color is added to the destination color without alpha affecting the result
  16635. */
  16636. static BLENDMODE_ONEONE: number;
  16637. /**
  16638. * Blend current color and particle color using particle’s alpha
  16639. */
  16640. static BLENDMODE_STANDARD: number;
  16641. /**
  16642. * Add current color and particle color multiplied by particle’s alpha
  16643. */
  16644. static BLENDMODE_ADD: number;
  16645. /**
  16646. * Multiply current color with particle color
  16647. */
  16648. static BLENDMODE_MULTIPLY: number;
  16649. /**
  16650. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16651. */
  16652. static BLENDMODE_MULTIPLYADD: number;
  16653. /**
  16654. * List of animations used by the particle system.
  16655. */
  16656. animations: Animation[];
  16657. /**
  16658. * The id of the Particle system.
  16659. */
  16660. id: string;
  16661. /**
  16662. * The friendly name of the Particle system.
  16663. */
  16664. name: string;
  16665. /**
  16666. * The rendering group used by the Particle system to chose when to render.
  16667. */
  16668. renderingGroupId: number;
  16669. /**
  16670. * The emitter represents the Mesh or position we are attaching the particle system to.
  16671. */
  16672. emitter: Nullable<AbstractMesh | Vector3>;
  16673. /**
  16674. * The maximum number of particles to emit per frame
  16675. */
  16676. emitRate: number;
  16677. /**
  16678. * If you want to launch only a few particles at once, that can be done, as well.
  16679. */
  16680. manualEmitCount: number;
  16681. /**
  16682. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16683. */
  16684. updateSpeed: number;
  16685. /**
  16686. * The amount of time the particle system is running (depends of the overall update speed).
  16687. */
  16688. targetStopDuration: number;
  16689. /**
  16690. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16691. */
  16692. disposeOnStop: boolean;
  16693. /**
  16694. * Minimum power of emitting particles.
  16695. */
  16696. minEmitPower: number;
  16697. /**
  16698. * Maximum power of emitting particles.
  16699. */
  16700. maxEmitPower: number;
  16701. /**
  16702. * Minimum life time of emitting particles.
  16703. */
  16704. minLifeTime: number;
  16705. /**
  16706. * Maximum life time of emitting particles.
  16707. */
  16708. maxLifeTime: number;
  16709. /**
  16710. * Minimum Size of emitting particles.
  16711. */
  16712. minSize: number;
  16713. /**
  16714. * Maximum Size of emitting particles.
  16715. */
  16716. maxSize: number;
  16717. /**
  16718. * Minimum scale of emitting particles on X axis.
  16719. */
  16720. minScaleX: number;
  16721. /**
  16722. * Maximum scale of emitting particles on X axis.
  16723. */
  16724. maxScaleX: number;
  16725. /**
  16726. * Minimum scale of emitting particles on Y axis.
  16727. */
  16728. minScaleY: number;
  16729. /**
  16730. * Maximum scale of emitting particles on Y axis.
  16731. */
  16732. maxScaleY: number;
  16733. /**
  16734. * Gets or sets the minimal initial rotation in radians.
  16735. */
  16736. minInitialRotation: number;
  16737. /**
  16738. * Gets or sets the maximal initial rotation in radians.
  16739. */
  16740. maxInitialRotation: number;
  16741. /**
  16742. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16743. */
  16744. minAngularSpeed: number;
  16745. /**
  16746. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16747. */
  16748. maxAngularSpeed: number;
  16749. /**
  16750. * The texture used to render each particle. (this can be a spritesheet)
  16751. */
  16752. particleTexture: Nullable<Texture>;
  16753. /**
  16754. * The layer mask we are rendering the particles through.
  16755. */
  16756. layerMask: number;
  16757. /**
  16758. * This can help using your own shader to render the particle system.
  16759. * The according effect will be created
  16760. */
  16761. customShader: any;
  16762. /**
  16763. * By default particle system starts as soon as they are created. This prevents the
  16764. * automatic start to happen and let you decide when to start emitting particles.
  16765. */
  16766. preventAutoStart: boolean;
  16767. private _noiseTexture;
  16768. /**
  16769. * Gets or sets a texture used to add random noise to particle positions
  16770. */
  16771. noiseTexture: Nullable<ProceduralTexture>;
  16772. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16773. noiseStrength: Vector3;
  16774. /**
  16775. * Callback triggered when the particle animation is ending.
  16776. */
  16777. onAnimationEnd: Nullable<() => void>;
  16778. /**
  16779. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16780. */
  16781. blendMode: number;
  16782. /**
  16783. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16784. * to override the particles.
  16785. */
  16786. forceDepthWrite: boolean;
  16787. /** 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 */
  16788. preWarmCycles: number;
  16789. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16790. preWarmStepOffset: number;
  16791. /**
  16792. * 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)
  16793. */
  16794. spriteCellChangeSpeed: number;
  16795. /**
  16796. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16797. */
  16798. startSpriteCellID: number;
  16799. /**
  16800. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16801. */
  16802. endSpriteCellID: number;
  16803. /**
  16804. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16805. */
  16806. spriteCellWidth: number;
  16807. /**
  16808. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16809. */
  16810. spriteCellHeight: number;
  16811. /**
  16812. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16813. */
  16814. spriteRandomStartCell: boolean;
  16815. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16816. translationPivot: Vector2;
  16817. /** @hidden */
  16818. protected _isAnimationSheetEnabled: boolean;
  16819. /**
  16820. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16821. */
  16822. beginAnimationOnStart: boolean;
  16823. /**
  16824. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16825. */
  16826. beginAnimationFrom: number;
  16827. /**
  16828. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16829. */
  16830. beginAnimationTo: number;
  16831. /**
  16832. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16833. */
  16834. beginAnimationLoop: boolean;
  16835. /**
  16836. * Gets or sets a world offset applied to all particles
  16837. */
  16838. worldOffset: Vector3;
  16839. /**
  16840. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16841. */
  16842. isAnimationSheetEnabled: boolean;
  16843. /**
  16844. * Get hosting scene
  16845. * @returns the scene
  16846. */
  16847. getScene(): Scene;
  16848. /**
  16849. * You can use gravity if you want to give an orientation to your particles.
  16850. */
  16851. gravity: Vector3;
  16852. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16853. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16854. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16855. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16856. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16857. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16858. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16859. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16860. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16861. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16862. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16863. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16864. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16865. /**
  16866. * Defines the delay in milliseconds before starting the system (0 by default)
  16867. */
  16868. startDelay: number;
  16869. /**
  16870. * Gets the current list of drag gradients.
  16871. * You must use addDragGradient and removeDragGradient to udpate this list
  16872. * @returns the list of drag gradients
  16873. */
  16874. getDragGradients(): Nullable<Array<FactorGradient>>;
  16875. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16876. limitVelocityDamping: number;
  16877. /**
  16878. * Gets the current list of limit velocity gradients.
  16879. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16880. * @returns the list of limit velocity gradients
  16881. */
  16882. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16883. /**
  16884. * Gets the current list of color gradients.
  16885. * You must use addColorGradient and removeColorGradient to udpate this list
  16886. * @returns the list of color gradients
  16887. */
  16888. getColorGradients(): Nullable<Array<ColorGradient>>;
  16889. /**
  16890. * Gets the current list of size gradients.
  16891. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16892. * @returns the list of size gradients
  16893. */
  16894. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16895. /**
  16896. * Gets the current list of color remap gradients.
  16897. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16898. * @returns the list of color remap gradients
  16899. */
  16900. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16901. /**
  16902. * Gets the current list of alpha remap gradients.
  16903. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16904. * @returns the list of alpha remap gradients
  16905. */
  16906. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16907. /**
  16908. * Gets the current list of life time gradients.
  16909. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16910. * @returns the list of life time gradients
  16911. */
  16912. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16913. /**
  16914. * Gets the current list of angular speed gradients.
  16915. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16916. * @returns the list of angular speed gradients
  16917. */
  16918. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16919. /**
  16920. * Gets the current list of velocity gradients.
  16921. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16922. * @returns the list of velocity gradients
  16923. */
  16924. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16925. /**
  16926. * Gets the current list of start size gradients.
  16927. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16928. * @returns the list of start size gradients
  16929. */
  16930. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16931. /**
  16932. * Gets the current list of emit rate gradients.
  16933. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16934. * @returns the list of emit rate gradients
  16935. */
  16936. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16937. /**
  16938. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16939. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16940. */
  16941. direction1: Vector3;
  16942. /**
  16943. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16944. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16945. */
  16946. direction2: Vector3;
  16947. /**
  16948. * 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.
  16949. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16950. */
  16951. minEmitBox: Vector3;
  16952. /**
  16953. * 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.
  16954. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16955. */
  16956. maxEmitBox: Vector3;
  16957. /**
  16958. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16959. */
  16960. color1: Color4;
  16961. /**
  16962. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16963. */
  16964. color2: Color4;
  16965. /**
  16966. * Color the particle will have at the end of its lifetime
  16967. */
  16968. colorDead: Color4;
  16969. /**
  16970. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16971. */
  16972. textureMask: Color4;
  16973. /**
  16974. * The particle emitter type defines the emitter used by the particle system.
  16975. * It can be for example box, sphere, or cone...
  16976. */
  16977. particleEmitterType: IParticleEmitterType;
  16978. /** @hidden */
  16979. _isSubEmitter: boolean;
  16980. /**
  16981. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16982. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16983. */
  16984. billboardMode: number;
  16985. protected _isBillboardBased: boolean;
  16986. /**
  16987. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16988. */
  16989. isBillboardBased: boolean;
  16990. /**
  16991. * The scene the particle system belongs to.
  16992. */
  16993. protected _scene: Scene;
  16994. /**
  16995. * Local cache of defines for image processing.
  16996. */
  16997. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16998. /**
  16999. * Default configuration related to image processing available in the standard Material.
  17000. */
  17001. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17002. /**
  17003. * Gets the image processing configuration used either in this material.
  17004. */
  17005. /**
  17006. * Sets the Default image processing configuration used either in the this material.
  17007. *
  17008. * If sets to null, the scene one is in use.
  17009. */
  17010. imageProcessingConfiguration: ImageProcessingConfiguration;
  17011. /**
  17012. * Attaches a new image processing configuration to the Standard Material.
  17013. * @param configuration
  17014. */
  17015. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17016. /** @hidden */
  17017. protected _reset(): void;
  17018. /** @hidden */
  17019. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17020. /**
  17021. * Instantiates a particle system.
  17022. * 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.
  17023. * @param name The name of the particle system
  17024. */
  17025. constructor(name: string);
  17026. /**
  17027. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17028. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17029. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17030. * @returns the emitter
  17031. */
  17032. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17033. /**
  17034. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17035. * @param radius The radius of the hemisphere to emit from
  17036. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17037. * @returns the emitter
  17038. */
  17039. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17040. /**
  17041. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17042. * @param radius The radius of the sphere to emit from
  17043. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17044. * @returns the emitter
  17045. */
  17046. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17047. /**
  17048. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17049. * @param radius The radius of the sphere to emit from
  17050. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17051. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17052. * @returns the emitter
  17053. */
  17054. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17055. /**
  17056. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17057. * @param radius The radius of the emission cylinder
  17058. * @param height The height of the emission cylinder
  17059. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17060. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17061. * @returns the emitter
  17062. */
  17063. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17064. /**
  17065. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17066. * @param radius The radius of the cylinder to emit from
  17067. * @param height The height of the emission cylinder
  17068. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17069. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17070. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17071. * @returns the emitter
  17072. */
  17073. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17074. /**
  17075. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17076. * @param radius The radius of the cone to emit from
  17077. * @param angle The base angle of the cone
  17078. * @returns the emitter
  17079. */
  17080. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17081. /**
  17082. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17083. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17084. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17085. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17086. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17087. * @returns the emitter
  17088. */
  17089. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17090. }
  17091. }
  17092. declare module "babylonjs/Particles/subEmitter" {
  17093. import { Scene } from "babylonjs/scene";
  17094. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17095. /**
  17096. * Type of sub emitter
  17097. */
  17098. export enum SubEmitterType {
  17099. /**
  17100. * Attached to the particle over it's lifetime
  17101. */
  17102. ATTACHED = 0,
  17103. /**
  17104. * Created when the particle dies
  17105. */
  17106. END = 1
  17107. }
  17108. /**
  17109. * Sub emitter class used to emit particles from an existing particle
  17110. */
  17111. export class SubEmitter {
  17112. /**
  17113. * the particle system to be used by the sub emitter
  17114. */
  17115. particleSystem: ParticleSystem;
  17116. /**
  17117. * Type of the submitter (Default: END)
  17118. */
  17119. type: SubEmitterType;
  17120. /**
  17121. * 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)
  17122. * Note: This only is supported when using an emitter of type Mesh
  17123. */
  17124. inheritDirection: boolean;
  17125. /**
  17126. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17127. */
  17128. inheritedVelocityAmount: number;
  17129. /**
  17130. * Creates a sub emitter
  17131. * @param particleSystem the particle system to be used by the sub emitter
  17132. */
  17133. constructor(
  17134. /**
  17135. * the particle system to be used by the sub emitter
  17136. */
  17137. particleSystem: ParticleSystem);
  17138. /**
  17139. * Clones the sub emitter
  17140. * @returns the cloned sub emitter
  17141. */
  17142. clone(): SubEmitter;
  17143. /**
  17144. * Serialize current object to a JSON object
  17145. * @returns the serialized object
  17146. */
  17147. serialize(): any;
  17148. /** @hidden */
  17149. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17150. /**
  17151. * Creates a new SubEmitter from a serialized JSON version
  17152. * @param serializationObject defines the JSON object to read from
  17153. * @param scene defines the hosting scene
  17154. * @param rootUrl defines the rootUrl for data loading
  17155. * @returns a new SubEmitter
  17156. */
  17157. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17158. /** Release associated resources */
  17159. dispose(): void;
  17160. }
  17161. }
  17162. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17163. /** @hidden */
  17164. export var clipPlaneFragmentDeclaration: {
  17165. name: string;
  17166. shader: string;
  17167. };
  17168. }
  17169. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17170. /** @hidden */
  17171. export var imageProcessingDeclaration: {
  17172. name: string;
  17173. shader: string;
  17174. };
  17175. }
  17176. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17177. /** @hidden */
  17178. export var imageProcessingFunctions: {
  17179. name: string;
  17180. shader: string;
  17181. };
  17182. }
  17183. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17184. /** @hidden */
  17185. export var clipPlaneFragment: {
  17186. name: string;
  17187. shader: string;
  17188. };
  17189. }
  17190. declare module "babylonjs/Shaders/particles.fragment" {
  17191. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17192. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17193. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17194. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17195. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17196. /** @hidden */
  17197. export var particlesPixelShader: {
  17198. name: string;
  17199. shader: string;
  17200. };
  17201. }
  17202. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17203. /** @hidden */
  17204. export var clipPlaneVertexDeclaration: {
  17205. name: string;
  17206. shader: string;
  17207. };
  17208. }
  17209. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17210. /** @hidden */
  17211. export var clipPlaneVertex: {
  17212. name: string;
  17213. shader: string;
  17214. };
  17215. }
  17216. declare module "babylonjs/Shaders/particles.vertex" {
  17217. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17218. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17219. /** @hidden */
  17220. export var particlesVertexShader: {
  17221. name: string;
  17222. shader: string;
  17223. };
  17224. }
  17225. declare module "babylonjs/Particles/particleSystem" {
  17226. import { Nullable } from "babylonjs/types";
  17227. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17228. import { Observable } from "babylonjs/Misc/observable";
  17229. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17230. import { Effect } from "babylonjs/Materials/effect";
  17231. import { Scene, IDisposable } from "babylonjs/scene";
  17232. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17233. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17234. import { Particle } from "babylonjs/Particles/particle";
  17235. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17236. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17237. import "babylonjs/Shaders/particles.fragment";
  17238. import "babylonjs/Shaders/particles.vertex";
  17239. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17240. /**
  17241. * This represents a particle system in Babylon.
  17242. * 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.
  17243. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17244. * @example https://doc.babylonjs.com/babylon101/particles
  17245. */
  17246. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17247. /**
  17248. * Billboard mode will only apply to Y axis
  17249. */
  17250. static readonly BILLBOARDMODE_Y: number;
  17251. /**
  17252. * Billboard mode will apply to all axes
  17253. */
  17254. static readonly BILLBOARDMODE_ALL: number;
  17255. /**
  17256. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17257. */
  17258. static readonly BILLBOARDMODE_STRETCHED: number;
  17259. /**
  17260. * This function can be defined to provide custom update for active particles.
  17261. * This function will be called instead of regular update (age, position, color, etc.).
  17262. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17263. */
  17264. updateFunction: (particles: Particle[]) => void;
  17265. private _emitterWorldMatrix;
  17266. /**
  17267. * This function can be defined to specify initial direction for every new particle.
  17268. * It by default use the emitterType defined function
  17269. */
  17270. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17271. /**
  17272. * This function can be defined to specify initial position for every new particle.
  17273. * It by default use the emitterType defined function
  17274. */
  17275. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17276. /**
  17277. * @hidden
  17278. */
  17279. _inheritedVelocityOffset: Vector3;
  17280. /**
  17281. * An event triggered when the system is disposed
  17282. */
  17283. onDisposeObservable: Observable<ParticleSystem>;
  17284. private _onDisposeObserver;
  17285. /**
  17286. * Sets a callback that will be triggered when the system is disposed
  17287. */
  17288. onDispose: () => void;
  17289. private _particles;
  17290. private _epsilon;
  17291. private _capacity;
  17292. private _stockParticles;
  17293. private _newPartsExcess;
  17294. private _vertexData;
  17295. private _vertexBuffer;
  17296. private _vertexBuffers;
  17297. private _spriteBuffer;
  17298. private _indexBuffer;
  17299. private _effect;
  17300. private _customEffect;
  17301. private _cachedDefines;
  17302. private _scaledColorStep;
  17303. private _colorDiff;
  17304. private _scaledDirection;
  17305. private _scaledGravity;
  17306. private _currentRenderId;
  17307. private _alive;
  17308. private _useInstancing;
  17309. private _started;
  17310. private _stopped;
  17311. private _actualFrame;
  17312. private _scaledUpdateSpeed;
  17313. private _vertexBufferSize;
  17314. /** @hidden */
  17315. _currentEmitRateGradient: Nullable<FactorGradient>;
  17316. /** @hidden */
  17317. _currentEmitRate1: number;
  17318. /** @hidden */
  17319. _currentEmitRate2: number;
  17320. /** @hidden */
  17321. _currentStartSizeGradient: Nullable<FactorGradient>;
  17322. /** @hidden */
  17323. _currentStartSize1: number;
  17324. /** @hidden */
  17325. _currentStartSize2: number;
  17326. private readonly _rawTextureWidth;
  17327. private _rampGradientsTexture;
  17328. private _useRampGradients;
  17329. /** Gets or sets a boolean indicating that ramp gradients must be used
  17330. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17331. */
  17332. useRampGradients: boolean;
  17333. /**
  17334. * 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.
  17335. * 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: [])
  17336. */
  17337. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17338. private _subEmitters;
  17339. /**
  17340. * @hidden
  17341. * If the particle systems emitter should be disposed when the particle system is disposed
  17342. */
  17343. _disposeEmitterOnDispose: boolean;
  17344. /**
  17345. * The current active Sub-systems, this property is used by the root particle system only.
  17346. */
  17347. activeSubSystems: Array<ParticleSystem>;
  17348. private _rootParticleSystem;
  17349. /**
  17350. * Gets the current list of active particles
  17351. */
  17352. readonly particles: Particle[];
  17353. /**
  17354. * Returns the string "ParticleSystem"
  17355. * @returns a string containing the class name
  17356. */
  17357. getClassName(): string;
  17358. /**
  17359. * Instantiates a particle system.
  17360. * 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.
  17361. * @param name The name of the particle system
  17362. * @param capacity The max number of particles alive at the same time
  17363. * @param scene The scene the particle system belongs to
  17364. * @param customEffect a custom effect used to change the way particles are rendered by default
  17365. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17366. * @param epsilon Offset used to render the particles
  17367. */
  17368. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17369. private _addFactorGradient;
  17370. private _removeFactorGradient;
  17371. /**
  17372. * Adds a new life time gradient
  17373. * @param gradient defines the gradient to use (between 0 and 1)
  17374. * @param factor defines the life time factor to affect to the specified gradient
  17375. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17376. * @returns the current particle system
  17377. */
  17378. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17379. /**
  17380. * Remove a specific life time gradient
  17381. * @param gradient defines the gradient to remove
  17382. * @returns the current particle system
  17383. */
  17384. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17385. /**
  17386. * Adds a new size gradient
  17387. * @param gradient defines the gradient to use (between 0 and 1)
  17388. * @param factor defines the size factor to affect to the specified gradient
  17389. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17390. * @returns the current particle system
  17391. */
  17392. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17393. /**
  17394. * Remove a specific size gradient
  17395. * @param gradient defines the gradient to remove
  17396. * @returns the current particle system
  17397. */
  17398. removeSizeGradient(gradient: number): IParticleSystem;
  17399. /**
  17400. * Adds a new color remap gradient
  17401. * @param gradient defines the gradient to use (between 0 and 1)
  17402. * @param min defines the color remap minimal range
  17403. * @param max defines the color remap maximal range
  17404. * @returns the current particle system
  17405. */
  17406. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17407. /**
  17408. * Remove a specific color remap gradient
  17409. * @param gradient defines the gradient to remove
  17410. * @returns the current particle system
  17411. */
  17412. removeColorRemapGradient(gradient: number): IParticleSystem;
  17413. /**
  17414. * Adds a new alpha remap gradient
  17415. * @param gradient defines the gradient to use (between 0 and 1)
  17416. * @param min defines the alpha remap minimal range
  17417. * @param max defines the alpha remap maximal range
  17418. * @returns the current particle system
  17419. */
  17420. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17421. /**
  17422. * Remove a specific alpha remap gradient
  17423. * @param gradient defines the gradient to remove
  17424. * @returns the current particle system
  17425. */
  17426. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17427. /**
  17428. * Adds a new angular speed gradient
  17429. * @param gradient defines the gradient to use (between 0 and 1)
  17430. * @param factor defines the angular speed to affect to the specified gradient
  17431. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17432. * @returns the current particle system
  17433. */
  17434. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17435. /**
  17436. * Remove a specific angular speed gradient
  17437. * @param gradient defines the gradient to remove
  17438. * @returns the current particle system
  17439. */
  17440. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17441. /**
  17442. * Adds a new velocity gradient
  17443. * @param gradient defines the gradient to use (between 0 and 1)
  17444. * @param factor defines the velocity to affect to the specified gradient
  17445. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17446. * @returns the current particle system
  17447. */
  17448. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17449. /**
  17450. * Remove a specific velocity gradient
  17451. * @param gradient defines the gradient to remove
  17452. * @returns the current particle system
  17453. */
  17454. removeVelocityGradient(gradient: number): IParticleSystem;
  17455. /**
  17456. * Adds a new limit velocity gradient
  17457. * @param gradient defines the gradient to use (between 0 and 1)
  17458. * @param factor defines the limit velocity value to affect to the specified gradient
  17459. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17460. * @returns the current particle system
  17461. */
  17462. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17463. /**
  17464. * Remove a specific limit velocity gradient
  17465. * @param gradient defines the gradient to remove
  17466. * @returns the current particle system
  17467. */
  17468. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17469. /**
  17470. * Adds a new drag gradient
  17471. * @param gradient defines the gradient to use (between 0 and 1)
  17472. * @param factor defines the drag value to affect to the specified gradient
  17473. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17474. * @returns the current particle system
  17475. */
  17476. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17477. /**
  17478. * Remove a specific drag gradient
  17479. * @param gradient defines the gradient to remove
  17480. * @returns the current particle system
  17481. */
  17482. removeDragGradient(gradient: number): IParticleSystem;
  17483. /**
  17484. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17485. * @param gradient defines the gradient to use (between 0 and 1)
  17486. * @param factor defines the emit rate value to affect to the specified gradient
  17487. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17488. * @returns the current particle system
  17489. */
  17490. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17491. /**
  17492. * Remove a specific emit rate gradient
  17493. * @param gradient defines the gradient to remove
  17494. * @returns the current particle system
  17495. */
  17496. removeEmitRateGradient(gradient: number): IParticleSystem;
  17497. /**
  17498. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17499. * @param gradient defines the gradient to use (between 0 and 1)
  17500. * @param factor defines the start size value to affect to the specified gradient
  17501. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17502. * @returns the current particle system
  17503. */
  17504. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17505. /**
  17506. * Remove a specific start size gradient
  17507. * @param gradient defines the gradient to remove
  17508. * @returns the current particle system
  17509. */
  17510. removeStartSizeGradient(gradient: number): IParticleSystem;
  17511. private _createRampGradientTexture;
  17512. /**
  17513. * Gets the current list of ramp gradients.
  17514. * You must use addRampGradient and removeRampGradient to udpate this list
  17515. * @returns the list of ramp gradients
  17516. */
  17517. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17518. /**
  17519. * Adds a new ramp gradient used to remap particle colors
  17520. * @param gradient defines the gradient to use (between 0 and 1)
  17521. * @param color defines the color to affect to the specified gradient
  17522. * @returns the current particle system
  17523. */
  17524. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17525. /**
  17526. * Remove a specific ramp gradient
  17527. * @param gradient defines the gradient to remove
  17528. * @returns the current particle system
  17529. */
  17530. removeRampGradient(gradient: number): ParticleSystem;
  17531. /**
  17532. * Adds a new color gradient
  17533. * @param gradient defines the gradient to use (between 0 and 1)
  17534. * @param color1 defines the color to affect to the specified gradient
  17535. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17536. * @returns this particle system
  17537. */
  17538. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17539. /**
  17540. * Remove a specific color gradient
  17541. * @param gradient defines the gradient to remove
  17542. * @returns this particle system
  17543. */
  17544. removeColorGradient(gradient: number): IParticleSystem;
  17545. private _fetchR;
  17546. protected _reset(): void;
  17547. private _resetEffect;
  17548. private _createVertexBuffers;
  17549. private _createIndexBuffer;
  17550. /**
  17551. * Gets the maximum number of particles active at the same time.
  17552. * @returns The max number of active particles.
  17553. */
  17554. getCapacity(): number;
  17555. /**
  17556. * Gets whether there are still active particles in the system.
  17557. * @returns True if it is alive, otherwise false.
  17558. */
  17559. isAlive(): boolean;
  17560. /**
  17561. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17562. * @returns True if it has been started, otherwise false.
  17563. */
  17564. isStarted(): boolean;
  17565. private _prepareSubEmitterInternalArray;
  17566. /**
  17567. * Starts the particle system and begins to emit
  17568. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17569. */
  17570. start(delay?: number): void;
  17571. /**
  17572. * Stops the particle system.
  17573. * @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.
  17574. */
  17575. stop(stopSubEmitters?: boolean): void;
  17576. /**
  17577. * Remove all active particles
  17578. */
  17579. reset(): void;
  17580. /**
  17581. * @hidden (for internal use only)
  17582. */
  17583. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17584. /**
  17585. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17586. * Its lifetime will start back at 0.
  17587. */
  17588. recycleParticle: (particle: Particle) => void;
  17589. private _stopSubEmitters;
  17590. private _createParticle;
  17591. private _removeFromRoot;
  17592. private _emitFromParticle;
  17593. private _update;
  17594. /** @hidden */
  17595. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17596. /** @hidden */
  17597. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17598. /** @hidden */
  17599. private _getEffect;
  17600. /**
  17601. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17602. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17603. */
  17604. animate(preWarmOnly?: boolean): void;
  17605. private _appendParticleVertices;
  17606. /**
  17607. * Rebuilds the particle system.
  17608. */
  17609. rebuild(): void;
  17610. /**
  17611. * Is this system ready to be used/rendered
  17612. * @return true if the system is ready
  17613. */
  17614. isReady(): boolean;
  17615. private _render;
  17616. /**
  17617. * Renders the particle system in its current state.
  17618. * @returns the current number of particles
  17619. */
  17620. render(): number;
  17621. /**
  17622. * Disposes the particle system and free the associated resources
  17623. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17624. */
  17625. dispose(disposeTexture?: boolean): void;
  17626. /**
  17627. * Clones the particle system.
  17628. * @param name The name of the cloned object
  17629. * @param newEmitter The new emitter to use
  17630. * @returns the cloned particle system
  17631. */
  17632. clone(name: string, newEmitter: any): ParticleSystem;
  17633. /**
  17634. * Serializes the particle system to a JSON object.
  17635. * @returns the JSON object
  17636. */
  17637. serialize(): any;
  17638. /** @hidden */
  17639. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17640. /** @hidden */
  17641. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17642. /**
  17643. * Parses a JSON object to create a particle system.
  17644. * @param parsedParticleSystem The JSON object to parse
  17645. * @param scene The scene to create the particle system in
  17646. * @param rootUrl The root url to use to load external dependencies like texture
  17647. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17648. * @returns the Parsed particle system
  17649. */
  17650. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17651. }
  17652. }
  17653. declare module "babylonjs/Particles/particle" {
  17654. import { Nullable } from "babylonjs/types";
  17655. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17656. import { Color4 } from "babylonjs/Maths/math.color";
  17657. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17658. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17659. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17660. /**
  17661. * A particle represents one of the element emitted by a particle system.
  17662. * This is mainly define by its coordinates, direction, velocity and age.
  17663. */
  17664. export class Particle {
  17665. /**
  17666. * The particle system the particle belongs to.
  17667. */
  17668. particleSystem: ParticleSystem;
  17669. private static _Count;
  17670. /**
  17671. * Unique ID of the particle
  17672. */
  17673. id: number;
  17674. /**
  17675. * The world position of the particle in the scene.
  17676. */
  17677. position: Vector3;
  17678. /**
  17679. * The world direction of the particle in the scene.
  17680. */
  17681. direction: Vector3;
  17682. /**
  17683. * The color of the particle.
  17684. */
  17685. color: Color4;
  17686. /**
  17687. * The color change of the particle per step.
  17688. */
  17689. colorStep: Color4;
  17690. /**
  17691. * Defines how long will the life of the particle be.
  17692. */
  17693. lifeTime: number;
  17694. /**
  17695. * The current age of the particle.
  17696. */
  17697. age: number;
  17698. /**
  17699. * The current size of the particle.
  17700. */
  17701. size: number;
  17702. /**
  17703. * The current scale of the particle.
  17704. */
  17705. scale: Vector2;
  17706. /**
  17707. * The current angle of the particle.
  17708. */
  17709. angle: number;
  17710. /**
  17711. * Defines how fast is the angle changing.
  17712. */
  17713. angularSpeed: number;
  17714. /**
  17715. * Defines the cell index used by the particle to be rendered from a sprite.
  17716. */
  17717. cellIndex: number;
  17718. /**
  17719. * The information required to support color remapping
  17720. */
  17721. remapData: Vector4;
  17722. /** @hidden */
  17723. _randomCellOffset?: number;
  17724. /** @hidden */
  17725. _initialDirection: Nullable<Vector3>;
  17726. /** @hidden */
  17727. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17728. /** @hidden */
  17729. _initialStartSpriteCellID: number;
  17730. /** @hidden */
  17731. _initialEndSpriteCellID: number;
  17732. /** @hidden */
  17733. _currentColorGradient: Nullable<ColorGradient>;
  17734. /** @hidden */
  17735. _currentColor1: Color4;
  17736. /** @hidden */
  17737. _currentColor2: Color4;
  17738. /** @hidden */
  17739. _currentSizeGradient: Nullable<FactorGradient>;
  17740. /** @hidden */
  17741. _currentSize1: number;
  17742. /** @hidden */
  17743. _currentSize2: number;
  17744. /** @hidden */
  17745. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17746. /** @hidden */
  17747. _currentAngularSpeed1: number;
  17748. /** @hidden */
  17749. _currentAngularSpeed2: number;
  17750. /** @hidden */
  17751. _currentVelocityGradient: Nullable<FactorGradient>;
  17752. /** @hidden */
  17753. _currentVelocity1: number;
  17754. /** @hidden */
  17755. _currentVelocity2: number;
  17756. /** @hidden */
  17757. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17758. /** @hidden */
  17759. _currentLimitVelocity1: number;
  17760. /** @hidden */
  17761. _currentLimitVelocity2: number;
  17762. /** @hidden */
  17763. _currentDragGradient: Nullable<FactorGradient>;
  17764. /** @hidden */
  17765. _currentDrag1: number;
  17766. /** @hidden */
  17767. _currentDrag2: number;
  17768. /** @hidden */
  17769. _randomNoiseCoordinates1: Vector3;
  17770. /** @hidden */
  17771. _randomNoiseCoordinates2: Vector3;
  17772. /**
  17773. * Creates a new instance Particle
  17774. * @param particleSystem the particle system the particle belongs to
  17775. */
  17776. constructor(
  17777. /**
  17778. * The particle system the particle belongs to.
  17779. */
  17780. particleSystem: ParticleSystem);
  17781. private updateCellInfoFromSystem;
  17782. /**
  17783. * Defines how the sprite cell index is updated for the particle
  17784. */
  17785. updateCellIndex(): void;
  17786. /** @hidden */
  17787. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17788. /** @hidden */
  17789. _inheritParticleInfoToSubEmitters(): void;
  17790. /** @hidden */
  17791. _reset(): void;
  17792. /**
  17793. * Copy the properties of particle to another one.
  17794. * @param other the particle to copy the information to.
  17795. */
  17796. copyTo(other: Particle): void;
  17797. }
  17798. }
  17799. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17800. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17801. import { Effect } from "babylonjs/Materials/effect";
  17802. import { Particle } from "babylonjs/Particles/particle";
  17803. /**
  17804. * Particle emitter represents a volume emitting particles.
  17805. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17806. */
  17807. export interface IParticleEmitterType {
  17808. /**
  17809. * Called by the particle System when the direction is computed for the created particle.
  17810. * @param worldMatrix is the world matrix of the particle system
  17811. * @param directionToUpdate is the direction vector to update with the result
  17812. * @param particle is the particle we are computed the direction for
  17813. */
  17814. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17815. /**
  17816. * Called by the particle System when the position is computed for the created particle.
  17817. * @param worldMatrix is the world matrix of the particle system
  17818. * @param positionToUpdate is the position vector to update with the result
  17819. * @param particle is the particle we are computed the position for
  17820. */
  17821. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17822. /**
  17823. * Clones the current emitter and returns a copy of it
  17824. * @returns the new emitter
  17825. */
  17826. clone(): IParticleEmitterType;
  17827. /**
  17828. * Called by the GPUParticleSystem to setup the update shader
  17829. * @param effect defines the update shader
  17830. */
  17831. applyToShader(effect: Effect): void;
  17832. /**
  17833. * Returns a string to use to update the GPU particles update shader
  17834. * @returns the effect defines string
  17835. */
  17836. getEffectDefines(): string;
  17837. /**
  17838. * Returns a string representing the class name
  17839. * @returns a string containing the class name
  17840. */
  17841. getClassName(): string;
  17842. /**
  17843. * Serializes the particle system to a JSON object.
  17844. * @returns the JSON object
  17845. */
  17846. serialize(): any;
  17847. /**
  17848. * Parse properties from a JSON object
  17849. * @param serializationObject defines the JSON object
  17850. */
  17851. parse(serializationObject: any): void;
  17852. }
  17853. }
  17854. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  17855. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17856. import { Effect } from "babylonjs/Materials/effect";
  17857. import { Particle } from "babylonjs/Particles/particle";
  17858. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17859. /**
  17860. * Particle emitter emitting particles from the inside of a box.
  17861. * It emits the particles randomly between 2 given directions.
  17862. */
  17863. export class BoxParticleEmitter implements IParticleEmitterType {
  17864. /**
  17865. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17866. */
  17867. direction1: Vector3;
  17868. /**
  17869. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17870. */
  17871. direction2: Vector3;
  17872. /**
  17873. * 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.
  17874. */
  17875. minEmitBox: Vector3;
  17876. /**
  17877. * 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.
  17878. */
  17879. maxEmitBox: Vector3;
  17880. /**
  17881. * Creates a new instance BoxParticleEmitter
  17882. */
  17883. constructor();
  17884. /**
  17885. * Called by the particle System when the direction is computed for the created particle.
  17886. * @param worldMatrix is the world matrix of the particle system
  17887. * @param directionToUpdate is the direction vector to update with the result
  17888. * @param particle is the particle we are computed the direction for
  17889. */
  17890. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17891. /**
  17892. * Called by the particle System when the position is computed for the created particle.
  17893. * @param worldMatrix is the world matrix of the particle system
  17894. * @param positionToUpdate is the position vector to update with the result
  17895. * @param particle is the particle we are computed the position for
  17896. */
  17897. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17898. /**
  17899. * Clones the current emitter and returns a copy of it
  17900. * @returns the new emitter
  17901. */
  17902. clone(): BoxParticleEmitter;
  17903. /**
  17904. * Called by the GPUParticleSystem to setup the update shader
  17905. * @param effect defines the update shader
  17906. */
  17907. applyToShader(effect: Effect): void;
  17908. /**
  17909. * Returns a string to use to update the GPU particles update shader
  17910. * @returns a string containng the defines string
  17911. */
  17912. getEffectDefines(): string;
  17913. /**
  17914. * Returns the string "BoxParticleEmitter"
  17915. * @returns a string containing the class name
  17916. */
  17917. getClassName(): string;
  17918. /**
  17919. * Serializes the particle system to a JSON object.
  17920. * @returns the JSON object
  17921. */
  17922. serialize(): any;
  17923. /**
  17924. * Parse properties from a JSON object
  17925. * @param serializationObject defines the JSON object
  17926. */
  17927. parse(serializationObject: any): void;
  17928. }
  17929. }
  17930. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  17931. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17932. import { Effect } from "babylonjs/Materials/effect";
  17933. import { Particle } from "babylonjs/Particles/particle";
  17934. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17935. /**
  17936. * Particle emitter emitting particles from the inside of a cone.
  17937. * It emits the particles alongside the cone volume from the base to the particle.
  17938. * The emission direction might be randomized.
  17939. */
  17940. export class ConeParticleEmitter implements IParticleEmitterType {
  17941. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17942. directionRandomizer: number;
  17943. private _radius;
  17944. private _angle;
  17945. private _height;
  17946. /**
  17947. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17948. */
  17949. radiusRange: number;
  17950. /**
  17951. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17952. */
  17953. heightRange: number;
  17954. /**
  17955. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17956. */
  17957. emitFromSpawnPointOnly: boolean;
  17958. /**
  17959. * Gets or sets the radius of the emission cone
  17960. */
  17961. radius: number;
  17962. /**
  17963. * Gets or sets the angle of the emission cone
  17964. */
  17965. angle: number;
  17966. private _buildHeight;
  17967. /**
  17968. * Creates a new instance ConeParticleEmitter
  17969. * @param radius the radius of the emission cone (1 by default)
  17970. * @param angle the cone base angle (PI by default)
  17971. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17972. */
  17973. constructor(radius?: number, angle?: number,
  17974. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17975. directionRandomizer?: number);
  17976. /**
  17977. * Called by the particle System when the direction is computed for the created particle.
  17978. * @param worldMatrix is the world matrix of the particle system
  17979. * @param directionToUpdate is the direction vector to update with the result
  17980. * @param particle is the particle we are computed the direction for
  17981. */
  17982. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17983. /**
  17984. * Called by the particle System when the position is computed for the created particle.
  17985. * @param worldMatrix is the world matrix of the particle system
  17986. * @param positionToUpdate is the position vector to update with the result
  17987. * @param particle is the particle we are computed the position for
  17988. */
  17989. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17990. /**
  17991. * Clones the current emitter and returns a copy of it
  17992. * @returns the new emitter
  17993. */
  17994. clone(): ConeParticleEmitter;
  17995. /**
  17996. * Called by the GPUParticleSystem to setup the update shader
  17997. * @param effect defines the update shader
  17998. */
  17999. applyToShader(effect: Effect): void;
  18000. /**
  18001. * Returns a string to use to update the GPU particles update shader
  18002. * @returns a string containng the defines string
  18003. */
  18004. getEffectDefines(): string;
  18005. /**
  18006. * Returns the string "ConeParticleEmitter"
  18007. * @returns a string containing the class name
  18008. */
  18009. getClassName(): string;
  18010. /**
  18011. * Serializes the particle system to a JSON object.
  18012. * @returns the JSON object
  18013. */
  18014. serialize(): any;
  18015. /**
  18016. * Parse properties from a JSON object
  18017. * @param serializationObject defines the JSON object
  18018. */
  18019. parse(serializationObject: any): void;
  18020. }
  18021. }
  18022. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18023. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18024. import { Effect } from "babylonjs/Materials/effect";
  18025. import { Particle } from "babylonjs/Particles/particle";
  18026. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18027. /**
  18028. * Particle emitter emitting particles from the inside of a cylinder.
  18029. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18030. */
  18031. export class CylinderParticleEmitter implements IParticleEmitterType {
  18032. /**
  18033. * The radius of the emission cylinder.
  18034. */
  18035. radius: number;
  18036. /**
  18037. * The height of the emission cylinder.
  18038. */
  18039. height: number;
  18040. /**
  18041. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18042. */
  18043. radiusRange: number;
  18044. /**
  18045. * How much to randomize the particle direction [0-1].
  18046. */
  18047. directionRandomizer: number;
  18048. /**
  18049. * Creates a new instance CylinderParticleEmitter
  18050. * @param radius the radius of the emission cylinder (1 by default)
  18051. * @param height the height of the emission cylinder (1 by default)
  18052. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18053. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18054. */
  18055. constructor(
  18056. /**
  18057. * The radius of the emission cylinder.
  18058. */
  18059. radius?: number,
  18060. /**
  18061. * The height of the emission cylinder.
  18062. */
  18063. height?: number,
  18064. /**
  18065. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18066. */
  18067. radiusRange?: number,
  18068. /**
  18069. * How much to randomize the particle direction [0-1].
  18070. */
  18071. directionRandomizer?: number);
  18072. /**
  18073. * Called by the particle System when the direction is computed for the created particle.
  18074. * @param worldMatrix is the world matrix of the particle system
  18075. * @param directionToUpdate is the direction vector to update with the result
  18076. * @param particle is the particle we are computed the direction for
  18077. */
  18078. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18079. /**
  18080. * Called by the particle System when the position is computed for the created particle.
  18081. * @param worldMatrix is the world matrix of the particle system
  18082. * @param positionToUpdate is the position vector to update with the result
  18083. * @param particle is the particle we are computed the position for
  18084. */
  18085. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18086. /**
  18087. * Clones the current emitter and returns a copy of it
  18088. * @returns the new emitter
  18089. */
  18090. clone(): CylinderParticleEmitter;
  18091. /**
  18092. * Called by the GPUParticleSystem to setup the update shader
  18093. * @param effect defines the update shader
  18094. */
  18095. applyToShader(effect: Effect): void;
  18096. /**
  18097. * Returns a string to use to update the GPU particles update shader
  18098. * @returns a string containng the defines string
  18099. */
  18100. getEffectDefines(): string;
  18101. /**
  18102. * Returns the string "CylinderParticleEmitter"
  18103. * @returns a string containing the class name
  18104. */
  18105. getClassName(): string;
  18106. /**
  18107. * Serializes the particle system to a JSON object.
  18108. * @returns the JSON object
  18109. */
  18110. serialize(): any;
  18111. /**
  18112. * Parse properties from a JSON object
  18113. * @param serializationObject defines the JSON object
  18114. */
  18115. parse(serializationObject: any): void;
  18116. }
  18117. /**
  18118. * Particle emitter emitting particles from the inside of a cylinder.
  18119. * It emits the particles randomly between two vectors.
  18120. */
  18121. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18122. /**
  18123. * The min limit of the emission direction.
  18124. */
  18125. direction1: Vector3;
  18126. /**
  18127. * The max limit of the emission direction.
  18128. */
  18129. direction2: Vector3;
  18130. /**
  18131. * Creates a new instance CylinderDirectedParticleEmitter
  18132. * @param radius the radius of the emission cylinder (1 by default)
  18133. * @param height the height of the emission cylinder (1 by default)
  18134. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18135. * @param direction1 the min limit of the emission direction (up vector by default)
  18136. * @param direction2 the max limit of the emission direction (up vector by default)
  18137. */
  18138. constructor(radius?: number, height?: number, radiusRange?: number,
  18139. /**
  18140. * The min limit of the emission direction.
  18141. */
  18142. direction1?: Vector3,
  18143. /**
  18144. * The max limit of the emission direction.
  18145. */
  18146. direction2?: Vector3);
  18147. /**
  18148. * Called by the particle System when the direction is computed for the created particle.
  18149. * @param worldMatrix is the world matrix of the particle system
  18150. * @param directionToUpdate is the direction vector to update with the result
  18151. * @param particle is the particle we are computed the direction for
  18152. */
  18153. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18154. /**
  18155. * Clones the current emitter and returns a copy of it
  18156. * @returns the new emitter
  18157. */
  18158. clone(): CylinderDirectedParticleEmitter;
  18159. /**
  18160. * Called by the GPUParticleSystem to setup the update shader
  18161. * @param effect defines the update shader
  18162. */
  18163. applyToShader(effect: Effect): void;
  18164. /**
  18165. * Returns a string to use to update the GPU particles update shader
  18166. * @returns a string containng the defines string
  18167. */
  18168. getEffectDefines(): string;
  18169. /**
  18170. * Returns the string "CylinderDirectedParticleEmitter"
  18171. * @returns a string containing the class name
  18172. */
  18173. getClassName(): string;
  18174. /**
  18175. * Serializes the particle system to a JSON object.
  18176. * @returns the JSON object
  18177. */
  18178. serialize(): any;
  18179. /**
  18180. * Parse properties from a JSON object
  18181. * @param serializationObject defines the JSON object
  18182. */
  18183. parse(serializationObject: any): void;
  18184. }
  18185. }
  18186. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18187. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18188. import { Effect } from "babylonjs/Materials/effect";
  18189. import { Particle } from "babylonjs/Particles/particle";
  18190. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18191. /**
  18192. * Particle emitter emitting particles from the inside of a hemisphere.
  18193. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18194. */
  18195. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18196. /**
  18197. * The radius of the emission hemisphere.
  18198. */
  18199. radius: number;
  18200. /**
  18201. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18202. */
  18203. radiusRange: number;
  18204. /**
  18205. * How much to randomize the particle direction [0-1].
  18206. */
  18207. directionRandomizer: number;
  18208. /**
  18209. * Creates a new instance HemisphericParticleEmitter
  18210. * @param radius the radius of the emission hemisphere (1 by default)
  18211. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18212. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18213. */
  18214. constructor(
  18215. /**
  18216. * The radius of the emission hemisphere.
  18217. */
  18218. radius?: number,
  18219. /**
  18220. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18221. */
  18222. radiusRange?: number,
  18223. /**
  18224. * How much to randomize the particle direction [0-1].
  18225. */
  18226. directionRandomizer?: number);
  18227. /**
  18228. * Called by the particle System when the direction is computed for the created particle.
  18229. * @param worldMatrix is the world matrix of the particle system
  18230. * @param directionToUpdate is the direction vector to update with the result
  18231. * @param particle is the particle we are computed the direction for
  18232. */
  18233. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18234. /**
  18235. * Called by the particle System when the position is computed for the created particle.
  18236. * @param worldMatrix is the world matrix of the particle system
  18237. * @param positionToUpdate is the position vector to update with the result
  18238. * @param particle is the particle we are computed the position for
  18239. */
  18240. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18241. /**
  18242. * Clones the current emitter and returns a copy of it
  18243. * @returns the new emitter
  18244. */
  18245. clone(): HemisphericParticleEmitter;
  18246. /**
  18247. * Called by the GPUParticleSystem to setup the update shader
  18248. * @param effect defines the update shader
  18249. */
  18250. applyToShader(effect: Effect): void;
  18251. /**
  18252. * Returns a string to use to update the GPU particles update shader
  18253. * @returns a string containng the defines string
  18254. */
  18255. getEffectDefines(): string;
  18256. /**
  18257. * Returns the string "HemisphericParticleEmitter"
  18258. * @returns a string containing the class name
  18259. */
  18260. getClassName(): string;
  18261. /**
  18262. * Serializes the particle system to a JSON object.
  18263. * @returns the JSON object
  18264. */
  18265. serialize(): any;
  18266. /**
  18267. * Parse properties from a JSON object
  18268. * @param serializationObject defines the JSON object
  18269. */
  18270. parse(serializationObject: any): void;
  18271. }
  18272. }
  18273. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18274. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18275. import { Effect } from "babylonjs/Materials/effect";
  18276. import { Particle } from "babylonjs/Particles/particle";
  18277. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18278. /**
  18279. * Particle emitter emitting particles from a point.
  18280. * It emits the particles randomly between 2 given directions.
  18281. */
  18282. export class PointParticleEmitter implements IParticleEmitterType {
  18283. /**
  18284. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18285. */
  18286. direction1: Vector3;
  18287. /**
  18288. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18289. */
  18290. direction2: Vector3;
  18291. /**
  18292. * Creates a new instance PointParticleEmitter
  18293. */
  18294. constructor();
  18295. /**
  18296. * Called by the particle System when the direction is computed for the created particle.
  18297. * @param worldMatrix is the world matrix of the particle system
  18298. * @param directionToUpdate is the direction vector to update with the result
  18299. * @param particle is the particle we are computed the direction for
  18300. */
  18301. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18302. /**
  18303. * Called by the particle System when the position is computed for the created particle.
  18304. * @param worldMatrix is the world matrix of the particle system
  18305. * @param positionToUpdate is the position vector to update with the result
  18306. * @param particle is the particle we are computed the position for
  18307. */
  18308. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18309. /**
  18310. * Clones the current emitter and returns a copy of it
  18311. * @returns the new emitter
  18312. */
  18313. clone(): PointParticleEmitter;
  18314. /**
  18315. * Called by the GPUParticleSystem to setup the update shader
  18316. * @param effect defines the update shader
  18317. */
  18318. applyToShader(effect: Effect): void;
  18319. /**
  18320. * Returns a string to use to update the GPU particles update shader
  18321. * @returns a string containng the defines string
  18322. */
  18323. getEffectDefines(): string;
  18324. /**
  18325. * Returns the string "PointParticleEmitter"
  18326. * @returns a string containing the class name
  18327. */
  18328. getClassName(): string;
  18329. /**
  18330. * Serializes the particle system to a JSON object.
  18331. * @returns the JSON object
  18332. */
  18333. serialize(): any;
  18334. /**
  18335. * Parse properties from a JSON object
  18336. * @param serializationObject defines the JSON object
  18337. */
  18338. parse(serializationObject: any): void;
  18339. }
  18340. }
  18341. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18342. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18343. import { Effect } from "babylonjs/Materials/effect";
  18344. import { Particle } from "babylonjs/Particles/particle";
  18345. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18346. /**
  18347. * Particle emitter emitting particles from the inside of a sphere.
  18348. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18349. */
  18350. export class SphereParticleEmitter implements IParticleEmitterType {
  18351. /**
  18352. * The radius of the emission sphere.
  18353. */
  18354. radius: number;
  18355. /**
  18356. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18357. */
  18358. radiusRange: number;
  18359. /**
  18360. * How much to randomize the particle direction [0-1].
  18361. */
  18362. directionRandomizer: number;
  18363. /**
  18364. * Creates a new instance SphereParticleEmitter
  18365. * @param radius the radius of the emission sphere (1 by default)
  18366. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18367. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18368. */
  18369. constructor(
  18370. /**
  18371. * The radius of the emission sphere.
  18372. */
  18373. radius?: number,
  18374. /**
  18375. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18376. */
  18377. radiusRange?: number,
  18378. /**
  18379. * How much to randomize the particle direction [0-1].
  18380. */
  18381. directionRandomizer?: number);
  18382. /**
  18383. * Called by the particle System when the direction is computed for the created particle.
  18384. * @param worldMatrix is the world matrix of the particle system
  18385. * @param directionToUpdate is the direction vector to update with the result
  18386. * @param particle is the particle we are computed the direction for
  18387. */
  18388. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18389. /**
  18390. * Called by the particle System when the position is computed for the created particle.
  18391. * @param worldMatrix is the world matrix of the particle system
  18392. * @param positionToUpdate is the position vector to update with the result
  18393. * @param particle is the particle we are computed the position for
  18394. */
  18395. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18396. /**
  18397. * Clones the current emitter and returns a copy of it
  18398. * @returns the new emitter
  18399. */
  18400. clone(): SphereParticleEmitter;
  18401. /**
  18402. * Called by the GPUParticleSystem to setup the update shader
  18403. * @param effect defines the update shader
  18404. */
  18405. applyToShader(effect: Effect): void;
  18406. /**
  18407. * Returns a string to use to update the GPU particles update shader
  18408. * @returns a string containng the defines string
  18409. */
  18410. getEffectDefines(): string;
  18411. /**
  18412. * Returns the string "SphereParticleEmitter"
  18413. * @returns a string containing the class name
  18414. */
  18415. getClassName(): string;
  18416. /**
  18417. * Serializes the particle system to a JSON object.
  18418. * @returns the JSON object
  18419. */
  18420. serialize(): any;
  18421. /**
  18422. * Parse properties from a JSON object
  18423. * @param serializationObject defines the JSON object
  18424. */
  18425. parse(serializationObject: any): void;
  18426. }
  18427. /**
  18428. * Particle emitter emitting particles from the inside of a sphere.
  18429. * It emits the particles randomly between two vectors.
  18430. */
  18431. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18432. /**
  18433. * The min limit of the emission direction.
  18434. */
  18435. direction1: Vector3;
  18436. /**
  18437. * The max limit of the emission direction.
  18438. */
  18439. direction2: Vector3;
  18440. /**
  18441. * Creates a new instance SphereDirectedParticleEmitter
  18442. * @param radius the radius of the emission sphere (1 by default)
  18443. * @param direction1 the min limit of the emission direction (up vector by default)
  18444. * @param direction2 the max limit of the emission direction (up vector by default)
  18445. */
  18446. constructor(radius?: number,
  18447. /**
  18448. * The min limit of the emission direction.
  18449. */
  18450. direction1?: Vector3,
  18451. /**
  18452. * The max limit of the emission direction.
  18453. */
  18454. direction2?: Vector3);
  18455. /**
  18456. * Called by the particle System when the direction is computed for the created particle.
  18457. * @param worldMatrix is the world matrix of the particle system
  18458. * @param directionToUpdate is the direction vector to update with the result
  18459. * @param particle is the particle we are computed the direction for
  18460. */
  18461. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18462. /**
  18463. * Clones the current emitter and returns a copy of it
  18464. * @returns the new emitter
  18465. */
  18466. clone(): SphereDirectedParticleEmitter;
  18467. /**
  18468. * Called by the GPUParticleSystem to setup the update shader
  18469. * @param effect defines the update shader
  18470. */
  18471. applyToShader(effect: Effect): void;
  18472. /**
  18473. * Returns a string to use to update the GPU particles update shader
  18474. * @returns a string containng the defines string
  18475. */
  18476. getEffectDefines(): string;
  18477. /**
  18478. * Returns the string "SphereDirectedParticleEmitter"
  18479. * @returns a string containing the class name
  18480. */
  18481. getClassName(): string;
  18482. /**
  18483. * Serializes the particle system to a JSON object.
  18484. * @returns the JSON object
  18485. */
  18486. serialize(): any;
  18487. /**
  18488. * Parse properties from a JSON object
  18489. * @param serializationObject defines the JSON object
  18490. */
  18491. parse(serializationObject: any): void;
  18492. }
  18493. }
  18494. declare module "babylonjs/Particles/EmitterTypes/index" {
  18495. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18496. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18497. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18498. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18499. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18500. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18501. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18502. }
  18503. declare module "babylonjs/Particles/IParticleSystem" {
  18504. import { Nullable } from "babylonjs/types";
  18505. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18506. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18507. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18508. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18509. import { Texture } from "babylonjs/Materials/Textures/texture";
  18510. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18511. import { Scene } from "babylonjs/scene";
  18512. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18513. import { Animation } from "babylonjs/Animations/animation";
  18514. /**
  18515. * Interface representing a particle system in Babylon.js.
  18516. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18517. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18518. */
  18519. export interface IParticleSystem {
  18520. /**
  18521. * List of animations used by the particle system.
  18522. */
  18523. animations: Animation[];
  18524. /**
  18525. * The id of the Particle system.
  18526. */
  18527. id: string;
  18528. /**
  18529. * The name of the Particle system.
  18530. */
  18531. name: string;
  18532. /**
  18533. * The emitter represents the Mesh or position we are attaching the particle system to.
  18534. */
  18535. emitter: Nullable<AbstractMesh | Vector3>;
  18536. /**
  18537. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18538. */
  18539. isBillboardBased: boolean;
  18540. /**
  18541. * The rendering group used by the Particle system to chose when to render.
  18542. */
  18543. renderingGroupId: number;
  18544. /**
  18545. * The layer mask we are rendering the particles through.
  18546. */
  18547. layerMask: number;
  18548. /**
  18549. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18550. */
  18551. updateSpeed: number;
  18552. /**
  18553. * The amount of time the particle system is running (depends of the overall update speed).
  18554. */
  18555. targetStopDuration: number;
  18556. /**
  18557. * The texture used to render each particle. (this can be a spritesheet)
  18558. */
  18559. particleTexture: Nullable<Texture>;
  18560. /**
  18561. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18562. */
  18563. blendMode: number;
  18564. /**
  18565. * Minimum life time of emitting particles.
  18566. */
  18567. minLifeTime: number;
  18568. /**
  18569. * Maximum life time of emitting particles.
  18570. */
  18571. maxLifeTime: number;
  18572. /**
  18573. * Minimum Size of emitting particles.
  18574. */
  18575. minSize: number;
  18576. /**
  18577. * Maximum Size of emitting particles.
  18578. */
  18579. maxSize: number;
  18580. /**
  18581. * Minimum scale of emitting particles on X axis.
  18582. */
  18583. minScaleX: number;
  18584. /**
  18585. * Maximum scale of emitting particles on X axis.
  18586. */
  18587. maxScaleX: number;
  18588. /**
  18589. * Minimum scale of emitting particles on Y axis.
  18590. */
  18591. minScaleY: number;
  18592. /**
  18593. * Maximum scale of emitting particles on Y axis.
  18594. */
  18595. maxScaleY: number;
  18596. /**
  18597. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18598. */
  18599. color1: Color4;
  18600. /**
  18601. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18602. */
  18603. color2: Color4;
  18604. /**
  18605. * Color the particle will have at the end of its lifetime.
  18606. */
  18607. colorDead: Color4;
  18608. /**
  18609. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18610. */
  18611. emitRate: number;
  18612. /**
  18613. * You can use gravity if you want to give an orientation to your particles.
  18614. */
  18615. gravity: Vector3;
  18616. /**
  18617. * Minimum power of emitting particles.
  18618. */
  18619. minEmitPower: number;
  18620. /**
  18621. * Maximum power of emitting particles.
  18622. */
  18623. maxEmitPower: number;
  18624. /**
  18625. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18626. */
  18627. minAngularSpeed: number;
  18628. /**
  18629. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18630. */
  18631. maxAngularSpeed: number;
  18632. /**
  18633. * Gets or sets the minimal initial rotation in radians.
  18634. */
  18635. minInitialRotation: number;
  18636. /**
  18637. * Gets or sets the maximal initial rotation in radians.
  18638. */
  18639. maxInitialRotation: number;
  18640. /**
  18641. * The particle emitter type defines the emitter used by the particle system.
  18642. * It can be for example box, sphere, or cone...
  18643. */
  18644. particleEmitterType: Nullable<IParticleEmitterType>;
  18645. /**
  18646. * Defines the delay in milliseconds before starting the system (0 by default)
  18647. */
  18648. startDelay: number;
  18649. /**
  18650. * 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
  18651. */
  18652. preWarmCycles: number;
  18653. /**
  18654. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18655. */
  18656. preWarmStepOffset: number;
  18657. /**
  18658. * 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)
  18659. */
  18660. spriteCellChangeSpeed: number;
  18661. /**
  18662. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18663. */
  18664. startSpriteCellID: number;
  18665. /**
  18666. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18667. */
  18668. endSpriteCellID: number;
  18669. /**
  18670. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18671. */
  18672. spriteCellWidth: number;
  18673. /**
  18674. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18675. */
  18676. spriteCellHeight: number;
  18677. /**
  18678. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18679. */
  18680. spriteRandomStartCell: boolean;
  18681. /**
  18682. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18683. */
  18684. isAnimationSheetEnabled: boolean;
  18685. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18686. translationPivot: Vector2;
  18687. /**
  18688. * Gets or sets a texture used to add random noise to particle positions
  18689. */
  18690. noiseTexture: Nullable<BaseTexture>;
  18691. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18692. noiseStrength: Vector3;
  18693. /**
  18694. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18695. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18696. */
  18697. billboardMode: number;
  18698. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18699. limitVelocityDamping: number;
  18700. /**
  18701. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18702. */
  18703. beginAnimationOnStart: boolean;
  18704. /**
  18705. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18706. */
  18707. beginAnimationFrom: number;
  18708. /**
  18709. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18710. */
  18711. beginAnimationTo: number;
  18712. /**
  18713. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18714. */
  18715. beginAnimationLoop: boolean;
  18716. /**
  18717. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18718. */
  18719. disposeOnStop: boolean;
  18720. /**
  18721. * Gets the maximum number of particles active at the same time.
  18722. * @returns The max number of active particles.
  18723. */
  18724. getCapacity(): number;
  18725. /**
  18726. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18727. * @returns True if it has been started, otherwise false.
  18728. */
  18729. isStarted(): boolean;
  18730. /**
  18731. * Animates the particle system for this frame.
  18732. */
  18733. animate(): void;
  18734. /**
  18735. * Renders the particle system in its current state.
  18736. * @returns the current number of particles
  18737. */
  18738. render(): number;
  18739. /**
  18740. * Dispose the particle system and frees its associated resources.
  18741. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18742. */
  18743. dispose(disposeTexture?: boolean): void;
  18744. /**
  18745. * Clones the particle system.
  18746. * @param name The name of the cloned object
  18747. * @param newEmitter The new emitter to use
  18748. * @returns the cloned particle system
  18749. */
  18750. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18751. /**
  18752. * Serializes the particle system to a JSON object.
  18753. * @returns the JSON object
  18754. */
  18755. serialize(): any;
  18756. /**
  18757. * Rebuild the particle system
  18758. */
  18759. rebuild(): void;
  18760. /**
  18761. * Starts the particle system and begins to emit
  18762. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18763. */
  18764. start(delay?: number): void;
  18765. /**
  18766. * Stops the particle system.
  18767. */
  18768. stop(): void;
  18769. /**
  18770. * Remove all active particles
  18771. */
  18772. reset(): void;
  18773. /**
  18774. * Is this system ready to be used/rendered
  18775. * @return true if the system is ready
  18776. */
  18777. isReady(): boolean;
  18778. /**
  18779. * Adds a new color gradient
  18780. * @param gradient defines the gradient to use (between 0 and 1)
  18781. * @param color1 defines the color to affect to the specified gradient
  18782. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18783. * @returns the current particle system
  18784. */
  18785. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18786. /**
  18787. * Remove a specific color gradient
  18788. * @param gradient defines the gradient to remove
  18789. * @returns the current particle system
  18790. */
  18791. removeColorGradient(gradient: number): IParticleSystem;
  18792. /**
  18793. * Adds a new size gradient
  18794. * @param gradient defines the gradient to use (between 0 and 1)
  18795. * @param factor defines the size factor to affect to the specified gradient
  18796. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18797. * @returns the current particle system
  18798. */
  18799. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18800. /**
  18801. * Remove a specific size gradient
  18802. * @param gradient defines the gradient to remove
  18803. * @returns the current particle system
  18804. */
  18805. removeSizeGradient(gradient: number): IParticleSystem;
  18806. /**
  18807. * Gets the current list of color gradients.
  18808. * You must use addColorGradient and removeColorGradient to udpate this list
  18809. * @returns the list of color gradients
  18810. */
  18811. getColorGradients(): Nullable<Array<ColorGradient>>;
  18812. /**
  18813. * Gets the current list of size gradients.
  18814. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18815. * @returns the list of size gradients
  18816. */
  18817. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18818. /**
  18819. * Gets the current list of angular speed gradients.
  18820. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18821. * @returns the list of angular speed gradients
  18822. */
  18823. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18824. /**
  18825. * Adds a new angular speed gradient
  18826. * @param gradient defines the gradient to use (between 0 and 1)
  18827. * @param factor defines the angular speed to affect to the specified gradient
  18828. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18829. * @returns the current particle system
  18830. */
  18831. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18832. /**
  18833. * Remove a specific angular speed gradient
  18834. * @param gradient defines the gradient to remove
  18835. * @returns the current particle system
  18836. */
  18837. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18838. /**
  18839. * Gets the current list of velocity gradients.
  18840. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18841. * @returns the list of velocity gradients
  18842. */
  18843. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18844. /**
  18845. * Adds a new velocity gradient
  18846. * @param gradient defines the gradient to use (between 0 and 1)
  18847. * @param factor defines the velocity to affect to the specified gradient
  18848. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18849. * @returns the current particle system
  18850. */
  18851. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18852. /**
  18853. * Remove a specific velocity gradient
  18854. * @param gradient defines the gradient to remove
  18855. * @returns the current particle system
  18856. */
  18857. removeVelocityGradient(gradient: number): IParticleSystem;
  18858. /**
  18859. * Gets the current list of limit velocity gradients.
  18860. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18861. * @returns the list of limit velocity gradients
  18862. */
  18863. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18864. /**
  18865. * Adds a new limit velocity gradient
  18866. * @param gradient defines the gradient to use (between 0 and 1)
  18867. * @param factor defines the limit velocity to affect to the specified gradient
  18868. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18869. * @returns the current particle system
  18870. */
  18871. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18872. /**
  18873. * Remove a specific limit velocity gradient
  18874. * @param gradient defines the gradient to remove
  18875. * @returns the current particle system
  18876. */
  18877. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18878. /**
  18879. * Adds a new drag gradient
  18880. * @param gradient defines the gradient to use (between 0 and 1)
  18881. * @param factor defines the drag to affect to the specified gradient
  18882. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18883. * @returns the current particle system
  18884. */
  18885. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18886. /**
  18887. * Remove a specific drag gradient
  18888. * @param gradient defines the gradient to remove
  18889. * @returns the current particle system
  18890. */
  18891. removeDragGradient(gradient: number): IParticleSystem;
  18892. /**
  18893. * Gets the current list of drag gradients.
  18894. * You must use addDragGradient and removeDragGradient to udpate this list
  18895. * @returns the list of drag gradients
  18896. */
  18897. getDragGradients(): Nullable<Array<FactorGradient>>;
  18898. /**
  18899. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18900. * @param gradient defines the gradient to use (between 0 and 1)
  18901. * @param factor defines the emit rate to affect to the specified gradient
  18902. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18903. * @returns the current particle system
  18904. */
  18905. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18906. /**
  18907. * Remove a specific emit rate gradient
  18908. * @param gradient defines the gradient to remove
  18909. * @returns the current particle system
  18910. */
  18911. removeEmitRateGradient(gradient: number): IParticleSystem;
  18912. /**
  18913. * Gets the current list of emit rate gradients.
  18914. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18915. * @returns the list of emit rate gradients
  18916. */
  18917. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18918. /**
  18919. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18920. * @param gradient defines the gradient to use (between 0 and 1)
  18921. * @param factor defines the start size to affect to the specified gradient
  18922. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18923. * @returns the current particle system
  18924. */
  18925. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18926. /**
  18927. * Remove a specific start size gradient
  18928. * @param gradient defines the gradient to remove
  18929. * @returns the current particle system
  18930. */
  18931. removeStartSizeGradient(gradient: number): IParticleSystem;
  18932. /**
  18933. * Gets the current list of start size gradients.
  18934. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18935. * @returns the list of start size gradients
  18936. */
  18937. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18938. /**
  18939. * Adds a new life time gradient
  18940. * @param gradient defines the gradient to use (between 0 and 1)
  18941. * @param factor defines the life time factor to affect to the specified gradient
  18942. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18943. * @returns the current particle system
  18944. */
  18945. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18946. /**
  18947. * Remove a specific life time gradient
  18948. * @param gradient defines the gradient to remove
  18949. * @returns the current particle system
  18950. */
  18951. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18952. /**
  18953. * Gets the current list of life time gradients.
  18954. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18955. * @returns the list of life time gradients
  18956. */
  18957. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18958. /**
  18959. * Gets the current list of color gradients.
  18960. * You must use addColorGradient and removeColorGradient to udpate this list
  18961. * @returns the list of color gradients
  18962. */
  18963. getColorGradients(): Nullable<Array<ColorGradient>>;
  18964. /**
  18965. * Adds a new ramp gradient used to remap particle colors
  18966. * @param gradient defines the gradient to use (between 0 and 1)
  18967. * @param color defines the color to affect to the specified gradient
  18968. * @returns the current particle system
  18969. */
  18970. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18971. /**
  18972. * Gets the current list of ramp gradients.
  18973. * You must use addRampGradient and removeRampGradient to udpate this list
  18974. * @returns the list of ramp gradients
  18975. */
  18976. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18977. /** Gets or sets a boolean indicating that ramp gradients must be used
  18978. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18979. */
  18980. useRampGradients: boolean;
  18981. /**
  18982. * Adds a new color remap gradient
  18983. * @param gradient defines the gradient to use (between 0 and 1)
  18984. * @param min defines the color remap minimal range
  18985. * @param max defines the color remap maximal range
  18986. * @returns the current particle system
  18987. */
  18988. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18989. /**
  18990. * Gets the current list of color remap gradients.
  18991. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18992. * @returns the list of color remap gradients
  18993. */
  18994. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18995. /**
  18996. * Adds a new alpha remap gradient
  18997. * @param gradient defines the gradient to use (between 0 and 1)
  18998. * @param min defines the alpha remap minimal range
  18999. * @param max defines the alpha remap maximal range
  19000. * @returns the current particle system
  19001. */
  19002. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19003. /**
  19004. * Gets the current list of alpha remap gradients.
  19005. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19006. * @returns the list of alpha remap gradients
  19007. */
  19008. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19009. /**
  19010. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19011. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19012. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19013. * @returns the emitter
  19014. */
  19015. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19016. /**
  19017. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19018. * @param radius The radius of the hemisphere to emit from
  19019. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19020. * @returns the emitter
  19021. */
  19022. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19023. /**
  19024. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19025. * @param radius The radius of the sphere to emit from
  19026. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19027. * @returns the emitter
  19028. */
  19029. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19030. /**
  19031. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19032. * @param radius The radius of the sphere to emit from
  19033. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19034. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19035. * @returns the emitter
  19036. */
  19037. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19038. /**
  19039. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19040. * @param radius The radius of the emission cylinder
  19041. * @param height The height of the emission cylinder
  19042. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19043. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19044. * @returns the emitter
  19045. */
  19046. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19047. /**
  19048. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19049. * @param radius The radius of the cylinder to emit from
  19050. * @param height The height of the emission cylinder
  19051. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19052. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19053. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19054. * @returns the emitter
  19055. */
  19056. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19057. /**
  19058. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19059. * @param radius The radius of the cone to emit from
  19060. * @param angle The base angle of the cone
  19061. * @returns the emitter
  19062. */
  19063. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19064. /**
  19065. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19066. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19067. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19068. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19069. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19070. * @returns the emitter
  19071. */
  19072. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19073. /**
  19074. * Get hosting scene
  19075. * @returns the scene
  19076. */
  19077. getScene(): Scene;
  19078. }
  19079. }
  19080. declare module "babylonjs/Meshes/instancedMesh" {
  19081. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19082. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19083. import { Camera } from "babylonjs/Cameras/camera";
  19084. import { Node } from "babylonjs/node";
  19085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19086. import { Mesh } from "babylonjs/Meshes/mesh";
  19087. import { Material } from "babylonjs/Materials/material";
  19088. import { Skeleton } from "babylonjs/Bones/skeleton";
  19089. import { Light } from "babylonjs/Lights/light";
  19090. /**
  19091. * Creates an instance based on a source mesh.
  19092. */
  19093. export class InstancedMesh extends AbstractMesh {
  19094. private _sourceMesh;
  19095. private _currentLOD;
  19096. /** @hidden */
  19097. _indexInSourceMeshInstanceArray: number;
  19098. constructor(name: string, source: Mesh);
  19099. /**
  19100. * Returns the string "InstancedMesh".
  19101. */
  19102. getClassName(): string;
  19103. /** Gets the list of lights affecting that mesh */
  19104. readonly lightSources: Light[];
  19105. _resyncLightSources(): void;
  19106. _resyncLighSource(light: Light): void;
  19107. _removeLightSource(light: Light, dispose: boolean): void;
  19108. /**
  19109. * If the source mesh receives shadows
  19110. */
  19111. readonly receiveShadows: boolean;
  19112. /**
  19113. * The material of the source mesh
  19114. */
  19115. readonly material: Nullable<Material>;
  19116. /**
  19117. * Visibility of the source mesh
  19118. */
  19119. readonly visibility: number;
  19120. /**
  19121. * Skeleton of the source mesh
  19122. */
  19123. readonly skeleton: Nullable<Skeleton>;
  19124. /**
  19125. * Rendering ground id of the source mesh
  19126. */
  19127. renderingGroupId: number;
  19128. /**
  19129. * Returns the total number of vertices (integer).
  19130. */
  19131. getTotalVertices(): number;
  19132. /**
  19133. * Returns a positive integer : the total number of indices in this mesh geometry.
  19134. * @returns the numner of indices or zero if the mesh has no geometry.
  19135. */
  19136. getTotalIndices(): number;
  19137. /**
  19138. * The source mesh of the instance
  19139. */
  19140. readonly sourceMesh: Mesh;
  19141. /**
  19142. * Is this node ready to be used/rendered
  19143. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19144. * @return {boolean} is it ready
  19145. */
  19146. isReady(completeCheck?: boolean): boolean;
  19147. /**
  19148. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19149. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19150. * @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.
  19151. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19152. */
  19153. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19154. /**
  19155. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19156. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19157. * The `data` are either a numeric array either a Float32Array.
  19158. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19159. * 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).
  19160. * Note that a new underlying VertexBuffer object is created each call.
  19161. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19162. *
  19163. * Possible `kind` values :
  19164. * - VertexBuffer.PositionKind
  19165. * - VertexBuffer.UVKind
  19166. * - VertexBuffer.UV2Kind
  19167. * - VertexBuffer.UV3Kind
  19168. * - VertexBuffer.UV4Kind
  19169. * - VertexBuffer.UV5Kind
  19170. * - VertexBuffer.UV6Kind
  19171. * - VertexBuffer.ColorKind
  19172. * - VertexBuffer.MatricesIndicesKind
  19173. * - VertexBuffer.MatricesIndicesExtraKind
  19174. * - VertexBuffer.MatricesWeightsKind
  19175. * - VertexBuffer.MatricesWeightsExtraKind
  19176. *
  19177. * Returns the Mesh.
  19178. */
  19179. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19180. /**
  19181. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19182. * If the mesh has no geometry, it is simply returned as it is.
  19183. * The `data` are either a numeric array either a Float32Array.
  19184. * No new underlying VertexBuffer object is created.
  19185. * 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.
  19186. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19187. *
  19188. * Possible `kind` values :
  19189. * - VertexBuffer.PositionKind
  19190. * - VertexBuffer.UVKind
  19191. * - VertexBuffer.UV2Kind
  19192. * - VertexBuffer.UV3Kind
  19193. * - VertexBuffer.UV4Kind
  19194. * - VertexBuffer.UV5Kind
  19195. * - VertexBuffer.UV6Kind
  19196. * - VertexBuffer.ColorKind
  19197. * - VertexBuffer.MatricesIndicesKind
  19198. * - VertexBuffer.MatricesIndicesExtraKind
  19199. * - VertexBuffer.MatricesWeightsKind
  19200. * - VertexBuffer.MatricesWeightsExtraKind
  19201. *
  19202. * Returns the Mesh.
  19203. */
  19204. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19205. /**
  19206. * Sets the mesh indices.
  19207. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19208. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19209. * This method creates a new index buffer each call.
  19210. * Returns the Mesh.
  19211. */
  19212. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19213. /**
  19214. * Boolean : True if the mesh owns the requested kind of data.
  19215. */
  19216. isVerticesDataPresent(kind: string): boolean;
  19217. /**
  19218. * Returns an array of indices (IndicesArray).
  19219. */
  19220. getIndices(): Nullable<IndicesArray>;
  19221. readonly _positions: Nullable<Vector3[]>;
  19222. /**
  19223. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19224. * This means the mesh underlying bounding box and sphere are recomputed.
  19225. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19226. * @returns the current mesh
  19227. */
  19228. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19229. /** @hidden */
  19230. _preActivate(): InstancedMesh;
  19231. /** @hidden */
  19232. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19233. /** @hidden */
  19234. _postActivate(): void;
  19235. getWorldMatrix(): Matrix;
  19236. readonly isAnInstance: boolean;
  19237. /**
  19238. * Returns the current associated LOD AbstractMesh.
  19239. */
  19240. getLOD(camera: Camera): AbstractMesh;
  19241. /** @hidden */
  19242. _syncSubMeshes(): InstancedMesh;
  19243. /** @hidden */
  19244. _generatePointsArray(): boolean;
  19245. /**
  19246. * Creates a new InstancedMesh from the current mesh.
  19247. * - name (string) : the cloned mesh name
  19248. * - newParent (optional Node) : the optional Node to parent the clone to.
  19249. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19250. *
  19251. * Returns the clone.
  19252. */
  19253. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19254. /**
  19255. * Disposes the InstancedMesh.
  19256. * Returns nothing.
  19257. */
  19258. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19259. }
  19260. }
  19261. declare module "babylonjs/Materials/shaderMaterial" {
  19262. import { Scene } from "babylonjs/scene";
  19263. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19264. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19265. import { Mesh } from "babylonjs/Meshes/mesh";
  19266. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19267. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19268. import { Texture } from "babylonjs/Materials/Textures/texture";
  19269. import { Material } from "babylonjs/Materials/material";
  19270. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19271. /**
  19272. * Defines the options associated with the creation of a shader material.
  19273. */
  19274. export interface IShaderMaterialOptions {
  19275. /**
  19276. * Does the material work in alpha blend mode
  19277. */
  19278. needAlphaBlending: boolean;
  19279. /**
  19280. * Does the material work in alpha test mode
  19281. */
  19282. needAlphaTesting: boolean;
  19283. /**
  19284. * The list of attribute names used in the shader
  19285. */
  19286. attributes: string[];
  19287. /**
  19288. * The list of unifrom names used in the shader
  19289. */
  19290. uniforms: string[];
  19291. /**
  19292. * The list of UBO names used in the shader
  19293. */
  19294. uniformBuffers: string[];
  19295. /**
  19296. * The list of sampler names used in the shader
  19297. */
  19298. samplers: string[];
  19299. /**
  19300. * The list of defines used in the shader
  19301. */
  19302. defines: string[];
  19303. }
  19304. /**
  19305. * 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.
  19306. *
  19307. * This returned material effects how the mesh will look based on the code in the shaders.
  19308. *
  19309. * @see http://doc.babylonjs.com/how_to/shader_material
  19310. */
  19311. export class ShaderMaterial extends Material {
  19312. private _shaderPath;
  19313. private _options;
  19314. private _textures;
  19315. private _textureArrays;
  19316. private _floats;
  19317. private _ints;
  19318. private _floatsArrays;
  19319. private _colors3;
  19320. private _colors3Arrays;
  19321. private _colors4;
  19322. private _colors4Arrays;
  19323. private _vectors2;
  19324. private _vectors3;
  19325. private _vectors4;
  19326. private _matrices;
  19327. private _matrices3x3;
  19328. private _matrices2x2;
  19329. private _vectors2Arrays;
  19330. private _vectors3Arrays;
  19331. private _vectors4Arrays;
  19332. private _cachedWorldViewMatrix;
  19333. private _cachedWorldViewProjectionMatrix;
  19334. private _renderId;
  19335. /**
  19336. * Instantiate a new shader material.
  19337. * 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.
  19338. * This returned material effects how the mesh will look based on the code in the shaders.
  19339. * @see http://doc.babylonjs.com/how_to/shader_material
  19340. * @param name Define the name of the material in the scene
  19341. * @param scene Define the scene the material belongs to
  19342. * @param shaderPath Defines the route to the shader code in one of three ways:
  19343. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19344. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19345. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19346. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19347. * @param options Define the options used to create the shader
  19348. */
  19349. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19350. /**
  19351. * Gets the options used to compile the shader.
  19352. * They can be modified to trigger a new compilation
  19353. */
  19354. readonly options: IShaderMaterialOptions;
  19355. /**
  19356. * Gets the current class name of the material e.g. "ShaderMaterial"
  19357. * Mainly use in serialization.
  19358. * @returns the class name
  19359. */
  19360. getClassName(): string;
  19361. /**
  19362. * Specifies if the material will require alpha blending
  19363. * @returns a boolean specifying if alpha blending is needed
  19364. */
  19365. needAlphaBlending(): boolean;
  19366. /**
  19367. * Specifies if this material should be rendered in alpha test mode
  19368. * @returns a boolean specifying if an alpha test is needed.
  19369. */
  19370. needAlphaTesting(): boolean;
  19371. private _checkUniform;
  19372. /**
  19373. * Set a texture in the shader.
  19374. * @param name Define the name of the uniform samplers as defined in the shader
  19375. * @param texture Define the texture to bind to this sampler
  19376. * @return the material itself allowing "fluent" like uniform updates
  19377. */
  19378. setTexture(name: string, texture: Texture): ShaderMaterial;
  19379. /**
  19380. * Set a texture array in the shader.
  19381. * @param name Define the name of the uniform sampler array as defined in the shader
  19382. * @param textures Define the list of textures to bind to this sampler
  19383. * @return the material itself allowing "fluent" like uniform updates
  19384. */
  19385. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19386. /**
  19387. * Set a float in the shader.
  19388. * @param name Define the name of the uniform as defined in the shader
  19389. * @param value Define the value to give to the uniform
  19390. * @return the material itself allowing "fluent" like uniform updates
  19391. */
  19392. setFloat(name: string, value: number): ShaderMaterial;
  19393. /**
  19394. * Set a int in the shader.
  19395. * @param name Define the name of the uniform as defined in the shader
  19396. * @param value Define the value to give to the uniform
  19397. * @return the material itself allowing "fluent" like uniform updates
  19398. */
  19399. setInt(name: string, value: number): ShaderMaterial;
  19400. /**
  19401. * Set an array of floats in the shader.
  19402. * @param name Define the name of the uniform as defined in the shader
  19403. * @param value Define the value to give to the uniform
  19404. * @return the material itself allowing "fluent" like uniform updates
  19405. */
  19406. setFloats(name: string, value: number[]): ShaderMaterial;
  19407. /**
  19408. * Set a vec3 in the shader from a Color3.
  19409. * @param name Define the name of the uniform as defined in the shader
  19410. * @param value Define the value to give to the uniform
  19411. * @return the material itself allowing "fluent" like uniform updates
  19412. */
  19413. setColor3(name: string, value: Color3): ShaderMaterial;
  19414. /**
  19415. * Set a vec3 array in the shader from a Color3 array.
  19416. * @param name Define the name of the uniform as defined in the shader
  19417. * @param value Define the value to give to the uniform
  19418. * @return the material itself allowing "fluent" like uniform updates
  19419. */
  19420. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19421. /**
  19422. * Set a vec4 in the shader from a Color4.
  19423. * @param name Define the name of the uniform as defined in the shader
  19424. * @param value Define the value to give to the uniform
  19425. * @return the material itself allowing "fluent" like uniform updates
  19426. */
  19427. setColor4(name: string, value: Color4): ShaderMaterial;
  19428. /**
  19429. * Set a vec4 array in the shader from a Color4 array.
  19430. * @param name Define the name of the uniform as defined in the shader
  19431. * @param value Define the value to give to the uniform
  19432. * @return the material itself allowing "fluent" like uniform updates
  19433. */
  19434. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19435. /**
  19436. * Set a vec2 in the shader from a Vector2.
  19437. * @param name Define the name of the uniform as defined in the shader
  19438. * @param value Define the value to give to the uniform
  19439. * @return the material itself allowing "fluent" like uniform updates
  19440. */
  19441. setVector2(name: string, value: Vector2): ShaderMaterial;
  19442. /**
  19443. * Set a vec3 in the shader from a Vector3.
  19444. * @param name Define the name of the uniform as defined in the shader
  19445. * @param value Define the value to give to the uniform
  19446. * @return the material itself allowing "fluent" like uniform updates
  19447. */
  19448. setVector3(name: string, value: Vector3): ShaderMaterial;
  19449. /**
  19450. * Set a vec4 in the shader from a Vector4.
  19451. * @param name Define the name of the uniform as defined in the shader
  19452. * @param value Define the value to give to the uniform
  19453. * @return the material itself allowing "fluent" like uniform updates
  19454. */
  19455. setVector4(name: string, value: Vector4): ShaderMaterial;
  19456. /**
  19457. * Set a mat4 in the shader from a Matrix.
  19458. * @param name Define the name of the uniform as defined in the shader
  19459. * @param value Define the value to give to the uniform
  19460. * @return the material itself allowing "fluent" like uniform updates
  19461. */
  19462. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19463. /**
  19464. * Set a mat3 in the shader from a Float32Array.
  19465. * @param name Define the name of the uniform as defined in the shader
  19466. * @param value Define the value to give to the uniform
  19467. * @return the material itself allowing "fluent" like uniform updates
  19468. */
  19469. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19470. /**
  19471. * Set a mat2 in the shader from a Float32Array.
  19472. * @param name Define the name of the uniform as defined in the shader
  19473. * @param value Define the value to give to the uniform
  19474. * @return the material itself allowing "fluent" like uniform updates
  19475. */
  19476. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19477. /**
  19478. * Set a vec2 array in the shader from a number array.
  19479. * @param name Define the name of the uniform as defined in the shader
  19480. * @param value Define the value to give to the uniform
  19481. * @return the material itself allowing "fluent" like uniform updates
  19482. */
  19483. setArray2(name: string, value: number[]): ShaderMaterial;
  19484. /**
  19485. * Set a vec3 array in the shader from a number array.
  19486. * @param name Define the name of the uniform as defined in the shader
  19487. * @param value Define the value to give to the uniform
  19488. * @return the material itself allowing "fluent" like uniform updates
  19489. */
  19490. setArray3(name: string, value: number[]): ShaderMaterial;
  19491. /**
  19492. * Set a vec4 array in the shader from a number array.
  19493. * @param name Define the name of the uniform as defined in the shader
  19494. * @param value Define the value to give to the uniform
  19495. * @return the material itself allowing "fluent" like uniform updates
  19496. */
  19497. setArray4(name: string, value: number[]): ShaderMaterial;
  19498. private _checkCache;
  19499. /**
  19500. * Specifies that the submesh is ready to be used
  19501. * @param mesh defines the mesh to check
  19502. * @param subMesh defines which submesh to check
  19503. * @param useInstances specifies that instances should be used
  19504. * @returns a boolean indicating that the submesh is ready or not
  19505. */
  19506. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19507. /**
  19508. * Checks if the material is ready to render the requested mesh
  19509. * @param mesh Define the mesh to render
  19510. * @param useInstances Define whether or not the material is used with instances
  19511. * @returns true if ready, otherwise false
  19512. */
  19513. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19514. /**
  19515. * Binds the world matrix to the material
  19516. * @param world defines the world transformation matrix
  19517. */
  19518. bindOnlyWorldMatrix(world: Matrix): void;
  19519. /**
  19520. * Binds the material to the mesh
  19521. * @param world defines the world transformation matrix
  19522. * @param mesh defines the mesh to bind the material to
  19523. */
  19524. bind(world: Matrix, mesh?: Mesh): void;
  19525. /**
  19526. * Gets the active textures from the material
  19527. * @returns an array of textures
  19528. */
  19529. getActiveTextures(): BaseTexture[];
  19530. /**
  19531. * Specifies if the material uses a texture
  19532. * @param texture defines the texture to check against the material
  19533. * @returns a boolean specifying if the material uses the texture
  19534. */
  19535. hasTexture(texture: BaseTexture): boolean;
  19536. /**
  19537. * Makes a duplicate of the material, and gives it a new name
  19538. * @param name defines the new name for the duplicated material
  19539. * @returns the cloned material
  19540. */
  19541. clone(name: string): ShaderMaterial;
  19542. /**
  19543. * Disposes the material
  19544. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19545. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19546. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19547. */
  19548. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19549. /**
  19550. * Serializes this material in a JSON representation
  19551. * @returns the serialized material object
  19552. */
  19553. serialize(): any;
  19554. /**
  19555. * Creates a shader material from parsed shader material data
  19556. * @param source defines the JSON represnetation of the material
  19557. * @param scene defines the hosting scene
  19558. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19559. * @returns a new material
  19560. */
  19561. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19562. }
  19563. }
  19564. declare module "babylonjs/Shaders/color.fragment" {
  19565. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19566. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19567. /** @hidden */
  19568. export var colorPixelShader: {
  19569. name: string;
  19570. shader: string;
  19571. };
  19572. }
  19573. declare module "babylonjs/Shaders/color.vertex" {
  19574. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19575. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19576. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19577. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19578. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19579. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19580. /** @hidden */
  19581. export var colorVertexShader: {
  19582. name: string;
  19583. shader: string;
  19584. };
  19585. }
  19586. declare module "babylonjs/Meshes/linesMesh" {
  19587. import { Nullable } from "babylonjs/types";
  19588. import { Scene } from "babylonjs/scene";
  19589. import { Color3 } from "babylonjs/Maths/math.color";
  19590. import { Node } from "babylonjs/node";
  19591. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19592. import { Mesh } from "babylonjs/Meshes/mesh";
  19593. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19594. import { Effect } from "babylonjs/Materials/effect";
  19595. import { Material } from "babylonjs/Materials/material";
  19596. import "babylonjs/Shaders/color.fragment";
  19597. import "babylonjs/Shaders/color.vertex";
  19598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19599. /**
  19600. * Line mesh
  19601. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19602. */
  19603. export class LinesMesh extends Mesh {
  19604. /**
  19605. * If vertex color should be applied to the mesh
  19606. */
  19607. readonly useVertexColor?: boolean | undefined;
  19608. /**
  19609. * If vertex alpha should be applied to the mesh
  19610. */
  19611. readonly useVertexAlpha?: boolean | undefined;
  19612. /**
  19613. * Color of the line (Default: White)
  19614. */
  19615. color: Color3;
  19616. /**
  19617. * Alpha of the line (Default: 1)
  19618. */
  19619. alpha: number;
  19620. /**
  19621. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19622. * This margin is expressed in world space coordinates, so its value may vary.
  19623. * Default value is 0.1
  19624. */
  19625. intersectionThreshold: number;
  19626. private _colorShader;
  19627. private color4;
  19628. /**
  19629. * Creates a new LinesMesh
  19630. * @param name defines the name
  19631. * @param scene defines the hosting scene
  19632. * @param parent defines the parent mesh if any
  19633. * @param source defines the optional source LinesMesh used to clone data from
  19634. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19635. * When false, achieved by calling a clone(), also passing False.
  19636. * This will make creation of children, recursive.
  19637. * @param useVertexColor defines if this LinesMesh supports vertex color
  19638. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19639. */
  19640. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19641. /**
  19642. * If vertex color should be applied to the mesh
  19643. */
  19644. useVertexColor?: boolean | undefined,
  19645. /**
  19646. * If vertex alpha should be applied to the mesh
  19647. */
  19648. useVertexAlpha?: boolean | undefined);
  19649. private _addClipPlaneDefine;
  19650. private _removeClipPlaneDefine;
  19651. isReady(): boolean;
  19652. /**
  19653. * Returns the string "LineMesh"
  19654. */
  19655. getClassName(): string;
  19656. /**
  19657. * @hidden
  19658. */
  19659. /**
  19660. * @hidden
  19661. */
  19662. material: Material;
  19663. /**
  19664. * @hidden
  19665. */
  19666. readonly checkCollisions: boolean;
  19667. /** @hidden */
  19668. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19669. /** @hidden */
  19670. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19671. /**
  19672. * Disposes of the line mesh
  19673. * @param doNotRecurse If children should be disposed
  19674. */
  19675. dispose(doNotRecurse?: boolean): void;
  19676. /**
  19677. * Returns a new LineMesh object cloned from the current one.
  19678. */
  19679. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19680. /**
  19681. * Creates a new InstancedLinesMesh object from the mesh model.
  19682. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19683. * @param name defines the name of the new instance
  19684. * @returns a new InstancedLinesMesh
  19685. */
  19686. createInstance(name: string): InstancedLinesMesh;
  19687. }
  19688. /**
  19689. * Creates an instance based on a source LinesMesh
  19690. */
  19691. export class InstancedLinesMesh extends InstancedMesh {
  19692. /**
  19693. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19694. * This margin is expressed in world space coordinates, so its value may vary.
  19695. * Initilized with the intersectionThreshold value of the source LinesMesh
  19696. */
  19697. intersectionThreshold: number;
  19698. constructor(name: string, source: LinesMesh);
  19699. /**
  19700. * Returns the string "InstancedLinesMesh".
  19701. */
  19702. getClassName(): string;
  19703. }
  19704. }
  19705. declare module "babylonjs/Shaders/line.fragment" {
  19706. /** @hidden */
  19707. export var linePixelShader: {
  19708. name: string;
  19709. shader: string;
  19710. };
  19711. }
  19712. declare module "babylonjs/Shaders/line.vertex" {
  19713. /** @hidden */
  19714. export var lineVertexShader: {
  19715. name: string;
  19716. shader: string;
  19717. };
  19718. }
  19719. declare module "babylonjs/Rendering/edgesRenderer" {
  19720. import { Nullable } from "babylonjs/types";
  19721. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19722. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19723. import { Vector3 } from "babylonjs/Maths/math.vector";
  19724. import { IDisposable } from "babylonjs/scene";
  19725. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19726. import "babylonjs/Shaders/line.fragment";
  19727. import "babylonjs/Shaders/line.vertex";
  19728. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19729. module "babylonjs/Meshes/abstractMesh" {
  19730. interface AbstractMesh {
  19731. /**
  19732. * Gets the edgesRenderer associated with the mesh
  19733. */
  19734. edgesRenderer: Nullable<EdgesRenderer>;
  19735. }
  19736. }
  19737. module "babylonjs/Meshes/linesMesh" {
  19738. interface LinesMesh {
  19739. /**
  19740. * Enables the edge rendering mode on the mesh.
  19741. * This mode makes the mesh edges visible
  19742. * @param epsilon defines the maximal distance between two angles to detect a face
  19743. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19744. * @returns the currentAbstractMesh
  19745. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19746. */
  19747. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19748. }
  19749. }
  19750. module "babylonjs/Meshes/linesMesh" {
  19751. interface InstancedLinesMesh {
  19752. /**
  19753. * Enables the edge rendering mode on the mesh.
  19754. * This mode makes the mesh edges visible
  19755. * @param epsilon defines the maximal distance between two angles to detect a face
  19756. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19757. * @returns the current InstancedLinesMesh
  19758. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19759. */
  19760. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19761. }
  19762. }
  19763. /**
  19764. * Defines the minimum contract an Edges renderer should follow.
  19765. */
  19766. export interface IEdgesRenderer extends IDisposable {
  19767. /**
  19768. * Gets or sets a boolean indicating if the edgesRenderer is active
  19769. */
  19770. isEnabled: boolean;
  19771. /**
  19772. * Renders the edges of the attached mesh,
  19773. */
  19774. render(): void;
  19775. /**
  19776. * Checks wether or not the edges renderer is ready to render.
  19777. * @return true if ready, otherwise false.
  19778. */
  19779. isReady(): boolean;
  19780. }
  19781. /**
  19782. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19783. */
  19784. export class EdgesRenderer implements IEdgesRenderer {
  19785. /**
  19786. * Define the size of the edges with an orthographic camera
  19787. */
  19788. edgesWidthScalerForOrthographic: number;
  19789. /**
  19790. * Define the size of the edges with a perspective camera
  19791. */
  19792. edgesWidthScalerForPerspective: number;
  19793. protected _source: AbstractMesh;
  19794. protected _linesPositions: number[];
  19795. protected _linesNormals: number[];
  19796. protected _linesIndices: number[];
  19797. protected _epsilon: number;
  19798. protected _indicesCount: number;
  19799. protected _lineShader: ShaderMaterial;
  19800. protected _ib: DataBuffer;
  19801. protected _buffers: {
  19802. [key: string]: Nullable<VertexBuffer>;
  19803. };
  19804. protected _checkVerticesInsteadOfIndices: boolean;
  19805. private _meshRebuildObserver;
  19806. private _meshDisposeObserver;
  19807. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19808. isEnabled: boolean;
  19809. /**
  19810. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19811. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19812. * @param source Mesh used to create edges
  19813. * @param epsilon sum of angles in adjacency to check for edge
  19814. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19815. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19816. */
  19817. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19818. protected _prepareRessources(): void;
  19819. /** @hidden */
  19820. _rebuild(): void;
  19821. /**
  19822. * Releases the required resources for the edges renderer
  19823. */
  19824. dispose(): void;
  19825. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19826. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19827. /**
  19828. * Checks if the pair of p0 and p1 is en edge
  19829. * @param faceIndex
  19830. * @param edge
  19831. * @param faceNormals
  19832. * @param p0
  19833. * @param p1
  19834. * @private
  19835. */
  19836. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19837. /**
  19838. * push line into the position, normal and index buffer
  19839. * @protected
  19840. */
  19841. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19842. /**
  19843. * Generates lines edges from adjacencjes
  19844. * @private
  19845. */
  19846. _generateEdgesLines(): void;
  19847. /**
  19848. * Checks wether or not the edges renderer is ready to render.
  19849. * @return true if ready, otherwise false.
  19850. */
  19851. isReady(): boolean;
  19852. /**
  19853. * Renders the edges of the attached mesh,
  19854. */
  19855. render(): void;
  19856. }
  19857. /**
  19858. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19859. */
  19860. export class LineEdgesRenderer extends EdgesRenderer {
  19861. /**
  19862. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19863. * @param source LineMesh used to generate edges
  19864. * @param epsilon not important (specified angle for edge detection)
  19865. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19866. */
  19867. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19868. /**
  19869. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19870. */
  19871. _generateEdgesLines(): void;
  19872. }
  19873. }
  19874. declare module "babylonjs/Rendering/renderingGroup" {
  19875. import { SmartArray } from "babylonjs/Misc/smartArray";
  19876. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19878. import { Nullable } from "babylonjs/types";
  19879. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19880. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  19881. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19882. import { Material } from "babylonjs/Materials/material";
  19883. import { Scene } from "babylonjs/scene";
  19884. /**
  19885. * This represents the object necessary to create a rendering group.
  19886. * This is exclusively used and created by the rendering manager.
  19887. * To modify the behavior, you use the available helpers in your scene or meshes.
  19888. * @hidden
  19889. */
  19890. export class RenderingGroup {
  19891. index: number;
  19892. private static _zeroVector;
  19893. private _scene;
  19894. private _opaqueSubMeshes;
  19895. private _transparentSubMeshes;
  19896. private _alphaTestSubMeshes;
  19897. private _depthOnlySubMeshes;
  19898. private _particleSystems;
  19899. private _spriteManagers;
  19900. private _opaqueSortCompareFn;
  19901. private _alphaTestSortCompareFn;
  19902. private _transparentSortCompareFn;
  19903. private _renderOpaque;
  19904. private _renderAlphaTest;
  19905. private _renderTransparent;
  19906. /** @hidden */
  19907. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19908. onBeforeTransparentRendering: () => void;
  19909. /**
  19910. * Set the opaque sort comparison function.
  19911. * If null the sub meshes will be render in the order they were created
  19912. */
  19913. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19914. /**
  19915. * Set the alpha test sort comparison function.
  19916. * If null the sub meshes will be render in the order they were created
  19917. */
  19918. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19919. /**
  19920. * Set the transparent sort comparison function.
  19921. * If null the sub meshes will be render in the order they were created
  19922. */
  19923. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19924. /**
  19925. * Creates a new rendering group.
  19926. * @param index The rendering group index
  19927. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19928. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19929. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19930. */
  19931. 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>);
  19932. /**
  19933. * Render all the sub meshes contained in the group.
  19934. * @param customRenderFunction Used to override the default render behaviour of the group.
  19935. * @returns true if rendered some submeshes.
  19936. */
  19937. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19938. /**
  19939. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19940. * @param subMeshes The submeshes to render
  19941. */
  19942. private renderOpaqueSorted;
  19943. /**
  19944. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19945. * @param subMeshes The submeshes to render
  19946. */
  19947. private renderAlphaTestSorted;
  19948. /**
  19949. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19950. * @param subMeshes The submeshes to render
  19951. */
  19952. private renderTransparentSorted;
  19953. /**
  19954. * Renders the submeshes in a specified order.
  19955. * @param subMeshes The submeshes to sort before render
  19956. * @param sortCompareFn The comparison function use to sort
  19957. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19958. * @param transparent Specifies to activate blending if true
  19959. */
  19960. private static renderSorted;
  19961. /**
  19962. * Renders the submeshes in the order they were dispatched (no sort applied).
  19963. * @param subMeshes The submeshes to render
  19964. */
  19965. private static renderUnsorted;
  19966. /**
  19967. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19968. * are rendered back to front if in the same alpha index.
  19969. *
  19970. * @param a The first submesh
  19971. * @param b The second submesh
  19972. * @returns The result of the comparison
  19973. */
  19974. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19975. /**
  19976. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19977. * are rendered back to front.
  19978. *
  19979. * @param a The first submesh
  19980. * @param b The second submesh
  19981. * @returns The result of the comparison
  19982. */
  19983. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19984. /**
  19985. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19986. * are rendered front to back (prevent overdraw).
  19987. *
  19988. * @param a The first submesh
  19989. * @param b The second submesh
  19990. * @returns The result of the comparison
  19991. */
  19992. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19993. /**
  19994. * Resets the different lists of submeshes to prepare a new frame.
  19995. */
  19996. prepare(): void;
  19997. dispose(): void;
  19998. /**
  19999. * Inserts the submesh in its correct queue depending on its material.
  20000. * @param subMesh The submesh to dispatch
  20001. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20002. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20003. */
  20004. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20005. dispatchSprites(spriteManager: ISpriteManager): void;
  20006. dispatchParticles(particleSystem: IParticleSystem): void;
  20007. private _renderParticles;
  20008. private _renderSprites;
  20009. }
  20010. }
  20011. declare module "babylonjs/Rendering/renderingManager" {
  20012. import { Nullable } from "babylonjs/types";
  20013. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20014. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20015. import { SmartArray } from "babylonjs/Misc/smartArray";
  20016. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20017. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20018. import { Material } from "babylonjs/Materials/material";
  20019. import { Scene } from "babylonjs/scene";
  20020. import { Camera } from "babylonjs/Cameras/camera";
  20021. /**
  20022. * Interface describing the different options available in the rendering manager
  20023. * regarding Auto Clear between groups.
  20024. */
  20025. export interface IRenderingManagerAutoClearSetup {
  20026. /**
  20027. * Defines whether or not autoclear is enable.
  20028. */
  20029. autoClear: boolean;
  20030. /**
  20031. * Defines whether or not to autoclear the depth buffer.
  20032. */
  20033. depth: boolean;
  20034. /**
  20035. * Defines whether or not to autoclear the stencil buffer.
  20036. */
  20037. stencil: boolean;
  20038. }
  20039. /**
  20040. * This class is used by the onRenderingGroupObservable
  20041. */
  20042. export class RenderingGroupInfo {
  20043. /**
  20044. * The Scene that being rendered
  20045. */
  20046. scene: Scene;
  20047. /**
  20048. * The camera currently used for the rendering pass
  20049. */
  20050. camera: Nullable<Camera>;
  20051. /**
  20052. * The ID of the renderingGroup being processed
  20053. */
  20054. renderingGroupId: number;
  20055. }
  20056. /**
  20057. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20058. * It is enable to manage the different groups as well as the different necessary sort functions.
  20059. * This should not be used directly aside of the few static configurations
  20060. */
  20061. export class RenderingManager {
  20062. /**
  20063. * The max id used for rendering groups (not included)
  20064. */
  20065. static MAX_RENDERINGGROUPS: number;
  20066. /**
  20067. * The min id used for rendering groups (included)
  20068. */
  20069. static MIN_RENDERINGGROUPS: number;
  20070. /**
  20071. * Used to globally prevent autoclearing scenes.
  20072. */
  20073. static AUTOCLEAR: boolean;
  20074. /**
  20075. * @hidden
  20076. */
  20077. _useSceneAutoClearSetup: boolean;
  20078. private _scene;
  20079. private _renderingGroups;
  20080. private _depthStencilBufferAlreadyCleaned;
  20081. private _autoClearDepthStencil;
  20082. private _customOpaqueSortCompareFn;
  20083. private _customAlphaTestSortCompareFn;
  20084. private _customTransparentSortCompareFn;
  20085. private _renderingGroupInfo;
  20086. /**
  20087. * Instantiates a new rendering group for a particular scene
  20088. * @param scene Defines the scene the groups belongs to
  20089. */
  20090. constructor(scene: Scene);
  20091. private _clearDepthStencilBuffer;
  20092. /**
  20093. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20094. * @hidden
  20095. */
  20096. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20097. /**
  20098. * Resets the different information of the group to prepare a new frame
  20099. * @hidden
  20100. */
  20101. reset(): void;
  20102. /**
  20103. * Dispose and release the group and its associated resources.
  20104. * @hidden
  20105. */
  20106. dispose(): void;
  20107. /**
  20108. * Clear the info related to rendering groups preventing retention points during dispose.
  20109. */
  20110. freeRenderingGroups(): void;
  20111. private _prepareRenderingGroup;
  20112. /**
  20113. * Add a sprite manager to the rendering manager in order to render it this frame.
  20114. * @param spriteManager Define the sprite manager to render
  20115. */
  20116. dispatchSprites(spriteManager: ISpriteManager): void;
  20117. /**
  20118. * Add a particle system to the rendering manager in order to render it this frame.
  20119. * @param particleSystem Define the particle system to render
  20120. */
  20121. dispatchParticles(particleSystem: IParticleSystem): void;
  20122. /**
  20123. * Add a submesh to the manager in order to render it this frame
  20124. * @param subMesh The submesh to dispatch
  20125. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20126. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20127. */
  20128. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20129. /**
  20130. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20131. * This allowed control for front to back rendering or reversly depending of the special needs.
  20132. *
  20133. * @param renderingGroupId The rendering group id corresponding to its index
  20134. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20135. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20136. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20137. */
  20138. 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;
  20139. /**
  20140. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20141. *
  20142. * @param renderingGroupId The rendering group id corresponding to its index
  20143. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20144. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20145. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20146. */
  20147. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20148. /**
  20149. * Gets the current auto clear configuration for one rendering group of the rendering
  20150. * manager.
  20151. * @param index the rendering group index to get the information for
  20152. * @returns The auto clear setup for the requested rendering group
  20153. */
  20154. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20155. }
  20156. }
  20157. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20158. import { Observable } from "babylonjs/Misc/observable";
  20159. import { SmartArray } from "babylonjs/Misc/smartArray";
  20160. import { Nullable } from "babylonjs/types";
  20161. import { Camera } from "babylonjs/Cameras/camera";
  20162. import { Scene } from "babylonjs/scene";
  20163. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20164. import { Color4 } from "babylonjs/Maths/math.color";
  20165. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20167. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20168. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20169. import { Texture } from "babylonjs/Materials/Textures/texture";
  20170. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20171. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20172. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20173. import { Engine } from "babylonjs/Engines/engine";
  20174. /**
  20175. * This Helps creating a texture that will be created from a camera in your scene.
  20176. * It is basically a dynamic texture that could be used to create special effects for instance.
  20177. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20178. */
  20179. export class RenderTargetTexture extends Texture {
  20180. isCube: boolean;
  20181. /**
  20182. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20183. */
  20184. static readonly REFRESHRATE_RENDER_ONCE: number;
  20185. /**
  20186. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20187. */
  20188. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20189. /**
  20190. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20191. * the central point of your effect and can save a lot of performances.
  20192. */
  20193. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20194. /**
  20195. * Use this predicate to dynamically define the list of mesh you want to render.
  20196. * If set, the renderList property will be overwritten.
  20197. */
  20198. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20199. private _renderList;
  20200. /**
  20201. * Use this list to define the list of mesh you want to render.
  20202. */
  20203. renderList: Nullable<Array<AbstractMesh>>;
  20204. private _hookArray;
  20205. /**
  20206. * Define if particles should be rendered in your texture.
  20207. */
  20208. renderParticles: boolean;
  20209. /**
  20210. * Define if sprites should be rendered in your texture.
  20211. */
  20212. renderSprites: boolean;
  20213. /**
  20214. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20215. */
  20216. coordinatesMode: number;
  20217. /**
  20218. * Define the camera used to render the texture.
  20219. */
  20220. activeCamera: Nullable<Camera>;
  20221. /**
  20222. * Override the render function of the texture with your own one.
  20223. */
  20224. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20225. /**
  20226. * Define if camera post processes should be use while rendering the texture.
  20227. */
  20228. useCameraPostProcesses: boolean;
  20229. /**
  20230. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20231. */
  20232. ignoreCameraViewport: boolean;
  20233. private _postProcessManager;
  20234. private _postProcesses;
  20235. private _resizeObserver;
  20236. /**
  20237. * An event triggered when the texture is unbind.
  20238. */
  20239. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20240. /**
  20241. * An event triggered when the texture is unbind.
  20242. */
  20243. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20244. private _onAfterUnbindObserver;
  20245. /**
  20246. * Set a after unbind callback in the texture.
  20247. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20248. */
  20249. onAfterUnbind: () => void;
  20250. /**
  20251. * An event triggered before rendering the texture
  20252. */
  20253. onBeforeRenderObservable: Observable<number>;
  20254. private _onBeforeRenderObserver;
  20255. /**
  20256. * Set a before render callback in the texture.
  20257. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20258. */
  20259. onBeforeRender: (faceIndex: number) => void;
  20260. /**
  20261. * An event triggered after rendering the texture
  20262. */
  20263. onAfterRenderObservable: Observable<number>;
  20264. private _onAfterRenderObserver;
  20265. /**
  20266. * Set a after render callback in the texture.
  20267. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20268. */
  20269. onAfterRender: (faceIndex: number) => void;
  20270. /**
  20271. * An event triggered after the texture clear
  20272. */
  20273. onClearObservable: Observable<Engine>;
  20274. private _onClearObserver;
  20275. /**
  20276. * Set a clear callback in the texture.
  20277. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20278. */
  20279. onClear: (Engine: Engine) => void;
  20280. /**
  20281. * An event triggered when the texture is resized.
  20282. */
  20283. onResizeObservable: Observable<RenderTargetTexture>;
  20284. /**
  20285. * Define the clear color of the Render Target if it should be different from the scene.
  20286. */
  20287. clearColor: Color4;
  20288. protected _size: number | {
  20289. width: number;
  20290. height: number;
  20291. };
  20292. protected _initialSizeParameter: number | {
  20293. width: number;
  20294. height: number;
  20295. } | {
  20296. ratio: number;
  20297. };
  20298. protected _sizeRatio: Nullable<number>;
  20299. /** @hidden */
  20300. _generateMipMaps: boolean;
  20301. protected _renderingManager: RenderingManager;
  20302. /** @hidden */
  20303. _waitingRenderList: string[];
  20304. protected _doNotChangeAspectRatio: boolean;
  20305. protected _currentRefreshId: number;
  20306. protected _refreshRate: number;
  20307. protected _textureMatrix: Matrix;
  20308. protected _samples: number;
  20309. protected _renderTargetOptions: RenderTargetCreationOptions;
  20310. /**
  20311. * Gets render target creation options that were used.
  20312. */
  20313. readonly renderTargetOptions: RenderTargetCreationOptions;
  20314. protected _engine: Engine;
  20315. protected _onRatioRescale(): void;
  20316. /**
  20317. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20318. * It must define where the camera used to render the texture is set
  20319. */
  20320. boundingBoxPosition: Vector3;
  20321. private _boundingBoxSize;
  20322. /**
  20323. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20324. * When defined, the cubemap will switch to local mode
  20325. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20326. * @example https://www.babylonjs-playground.com/#RNASML
  20327. */
  20328. boundingBoxSize: Vector3;
  20329. /**
  20330. * In case the RTT has been created with a depth texture, get the associated
  20331. * depth texture.
  20332. * Otherwise, return null.
  20333. */
  20334. depthStencilTexture: Nullable<InternalTexture>;
  20335. /**
  20336. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20337. * or used a shadow, depth texture...
  20338. * @param name The friendly name of the texture
  20339. * @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)
  20340. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20341. * @param generateMipMaps True if mip maps need to be generated after render.
  20342. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20343. * @param type The type of the buffer in the RTT (int, half float, float...)
  20344. * @param isCube True if a cube texture needs to be created
  20345. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20346. * @param generateDepthBuffer True to generate a depth buffer
  20347. * @param generateStencilBuffer True to generate a stencil buffer
  20348. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20349. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20350. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20351. */
  20352. constructor(name: string, size: number | {
  20353. width: number;
  20354. height: number;
  20355. } | {
  20356. ratio: number;
  20357. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20358. /**
  20359. * Creates a depth stencil texture.
  20360. * This is only available in WebGL 2 or with the depth texture extension available.
  20361. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20362. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20363. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20364. */
  20365. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20366. private _processSizeParameter;
  20367. /**
  20368. * Define the number of samples to use in case of MSAA.
  20369. * It defaults to one meaning no MSAA has been enabled.
  20370. */
  20371. samples: number;
  20372. /**
  20373. * Resets the refresh counter of the texture and start bak from scratch.
  20374. * Could be useful to regenerate the texture if it is setup to render only once.
  20375. */
  20376. resetRefreshCounter(): void;
  20377. /**
  20378. * Define the refresh rate of the texture or the rendering frequency.
  20379. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20380. */
  20381. refreshRate: number;
  20382. /**
  20383. * Adds a post process to the render target rendering passes.
  20384. * @param postProcess define the post process to add
  20385. */
  20386. addPostProcess(postProcess: PostProcess): void;
  20387. /**
  20388. * Clear all the post processes attached to the render target
  20389. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20390. */
  20391. clearPostProcesses(dispose?: boolean): void;
  20392. /**
  20393. * Remove one of the post process from the list of attached post processes to the texture
  20394. * @param postProcess define the post process to remove from the list
  20395. */
  20396. removePostProcess(postProcess: PostProcess): void;
  20397. /** @hidden */
  20398. _shouldRender(): boolean;
  20399. /**
  20400. * Gets the actual render size of the texture.
  20401. * @returns the width of the render size
  20402. */
  20403. getRenderSize(): number;
  20404. /**
  20405. * Gets the actual render width of the texture.
  20406. * @returns the width of the render size
  20407. */
  20408. getRenderWidth(): number;
  20409. /**
  20410. * Gets the actual render height of the texture.
  20411. * @returns the height of the render size
  20412. */
  20413. getRenderHeight(): number;
  20414. /**
  20415. * Get if the texture can be rescaled or not.
  20416. */
  20417. readonly canRescale: boolean;
  20418. /**
  20419. * Resize the texture using a ratio.
  20420. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20421. */
  20422. scale(ratio: number): void;
  20423. /**
  20424. * Get the texture reflection matrix used to rotate/transform the reflection.
  20425. * @returns the reflection matrix
  20426. */
  20427. getReflectionTextureMatrix(): Matrix;
  20428. /**
  20429. * Resize the texture to a new desired size.
  20430. * Be carrefull as it will recreate all the data in the new texture.
  20431. * @param size Define the new size. It can be:
  20432. * - a number for squared texture,
  20433. * - an object containing { width: number, height: number }
  20434. * - or an object containing a ratio { ratio: number }
  20435. */
  20436. resize(size: number | {
  20437. width: number;
  20438. height: number;
  20439. } | {
  20440. ratio: number;
  20441. }): void;
  20442. /**
  20443. * Renders all the objects from the render list into the texture.
  20444. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20445. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20446. */
  20447. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20448. private _bestReflectionRenderTargetDimension;
  20449. /**
  20450. * @hidden
  20451. * @param faceIndex face index to bind to if this is a cubetexture
  20452. */
  20453. _bindFrameBuffer(faceIndex?: number): void;
  20454. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20455. private renderToTarget;
  20456. /**
  20457. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20458. * This allowed control for front to back rendering or reversly depending of the special needs.
  20459. *
  20460. * @param renderingGroupId The rendering group id corresponding to its index
  20461. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20462. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20463. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20464. */
  20465. 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;
  20466. /**
  20467. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20468. *
  20469. * @param renderingGroupId The rendering group id corresponding to its index
  20470. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20471. */
  20472. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20473. /**
  20474. * Clones the texture.
  20475. * @returns the cloned texture
  20476. */
  20477. clone(): RenderTargetTexture;
  20478. /**
  20479. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20480. * @returns The JSON representation of the texture
  20481. */
  20482. serialize(): any;
  20483. /**
  20484. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20485. */
  20486. disposeFramebufferObjects(): void;
  20487. /**
  20488. * Dispose the texture and release its associated resources.
  20489. */
  20490. dispose(): void;
  20491. /** @hidden */
  20492. _rebuild(): void;
  20493. /**
  20494. * Clear the info related to rendering groups preventing retention point in material dispose.
  20495. */
  20496. freeRenderingGroups(): void;
  20497. /**
  20498. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20499. * @returns the view count
  20500. */
  20501. getViewCount(): number;
  20502. }
  20503. }
  20504. declare module "babylonjs/Materials/material" {
  20505. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20506. import { SmartArray } from "babylonjs/Misc/smartArray";
  20507. import { Observable } from "babylonjs/Misc/observable";
  20508. import { Nullable } from "babylonjs/types";
  20509. import { Scene } from "babylonjs/scene";
  20510. import { Matrix } from "babylonjs/Maths/math.vector";
  20511. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20512. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20513. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20514. import { Effect } from "babylonjs/Materials/effect";
  20515. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20516. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20517. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20518. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20519. import { Mesh } from "babylonjs/Meshes/mesh";
  20520. import { Animation } from "babylonjs/Animations/animation";
  20521. /**
  20522. * Base class for the main features of a material in Babylon.js
  20523. */
  20524. export class Material implements IAnimatable {
  20525. /**
  20526. * Returns the triangle fill mode
  20527. */
  20528. static readonly TriangleFillMode: number;
  20529. /**
  20530. * Returns the wireframe mode
  20531. */
  20532. static readonly WireFrameFillMode: number;
  20533. /**
  20534. * Returns the point fill mode
  20535. */
  20536. static readonly PointFillMode: number;
  20537. /**
  20538. * Returns the point list draw mode
  20539. */
  20540. static readonly PointListDrawMode: number;
  20541. /**
  20542. * Returns the line list draw mode
  20543. */
  20544. static readonly LineListDrawMode: number;
  20545. /**
  20546. * Returns the line loop draw mode
  20547. */
  20548. static readonly LineLoopDrawMode: number;
  20549. /**
  20550. * Returns the line strip draw mode
  20551. */
  20552. static readonly LineStripDrawMode: number;
  20553. /**
  20554. * Returns the triangle strip draw mode
  20555. */
  20556. static readonly TriangleStripDrawMode: number;
  20557. /**
  20558. * Returns the triangle fan draw mode
  20559. */
  20560. static readonly TriangleFanDrawMode: number;
  20561. /**
  20562. * Stores the clock-wise side orientation
  20563. */
  20564. static readonly ClockWiseSideOrientation: number;
  20565. /**
  20566. * Stores the counter clock-wise side orientation
  20567. */
  20568. static readonly CounterClockWiseSideOrientation: number;
  20569. /**
  20570. * The dirty texture flag value
  20571. */
  20572. static readonly TextureDirtyFlag: number;
  20573. /**
  20574. * The dirty light flag value
  20575. */
  20576. static readonly LightDirtyFlag: number;
  20577. /**
  20578. * The dirty fresnel flag value
  20579. */
  20580. static readonly FresnelDirtyFlag: number;
  20581. /**
  20582. * The dirty attribute flag value
  20583. */
  20584. static readonly AttributesDirtyFlag: number;
  20585. /**
  20586. * The dirty misc flag value
  20587. */
  20588. static readonly MiscDirtyFlag: number;
  20589. /**
  20590. * The all dirty flag value
  20591. */
  20592. static readonly AllDirtyFlag: number;
  20593. /**
  20594. * The ID of the material
  20595. */
  20596. id: string;
  20597. /**
  20598. * Gets or sets the unique id of the material
  20599. */
  20600. uniqueId: number;
  20601. /**
  20602. * The name of the material
  20603. */
  20604. name: string;
  20605. /**
  20606. * Gets or sets user defined metadata
  20607. */
  20608. metadata: any;
  20609. /**
  20610. * For internal use only. Please do not use.
  20611. */
  20612. reservedDataStore: any;
  20613. /**
  20614. * Specifies if the ready state should be checked on each call
  20615. */
  20616. checkReadyOnEveryCall: boolean;
  20617. /**
  20618. * Specifies if the ready state should be checked once
  20619. */
  20620. checkReadyOnlyOnce: boolean;
  20621. /**
  20622. * The state of the material
  20623. */
  20624. state: string;
  20625. /**
  20626. * The alpha value of the material
  20627. */
  20628. protected _alpha: number;
  20629. /**
  20630. * List of inspectable custom properties (used by the Inspector)
  20631. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20632. */
  20633. inspectableCustomProperties: IInspectable[];
  20634. /**
  20635. * Sets the alpha value of the material
  20636. */
  20637. /**
  20638. * Gets the alpha value of the material
  20639. */
  20640. alpha: number;
  20641. /**
  20642. * Specifies if back face culling is enabled
  20643. */
  20644. protected _backFaceCulling: boolean;
  20645. /**
  20646. * Sets the back-face culling state
  20647. */
  20648. /**
  20649. * Gets the back-face culling state
  20650. */
  20651. backFaceCulling: boolean;
  20652. /**
  20653. * Stores the value for side orientation
  20654. */
  20655. sideOrientation: number;
  20656. /**
  20657. * Callback triggered when the material is compiled
  20658. */
  20659. onCompiled: Nullable<(effect: Effect) => void>;
  20660. /**
  20661. * Callback triggered when an error occurs
  20662. */
  20663. onError: Nullable<(effect: Effect, errors: string) => void>;
  20664. /**
  20665. * Callback triggered to get the render target textures
  20666. */
  20667. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20668. /**
  20669. * Gets a boolean indicating that current material needs to register RTT
  20670. */
  20671. readonly hasRenderTargetTextures: boolean;
  20672. /**
  20673. * Specifies if the material should be serialized
  20674. */
  20675. doNotSerialize: boolean;
  20676. /**
  20677. * @hidden
  20678. */
  20679. _storeEffectOnSubMeshes: boolean;
  20680. /**
  20681. * Stores the animations for the material
  20682. */
  20683. animations: Nullable<Array<Animation>>;
  20684. /**
  20685. * An event triggered when the material is disposed
  20686. */
  20687. onDisposeObservable: Observable<Material>;
  20688. /**
  20689. * An observer which watches for dispose events
  20690. */
  20691. private _onDisposeObserver;
  20692. private _onUnBindObservable;
  20693. /**
  20694. * Called during a dispose event
  20695. */
  20696. onDispose: () => void;
  20697. private _onBindObservable;
  20698. /**
  20699. * An event triggered when the material is bound
  20700. */
  20701. readonly onBindObservable: Observable<AbstractMesh>;
  20702. /**
  20703. * An observer which watches for bind events
  20704. */
  20705. private _onBindObserver;
  20706. /**
  20707. * Called during a bind event
  20708. */
  20709. onBind: (Mesh: AbstractMesh) => void;
  20710. /**
  20711. * An event triggered when the material is unbound
  20712. */
  20713. readonly onUnBindObservable: Observable<Material>;
  20714. /**
  20715. * Stores the value of the alpha mode
  20716. */
  20717. private _alphaMode;
  20718. /**
  20719. * Sets the value of the alpha mode.
  20720. *
  20721. * | Value | Type | Description |
  20722. * | --- | --- | --- |
  20723. * | 0 | ALPHA_DISABLE | |
  20724. * | 1 | ALPHA_ADD | |
  20725. * | 2 | ALPHA_COMBINE | |
  20726. * | 3 | ALPHA_SUBTRACT | |
  20727. * | 4 | ALPHA_MULTIPLY | |
  20728. * | 5 | ALPHA_MAXIMIZED | |
  20729. * | 6 | ALPHA_ONEONE | |
  20730. * | 7 | ALPHA_PREMULTIPLIED | |
  20731. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20732. * | 9 | ALPHA_INTERPOLATE | |
  20733. * | 10 | ALPHA_SCREENMODE | |
  20734. *
  20735. */
  20736. /**
  20737. * Gets the value of the alpha mode
  20738. */
  20739. alphaMode: number;
  20740. /**
  20741. * Stores the state of the need depth pre-pass value
  20742. */
  20743. private _needDepthPrePass;
  20744. /**
  20745. * Sets the need depth pre-pass value
  20746. */
  20747. /**
  20748. * Gets the depth pre-pass value
  20749. */
  20750. needDepthPrePass: boolean;
  20751. /**
  20752. * Specifies if depth writing should be disabled
  20753. */
  20754. disableDepthWrite: boolean;
  20755. /**
  20756. * Specifies if depth writing should be forced
  20757. */
  20758. forceDepthWrite: boolean;
  20759. /**
  20760. * Specifies if there should be a separate pass for culling
  20761. */
  20762. separateCullingPass: boolean;
  20763. /**
  20764. * Stores the state specifing if fog should be enabled
  20765. */
  20766. private _fogEnabled;
  20767. /**
  20768. * Sets the state for enabling fog
  20769. */
  20770. /**
  20771. * Gets the value of the fog enabled state
  20772. */
  20773. fogEnabled: boolean;
  20774. /**
  20775. * Stores the size of points
  20776. */
  20777. pointSize: number;
  20778. /**
  20779. * Stores the z offset value
  20780. */
  20781. zOffset: number;
  20782. /**
  20783. * Gets a value specifying if wireframe mode is enabled
  20784. */
  20785. /**
  20786. * Sets the state of wireframe mode
  20787. */
  20788. wireframe: boolean;
  20789. /**
  20790. * Gets the value specifying if point clouds are enabled
  20791. */
  20792. /**
  20793. * Sets the state of point cloud mode
  20794. */
  20795. pointsCloud: boolean;
  20796. /**
  20797. * Gets the material fill mode
  20798. */
  20799. /**
  20800. * Sets the material fill mode
  20801. */
  20802. fillMode: number;
  20803. /**
  20804. * @hidden
  20805. * Stores the effects for the material
  20806. */
  20807. _effect: Nullable<Effect>;
  20808. /**
  20809. * @hidden
  20810. * Specifies if the material was previously ready
  20811. */
  20812. _wasPreviouslyReady: boolean;
  20813. /**
  20814. * Specifies if uniform buffers should be used
  20815. */
  20816. private _useUBO;
  20817. /**
  20818. * Stores a reference to the scene
  20819. */
  20820. private _scene;
  20821. /**
  20822. * Stores the fill mode state
  20823. */
  20824. private _fillMode;
  20825. /**
  20826. * Specifies if the depth write state should be cached
  20827. */
  20828. private _cachedDepthWriteState;
  20829. /**
  20830. * Stores the uniform buffer
  20831. */
  20832. protected _uniformBuffer: UniformBuffer;
  20833. /** @hidden */
  20834. _indexInSceneMaterialArray: number;
  20835. /** @hidden */
  20836. meshMap: Nullable<{
  20837. [id: string]: AbstractMesh | undefined;
  20838. }>;
  20839. /**
  20840. * Creates a material instance
  20841. * @param name defines the name of the material
  20842. * @param scene defines the scene to reference
  20843. * @param doNotAdd specifies if the material should be added to the scene
  20844. */
  20845. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20846. /**
  20847. * Returns a string representation of the current material
  20848. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20849. * @returns a string with material information
  20850. */
  20851. toString(fullDetails?: boolean): string;
  20852. /**
  20853. * Gets the class name of the material
  20854. * @returns a string with the class name of the material
  20855. */
  20856. getClassName(): string;
  20857. /**
  20858. * Specifies if updates for the material been locked
  20859. */
  20860. readonly isFrozen: boolean;
  20861. /**
  20862. * Locks updates for the material
  20863. */
  20864. freeze(): void;
  20865. /**
  20866. * Unlocks updates for the material
  20867. */
  20868. unfreeze(): void;
  20869. /**
  20870. * Specifies if the material is ready to be used
  20871. * @param mesh defines the mesh to check
  20872. * @param useInstances specifies if instances should be used
  20873. * @returns a boolean indicating if the material is ready to be used
  20874. */
  20875. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20876. /**
  20877. * Specifies that the submesh is ready to be used
  20878. * @param mesh defines the mesh to check
  20879. * @param subMesh defines which submesh to check
  20880. * @param useInstances specifies that instances should be used
  20881. * @returns a boolean indicating that the submesh is ready or not
  20882. */
  20883. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20884. /**
  20885. * Returns the material effect
  20886. * @returns the effect associated with the material
  20887. */
  20888. getEffect(): Nullable<Effect>;
  20889. /**
  20890. * Returns the current scene
  20891. * @returns a Scene
  20892. */
  20893. getScene(): Scene;
  20894. /**
  20895. * Specifies if the material will require alpha blending
  20896. * @returns a boolean specifying if alpha blending is needed
  20897. */
  20898. needAlphaBlending(): boolean;
  20899. /**
  20900. * Specifies if the mesh will require alpha blending
  20901. * @param mesh defines the mesh to check
  20902. * @returns a boolean specifying if alpha blending is needed for the mesh
  20903. */
  20904. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20905. /**
  20906. * Specifies if this material should be rendered in alpha test mode
  20907. * @returns a boolean specifying if an alpha test is needed.
  20908. */
  20909. needAlphaTesting(): boolean;
  20910. /**
  20911. * Gets the texture used for the alpha test
  20912. * @returns the texture to use for alpha testing
  20913. */
  20914. getAlphaTestTexture(): Nullable<BaseTexture>;
  20915. /**
  20916. * Marks the material to indicate that it needs to be re-calculated
  20917. */
  20918. markDirty(): void;
  20919. /** @hidden */
  20920. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20921. /**
  20922. * Binds the material to the mesh
  20923. * @param world defines the world transformation matrix
  20924. * @param mesh defines the mesh to bind the material to
  20925. */
  20926. bind(world: Matrix, mesh?: Mesh): void;
  20927. /**
  20928. * Binds the submesh to the material
  20929. * @param world defines the world transformation matrix
  20930. * @param mesh defines the mesh containing the submesh
  20931. * @param subMesh defines the submesh to bind the material to
  20932. */
  20933. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20934. /**
  20935. * Binds the world matrix to the material
  20936. * @param world defines the world transformation matrix
  20937. */
  20938. bindOnlyWorldMatrix(world: Matrix): void;
  20939. /**
  20940. * Binds the scene's uniform buffer to the effect.
  20941. * @param effect defines the effect to bind to the scene uniform buffer
  20942. * @param sceneUbo defines the uniform buffer storing scene data
  20943. */
  20944. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20945. /**
  20946. * Binds the view matrix to the effect
  20947. * @param effect defines the effect to bind the view matrix to
  20948. */
  20949. bindView(effect: Effect): void;
  20950. /**
  20951. * Binds the view projection matrix to the effect
  20952. * @param effect defines the effect to bind the view projection matrix to
  20953. */
  20954. bindViewProjection(effect: Effect): void;
  20955. /**
  20956. * Specifies if material alpha testing should be turned on for the mesh
  20957. * @param mesh defines the mesh to check
  20958. */
  20959. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20960. /**
  20961. * Processes to execute after binding the material to a mesh
  20962. * @param mesh defines the rendered mesh
  20963. */
  20964. protected _afterBind(mesh?: Mesh): void;
  20965. /**
  20966. * Unbinds the material from the mesh
  20967. */
  20968. unbind(): void;
  20969. /**
  20970. * Gets the active textures from the material
  20971. * @returns an array of textures
  20972. */
  20973. getActiveTextures(): BaseTexture[];
  20974. /**
  20975. * Specifies if the material uses a texture
  20976. * @param texture defines the texture to check against the material
  20977. * @returns a boolean specifying if the material uses the texture
  20978. */
  20979. hasTexture(texture: BaseTexture): boolean;
  20980. /**
  20981. * Makes a duplicate of the material, and gives it a new name
  20982. * @param name defines the new name for the duplicated material
  20983. * @returns the cloned material
  20984. */
  20985. clone(name: string): Nullable<Material>;
  20986. /**
  20987. * Gets the meshes bound to the material
  20988. * @returns an array of meshes bound to the material
  20989. */
  20990. getBindedMeshes(): AbstractMesh[];
  20991. /**
  20992. * Force shader compilation
  20993. * @param mesh defines the mesh associated with this material
  20994. * @param onCompiled defines a function to execute once the material is compiled
  20995. * @param options defines the options to configure the compilation
  20996. */
  20997. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20998. clipPlane: boolean;
  20999. }>): void;
  21000. /**
  21001. * Force shader compilation
  21002. * @param mesh defines the mesh that will use this material
  21003. * @param options defines additional options for compiling the shaders
  21004. * @returns a promise that resolves when the compilation completes
  21005. */
  21006. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21007. clipPlane: boolean;
  21008. }>): Promise<void>;
  21009. private static readonly _AllDirtyCallBack;
  21010. private static readonly _ImageProcessingDirtyCallBack;
  21011. private static readonly _TextureDirtyCallBack;
  21012. private static readonly _FresnelDirtyCallBack;
  21013. private static readonly _MiscDirtyCallBack;
  21014. private static readonly _LightsDirtyCallBack;
  21015. private static readonly _AttributeDirtyCallBack;
  21016. private static _FresnelAndMiscDirtyCallBack;
  21017. private static _TextureAndMiscDirtyCallBack;
  21018. private static readonly _DirtyCallbackArray;
  21019. private static readonly _RunDirtyCallBacks;
  21020. /**
  21021. * Marks a define in the material to indicate that it needs to be re-computed
  21022. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21023. */
  21024. markAsDirty(flag: number): void;
  21025. /**
  21026. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21027. * @param func defines a function which checks material defines against the submeshes
  21028. */
  21029. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21030. /**
  21031. * Indicates that we need to re-calculated for all submeshes
  21032. */
  21033. protected _markAllSubMeshesAsAllDirty(): void;
  21034. /**
  21035. * Indicates that image processing needs to be re-calculated for all submeshes
  21036. */
  21037. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21038. /**
  21039. * Indicates that textures need to be re-calculated for all submeshes
  21040. */
  21041. protected _markAllSubMeshesAsTexturesDirty(): void;
  21042. /**
  21043. * Indicates that fresnel needs to be re-calculated for all submeshes
  21044. */
  21045. protected _markAllSubMeshesAsFresnelDirty(): void;
  21046. /**
  21047. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21048. */
  21049. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21050. /**
  21051. * Indicates that lights need to be re-calculated for all submeshes
  21052. */
  21053. protected _markAllSubMeshesAsLightsDirty(): void;
  21054. /**
  21055. * Indicates that attributes need to be re-calculated for all submeshes
  21056. */
  21057. protected _markAllSubMeshesAsAttributesDirty(): void;
  21058. /**
  21059. * Indicates that misc needs to be re-calculated for all submeshes
  21060. */
  21061. protected _markAllSubMeshesAsMiscDirty(): void;
  21062. /**
  21063. * Indicates that textures and misc need to be re-calculated for all submeshes
  21064. */
  21065. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21066. /**
  21067. * Disposes the material
  21068. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21069. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21070. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21071. */
  21072. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21073. /** @hidden */
  21074. private releaseVertexArrayObject;
  21075. /**
  21076. * Serializes this material
  21077. * @returns the serialized material object
  21078. */
  21079. serialize(): any;
  21080. /**
  21081. * Creates a material from parsed material data
  21082. * @param parsedMaterial defines parsed material data
  21083. * @param scene defines the hosting scene
  21084. * @param rootUrl defines the root URL to use to load textures
  21085. * @returns a new material
  21086. */
  21087. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21088. }
  21089. }
  21090. declare module "babylonjs/Materials/multiMaterial" {
  21091. import { Nullable } from "babylonjs/types";
  21092. import { Scene } from "babylonjs/scene";
  21093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21094. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21095. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21096. import { Material } from "babylonjs/Materials/material";
  21097. /**
  21098. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21099. * separate meshes. This can be use to improve performances.
  21100. * @see http://doc.babylonjs.com/how_to/multi_materials
  21101. */
  21102. export class MultiMaterial extends Material {
  21103. private _subMaterials;
  21104. /**
  21105. * Gets or Sets the list of Materials used within the multi material.
  21106. * They need to be ordered according to the submeshes order in the associated mesh
  21107. */
  21108. subMaterials: Nullable<Material>[];
  21109. /**
  21110. * Function used to align with Node.getChildren()
  21111. * @returns the list of Materials used within the multi material
  21112. */
  21113. getChildren(): Nullable<Material>[];
  21114. /**
  21115. * Instantiates a new Multi Material
  21116. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21117. * separate meshes. This can be use to improve performances.
  21118. * @see http://doc.babylonjs.com/how_to/multi_materials
  21119. * @param name Define the name in the scene
  21120. * @param scene Define the scene the material belongs to
  21121. */
  21122. constructor(name: string, scene: Scene);
  21123. private _hookArray;
  21124. /**
  21125. * Get one of the submaterial by its index in the submaterials array
  21126. * @param index The index to look the sub material at
  21127. * @returns The Material if the index has been defined
  21128. */
  21129. getSubMaterial(index: number): Nullable<Material>;
  21130. /**
  21131. * Get the list of active textures for the whole sub materials list.
  21132. * @returns All the textures that will be used during the rendering
  21133. */
  21134. getActiveTextures(): BaseTexture[];
  21135. /**
  21136. * Gets the current class name of the material e.g. "MultiMaterial"
  21137. * Mainly use in serialization.
  21138. * @returns the class name
  21139. */
  21140. getClassName(): string;
  21141. /**
  21142. * Checks if the material is ready to render the requested sub mesh
  21143. * @param mesh Define the mesh the submesh belongs to
  21144. * @param subMesh Define the sub mesh to look readyness for
  21145. * @param useInstances Define whether or not the material is used with instances
  21146. * @returns true if ready, otherwise false
  21147. */
  21148. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21149. /**
  21150. * Clones the current material and its related sub materials
  21151. * @param name Define the name of the newly cloned material
  21152. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21153. * @returns the cloned material
  21154. */
  21155. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21156. /**
  21157. * Serializes the materials into a JSON representation.
  21158. * @returns the JSON representation
  21159. */
  21160. serialize(): any;
  21161. /**
  21162. * Dispose the material and release its associated resources
  21163. * @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)
  21164. * @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)
  21165. * @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)
  21166. */
  21167. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21168. /**
  21169. * Creates a MultiMaterial from parsed MultiMaterial data.
  21170. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21171. * @param scene defines the hosting scene
  21172. * @returns a new MultiMaterial
  21173. */
  21174. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21175. }
  21176. }
  21177. declare module "babylonjs/Meshes/subMesh" {
  21178. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21179. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21180. import { Engine } from "babylonjs/Engines/engine";
  21181. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21182. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21183. import { Effect } from "babylonjs/Materials/effect";
  21184. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21185. import { Plane } from "babylonjs/Maths/math.plane";
  21186. import { Collider } from "babylonjs/Collisions/collider";
  21187. import { Material } from "babylonjs/Materials/material";
  21188. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21189. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21190. import { Mesh } from "babylonjs/Meshes/mesh";
  21191. import { Ray } from "babylonjs/Culling/ray";
  21192. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21193. /**
  21194. * Base class for submeshes
  21195. */
  21196. export class BaseSubMesh {
  21197. /** @hidden */
  21198. _materialDefines: Nullable<MaterialDefines>;
  21199. /** @hidden */
  21200. _materialEffect: Nullable<Effect>;
  21201. /**
  21202. * Gets associated effect
  21203. */
  21204. readonly effect: Nullable<Effect>;
  21205. /**
  21206. * Sets associated effect (effect used to render this submesh)
  21207. * @param effect defines the effect to associate with
  21208. * @param defines defines the set of defines used to compile this effect
  21209. */
  21210. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21211. }
  21212. /**
  21213. * Defines a subdivision inside a mesh
  21214. */
  21215. export class SubMesh extends BaseSubMesh implements ICullable {
  21216. /** the material index to use */
  21217. materialIndex: number;
  21218. /** vertex index start */
  21219. verticesStart: number;
  21220. /** vertices count */
  21221. verticesCount: number;
  21222. /** index start */
  21223. indexStart: number;
  21224. /** indices count */
  21225. indexCount: number;
  21226. /** @hidden */
  21227. _linesIndexCount: number;
  21228. private _mesh;
  21229. private _renderingMesh;
  21230. private _boundingInfo;
  21231. private _linesIndexBuffer;
  21232. /** @hidden */
  21233. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21234. /** @hidden */
  21235. _trianglePlanes: Plane[];
  21236. /** @hidden */
  21237. _lastColliderTransformMatrix: Nullable<Matrix>;
  21238. /** @hidden */
  21239. _renderId: number;
  21240. /** @hidden */
  21241. _alphaIndex: number;
  21242. /** @hidden */
  21243. _distanceToCamera: number;
  21244. /** @hidden */
  21245. _id: number;
  21246. private _currentMaterial;
  21247. /**
  21248. * Add a new submesh to a mesh
  21249. * @param materialIndex defines the material index to use
  21250. * @param verticesStart defines vertex index start
  21251. * @param verticesCount defines vertices count
  21252. * @param indexStart defines index start
  21253. * @param indexCount defines indices count
  21254. * @param mesh defines the parent mesh
  21255. * @param renderingMesh defines an optional rendering mesh
  21256. * @param createBoundingBox defines if bounding box should be created for this submesh
  21257. * @returns the new submesh
  21258. */
  21259. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21260. /**
  21261. * Creates a new submesh
  21262. * @param materialIndex defines the material index to use
  21263. * @param verticesStart defines vertex index start
  21264. * @param verticesCount defines vertices count
  21265. * @param indexStart defines index start
  21266. * @param indexCount defines indices count
  21267. * @param mesh defines the parent mesh
  21268. * @param renderingMesh defines an optional rendering mesh
  21269. * @param createBoundingBox defines if bounding box should be created for this submesh
  21270. */
  21271. constructor(
  21272. /** the material index to use */
  21273. materialIndex: number,
  21274. /** vertex index start */
  21275. verticesStart: number,
  21276. /** vertices count */
  21277. verticesCount: number,
  21278. /** index start */
  21279. indexStart: number,
  21280. /** indices count */
  21281. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21282. /**
  21283. * Returns true if this submesh covers the entire parent mesh
  21284. * @ignorenaming
  21285. */
  21286. readonly IsGlobal: boolean;
  21287. /**
  21288. * Returns the submesh BoudingInfo object
  21289. * @returns current bounding info (or mesh's one if the submesh is global)
  21290. */
  21291. getBoundingInfo(): BoundingInfo;
  21292. /**
  21293. * Sets the submesh BoundingInfo
  21294. * @param boundingInfo defines the new bounding info to use
  21295. * @returns the SubMesh
  21296. */
  21297. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21298. /**
  21299. * Returns the mesh of the current submesh
  21300. * @return the parent mesh
  21301. */
  21302. getMesh(): AbstractMesh;
  21303. /**
  21304. * Returns the rendering mesh of the submesh
  21305. * @returns the rendering mesh (could be different from parent mesh)
  21306. */
  21307. getRenderingMesh(): Mesh;
  21308. /**
  21309. * Returns the submesh material
  21310. * @returns null or the current material
  21311. */
  21312. getMaterial(): Nullable<Material>;
  21313. /**
  21314. * Sets a new updated BoundingInfo object to the submesh
  21315. * @param data defines an optional position array to use to determine the bounding info
  21316. * @returns the SubMesh
  21317. */
  21318. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21319. /** @hidden */
  21320. _checkCollision(collider: Collider): boolean;
  21321. /**
  21322. * Updates the submesh BoundingInfo
  21323. * @param world defines the world matrix to use to update the bounding info
  21324. * @returns the submesh
  21325. */
  21326. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21327. /**
  21328. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21329. * @param frustumPlanes defines the frustum planes
  21330. * @returns true if the submesh is intersecting with the frustum
  21331. */
  21332. isInFrustum(frustumPlanes: Plane[]): boolean;
  21333. /**
  21334. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21335. * @param frustumPlanes defines the frustum planes
  21336. * @returns true if the submesh is inside the frustum
  21337. */
  21338. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21339. /**
  21340. * Renders the submesh
  21341. * @param enableAlphaMode defines if alpha needs to be used
  21342. * @returns the submesh
  21343. */
  21344. render(enableAlphaMode: boolean): SubMesh;
  21345. /**
  21346. * @hidden
  21347. */
  21348. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21349. /**
  21350. * Checks if the submesh intersects with a ray
  21351. * @param ray defines the ray to test
  21352. * @returns true is the passed ray intersects the submesh bounding box
  21353. */
  21354. canIntersects(ray: Ray): boolean;
  21355. /**
  21356. * Intersects current submesh with a ray
  21357. * @param ray defines the ray to test
  21358. * @param positions defines mesh's positions array
  21359. * @param indices defines mesh's indices array
  21360. * @param fastCheck defines if only bounding info should be used
  21361. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21362. * @returns intersection info or null if no intersection
  21363. */
  21364. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21365. /** @hidden */
  21366. private _intersectLines;
  21367. /** @hidden */
  21368. private _intersectUnIndexedLines;
  21369. /** @hidden */
  21370. private _intersectTriangles;
  21371. /** @hidden */
  21372. private _intersectUnIndexedTriangles;
  21373. /** @hidden */
  21374. _rebuild(): void;
  21375. /**
  21376. * Creates a new submesh from the passed mesh
  21377. * @param newMesh defines the new hosting mesh
  21378. * @param newRenderingMesh defines an optional rendering mesh
  21379. * @returns the new submesh
  21380. */
  21381. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21382. /**
  21383. * Release associated resources
  21384. */
  21385. dispose(): void;
  21386. /**
  21387. * Gets the class name
  21388. * @returns the string "SubMesh".
  21389. */
  21390. getClassName(): string;
  21391. /**
  21392. * Creates a new submesh from indices data
  21393. * @param materialIndex the index of the main mesh material
  21394. * @param startIndex the index where to start the copy in the mesh indices array
  21395. * @param indexCount the number of indices to copy then from the startIndex
  21396. * @param mesh the main mesh to create the submesh from
  21397. * @param renderingMesh the optional rendering mesh
  21398. * @returns a new submesh
  21399. */
  21400. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21401. }
  21402. }
  21403. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21404. /**
  21405. * Class used to represent data loading progression
  21406. */
  21407. export class SceneLoaderFlags {
  21408. private static _ForceFullSceneLoadingForIncremental;
  21409. private static _ShowLoadingScreen;
  21410. private static _CleanBoneMatrixWeights;
  21411. private static _loggingLevel;
  21412. /**
  21413. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21414. */
  21415. static ForceFullSceneLoadingForIncremental: boolean;
  21416. /**
  21417. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21418. */
  21419. static ShowLoadingScreen: boolean;
  21420. /**
  21421. * Defines the current logging level (while loading the scene)
  21422. * @ignorenaming
  21423. */
  21424. static loggingLevel: number;
  21425. /**
  21426. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21427. */
  21428. static CleanBoneMatrixWeights: boolean;
  21429. }
  21430. }
  21431. declare module "babylonjs/Meshes/geometry" {
  21432. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21433. import { Scene } from "babylonjs/scene";
  21434. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21435. import { Engine } from "babylonjs/Engines/engine";
  21436. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21437. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21438. import { Effect } from "babylonjs/Materials/effect";
  21439. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21440. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21441. import { Mesh } from "babylonjs/Meshes/mesh";
  21442. /**
  21443. * Class used to store geometry data (vertex buffers + index buffer)
  21444. */
  21445. export class Geometry implements IGetSetVerticesData {
  21446. /**
  21447. * Gets or sets the ID of the geometry
  21448. */
  21449. id: string;
  21450. /**
  21451. * Gets or sets the unique ID of the geometry
  21452. */
  21453. uniqueId: number;
  21454. /**
  21455. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21456. */
  21457. delayLoadState: number;
  21458. /**
  21459. * Gets the file containing the data to load when running in delay load state
  21460. */
  21461. delayLoadingFile: Nullable<string>;
  21462. /**
  21463. * Callback called when the geometry is updated
  21464. */
  21465. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21466. private _scene;
  21467. private _engine;
  21468. private _meshes;
  21469. private _totalVertices;
  21470. /** @hidden */
  21471. _indices: IndicesArray;
  21472. /** @hidden */
  21473. _vertexBuffers: {
  21474. [key: string]: VertexBuffer;
  21475. };
  21476. private _isDisposed;
  21477. private _extend;
  21478. private _boundingBias;
  21479. /** @hidden */
  21480. _delayInfo: Array<string>;
  21481. private _indexBuffer;
  21482. private _indexBufferIsUpdatable;
  21483. /** @hidden */
  21484. _boundingInfo: Nullable<BoundingInfo>;
  21485. /** @hidden */
  21486. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21487. /** @hidden */
  21488. _softwareSkinningFrameId: number;
  21489. private _vertexArrayObjects;
  21490. private _updatable;
  21491. /** @hidden */
  21492. _positions: Nullable<Vector3[]>;
  21493. /**
  21494. * 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
  21495. */
  21496. /**
  21497. * 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
  21498. */
  21499. boundingBias: Vector2;
  21500. /**
  21501. * Static function used to attach a new empty geometry to a mesh
  21502. * @param mesh defines the mesh to attach the geometry to
  21503. * @returns the new Geometry
  21504. */
  21505. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21506. /**
  21507. * Creates a new geometry
  21508. * @param id defines the unique ID
  21509. * @param scene defines the hosting scene
  21510. * @param vertexData defines the VertexData used to get geometry data
  21511. * @param updatable defines if geometry must be updatable (false by default)
  21512. * @param mesh defines the mesh that will be associated with the geometry
  21513. */
  21514. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21515. /**
  21516. * Gets the current extend of the geometry
  21517. */
  21518. readonly extend: {
  21519. minimum: Vector3;
  21520. maximum: Vector3;
  21521. };
  21522. /**
  21523. * Gets the hosting scene
  21524. * @returns the hosting Scene
  21525. */
  21526. getScene(): Scene;
  21527. /**
  21528. * Gets the hosting engine
  21529. * @returns the hosting Engine
  21530. */
  21531. getEngine(): Engine;
  21532. /**
  21533. * Defines if the geometry is ready to use
  21534. * @returns true if the geometry is ready to be used
  21535. */
  21536. isReady(): boolean;
  21537. /**
  21538. * Gets a value indicating that the geometry should not be serialized
  21539. */
  21540. readonly doNotSerialize: boolean;
  21541. /** @hidden */
  21542. _rebuild(): void;
  21543. /**
  21544. * Affects all geometry data in one call
  21545. * @param vertexData defines the geometry data
  21546. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21547. */
  21548. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21549. /**
  21550. * Set specific vertex data
  21551. * @param kind defines the data kind (Position, normal, etc...)
  21552. * @param data defines the vertex data to use
  21553. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21554. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21555. */
  21556. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21557. /**
  21558. * Removes a specific vertex data
  21559. * @param kind defines the data kind (Position, normal, etc...)
  21560. */
  21561. removeVerticesData(kind: string): void;
  21562. /**
  21563. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21564. * @param buffer defines the vertex buffer to use
  21565. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21566. */
  21567. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21568. /**
  21569. * Update a specific vertex buffer
  21570. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21571. * It will do nothing if the buffer is not updatable
  21572. * @param kind defines the data kind (Position, normal, etc...)
  21573. * @param data defines the data to use
  21574. * @param offset defines the offset in the target buffer where to store the data
  21575. * @param useBytes set to true if the offset is in bytes
  21576. */
  21577. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21578. /**
  21579. * Update a specific vertex buffer
  21580. * This function will create a new buffer if the current one is not updatable
  21581. * @param kind defines the data kind (Position, normal, etc...)
  21582. * @param data defines the data to use
  21583. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21584. */
  21585. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21586. private _updateBoundingInfo;
  21587. /** @hidden */
  21588. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21589. /**
  21590. * Gets total number of vertices
  21591. * @returns the total number of vertices
  21592. */
  21593. getTotalVertices(): number;
  21594. /**
  21595. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21596. * @param kind defines the data kind (Position, normal, etc...)
  21597. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21598. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21599. * @returns a float array containing vertex data
  21600. */
  21601. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21602. /**
  21603. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21604. * @param kind defines the data kind (Position, normal, etc...)
  21605. * @returns true if the vertex buffer with the specified kind is updatable
  21606. */
  21607. isVertexBufferUpdatable(kind: string): boolean;
  21608. /**
  21609. * Gets a specific vertex buffer
  21610. * @param kind defines the data kind (Position, normal, etc...)
  21611. * @returns a VertexBuffer
  21612. */
  21613. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21614. /**
  21615. * Returns all vertex buffers
  21616. * @return an object holding all vertex buffers indexed by kind
  21617. */
  21618. getVertexBuffers(): Nullable<{
  21619. [key: string]: VertexBuffer;
  21620. }>;
  21621. /**
  21622. * Gets a boolean indicating if specific vertex buffer is present
  21623. * @param kind defines the data kind (Position, normal, etc...)
  21624. * @returns true if data is present
  21625. */
  21626. isVerticesDataPresent(kind: string): boolean;
  21627. /**
  21628. * Gets a list of all attached data kinds (Position, normal, etc...)
  21629. * @returns a list of string containing all kinds
  21630. */
  21631. getVerticesDataKinds(): string[];
  21632. /**
  21633. * Update index buffer
  21634. * @param indices defines the indices to store in the index buffer
  21635. * @param offset defines the offset in the target buffer where to store the data
  21636. * @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)
  21637. */
  21638. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21639. /**
  21640. * Creates a new index buffer
  21641. * @param indices defines the indices to store in the index buffer
  21642. * @param totalVertices defines the total number of vertices (could be null)
  21643. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21644. */
  21645. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21646. /**
  21647. * Return the total number of indices
  21648. * @returns the total number of indices
  21649. */
  21650. getTotalIndices(): number;
  21651. /**
  21652. * Gets the index buffer array
  21653. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21654. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21655. * @returns the index buffer array
  21656. */
  21657. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21658. /**
  21659. * Gets the index buffer
  21660. * @return the index buffer
  21661. */
  21662. getIndexBuffer(): Nullable<DataBuffer>;
  21663. /** @hidden */
  21664. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21665. /**
  21666. * Release the associated resources for a specific mesh
  21667. * @param mesh defines the source mesh
  21668. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21669. */
  21670. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21671. /**
  21672. * Apply current geometry to a given mesh
  21673. * @param mesh defines the mesh to apply geometry to
  21674. */
  21675. applyToMesh(mesh: Mesh): void;
  21676. private _updateExtend;
  21677. private _applyToMesh;
  21678. private notifyUpdate;
  21679. /**
  21680. * Load the geometry if it was flagged as delay loaded
  21681. * @param scene defines the hosting scene
  21682. * @param onLoaded defines a callback called when the geometry is loaded
  21683. */
  21684. load(scene: Scene, onLoaded?: () => void): void;
  21685. private _queueLoad;
  21686. /**
  21687. * Invert the geometry to move from a right handed system to a left handed one.
  21688. */
  21689. toLeftHanded(): void;
  21690. /** @hidden */
  21691. _resetPointsArrayCache(): void;
  21692. /** @hidden */
  21693. _generatePointsArray(): boolean;
  21694. /**
  21695. * Gets a value indicating if the geometry is disposed
  21696. * @returns true if the geometry was disposed
  21697. */
  21698. isDisposed(): boolean;
  21699. private _disposeVertexArrayObjects;
  21700. /**
  21701. * Free all associated resources
  21702. */
  21703. dispose(): void;
  21704. /**
  21705. * Clone the current geometry into a new geometry
  21706. * @param id defines the unique ID of the new geometry
  21707. * @returns a new geometry object
  21708. */
  21709. copy(id: string): Geometry;
  21710. /**
  21711. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21712. * @return a JSON representation of the current geometry data (without the vertices data)
  21713. */
  21714. serialize(): any;
  21715. private toNumberArray;
  21716. /**
  21717. * Serialize all vertices data into a JSON oject
  21718. * @returns a JSON representation of the current geometry data
  21719. */
  21720. serializeVerticeData(): any;
  21721. /**
  21722. * Extracts a clone of a mesh geometry
  21723. * @param mesh defines the source mesh
  21724. * @param id defines the unique ID of the new geometry object
  21725. * @returns the new geometry object
  21726. */
  21727. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21728. /**
  21729. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21730. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21731. * Be aware Math.random() could cause collisions, but:
  21732. * "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"
  21733. * @returns a string containing a new GUID
  21734. */
  21735. static RandomId(): string;
  21736. /** @hidden */
  21737. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21738. private static _CleanMatricesWeights;
  21739. /**
  21740. * Create a new geometry from persisted data (Using .babylon file format)
  21741. * @param parsedVertexData defines the persisted data
  21742. * @param scene defines the hosting scene
  21743. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21744. * @returns the new geometry object
  21745. */
  21746. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21747. }
  21748. }
  21749. declare module "babylonjs/Meshes/mesh.vertexData" {
  21750. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21751. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21752. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21753. import { Geometry } from "babylonjs/Meshes/geometry";
  21754. import { Mesh } from "babylonjs/Meshes/mesh";
  21755. /**
  21756. * Define an interface for all classes that will get and set the data on vertices
  21757. */
  21758. export interface IGetSetVerticesData {
  21759. /**
  21760. * Gets a boolean indicating if specific vertex data is present
  21761. * @param kind defines the vertex data kind to use
  21762. * @returns true is data kind is present
  21763. */
  21764. isVerticesDataPresent(kind: string): boolean;
  21765. /**
  21766. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21767. * @param kind defines the data kind (Position, normal, etc...)
  21768. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21769. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21770. * @returns a float array containing vertex data
  21771. */
  21772. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21773. /**
  21774. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21775. * @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.
  21776. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21777. * @returns the indices array or an empty array if the mesh has no geometry
  21778. */
  21779. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21780. /**
  21781. * Set specific vertex data
  21782. * @param kind defines the data kind (Position, normal, etc...)
  21783. * @param data defines the vertex data to use
  21784. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21785. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21786. */
  21787. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21788. /**
  21789. * Update a specific associated vertex buffer
  21790. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21791. * - VertexBuffer.PositionKind
  21792. * - VertexBuffer.UVKind
  21793. * - VertexBuffer.UV2Kind
  21794. * - VertexBuffer.UV3Kind
  21795. * - VertexBuffer.UV4Kind
  21796. * - VertexBuffer.UV5Kind
  21797. * - VertexBuffer.UV6Kind
  21798. * - VertexBuffer.ColorKind
  21799. * - VertexBuffer.MatricesIndicesKind
  21800. * - VertexBuffer.MatricesIndicesExtraKind
  21801. * - VertexBuffer.MatricesWeightsKind
  21802. * - VertexBuffer.MatricesWeightsExtraKind
  21803. * @param data defines the data source
  21804. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21805. * @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)
  21806. */
  21807. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21808. /**
  21809. * Creates a new index buffer
  21810. * @param indices defines the indices to store in the index buffer
  21811. * @param totalVertices defines the total number of vertices (could be null)
  21812. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21813. */
  21814. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21815. }
  21816. /**
  21817. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21818. */
  21819. export class VertexData {
  21820. /**
  21821. * Mesh side orientation : usually the external or front surface
  21822. */
  21823. static readonly FRONTSIDE: number;
  21824. /**
  21825. * Mesh side orientation : usually the internal or back surface
  21826. */
  21827. static readonly BACKSIDE: number;
  21828. /**
  21829. * Mesh side orientation : both internal and external or front and back surfaces
  21830. */
  21831. static readonly DOUBLESIDE: number;
  21832. /**
  21833. * Mesh side orientation : by default, `FRONTSIDE`
  21834. */
  21835. static readonly DEFAULTSIDE: number;
  21836. /**
  21837. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21838. */
  21839. positions: Nullable<FloatArray>;
  21840. /**
  21841. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21842. */
  21843. normals: Nullable<FloatArray>;
  21844. /**
  21845. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21846. */
  21847. tangents: Nullable<FloatArray>;
  21848. /**
  21849. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21850. */
  21851. uvs: Nullable<FloatArray>;
  21852. /**
  21853. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21854. */
  21855. uvs2: Nullable<FloatArray>;
  21856. /**
  21857. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21858. */
  21859. uvs3: Nullable<FloatArray>;
  21860. /**
  21861. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21862. */
  21863. uvs4: Nullable<FloatArray>;
  21864. /**
  21865. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21866. */
  21867. uvs5: Nullable<FloatArray>;
  21868. /**
  21869. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21870. */
  21871. uvs6: Nullable<FloatArray>;
  21872. /**
  21873. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21874. */
  21875. colors: Nullable<FloatArray>;
  21876. /**
  21877. * 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).
  21878. */
  21879. matricesIndices: Nullable<FloatArray>;
  21880. /**
  21881. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21882. */
  21883. matricesWeights: Nullable<FloatArray>;
  21884. /**
  21885. * An array extending the number of possible indices
  21886. */
  21887. matricesIndicesExtra: Nullable<FloatArray>;
  21888. /**
  21889. * An array extending the number of possible weights when the number of indices is extended
  21890. */
  21891. matricesWeightsExtra: Nullable<FloatArray>;
  21892. /**
  21893. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21894. */
  21895. indices: Nullable<IndicesArray>;
  21896. /**
  21897. * Uses the passed data array to set the set the values for the specified kind of data
  21898. * @param data a linear array of floating numbers
  21899. * @param kind the type of data that is being set, eg positions, colors etc
  21900. */
  21901. set(data: FloatArray, kind: string): void;
  21902. /**
  21903. * Associates the vertexData to the passed Mesh.
  21904. * Sets it as updatable or not (default `false`)
  21905. * @param mesh the mesh the vertexData is applied to
  21906. * @param updatable when used and having the value true allows new data to update the vertexData
  21907. * @returns the VertexData
  21908. */
  21909. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21910. /**
  21911. * Associates the vertexData to the passed Geometry.
  21912. * Sets it as updatable or not (default `false`)
  21913. * @param geometry the geometry the vertexData is applied to
  21914. * @param updatable when used and having the value true allows new data to update the vertexData
  21915. * @returns VertexData
  21916. */
  21917. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21918. /**
  21919. * Updates the associated mesh
  21920. * @param mesh the mesh to be updated
  21921. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21922. * @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
  21923. * @returns VertexData
  21924. */
  21925. updateMesh(mesh: Mesh): VertexData;
  21926. /**
  21927. * Updates the associated geometry
  21928. * @param geometry the geometry to be updated
  21929. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21930. * @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
  21931. * @returns VertexData.
  21932. */
  21933. updateGeometry(geometry: Geometry): VertexData;
  21934. private _applyTo;
  21935. private _update;
  21936. /**
  21937. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21938. * @param matrix the transforming matrix
  21939. * @returns the VertexData
  21940. */
  21941. transform(matrix: Matrix): VertexData;
  21942. /**
  21943. * Merges the passed VertexData into the current one
  21944. * @param other the VertexData to be merged into the current one
  21945. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21946. * @returns the modified VertexData
  21947. */
  21948. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21949. private _mergeElement;
  21950. private _validate;
  21951. /**
  21952. * Serializes the VertexData
  21953. * @returns a serialized object
  21954. */
  21955. serialize(): any;
  21956. /**
  21957. * Extracts the vertexData from a mesh
  21958. * @param mesh the mesh from which to extract the VertexData
  21959. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21960. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21961. * @returns the object VertexData associated to the passed mesh
  21962. */
  21963. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21964. /**
  21965. * Extracts the vertexData from the geometry
  21966. * @param geometry the geometry from which to extract the VertexData
  21967. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21968. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21969. * @returns the object VertexData associated to the passed mesh
  21970. */
  21971. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21972. private static _ExtractFrom;
  21973. /**
  21974. * Creates the VertexData for a Ribbon
  21975. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21976. * * pathArray array of paths, each of which an array of successive Vector3
  21977. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21978. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21979. * * 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
  21980. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21981. * * 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)
  21982. * * 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)
  21983. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21984. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21985. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21986. * @returns the VertexData of the ribbon
  21987. */
  21988. static CreateRibbon(options: {
  21989. pathArray: Vector3[][];
  21990. closeArray?: boolean;
  21991. closePath?: boolean;
  21992. offset?: number;
  21993. sideOrientation?: number;
  21994. frontUVs?: Vector4;
  21995. backUVs?: Vector4;
  21996. invertUV?: boolean;
  21997. uvs?: Vector2[];
  21998. colors?: Color4[];
  21999. }): VertexData;
  22000. /**
  22001. * Creates the VertexData for a box
  22002. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22003. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22004. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22005. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22006. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22007. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22008. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22009. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22010. * * 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)
  22011. * * 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)
  22012. * @returns the VertexData of the box
  22013. */
  22014. static CreateBox(options: {
  22015. size?: number;
  22016. width?: number;
  22017. height?: number;
  22018. depth?: number;
  22019. faceUV?: Vector4[];
  22020. faceColors?: Color4[];
  22021. sideOrientation?: number;
  22022. frontUVs?: Vector4;
  22023. backUVs?: Vector4;
  22024. }): VertexData;
  22025. /**
  22026. * Creates the VertexData for a tiled box
  22027. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22028. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22029. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22030. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22031. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22032. * @returns the VertexData of the box
  22033. */
  22034. static CreateTiledBox(options: {
  22035. pattern?: number;
  22036. width?: number;
  22037. height?: number;
  22038. depth?: number;
  22039. tileSize?: number;
  22040. tileWidth?: number;
  22041. tileHeight?: number;
  22042. alignHorizontal?: number;
  22043. alignVertical?: number;
  22044. faceUV?: Vector4[];
  22045. faceColors?: Color4[];
  22046. sideOrientation?: number;
  22047. }): VertexData;
  22048. /**
  22049. * Creates the VertexData for a tiled plane
  22050. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22051. * * pattern a limited pattern arrangement depending on the number
  22052. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22053. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22054. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22055. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22056. * * 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)
  22057. * * 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)
  22058. * @returns the VertexData of the tiled plane
  22059. */
  22060. static CreateTiledPlane(options: {
  22061. pattern?: number;
  22062. tileSize?: number;
  22063. tileWidth?: number;
  22064. tileHeight?: number;
  22065. size?: number;
  22066. width?: number;
  22067. height?: number;
  22068. alignHorizontal?: number;
  22069. alignVertical?: number;
  22070. sideOrientation?: number;
  22071. frontUVs?: Vector4;
  22072. backUVs?: Vector4;
  22073. }): VertexData;
  22074. /**
  22075. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22076. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22077. * * segments sets the number of horizontal strips optional, default 32
  22078. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22079. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22080. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22081. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22082. * * 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
  22083. * * 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
  22084. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22085. * * 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)
  22086. * * 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)
  22087. * @returns the VertexData of the ellipsoid
  22088. */
  22089. static CreateSphere(options: {
  22090. segments?: number;
  22091. diameter?: number;
  22092. diameterX?: number;
  22093. diameterY?: number;
  22094. diameterZ?: number;
  22095. arc?: number;
  22096. slice?: number;
  22097. sideOrientation?: number;
  22098. frontUVs?: Vector4;
  22099. backUVs?: Vector4;
  22100. }): VertexData;
  22101. /**
  22102. * Creates the VertexData for a cylinder, cone or prism
  22103. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22104. * * height sets the height (y direction) of the cylinder, optional, default 2
  22105. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22106. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22107. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22108. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22109. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22110. * * 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
  22111. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22112. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22113. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22114. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22115. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22116. * * 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)
  22117. * * 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)
  22118. * @returns the VertexData of the cylinder, cone or prism
  22119. */
  22120. static CreateCylinder(options: {
  22121. height?: number;
  22122. diameterTop?: number;
  22123. diameterBottom?: number;
  22124. diameter?: number;
  22125. tessellation?: number;
  22126. subdivisions?: number;
  22127. arc?: number;
  22128. faceColors?: Color4[];
  22129. faceUV?: Vector4[];
  22130. hasRings?: boolean;
  22131. enclose?: boolean;
  22132. sideOrientation?: number;
  22133. frontUVs?: Vector4;
  22134. backUVs?: Vector4;
  22135. }): VertexData;
  22136. /**
  22137. * Creates the VertexData for a torus
  22138. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22139. * * diameter the diameter of the torus, optional default 1
  22140. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22141. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22142. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22143. * * 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)
  22144. * * 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)
  22145. * @returns the VertexData of the torus
  22146. */
  22147. static CreateTorus(options: {
  22148. diameter?: number;
  22149. thickness?: number;
  22150. tessellation?: number;
  22151. sideOrientation?: number;
  22152. frontUVs?: Vector4;
  22153. backUVs?: Vector4;
  22154. }): VertexData;
  22155. /**
  22156. * Creates the VertexData of the LineSystem
  22157. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22158. * - lines an array of lines, each line being an array of successive Vector3
  22159. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22160. * @returns the VertexData of the LineSystem
  22161. */
  22162. static CreateLineSystem(options: {
  22163. lines: Vector3[][];
  22164. colors?: Nullable<Color4[][]>;
  22165. }): VertexData;
  22166. /**
  22167. * Create the VertexData for a DashedLines
  22168. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22169. * - points an array successive Vector3
  22170. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22171. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22172. * - dashNb the intended total number of dashes, optional, default 200
  22173. * @returns the VertexData for the DashedLines
  22174. */
  22175. static CreateDashedLines(options: {
  22176. points: Vector3[];
  22177. dashSize?: number;
  22178. gapSize?: number;
  22179. dashNb?: number;
  22180. }): VertexData;
  22181. /**
  22182. * Creates the VertexData for a Ground
  22183. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22184. * - width the width (x direction) of the ground, optional, default 1
  22185. * - height the height (z direction) of the ground, optional, default 1
  22186. * - subdivisions the number of subdivisions per side, optional, default 1
  22187. * @returns the VertexData of the Ground
  22188. */
  22189. static CreateGround(options: {
  22190. width?: number;
  22191. height?: number;
  22192. subdivisions?: number;
  22193. subdivisionsX?: number;
  22194. subdivisionsY?: number;
  22195. }): VertexData;
  22196. /**
  22197. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22198. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22199. * * xmin the ground minimum X coordinate, optional, default -1
  22200. * * zmin the ground minimum Z coordinate, optional, default -1
  22201. * * xmax the ground maximum X coordinate, optional, default 1
  22202. * * zmax the ground maximum Z coordinate, optional, default 1
  22203. * * 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}
  22204. * * 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}
  22205. * @returns the VertexData of the TiledGround
  22206. */
  22207. static CreateTiledGround(options: {
  22208. xmin: number;
  22209. zmin: number;
  22210. xmax: number;
  22211. zmax: number;
  22212. subdivisions?: {
  22213. w: number;
  22214. h: number;
  22215. };
  22216. precision?: {
  22217. w: number;
  22218. h: number;
  22219. };
  22220. }): VertexData;
  22221. /**
  22222. * Creates the VertexData of the Ground designed from a heightmap
  22223. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22224. * * width the width (x direction) of the ground
  22225. * * height the height (z direction) of the ground
  22226. * * subdivisions the number of subdivisions per side
  22227. * * minHeight the minimum altitude on the ground, optional, default 0
  22228. * * maxHeight the maximum altitude on the ground, optional default 1
  22229. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22230. * * buffer the array holding the image color data
  22231. * * bufferWidth the width of image
  22232. * * bufferHeight the height of image
  22233. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22234. * @returns the VertexData of the Ground designed from a heightmap
  22235. */
  22236. static CreateGroundFromHeightMap(options: {
  22237. width: number;
  22238. height: number;
  22239. subdivisions: number;
  22240. minHeight: number;
  22241. maxHeight: number;
  22242. colorFilter: Color3;
  22243. buffer: Uint8Array;
  22244. bufferWidth: number;
  22245. bufferHeight: number;
  22246. alphaFilter: number;
  22247. }): VertexData;
  22248. /**
  22249. * Creates the VertexData for a Plane
  22250. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22251. * * size sets the width and height of the plane to the value of size, optional default 1
  22252. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22253. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22254. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22255. * * 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)
  22256. * * 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)
  22257. * @returns the VertexData of the box
  22258. */
  22259. static CreatePlane(options: {
  22260. size?: number;
  22261. width?: number;
  22262. height?: number;
  22263. sideOrientation?: number;
  22264. frontUVs?: Vector4;
  22265. backUVs?: Vector4;
  22266. }): VertexData;
  22267. /**
  22268. * Creates the VertexData of the Disc or regular Polygon
  22269. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22270. * * radius the radius of the disc, optional default 0.5
  22271. * * tessellation the number of polygon sides, optional, default 64
  22272. * * 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
  22273. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22274. * * 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)
  22275. * * 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)
  22276. * @returns the VertexData of the box
  22277. */
  22278. static CreateDisc(options: {
  22279. radius?: number;
  22280. tessellation?: number;
  22281. arc?: number;
  22282. sideOrientation?: number;
  22283. frontUVs?: Vector4;
  22284. backUVs?: Vector4;
  22285. }): VertexData;
  22286. /**
  22287. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22288. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22289. * @param polygon a mesh built from polygonTriangulation.build()
  22290. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22291. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22292. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22293. * @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)
  22294. * @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)
  22295. * @returns the VertexData of the Polygon
  22296. */
  22297. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22298. /**
  22299. * Creates the VertexData of the IcoSphere
  22300. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22301. * * radius the radius of the IcoSphere, optional default 1
  22302. * * radiusX allows stretching in the x direction, optional, default radius
  22303. * * radiusY allows stretching in the y direction, optional, default radius
  22304. * * radiusZ allows stretching in the z direction, optional, default radius
  22305. * * flat when true creates a flat shaded mesh, optional, default true
  22306. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22307. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22308. * * 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)
  22309. * * 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)
  22310. * @returns the VertexData of the IcoSphere
  22311. */
  22312. static CreateIcoSphere(options: {
  22313. radius?: number;
  22314. radiusX?: number;
  22315. radiusY?: number;
  22316. radiusZ?: number;
  22317. flat?: boolean;
  22318. subdivisions?: number;
  22319. sideOrientation?: number;
  22320. frontUVs?: Vector4;
  22321. backUVs?: Vector4;
  22322. }): VertexData;
  22323. /**
  22324. * Creates the VertexData for a Polyhedron
  22325. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22326. * * type provided types are:
  22327. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22328. * * 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)
  22329. * * size the size of the IcoSphere, optional default 1
  22330. * * sizeX allows stretching in the x direction, optional, default size
  22331. * * sizeY allows stretching in the y direction, optional, default size
  22332. * * sizeZ allows stretching in the z direction, optional, default size
  22333. * * 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
  22334. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22335. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22336. * * flat when true creates a flat shaded mesh, optional, default true
  22337. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22338. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22339. * * 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)
  22340. * * 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)
  22341. * @returns the VertexData of the Polyhedron
  22342. */
  22343. static CreatePolyhedron(options: {
  22344. type?: number;
  22345. size?: number;
  22346. sizeX?: number;
  22347. sizeY?: number;
  22348. sizeZ?: number;
  22349. custom?: any;
  22350. faceUV?: Vector4[];
  22351. faceColors?: Color4[];
  22352. flat?: boolean;
  22353. sideOrientation?: number;
  22354. frontUVs?: Vector4;
  22355. backUVs?: Vector4;
  22356. }): VertexData;
  22357. /**
  22358. * Creates the VertexData for a TorusKnot
  22359. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22360. * * radius the radius of the torus knot, optional, default 2
  22361. * * tube the thickness of the tube, optional, default 0.5
  22362. * * radialSegments the number of sides on each tube segments, optional, default 32
  22363. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22364. * * p the number of windings around the z axis, optional, default 2
  22365. * * q the number of windings around the x axis, optional, default 3
  22366. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22367. * * 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)
  22368. * * 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)
  22369. * @returns the VertexData of the Torus Knot
  22370. */
  22371. static CreateTorusKnot(options: {
  22372. radius?: number;
  22373. tube?: number;
  22374. radialSegments?: number;
  22375. tubularSegments?: number;
  22376. p?: number;
  22377. q?: number;
  22378. sideOrientation?: number;
  22379. frontUVs?: Vector4;
  22380. backUVs?: Vector4;
  22381. }): VertexData;
  22382. /**
  22383. * Compute normals for given positions and indices
  22384. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22385. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22386. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22387. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22388. * * facetNormals : optional array of facet normals (vector3)
  22389. * * facetPositions : optional array of facet positions (vector3)
  22390. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22391. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22392. * * bInfo : optional bounding info, required for facetPartitioning computation
  22393. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22394. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22395. * * useRightHandedSystem: optional boolean to for right handed system computation
  22396. * * depthSort : optional boolean to enable the facet depth sort computation
  22397. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22398. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22399. */
  22400. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22401. facetNormals?: any;
  22402. facetPositions?: any;
  22403. facetPartitioning?: any;
  22404. ratio?: number;
  22405. bInfo?: any;
  22406. bbSize?: Vector3;
  22407. subDiv?: any;
  22408. useRightHandedSystem?: boolean;
  22409. depthSort?: boolean;
  22410. distanceTo?: Vector3;
  22411. depthSortedFacets?: any;
  22412. }): void;
  22413. /** @hidden */
  22414. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22415. /**
  22416. * Applies VertexData created from the imported parameters to the geometry
  22417. * @param parsedVertexData the parsed data from an imported file
  22418. * @param geometry the geometry to apply the VertexData to
  22419. */
  22420. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22421. }
  22422. }
  22423. declare module "babylonjs/Morph/morphTarget" {
  22424. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22425. import { Observable } from "babylonjs/Misc/observable";
  22426. import { Nullable, FloatArray } from "babylonjs/types";
  22427. import { Scene } from "babylonjs/scene";
  22428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22429. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22430. /**
  22431. * Defines a target to use with MorphTargetManager
  22432. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22433. */
  22434. export class MorphTarget implements IAnimatable {
  22435. /** defines the name of the target */
  22436. name: string;
  22437. /**
  22438. * Gets or sets the list of animations
  22439. */
  22440. animations: import("babylonjs/Animations/animation").Animation[];
  22441. private _scene;
  22442. private _positions;
  22443. private _normals;
  22444. private _tangents;
  22445. private _uvs;
  22446. private _influence;
  22447. /**
  22448. * Observable raised when the influence changes
  22449. */
  22450. onInfluenceChanged: Observable<boolean>;
  22451. /** @hidden */
  22452. _onDataLayoutChanged: Observable<void>;
  22453. /**
  22454. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22455. */
  22456. influence: number;
  22457. /**
  22458. * Gets or sets the id of the morph Target
  22459. */
  22460. id: string;
  22461. private _animationPropertiesOverride;
  22462. /**
  22463. * Gets or sets the animation properties override
  22464. */
  22465. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22466. /**
  22467. * Creates a new MorphTarget
  22468. * @param name defines the name of the target
  22469. * @param influence defines the influence to use
  22470. * @param scene defines the scene the morphtarget belongs to
  22471. */
  22472. constructor(
  22473. /** defines the name of the target */
  22474. name: string, influence?: number, scene?: Nullable<Scene>);
  22475. /**
  22476. * Gets a boolean defining if the target contains position data
  22477. */
  22478. readonly hasPositions: boolean;
  22479. /**
  22480. * Gets a boolean defining if the target contains normal data
  22481. */
  22482. readonly hasNormals: boolean;
  22483. /**
  22484. * Gets a boolean defining if the target contains tangent data
  22485. */
  22486. readonly hasTangents: boolean;
  22487. /**
  22488. * Gets a boolean defining if the target contains texture coordinates data
  22489. */
  22490. readonly hasUVs: boolean;
  22491. /**
  22492. * Affects position data to this target
  22493. * @param data defines the position data to use
  22494. */
  22495. setPositions(data: Nullable<FloatArray>): void;
  22496. /**
  22497. * Gets the position data stored in this target
  22498. * @returns a FloatArray containing the position data (or null if not present)
  22499. */
  22500. getPositions(): Nullable<FloatArray>;
  22501. /**
  22502. * Affects normal data to this target
  22503. * @param data defines the normal data to use
  22504. */
  22505. setNormals(data: Nullable<FloatArray>): void;
  22506. /**
  22507. * Gets the normal data stored in this target
  22508. * @returns a FloatArray containing the normal data (or null if not present)
  22509. */
  22510. getNormals(): Nullable<FloatArray>;
  22511. /**
  22512. * Affects tangent data to this target
  22513. * @param data defines the tangent data to use
  22514. */
  22515. setTangents(data: Nullable<FloatArray>): void;
  22516. /**
  22517. * Gets the tangent data stored in this target
  22518. * @returns a FloatArray containing the tangent data (or null if not present)
  22519. */
  22520. getTangents(): Nullable<FloatArray>;
  22521. /**
  22522. * Affects texture coordinates data to this target
  22523. * @param data defines the texture coordinates data to use
  22524. */
  22525. setUVs(data: Nullable<FloatArray>): void;
  22526. /**
  22527. * Gets the texture coordinates data stored in this target
  22528. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22529. */
  22530. getUVs(): Nullable<FloatArray>;
  22531. /**
  22532. * Serializes the current target into a Serialization object
  22533. * @returns the serialized object
  22534. */
  22535. serialize(): any;
  22536. /**
  22537. * Returns the string "MorphTarget"
  22538. * @returns "MorphTarget"
  22539. */
  22540. getClassName(): string;
  22541. /**
  22542. * Creates a new target from serialized data
  22543. * @param serializationObject defines the serialized data to use
  22544. * @returns a new MorphTarget
  22545. */
  22546. static Parse(serializationObject: any): MorphTarget;
  22547. /**
  22548. * Creates a MorphTarget from mesh data
  22549. * @param mesh defines the source mesh
  22550. * @param name defines the name to use for the new target
  22551. * @param influence defines the influence to attach to the target
  22552. * @returns a new MorphTarget
  22553. */
  22554. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22555. }
  22556. }
  22557. declare module "babylonjs/Morph/morphTargetManager" {
  22558. import { Nullable } from "babylonjs/types";
  22559. import { Scene } from "babylonjs/scene";
  22560. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22561. /**
  22562. * This class is used to deform meshes using morphing between different targets
  22563. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22564. */
  22565. export class MorphTargetManager {
  22566. private _targets;
  22567. private _targetInfluenceChangedObservers;
  22568. private _targetDataLayoutChangedObservers;
  22569. private _activeTargets;
  22570. private _scene;
  22571. private _influences;
  22572. private _supportsNormals;
  22573. private _supportsTangents;
  22574. private _supportsUVs;
  22575. private _vertexCount;
  22576. private _uniqueId;
  22577. private _tempInfluences;
  22578. /**
  22579. * Gets or sets a boolean indicating if normals must be morphed
  22580. */
  22581. enableNormalMorphing: boolean;
  22582. /**
  22583. * Gets or sets a boolean indicating if tangents must be morphed
  22584. */
  22585. enableTangentMorphing: boolean;
  22586. /**
  22587. * Gets or sets a boolean indicating if UV must be morphed
  22588. */
  22589. enableUVMorphing: boolean;
  22590. /**
  22591. * Creates a new MorphTargetManager
  22592. * @param scene defines the current scene
  22593. */
  22594. constructor(scene?: Nullable<Scene>);
  22595. /**
  22596. * Gets the unique ID of this manager
  22597. */
  22598. readonly uniqueId: number;
  22599. /**
  22600. * Gets the number of vertices handled by this manager
  22601. */
  22602. readonly vertexCount: number;
  22603. /**
  22604. * Gets a boolean indicating if this manager supports morphing of normals
  22605. */
  22606. readonly supportsNormals: boolean;
  22607. /**
  22608. * Gets a boolean indicating if this manager supports morphing of tangents
  22609. */
  22610. readonly supportsTangents: boolean;
  22611. /**
  22612. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22613. */
  22614. readonly supportsUVs: boolean;
  22615. /**
  22616. * Gets the number of targets stored in this manager
  22617. */
  22618. readonly numTargets: number;
  22619. /**
  22620. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22621. */
  22622. readonly numInfluencers: number;
  22623. /**
  22624. * Gets the list of influences (one per target)
  22625. */
  22626. readonly influences: Float32Array;
  22627. /**
  22628. * Gets the active target at specified index. An active target is a target with an influence > 0
  22629. * @param index defines the index to check
  22630. * @returns the requested target
  22631. */
  22632. getActiveTarget(index: number): MorphTarget;
  22633. /**
  22634. * Gets the target at specified index
  22635. * @param index defines the index to check
  22636. * @returns the requested target
  22637. */
  22638. getTarget(index: number): MorphTarget;
  22639. /**
  22640. * Add a new target to this manager
  22641. * @param target defines the target to add
  22642. */
  22643. addTarget(target: MorphTarget): void;
  22644. /**
  22645. * Removes a target from the manager
  22646. * @param target defines the target to remove
  22647. */
  22648. removeTarget(target: MorphTarget): void;
  22649. /**
  22650. * Serializes the current manager into a Serialization object
  22651. * @returns the serialized object
  22652. */
  22653. serialize(): any;
  22654. private _syncActiveTargets;
  22655. /**
  22656. * Syncrhonize the targets with all the meshes using this morph target manager
  22657. */
  22658. synchronize(): void;
  22659. /**
  22660. * Creates a new MorphTargetManager from serialized data
  22661. * @param serializationObject defines the serialized data
  22662. * @param scene defines the hosting scene
  22663. * @returns the new MorphTargetManager
  22664. */
  22665. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22666. }
  22667. }
  22668. declare module "babylonjs/Meshes/meshLODLevel" {
  22669. import { Mesh } from "babylonjs/Meshes/mesh";
  22670. import { Nullable } from "babylonjs/types";
  22671. /**
  22672. * Class used to represent a specific level of detail of a mesh
  22673. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22674. */
  22675. export class MeshLODLevel {
  22676. /** Defines the distance where this level should start being displayed */
  22677. distance: number;
  22678. /** Defines the mesh to use to render this level */
  22679. mesh: Nullable<Mesh>;
  22680. /**
  22681. * Creates a new LOD level
  22682. * @param distance defines the distance where this level should star being displayed
  22683. * @param mesh defines the mesh to use to render this level
  22684. */
  22685. constructor(
  22686. /** Defines the distance where this level should start being displayed */
  22687. distance: number,
  22688. /** Defines the mesh to use to render this level */
  22689. mesh: Nullable<Mesh>);
  22690. }
  22691. }
  22692. declare module "babylonjs/Meshes/groundMesh" {
  22693. import { Scene } from "babylonjs/scene";
  22694. import { Vector3 } from "babylonjs/Maths/math.vector";
  22695. import { Mesh } from "babylonjs/Meshes/mesh";
  22696. /**
  22697. * Mesh representing the gorund
  22698. */
  22699. export class GroundMesh extends Mesh {
  22700. /** If octree should be generated */
  22701. generateOctree: boolean;
  22702. private _heightQuads;
  22703. /** @hidden */
  22704. _subdivisionsX: number;
  22705. /** @hidden */
  22706. _subdivisionsY: number;
  22707. /** @hidden */
  22708. _width: number;
  22709. /** @hidden */
  22710. _height: number;
  22711. /** @hidden */
  22712. _minX: number;
  22713. /** @hidden */
  22714. _maxX: number;
  22715. /** @hidden */
  22716. _minZ: number;
  22717. /** @hidden */
  22718. _maxZ: number;
  22719. constructor(name: string, scene: Scene);
  22720. /**
  22721. * "GroundMesh"
  22722. * @returns "GroundMesh"
  22723. */
  22724. getClassName(): string;
  22725. /**
  22726. * The minimum of x and y subdivisions
  22727. */
  22728. readonly subdivisions: number;
  22729. /**
  22730. * X subdivisions
  22731. */
  22732. readonly subdivisionsX: number;
  22733. /**
  22734. * Y subdivisions
  22735. */
  22736. readonly subdivisionsY: number;
  22737. /**
  22738. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22739. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22740. * @param chunksCount the number of subdivisions for x and y
  22741. * @param octreeBlocksSize (Default: 32)
  22742. */
  22743. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22744. /**
  22745. * Returns a height (y) value in the Worl system :
  22746. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22747. * @param x x coordinate
  22748. * @param z z coordinate
  22749. * @returns the ground y position if (x, z) are outside the ground surface.
  22750. */
  22751. getHeightAtCoordinates(x: number, z: number): number;
  22752. /**
  22753. * Returns a normalized vector (Vector3) orthogonal to the ground
  22754. * at the ground coordinates (x, z) expressed in the World system.
  22755. * @param x x coordinate
  22756. * @param z z coordinate
  22757. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22758. */
  22759. getNormalAtCoordinates(x: number, z: number): Vector3;
  22760. /**
  22761. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22762. * at the ground coordinates (x, z) expressed in the World system.
  22763. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22764. * @param x x coordinate
  22765. * @param z z coordinate
  22766. * @param ref vector to store the result
  22767. * @returns the GroundMesh.
  22768. */
  22769. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22770. /**
  22771. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22772. * if the ground has been updated.
  22773. * This can be used in the render loop.
  22774. * @returns the GroundMesh.
  22775. */
  22776. updateCoordinateHeights(): GroundMesh;
  22777. private _getFacetAt;
  22778. private _initHeightQuads;
  22779. private _computeHeightQuads;
  22780. /**
  22781. * Serializes this ground mesh
  22782. * @param serializationObject object to write serialization to
  22783. */
  22784. serialize(serializationObject: any): void;
  22785. /**
  22786. * Parses a serialized ground mesh
  22787. * @param parsedMesh the serialized mesh
  22788. * @param scene the scene to create the ground mesh in
  22789. * @returns the created ground mesh
  22790. */
  22791. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22792. }
  22793. }
  22794. declare module "babylonjs/Physics/physicsJoint" {
  22795. import { Vector3 } from "babylonjs/Maths/math.vector";
  22796. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22797. /**
  22798. * Interface for Physics-Joint data
  22799. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22800. */
  22801. export interface PhysicsJointData {
  22802. /**
  22803. * The main pivot of the joint
  22804. */
  22805. mainPivot?: Vector3;
  22806. /**
  22807. * The connected pivot of the joint
  22808. */
  22809. connectedPivot?: Vector3;
  22810. /**
  22811. * The main axis of the joint
  22812. */
  22813. mainAxis?: Vector3;
  22814. /**
  22815. * The connected axis of the joint
  22816. */
  22817. connectedAxis?: Vector3;
  22818. /**
  22819. * The collision of the joint
  22820. */
  22821. collision?: boolean;
  22822. /**
  22823. * Native Oimo/Cannon/Energy data
  22824. */
  22825. nativeParams?: any;
  22826. }
  22827. /**
  22828. * This is a holder class for the physics joint created by the physics plugin
  22829. * It holds a set of functions to control the underlying joint
  22830. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22831. */
  22832. export class PhysicsJoint {
  22833. /**
  22834. * The type of the physics joint
  22835. */
  22836. type: number;
  22837. /**
  22838. * The data for the physics joint
  22839. */
  22840. jointData: PhysicsJointData;
  22841. private _physicsJoint;
  22842. protected _physicsPlugin: IPhysicsEnginePlugin;
  22843. /**
  22844. * Initializes the physics joint
  22845. * @param type The type of the physics joint
  22846. * @param jointData The data for the physics joint
  22847. */
  22848. constructor(
  22849. /**
  22850. * The type of the physics joint
  22851. */
  22852. type: number,
  22853. /**
  22854. * The data for the physics joint
  22855. */
  22856. jointData: PhysicsJointData);
  22857. /**
  22858. * Gets the physics joint
  22859. */
  22860. /**
  22861. * Sets the physics joint
  22862. */
  22863. physicsJoint: any;
  22864. /**
  22865. * Sets the physics plugin
  22866. */
  22867. physicsPlugin: IPhysicsEnginePlugin;
  22868. /**
  22869. * Execute a function that is physics-plugin specific.
  22870. * @param {Function} func the function that will be executed.
  22871. * It accepts two parameters: the physics world and the physics joint
  22872. */
  22873. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22874. /**
  22875. * Distance-Joint type
  22876. */
  22877. static DistanceJoint: number;
  22878. /**
  22879. * Hinge-Joint type
  22880. */
  22881. static HingeJoint: number;
  22882. /**
  22883. * Ball-and-Socket joint type
  22884. */
  22885. static BallAndSocketJoint: number;
  22886. /**
  22887. * Wheel-Joint type
  22888. */
  22889. static WheelJoint: number;
  22890. /**
  22891. * Slider-Joint type
  22892. */
  22893. static SliderJoint: number;
  22894. /**
  22895. * Prismatic-Joint type
  22896. */
  22897. static PrismaticJoint: number;
  22898. /**
  22899. * Universal-Joint type
  22900. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22901. */
  22902. static UniversalJoint: number;
  22903. /**
  22904. * Hinge-Joint 2 type
  22905. */
  22906. static Hinge2Joint: number;
  22907. /**
  22908. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22909. */
  22910. static PointToPointJoint: number;
  22911. /**
  22912. * Spring-Joint type
  22913. */
  22914. static SpringJoint: number;
  22915. /**
  22916. * Lock-Joint type
  22917. */
  22918. static LockJoint: number;
  22919. }
  22920. /**
  22921. * A class representing a physics distance joint
  22922. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22923. */
  22924. export class DistanceJoint extends PhysicsJoint {
  22925. /**
  22926. *
  22927. * @param jointData The data for the Distance-Joint
  22928. */
  22929. constructor(jointData: DistanceJointData);
  22930. /**
  22931. * Update the predefined distance.
  22932. * @param maxDistance The maximum preferred distance
  22933. * @param minDistance The minimum preferred distance
  22934. */
  22935. updateDistance(maxDistance: number, minDistance?: number): void;
  22936. }
  22937. /**
  22938. * Represents a Motor-Enabled Joint
  22939. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22940. */
  22941. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22942. /**
  22943. * Initializes the Motor-Enabled Joint
  22944. * @param type The type of the joint
  22945. * @param jointData The physica joint data for the joint
  22946. */
  22947. constructor(type: number, jointData: PhysicsJointData);
  22948. /**
  22949. * Set the motor values.
  22950. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22951. * @param force the force to apply
  22952. * @param maxForce max force for this motor.
  22953. */
  22954. setMotor(force?: number, maxForce?: number): void;
  22955. /**
  22956. * Set the motor's limits.
  22957. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22958. * @param upperLimit The upper limit of the motor
  22959. * @param lowerLimit The lower limit of the motor
  22960. */
  22961. setLimit(upperLimit: number, lowerLimit?: number): void;
  22962. }
  22963. /**
  22964. * This class represents a single physics Hinge-Joint
  22965. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22966. */
  22967. export class HingeJoint extends MotorEnabledJoint {
  22968. /**
  22969. * Initializes the Hinge-Joint
  22970. * @param jointData The joint data for the Hinge-Joint
  22971. */
  22972. constructor(jointData: PhysicsJointData);
  22973. /**
  22974. * Set the motor values.
  22975. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22976. * @param {number} force the force to apply
  22977. * @param {number} maxForce max force for this motor.
  22978. */
  22979. setMotor(force?: number, maxForce?: number): void;
  22980. /**
  22981. * Set the motor's limits.
  22982. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22983. * @param upperLimit The upper limit of the motor
  22984. * @param lowerLimit The lower limit of the motor
  22985. */
  22986. setLimit(upperLimit: number, lowerLimit?: number): void;
  22987. }
  22988. /**
  22989. * This class represents a dual hinge physics joint (same as wheel joint)
  22990. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22991. */
  22992. export class Hinge2Joint extends MotorEnabledJoint {
  22993. /**
  22994. * Initializes the Hinge2-Joint
  22995. * @param jointData The joint data for the Hinge2-Joint
  22996. */
  22997. constructor(jointData: PhysicsJointData);
  22998. /**
  22999. * Set the motor values.
  23000. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23001. * @param {number} targetSpeed the speed the motor is to reach
  23002. * @param {number} maxForce max force for this motor.
  23003. * @param {motorIndex} the motor's index, 0 or 1.
  23004. */
  23005. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23006. /**
  23007. * Set the motor limits.
  23008. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23009. * @param {number} upperLimit the upper limit
  23010. * @param {number} lowerLimit lower limit
  23011. * @param {motorIndex} the motor's index, 0 or 1.
  23012. */
  23013. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23014. }
  23015. /**
  23016. * Interface for a motor enabled joint
  23017. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23018. */
  23019. export interface IMotorEnabledJoint {
  23020. /**
  23021. * Physics joint
  23022. */
  23023. physicsJoint: any;
  23024. /**
  23025. * Sets the motor of the motor-enabled joint
  23026. * @param force The force of the motor
  23027. * @param maxForce The maximum force of the motor
  23028. * @param motorIndex The index of the motor
  23029. */
  23030. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23031. /**
  23032. * Sets the limit of the motor
  23033. * @param upperLimit The upper limit of the motor
  23034. * @param lowerLimit The lower limit of the motor
  23035. * @param motorIndex The index of the motor
  23036. */
  23037. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23038. }
  23039. /**
  23040. * Joint data for a Distance-Joint
  23041. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23042. */
  23043. export interface DistanceJointData extends PhysicsJointData {
  23044. /**
  23045. * Max distance the 2 joint objects can be apart
  23046. */
  23047. maxDistance: number;
  23048. }
  23049. /**
  23050. * Joint data from a spring joint
  23051. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23052. */
  23053. export interface SpringJointData extends PhysicsJointData {
  23054. /**
  23055. * Length of the spring
  23056. */
  23057. length: number;
  23058. /**
  23059. * Stiffness of the spring
  23060. */
  23061. stiffness: number;
  23062. /**
  23063. * Damping of the spring
  23064. */
  23065. damping: number;
  23066. /** this callback will be called when applying the force to the impostors. */
  23067. forceApplicationCallback: () => void;
  23068. }
  23069. }
  23070. declare module "babylonjs/Physics/physicsRaycastResult" {
  23071. import { Vector3 } from "babylonjs/Maths/math.vector";
  23072. /**
  23073. * Holds the data for the raycast result
  23074. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23075. */
  23076. export class PhysicsRaycastResult {
  23077. private _hasHit;
  23078. private _hitDistance;
  23079. private _hitNormalWorld;
  23080. private _hitPointWorld;
  23081. private _rayFromWorld;
  23082. private _rayToWorld;
  23083. /**
  23084. * Gets if there was a hit
  23085. */
  23086. readonly hasHit: boolean;
  23087. /**
  23088. * Gets the distance from the hit
  23089. */
  23090. readonly hitDistance: number;
  23091. /**
  23092. * Gets the hit normal/direction in the world
  23093. */
  23094. readonly hitNormalWorld: Vector3;
  23095. /**
  23096. * Gets the hit point in the world
  23097. */
  23098. readonly hitPointWorld: Vector3;
  23099. /**
  23100. * Gets the ray "start point" of the ray in the world
  23101. */
  23102. readonly rayFromWorld: Vector3;
  23103. /**
  23104. * Gets the ray "end point" of the ray in the world
  23105. */
  23106. readonly rayToWorld: Vector3;
  23107. /**
  23108. * Sets the hit data (normal & point in world space)
  23109. * @param hitNormalWorld defines the normal in world space
  23110. * @param hitPointWorld defines the point in world space
  23111. */
  23112. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23113. /**
  23114. * Sets the distance from the start point to the hit point
  23115. * @param distance
  23116. */
  23117. setHitDistance(distance: number): void;
  23118. /**
  23119. * Calculates the distance manually
  23120. */
  23121. calculateHitDistance(): void;
  23122. /**
  23123. * Resets all the values to default
  23124. * @param from The from point on world space
  23125. * @param to The to point on world space
  23126. */
  23127. reset(from?: Vector3, to?: Vector3): void;
  23128. }
  23129. /**
  23130. * Interface for the size containing width and height
  23131. */
  23132. interface IXYZ {
  23133. /**
  23134. * X
  23135. */
  23136. x: number;
  23137. /**
  23138. * Y
  23139. */
  23140. y: number;
  23141. /**
  23142. * Z
  23143. */
  23144. z: number;
  23145. }
  23146. }
  23147. declare module "babylonjs/Physics/IPhysicsEngine" {
  23148. import { Nullable } from "babylonjs/types";
  23149. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23151. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23152. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23153. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23154. /**
  23155. * Interface used to describe a physics joint
  23156. */
  23157. export interface PhysicsImpostorJoint {
  23158. /** Defines the main impostor to which the joint is linked */
  23159. mainImpostor: PhysicsImpostor;
  23160. /** Defines the impostor that is connected to the main impostor using this joint */
  23161. connectedImpostor: PhysicsImpostor;
  23162. /** Defines the joint itself */
  23163. joint: PhysicsJoint;
  23164. }
  23165. /** @hidden */
  23166. export interface IPhysicsEnginePlugin {
  23167. world: any;
  23168. name: string;
  23169. setGravity(gravity: Vector3): void;
  23170. setTimeStep(timeStep: number): void;
  23171. getTimeStep(): number;
  23172. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23173. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23174. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23175. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23176. removePhysicsBody(impostor: PhysicsImpostor): void;
  23177. generateJoint(joint: PhysicsImpostorJoint): void;
  23178. removeJoint(joint: PhysicsImpostorJoint): void;
  23179. isSupported(): boolean;
  23180. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23181. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23182. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23183. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23184. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23185. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23186. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23187. getBodyMass(impostor: PhysicsImpostor): number;
  23188. getBodyFriction(impostor: PhysicsImpostor): number;
  23189. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23190. getBodyRestitution(impostor: PhysicsImpostor): number;
  23191. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23192. getBodyPressure?(impostor: PhysicsImpostor): number;
  23193. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23194. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23195. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23196. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23197. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23198. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23199. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23200. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23201. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23202. sleepBody(impostor: PhysicsImpostor): void;
  23203. wakeUpBody(impostor: PhysicsImpostor): void;
  23204. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23205. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23206. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23207. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23208. getRadius(impostor: PhysicsImpostor): number;
  23209. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23210. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23211. dispose(): void;
  23212. }
  23213. /**
  23214. * Interface used to define a physics engine
  23215. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23216. */
  23217. export interface IPhysicsEngine {
  23218. /**
  23219. * Gets the gravity vector used by the simulation
  23220. */
  23221. gravity: Vector3;
  23222. /**
  23223. * Sets the gravity vector used by the simulation
  23224. * @param gravity defines the gravity vector to use
  23225. */
  23226. setGravity(gravity: Vector3): void;
  23227. /**
  23228. * Set the time step of the physics engine.
  23229. * Default is 1/60.
  23230. * To slow it down, enter 1/600 for example.
  23231. * To speed it up, 1/30
  23232. * @param newTimeStep the new timestep to apply to this world.
  23233. */
  23234. setTimeStep(newTimeStep: number): void;
  23235. /**
  23236. * Get the time step of the physics engine.
  23237. * @returns the current time step
  23238. */
  23239. getTimeStep(): number;
  23240. /**
  23241. * Release all resources
  23242. */
  23243. dispose(): void;
  23244. /**
  23245. * Gets the name of the current physics plugin
  23246. * @returns the name of the plugin
  23247. */
  23248. getPhysicsPluginName(): string;
  23249. /**
  23250. * Adding a new impostor for the impostor tracking.
  23251. * This will be done by the impostor itself.
  23252. * @param impostor the impostor to add
  23253. */
  23254. addImpostor(impostor: PhysicsImpostor): void;
  23255. /**
  23256. * Remove an impostor from the engine.
  23257. * This impostor and its mesh will not longer be updated by the physics engine.
  23258. * @param impostor the impostor to remove
  23259. */
  23260. removeImpostor(impostor: PhysicsImpostor): void;
  23261. /**
  23262. * Add a joint to the physics engine
  23263. * @param mainImpostor defines the main impostor to which the joint is added.
  23264. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23265. * @param joint defines the joint that will connect both impostors.
  23266. */
  23267. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23268. /**
  23269. * Removes a joint from the simulation
  23270. * @param mainImpostor defines the impostor used with the joint
  23271. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23272. * @param joint defines the joint to remove
  23273. */
  23274. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23275. /**
  23276. * Gets the current plugin used to run the simulation
  23277. * @returns current plugin
  23278. */
  23279. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23280. /**
  23281. * Gets the list of physic impostors
  23282. * @returns an array of PhysicsImpostor
  23283. */
  23284. getImpostors(): Array<PhysicsImpostor>;
  23285. /**
  23286. * Gets the impostor for a physics enabled object
  23287. * @param object defines the object impersonated by the impostor
  23288. * @returns the PhysicsImpostor or null if not found
  23289. */
  23290. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23291. /**
  23292. * Gets the impostor for a physics body object
  23293. * @param body defines physics body used by the impostor
  23294. * @returns the PhysicsImpostor or null if not found
  23295. */
  23296. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23297. /**
  23298. * Does a raycast in the physics world
  23299. * @param from when should the ray start?
  23300. * @param to when should the ray end?
  23301. * @returns PhysicsRaycastResult
  23302. */
  23303. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23304. /**
  23305. * Called by the scene. No need to call it.
  23306. * @param delta defines the timespam between frames
  23307. */
  23308. _step(delta: number): void;
  23309. }
  23310. }
  23311. declare module "babylonjs/Physics/physicsImpostor" {
  23312. import { Nullable, IndicesArray } from "babylonjs/types";
  23313. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23314. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23315. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23316. import { Scene } from "babylonjs/scene";
  23317. import { Bone } from "babylonjs/Bones/bone";
  23318. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23319. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23320. import { Space } from "babylonjs/Maths/math.axis";
  23321. /**
  23322. * The interface for the physics imposter parameters
  23323. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23324. */
  23325. export interface PhysicsImpostorParameters {
  23326. /**
  23327. * The mass of the physics imposter
  23328. */
  23329. mass: number;
  23330. /**
  23331. * The friction of the physics imposter
  23332. */
  23333. friction?: number;
  23334. /**
  23335. * The coefficient of restitution of the physics imposter
  23336. */
  23337. restitution?: number;
  23338. /**
  23339. * The native options of the physics imposter
  23340. */
  23341. nativeOptions?: any;
  23342. /**
  23343. * Specifies if the parent should be ignored
  23344. */
  23345. ignoreParent?: boolean;
  23346. /**
  23347. * Specifies if bi-directional transformations should be disabled
  23348. */
  23349. disableBidirectionalTransformation?: boolean;
  23350. /**
  23351. * The pressure inside the physics imposter, soft object only
  23352. */
  23353. pressure?: number;
  23354. /**
  23355. * The stiffness the physics imposter, soft object only
  23356. */
  23357. stiffness?: number;
  23358. /**
  23359. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23360. */
  23361. velocityIterations?: number;
  23362. /**
  23363. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23364. */
  23365. positionIterations?: number;
  23366. /**
  23367. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23368. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23369. * Add to fix multiple points
  23370. */
  23371. fixedPoints?: number;
  23372. /**
  23373. * The collision margin around a soft object
  23374. */
  23375. margin?: number;
  23376. /**
  23377. * The collision margin around a soft object
  23378. */
  23379. damping?: number;
  23380. /**
  23381. * The path for a rope based on an extrusion
  23382. */
  23383. path?: any;
  23384. /**
  23385. * The shape of an extrusion used for a rope based on an extrusion
  23386. */
  23387. shape?: any;
  23388. }
  23389. /**
  23390. * Interface for a physics-enabled object
  23391. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23392. */
  23393. export interface IPhysicsEnabledObject {
  23394. /**
  23395. * The position of the physics-enabled object
  23396. */
  23397. position: Vector3;
  23398. /**
  23399. * The rotation of the physics-enabled object
  23400. */
  23401. rotationQuaternion: Nullable<Quaternion>;
  23402. /**
  23403. * The scale of the physics-enabled object
  23404. */
  23405. scaling: Vector3;
  23406. /**
  23407. * The rotation of the physics-enabled object
  23408. */
  23409. rotation?: Vector3;
  23410. /**
  23411. * The parent of the physics-enabled object
  23412. */
  23413. parent?: any;
  23414. /**
  23415. * The bounding info of the physics-enabled object
  23416. * @returns The bounding info of the physics-enabled object
  23417. */
  23418. getBoundingInfo(): BoundingInfo;
  23419. /**
  23420. * Computes the world matrix
  23421. * @param force Specifies if the world matrix should be computed by force
  23422. * @returns A world matrix
  23423. */
  23424. computeWorldMatrix(force: boolean): Matrix;
  23425. /**
  23426. * Gets the world matrix
  23427. * @returns A world matrix
  23428. */
  23429. getWorldMatrix?(): Matrix;
  23430. /**
  23431. * Gets the child meshes
  23432. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23433. * @returns An array of abstract meshes
  23434. */
  23435. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23436. /**
  23437. * Gets the vertex data
  23438. * @param kind The type of vertex data
  23439. * @returns A nullable array of numbers, or a float32 array
  23440. */
  23441. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23442. /**
  23443. * Gets the indices from the mesh
  23444. * @returns A nullable array of index arrays
  23445. */
  23446. getIndices?(): Nullable<IndicesArray>;
  23447. /**
  23448. * Gets the scene from the mesh
  23449. * @returns the indices array or null
  23450. */
  23451. getScene?(): Scene;
  23452. /**
  23453. * Gets the absolute position from the mesh
  23454. * @returns the absolute position
  23455. */
  23456. getAbsolutePosition(): Vector3;
  23457. /**
  23458. * Gets the absolute pivot point from the mesh
  23459. * @returns the absolute pivot point
  23460. */
  23461. getAbsolutePivotPoint(): Vector3;
  23462. /**
  23463. * Rotates the mesh
  23464. * @param axis The axis of rotation
  23465. * @param amount The amount of rotation
  23466. * @param space The space of the rotation
  23467. * @returns The rotation transform node
  23468. */
  23469. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23470. /**
  23471. * Translates the mesh
  23472. * @param axis The axis of translation
  23473. * @param distance The distance of translation
  23474. * @param space The space of the translation
  23475. * @returns The transform node
  23476. */
  23477. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23478. /**
  23479. * Sets the absolute position of the mesh
  23480. * @param absolutePosition The absolute position of the mesh
  23481. * @returns The transform node
  23482. */
  23483. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23484. /**
  23485. * Gets the class name of the mesh
  23486. * @returns The class name
  23487. */
  23488. getClassName(): string;
  23489. }
  23490. /**
  23491. * Represents a physics imposter
  23492. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23493. */
  23494. export class PhysicsImpostor {
  23495. /**
  23496. * The physics-enabled object used as the physics imposter
  23497. */
  23498. object: IPhysicsEnabledObject;
  23499. /**
  23500. * The type of the physics imposter
  23501. */
  23502. type: number;
  23503. private _options;
  23504. private _scene?;
  23505. /**
  23506. * The default object size of the imposter
  23507. */
  23508. static DEFAULT_OBJECT_SIZE: Vector3;
  23509. /**
  23510. * The identity quaternion of the imposter
  23511. */
  23512. static IDENTITY_QUATERNION: Quaternion;
  23513. /** @hidden */
  23514. _pluginData: any;
  23515. private _physicsEngine;
  23516. private _physicsBody;
  23517. private _bodyUpdateRequired;
  23518. private _onBeforePhysicsStepCallbacks;
  23519. private _onAfterPhysicsStepCallbacks;
  23520. /** @hidden */
  23521. _onPhysicsCollideCallbacks: Array<{
  23522. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23523. otherImpostors: Array<PhysicsImpostor>;
  23524. }>;
  23525. private _deltaPosition;
  23526. private _deltaRotation;
  23527. private _deltaRotationConjugated;
  23528. /** @hidden */
  23529. _isFromLine: boolean;
  23530. private _parent;
  23531. private _isDisposed;
  23532. private static _tmpVecs;
  23533. private static _tmpQuat;
  23534. /**
  23535. * Specifies if the physics imposter is disposed
  23536. */
  23537. readonly isDisposed: boolean;
  23538. /**
  23539. * Gets the mass of the physics imposter
  23540. */
  23541. mass: number;
  23542. /**
  23543. * Gets the coefficient of friction
  23544. */
  23545. /**
  23546. * Sets the coefficient of friction
  23547. */
  23548. friction: number;
  23549. /**
  23550. * Gets the coefficient of restitution
  23551. */
  23552. /**
  23553. * Sets the coefficient of restitution
  23554. */
  23555. restitution: number;
  23556. /**
  23557. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23558. */
  23559. /**
  23560. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23561. */
  23562. pressure: number;
  23563. /**
  23564. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23565. */
  23566. /**
  23567. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23568. */
  23569. stiffness: number;
  23570. /**
  23571. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23572. */
  23573. /**
  23574. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23575. */
  23576. velocityIterations: number;
  23577. /**
  23578. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23579. */
  23580. /**
  23581. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23582. */
  23583. positionIterations: number;
  23584. /**
  23585. * The unique id of the physics imposter
  23586. * set by the physics engine when adding this impostor to the array
  23587. */
  23588. uniqueId: number;
  23589. /**
  23590. * @hidden
  23591. */
  23592. soft: boolean;
  23593. /**
  23594. * @hidden
  23595. */
  23596. segments: number;
  23597. private _joints;
  23598. /**
  23599. * Initializes the physics imposter
  23600. * @param object The physics-enabled object used as the physics imposter
  23601. * @param type The type of the physics imposter
  23602. * @param _options The options for the physics imposter
  23603. * @param _scene The Babylon scene
  23604. */
  23605. constructor(
  23606. /**
  23607. * The physics-enabled object used as the physics imposter
  23608. */
  23609. object: IPhysicsEnabledObject,
  23610. /**
  23611. * The type of the physics imposter
  23612. */
  23613. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23614. /**
  23615. * This function will completly initialize this impostor.
  23616. * It will create a new body - but only if this mesh has no parent.
  23617. * If it has, this impostor will not be used other than to define the impostor
  23618. * of the child mesh.
  23619. * @hidden
  23620. */
  23621. _init(): void;
  23622. private _getPhysicsParent;
  23623. /**
  23624. * Should a new body be generated.
  23625. * @returns boolean specifying if body initialization is required
  23626. */
  23627. isBodyInitRequired(): boolean;
  23628. /**
  23629. * Sets the updated scaling
  23630. * @param updated Specifies if the scaling is updated
  23631. */
  23632. setScalingUpdated(): void;
  23633. /**
  23634. * Force a regeneration of this or the parent's impostor's body.
  23635. * Use under cautious - This will remove all joints already implemented.
  23636. */
  23637. forceUpdate(): void;
  23638. /**
  23639. * Gets the body that holds this impostor. Either its own, or its parent.
  23640. */
  23641. /**
  23642. * Set the physics body. Used mainly by the physics engine/plugin
  23643. */
  23644. physicsBody: any;
  23645. /**
  23646. * Get the parent of the physics imposter
  23647. * @returns Physics imposter or null
  23648. */
  23649. /**
  23650. * Sets the parent of the physics imposter
  23651. */
  23652. parent: Nullable<PhysicsImpostor>;
  23653. /**
  23654. * Resets the update flags
  23655. */
  23656. resetUpdateFlags(): void;
  23657. /**
  23658. * Gets the object extend size
  23659. * @returns the object extend size
  23660. */
  23661. getObjectExtendSize(): Vector3;
  23662. /**
  23663. * Gets the object center
  23664. * @returns The object center
  23665. */
  23666. getObjectCenter(): Vector3;
  23667. /**
  23668. * Get a specific parametes from the options parameter
  23669. * @param paramName The object parameter name
  23670. * @returns The object parameter
  23671. */
  23672. getParam(paramName: string): any;
  23673. /**
  23674. * Sets a specific parameter in the options given to the physics plugin
  23675. * @param paramName The parameter name
  23676. * @param value The value of the parameter
  23677. */
  23678. setParam(paramName: string, value: number): void;
  23679. /**
  23680. * Specifically change the body's mass option. Won't recreate the physics body object
  23681. * @param mass The mass of the physics imposter
  23682. */
  23683. setMass(mass: number): void;
  23684. /**
  23685. * Gets the linear velocity
  23686. * @returns linear velocity or null
  23687. */
  23688. getLinearVelocity(): Nullable<Vector3>;
  23689. /**
  23690. * Sets the linear velocity
  23691. * @param velocity linear velocity or null
  23692. */
  23693. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23694. /**
  23695. * Gets the angular velocity
  23696. * @returns angular velocity or null
  23697. */
  23698. getAngularVelocity(): Nullable<Vector3>;
  23699. /**
  23700. * Sets the angular velocity
  23701. * @param velocity The velocity or null
  23702. */
  23703. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23704. /**
  23705. * Execute a function with the physics plugin native code
  23706. * Provide a function the will have two variables - the world object and the physics body object
  23707. * @param func The function to execute with the physics plugin native code
  23708. */
  23709. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23710. /**
  23711. * Register a function that will be executed before the physics world is stepping forward
  23712. * @param func The function to execute before the physics world is stepped forward
  23713. */
  23714. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23715. /**
  23716. * Unregister a function that will be executed before the physics world is stepping forward
  23717. * @param func The function to execute before the physics world is stepped forward
  23718. */
  23719. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23720. /**
  23721. * Register a function that will be executed after the physics step
  23722. * @param func The function to execute after physics step
  23723. */
  23724. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23725. /**
  23726. * Unregisters a function that will be executed after the physics step
  23727. * @param func The function to execute after physics step
  23728. */
  23729. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23730. /**
  23731. * register a function that will be executed when this impostor collides against a different body
  23732. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23733. * @param func Callback that is executed on collision
  23734. */
  23735. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23736. /**
  23737. * Unregisters the physics imposter on contact
  23738. * @param collideAgainst The physics object to collide against
  23739. * @param func Callback to execute on collision
  23740. */
  23741. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23742. private _tmpQuat;
  23743. private _tmpQuat2;
  23744. /**
  23745. * Get the parent rotation
  23746. * @returns The parent rotation
  23747. */
  23748. getParentsRotation(): Quaternion;
  23749. /**
  23750. * this function is executed by the physics engine.
  23751. */
  23752. beforeStep: () => void;
  23753. /**
  23754. * this function is executed by the physics engine
  23755. */
  23756. afterStep: () => void;
  23757. /**
  23758. * Legacy collision detection event support
  23759. */
  23760. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23761. /**
  23762. * event and body object due to cannon's event-based architecture.
  23763. */
  23764. onCollide: (e: {
  23765. body: any;
  23766. }) => void;
  23767. /**
  23768. * Apply a force
  23769. * @param force The force to apply
  23770. * @param contactPoint The contact point for the force
  23771. * @returns The physics imposter
  23772. */
  23773. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23774. /**
  23775. * Apply an impulse
  23776. * @param force The impulse force
  23777. * @param contactPoint The contact point for the impulse force
  23778. * @returns The physics imposter
  23779. */
  23780. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23781. /**
  23782. * A help function to create a joint
  23783. * @param otherImpostor A physics imposter used to create a joint
  23784. * @param jointType The type of joint
  23785. * @param jointData The data for the joint
  23786. * @returns The physics imposter
  23787. */
  23788. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23789. /**
  23790. * Add a joint to this impostor with a different impostor
  23791. * @param otherImpostor A physics imposter used to add a joint
  23792. * @param joint The joint to add
  23793. * @returns The physics imposter
  23794. */
  23795. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23796. /**
  23797. * Add an anchor to a cloth impostor
  23798. * @param otherImpostor rigid impostor to anchor to
  23799. * @param width ratio across width from 0 to 1
  23800. * @param height ratio up height from 0 to 1
  23801. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23802. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23803. * @returns impostor the soft imposter
  23804. */
  23805. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23806. /**
  23807. * Add a hook to a rope impostor
  23808. * @param otherImpostor rigid impostor to anchor to
  23809. * @param length ratio across rope from 0 to 1
  23810. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23811. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23812. * @returns impostor the rope imposter
  23813. */
  23814. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23815. /**
  23816. * Will keep this body still, in a sleep mode.
  23817. * @returns the physics imposter
  23818. */
  23819. sleep(): PhysicsImpostor;
  23820. /**
  23821. * Wake the body up.
  23822. * @returns The physics imposter
  23823. */
  23824. wakeUp(): PhysicsImpostor;
  23825. /**
  23826. * Clones the physics imposter
  23827. * @param newObject The physics imposter clones to this physics-enabled object
  23828. * @returns A nullable physics imposter
  23829. */
  23830. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23831. /**
  23832. * Disposes the physics imposter
  23833. */
  23834. dispose(): void;
  23835. /**
  23836. * Sets the delta position
  23837. * @param position The delta position amount
  23838. */
  23839. setDeltaPosition(position: Vector3): void;
  23840. /**
  23841. * Sets the delta rotation
  23842. * @param rotation The delta rotation amount
  23843. */
  23844. setDeltaRotation(rotation: Quaternion): void;
  23845. /**
  23846. * Gets the box size of the physics imposter and stores the result in the input parameter
  23847. * @param result Stores the box size
  23848. * @returns The physics imposter
  23849. */
  23850. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23851. /**
  23852. * Gets the radius of the physics imposter
  23853. * @returns Radius of the physics imposter
  23854. */
  23855. getRadius(): number;
  23856. /**
  23857. * Sync a bone with this impostor
  23858. * @param bone The bone to sync to the impostor.
  23859. * @param boneMesh The mesh that the bone is influencing.
  23860. * @param jointPivot The pivot of the joint / bone in local space.
  23861. * @param distToJoint Optional distance from the impostor to the joint.
  23862. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23863. */
  23864. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23865. /**
  23866. * Sync impostor to a bone
  23867. * @param bone The bone that the impostor will be synced to.
  23868. * @param boneMesh The mesh that the bone is influencing.
  23869. * @param jointPivot The pivot of the joint / bone in local space.
  23870. * @param distToJoint Optional distance from the impostor to the joint.
  23871. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23872. * @param boneAxis Optional vector3 axis the bone is aligned with
  23873. */
  23874. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23875. /**
  23876. * No-Imposter type
  23877. */
  23878. static NoImpostor: number;
  23879. /**
  23880. * Sphere-Imposter type
  23881. */
  23882. static SphereImpostor: number;
  23883. /**
  23884. * Box-Imposter type
  23885. */
  23886. static BoxImpostor: number;
  23887. /**
  23888. * Plane-Imposter type
  23889. */
  23890. static PlaneImpostor: number;
  23891. /**
  23892. * Mesh-imposter type
  23893. */
  23894. static MeshImpostor: number;
  23895. /**
  23896. * Capsule-Impostor type (Ammo.js plugin only)
  23897. */
  23898. static CapsuleImpostor: number;
  23899. /**
  23900. * Cylinder-Imposter type
  23901. */
  23902. static CylinderImpostor: number;
  23903. /**
  23904. * Particle-Imposter type
  23905. */
  23906. static ParticleImpostor: number;
  23907. /**
  23908. * Heightmap-Imposter type
  23909. */
  23910. static HeightmapImpostor: number;
  23911. /**
  23912. * ConvexHull-Impostor type (Ammo.js plugin only)
  23913. */
  23914. static ConvexHullImpostor: number;
  23915. /**
  23916. * Rope-Imposter type
  23917. */
  23918. static RopeImpostor: number;
  23919. /**
  23920. * Cloth-Imposter type
  23921. */
  23922. static ClothImpostor: number;
  23923. /**
  23924. * Softbody-Imposter type
  23925. */
  23926. static SoftbodyImpostor: number;
  23927. }
  23928. }
  23929. declare module "babylonjs/Meshes/mesh" {
  23930. import { Observable } from "babylonjs/Misc/observable";
  23931. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23932. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23933. import { Camera } from "babylonjs/Cameras/camera";
  23934. import { Scene } from "babylonjs/scene";
  23935. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  23936. import { Color4 } from "babylonjs/Maths/math.color";
  23937. import { Engine } from "babylonjs/Engines/engine";
  23938. import { Node } from "babylonjs/node";
  23939. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23940. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23941. import { Buffer } from "babylonjs/Meshes/buffer";
  23942. import { Geometry } from "babylonjs/Meshes/geometry";
  23943. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23944. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23945. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  23946. import { Effect } from "babylonjs/Materials/effect";
  23947. import { Material } from "babylonjs/Materials/material";
  23948. import { Skeleton } from "babylonjs/Bones/skeleton";
  23949. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  23950. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  23951. import { Path3D } from "babylonjs/Maths/math.path";
  23952. import { Plane } from "babylonjs/Maths/math.plane";
  23953. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23954. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  23955. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  23956. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  23957. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23958. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  23959. /**
  23960. * @hidden
  23961. **/
  23962. export class _CreationDataStorage {
  23963. closePath?: boolean;
  23964. closeArray?: boolean;
  23965. idx: number[];
  23966. dashSize: number;
  23967. gapSize: number;
  23968. path3D: Path3D;
  23969. pathArray: Vector3[][];
  23970. arc: number;
  23971. radius: number;
  23972. cap: number;
  23973. tessellation: number;
  23974. }
  23975. /**
  23976. * @hidden
  23977. **/
  23978. class _InstanceDataStorage {
  23979. visibleInstances: any;
  23980. batchCache: _InstancesBatch;
  23981. instancesBufferSize: number;
  23982. instancesBuffer: Nullable<Buffer>;
  23983. instancesData: Float32Array;
  23984. overridenInstanceCount: number;
  23985. isFrozen: boolean;
  23986. previousBatch: Nullable<_InstancesBatch>;
  23987. hardwareInstancedRendering: boolean;
  23988. sideOrientation: number;
  23989. }
  23990. /**
  23991. * @hidden
  23992. **/
  23993. export class _InstancesBatch {
  23994. mustReturn: boolean;
  23995. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  23996. renderSelf: boolean[];
  23997. hardwareInstancedRendering: boolean[];
  23998. }
  23999. /**
  24000. * Class used to represent renderable models
  24001. */
  24002. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24003. /**
  24004. * Mesh side orientation : usually the external or front surface
  24005. */
  24006. static readonly FRONTSIDE: number;
  24007. /**
  24008. * Mesh side orientation : usually the internal or back surface
  24009. */
  24010. static readonly BACKSIDE: number;
  24011. /**
  24012. * Mesh side orientation : both internal and external or front and back surfaces
  24013. */
  24014. static readonly DOUBLESIDE: number;
  24015. /**
  24016. * Mesh side orientation : by default, `FRONTSIDE`
  24017. */
  24018. static readonly DEFAULTSIDE: number;
  24019. /**
  24020. * Mesh cap setting : no cap
  24021. */
  24022. static readonly NO_CAP: number;
  24023. /**
  24024. * Mesh cap setting : one cap at the beginning of the mesh
  24025. */
  24026. static readonly CAP_START: number;
  24027. /**
  24028. * Mesh cap setting : one cap at the end of the mesh
  24029. */
  24030. static readonly CAP_END: number;
  24031. /**
  24032. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24033. */
  24034. static readonly CAP_ALL: number;
  24035. /**
  24036. * Mesh pattern setting : no flip or rotate
  24037. */
  24038. static readonly NO_FLIP: number;
  24039. /**
  24040. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24041. */
  24042. static readonly FLIP_TILE: number;
  24043. /**
  24044. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24045. */
  24046. static readonly ROTATE_TILE: number;
  24047. /**
  24048. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24049. */
  24050. static readonly FLIP_ROW: number;
  24051. /**
  24052. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24053. */
  24054. static readonly ROTATE_ROW: number;
  24055. /**
  24056. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24057. */
  24058. static readonly FLIP_N_ROTATE_TILE: number;
  24059. /**
  24060. * Mesh pattern setting : rotate pattern and rotate
  24061. */
  24062. static readonly FLIP_N_ROTATE_ROW: number;
  24063. /**
  24064. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24065. */
  24066. static readonly CENTER: number;
  24067. /**
  24068. * Mesh tile positioning : part tiles on left
  24069. */
  24070. static readonly LEFT: number;
  24071. /**
  24072. * Mesh tile positioning : part tiles on right
  24073. */
  24074. static readonly RIGHT: number;
  24075. /**
  24076. * Mesh tile positioning : part tiles on top
  24077. */
  24078. static readonly TOP: number;
  24079. /**
  24080. * Mesh tile positioning : part tiles on bottom
  24081. */
  24082. static readonly BOTTOM: number;
  24083. /**
  24084. * Gets the default side orientation.
  24085. * @param orientation the orientation to value to attempt to get
  24086. * @returns the default orientation
  24087. * @hidden
  24088. */
  24089. static _GetDefaultSideOrientation(orientation?: number): number;
  24090. private _internalMeshDataInfo;
  24091. /**
  24092. * An event triggered before rendering the mesh
  24093. */
  24094. readonly onBeforeRenderObservable: Observable<Mesh>;
  24095. /**
  24096. * An event triggered before binding the mesh
  24097. */
  24098. readonly onBeforeBindObservable: Observable<Mesh>;
  24099. /**
  24100. * An event triggered after rendering the mesh
  24101. */
  24102. readonly onAfterRenderObservable: Observable<Mesh>;
  24103. /**
  24104. * An event triggered before drawing the mesh
  24105. */
  24106. readonly onBeforeDrawObservable: Observable<Mesh>;
  24107. private _onBeforeDrawObserver;
  24108. /**
  24109. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24110. */
  24111. onBeforeDraw: () => void;
  24112. readonly hasInstances: boolean;
  24113. /**
  24114. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24115. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24116. */
  24117. delayLoadState: number;
  24118. /**
  24119. * Gets the list of instances created from this mesh
  24120. * it is not supposed to be modified manually.
  24121. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24122. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24123. */
  24124. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24125. /**
  24126. * Gets the file containing delay loading data for this mesh
  24127. */
  24128. delayLoadingFile: string;
  24129. /** @hidden */
  24130. _binaryInfo: any;
  24131. /**
  24132. * User defined function used to change how LOD level selection is done
  24133. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24134. */
  24135. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24136. /**
  24137. * Gets or sets the morph target manager
  24138. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24139. */
  24140. morphTargetManager: Nullable<MorphTargetManager>;
  24141. /** @hidden */
  24142. _creationDataStorage: Nullable<_CreationDataStorage>;
  24143. /** @hidden */
  24144. _geometry: Nullable<Geometry>;
  24145. /** @hidden */
  24146. _delayInfo: Array<string>;
  24147. /** @hidden */
  24148. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24149. /** @hidden */
  24150. _instanceDataStorage: _InstanceDataStorage;
  24151. private _effectiveMaterial;
  24152. /** @hidden */
  24153. _shouldGenerateFlatShading: boolean;
  24154. /** @hidden */
  24155. _originalBuilderSideOrientation: number;
  24156. /**
  24157. * Use this property to change the original side orientation defined at construction time
  24158. */
  24159. overrideMaterialSideOrientation: Nullable<number>;
  24160. /**
  24161. * Gets the source mesh (the one used to clone this one from)
  24162. */
  24163. readonly source: Nullable<Mesh>;
  24164. /**
  24165. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24166. */
  24167. isUnIndexed: boolean;
  24168. /**
  24169. * @constructor
  24170. * @param name The value used by scene.getMeshByName() to do a lookup.
  24171. * @param scene The scene to add this mesh to.
  24172. * @param parent The parent of this mesh, if it has one
  24173. * @param source An optional Mesh from which geometry is shared, cloned.
  24174. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24175. * When false, achieved by calling a clone(), also passing False.
  24176. * This will make creation of children, recursive.
  24177. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24178. */
  24179. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24180. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24181. /**
  24182. * Gets the class name
  24183. * @returns the string "Mesh".
  24184. */
  24185. getClassName(): string;
  24186. /** @hidden */
  24187. readonly _isMesh: boolean;
  24188. /**
  24189. * Returns a description of this mesh
  24190. * @param fullDetails define if full details about this mesh must be used
  24191. * @returns a descriptive string representing this mesh
  24192. */
  24193. toString(fullDetails?: boolean): string;
  24194. /** @hidden */
  24195. _unBindEffect(): void;
  24196. /**
  24197. * Gets a boolean indicating if this mesh has LOD
  24198. */
  24199. readonly hasLODLevels: boolean;
  24200. /**
  24201. * Gets the list of MeshLODLevel associated with the current mesh
  24202. * @returns an array of MeshLODLevel
  24203. */
  24204. getLODLevels(): MeshLODLevel[];
  24205. private _sortLODLevels;
  24206. /**
  24207. * Add a mesh as LOD level triggered at the given distance.
  24208. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24209. * @param distance The distance from the center of the object to show this level
  24210. * @param mesh The mesh to be added as LOD level (can be null)
  24211. * @return This mesh (for chaining)
  24212. */
  24213. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24214. /**
  24215. * Returns the LOD level mesh at the passed distance or null if not found.
  24216. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24217. * @param distance The distance from the center of the object to show this level
  24218. * @returns a Mesh or `null`
  24219. */
  24220. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24221. /**
  24222. * Remove a mesh from the LOD array
  24223. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24224. * @param mesh defines the mesh to be removed
  24225. * @return This mesh (for chaining)
  24226. */
  24227. removeLODLevel(mesh: Mesh): Mesh;
  24228. /**
  24229. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24230. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24231. * @param camera defines the camera to use to compute distance
  24232. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24233. * @return This mesh (for chaining)
  24234. */
  24235. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24236. /**
  24237. * Gets the mesh internal Geometry object
  24238. */
  24239. readonly geometry: Nullable<Geometry>;
  24240. /**
  24241. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24242. * @returns the total number of vertices
  24243. */
  24244. getTotalVertices(): number;
  24245. /**
  24246. * Returns the content of an associated vertex buffer
  24247. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24248. * - VertexBuffer.PositionKind
  24249. * - VertexBuffer.UVKind
  24250. * - VertexBuffer.UV2Kind
  24251. * - VertexBuffer.UV3Kind
  24252. * - VertexBuffer.UV4Kind
  24253. * - VertexBuffer.UV5Kind
  24254. * - VertexBuffer.UV6Kind
  24255. * - VertexBuffer.ColorKind
  24256. * - VertexBuffer.MatricesIndicesKind
  24257. * - VertexBuffer.MatricesIndicesExtraKind
  24258. * - VertexBuffer.MatricesWeightsKind
  24259. * - VertexBuffer.MatricesWeightsExtraKind
  24260. * @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
  24261. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24262. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24263. */
  24264. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24265. /**
  24266. * Returns the mesh VertexBuffer object from the requested `kind`
  24267. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24268. * - VertexBuffer.PositionKind
  24269. * - VertexBuffer.NormalKind
  24270. * - VertexBuffer.UVKind
  24271. * - VertexBuffer.UV2Kind
  24272. * - VertexBuffer.UV3Kind
  24273. * - VertexBuffer.UV4Kind
  24274. * - VertexBuffer.UV5Kind
  24275. * - VertexBuffer.UV6Kind
  24276. * - VertexBuffer.ColorKind
  24277. * - VertexBuffer.MatricesIndicesKind
  24278. * - VertexBuffer.MatricesIndicesExtraKind
  24279. * - VertexBuffer.MatricesWeightsKind
  24280. * - VertexBuffer.MatricesWeightsExtraKind
  24281. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24282. */
  24283. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24284. /**
  24285. * Tests if a specific vertex buffer is associated with this mesh
  24286. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24287. * - VertexBuffer.PositionKind
  24288. * - VertexBuffer.NormalKind
  24289. * - VertexBuffer.UVKind
  24290. * - VertexBuffer.UV2Kind
  24291. * - VertexBuffer.UV3Kind
  24292. * - VertexBuffer.UV4Kind
  24293. * - VertexBuffer.UV5Kind
  24294. * - VertexBuffer.UV6Kind
  24295. * - VertexBuffer.ColorKind
  24296. * - VertexBuffer.MatricesIndicesKind
  24297. * - VertexBuffer.MatricesIndicesExtraKind
  24298. * - VertexBuffer.MatricesWeightsKind
  24299. * - VertexBuffer.MatricesWeightsExtraKind
  24300. * @returns a boolean
  24301. */
  24302. isVerticesDataPresent(kind: string): boolean;
  24303. /**
  24304. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24305. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24306. * - VertexBuffer.PositionKind
  24307. * - VertexBuffer.UVKind
  24308. * - VertexBuffer.UV2Kind
  24309. * - VertexBuffer.UV3Kind
  24310. * - VertexBuffer.UV4Kind
  24311. * - VertexBuffer.UV5Kind
  24312. * - VertexBuffer.UV6Kind
  24313. * - VertexBuffer.ColorKind
  24314. * - VertexBuffer.MatricesIndicesKind
  24315. * - VertexBuffer.MatricesIndicesExtraKind
  24316. * - VertexBuffer.MatricesWeightsKind
  24317. * - VertexBuffer.MatricesWeightsExtraKind
  24318. * @returns a boolean
  24319. */
  24320. isVertexBufferUpdatable(kind: string): boolean;
  24321. /**
  24322. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24323. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24324. * - VertexBuffer.PositionKind
  24325. * - VertexBuffer.NormalKind
  24326. * - VertexBuffer.UVKind
  24327. * - VertexBuffer.UV2Kind
  24328. * - VertexBuffer.UV3Kind
  24329. * - VertexBuffer.UV4Kind
  24330. * - VertexBuffer.UV5Kind
  24331. * - VertexBuffer.UV6Kind
  24332. * - VertexBuffer.ColorKind
  24333. * - VertexBuffer.MatricesIndicesKind
  24334. * - VertexBuffer.MatricesIndicesExtraKind
  24335. * - VertexBuffer.MatricesWeightsKind
  24336. * - VertexBuffer.MatricesWeightsExtraKind
  24337. * @returns an array of strings
  24338. */
  24339. getVerticesDataKinds(): string[];
  24340. /**
  24341. * Returns a positive integer : the total number of indices in this mesh geometry.
  24342. * @returns the numner of indices or zero if the mesh has no geometry.
  24343. */
  24344. getTotalIndices(): number;
  24345. /**
  24346. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24347. * @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.
  24348. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24349. * @returns the indices array or an empty array if the mesh has no geometry
  24350. */
  24351. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24352. readonly isBlocked: boolean;
  24353. /**
  24354. * Determine if the current mesh is ready to be rendered
  24355. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24356. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24357. * @returns true if all associated assets are ready (material, textures, shaders)
  24358. */
  24359. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24360. /**
  24361. * 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.
  24362. */
  24363. readonly areNormalsFrozen: boolean;
  24364. /**
  24365. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  24366. * @returns the current mesh
  24367. */
  24368. freezeNormals(): Mesh;
  24369. /**
  24370. * 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
  24371. * @returns the current mesh
  24372. */
  24373. unfreezeNormals(): Mesh;
  24374. /**
  24375. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24376. */
  24377. overridenInstanceCount: number;
  24378. /** @hidden */
  24379. _preActivate(): Mesh;
  24380. /** @hidden */
  24381. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24382. /** @hidden */
  24383. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24384. /**
  24385. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24386. * This means the mesh underlying bounding box and sphere are recomputed.
  24387. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24388. * @returns the current mesh
  24389. */
  24390. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24391. /** @hidden */
  24392. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24393. /**
  24394. * This function will subdivide the mesh into multiple submeshes
  24395. * @param count defines the expected number of submeshes
  24396. */
  24397. subdivide(count: number): void;
  24398. /**
  24399. * Copy a FloatArray into a specific associated vertex buffer
  24400. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24401. * - VertexBuffer.PositionKind
  24402. * - VertexBuffer.UVKind
  24403. * - VertexBuffer.UV2Kind
  24404. * - VertexBuffer.UV3Kind
  24405. * - VertexBuffer.UV4Kind
  24406. * - VertexBuffer.UV5Kind
  24407. * - VertexBuffer.UV6Kind
  24408. * - VertexBuffer.ColorKind
  24409. * - VertexBuffer.MatricesIndicesKind
  24410. * - VertexBuffer.MatricesIndicesExtraKind
  24411. * - VertexBuffer.MatricesWeightsKind
  24412. * - VertexBuffer.MatricesWeightsExtraKind
  24413. * @param data defines the data source
  24414. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24415. * @param stride defines the data stride size (can be null)
  24416. * @returns the current mesh
  24417. */
  24418. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24419. /**
  24420. * Flags an associated vertex buffer as updatable
  24421. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24422. * - VertexBuffer.PositionKind
  24423. * - VertexBuffer.UVKind
  24424. * - VertexBuffer.UV2Kind
  24425. * - VertexBuffer.UV3Kind
  24426. * - VertexBuffer.UV4Kind
  24427. * - VertexBuffer.UV5Kind
  24428. * - VertexBuffer.UV6Kind
  24429. * - VertexBuffer.ColorKind
  24430. * - VertexBuffer.MatricesIndicesKind
  24431. * - VertexBuffer.MatricesIndicesExtraKind
  24432. * - VertexBuffer.MatricesWeightsKind
  24433. * - VertexBuffer.MatricesWeightsExtraKind
  24434. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24435. */
  24436. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24437. /**
  24438. * Sets the mesh global Vertex Buffer
  24439. * @param buffer defines the buffer to use
  24440. * @returns the current mesh
  24441. */
  24442. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24443. /**
  24444. * Update a specific associated vertex buffer
  24445. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24446. * - VertexBuffer.PositionKind
  24447. * - VertexBuffer.UVKind
  24448. * - VertexBuffer.UV2Kind
  24449. * - VertexBuffer.UV3Kind
  24450. * - VertexBuffer.UV4Kind
  24451. * - VertexBuffer.UV5Kind
  24452. * - VertexBuffer.UV6Kind
  24453. * - VertexBuffer.ColorKind
  24454. * - VertexBuffer.MatricesIndicesKind
  24455. * - VertexBuffer.MatricesIndicesExtraKind
  24456. * - VertexBuffer.MatricesWeightsKind
  24457. * - VertexBuffer.MatricesWeightsExtraKind
  24458. * @param data defines the data source
  24459. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24460. * @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)
  24461. * @returns the current mesh
  24462. */
  24463. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24464. /**
  24465. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24466. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24467. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24468. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24469. * @returns the current mesh
  24470. */
  24471. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24472. /**
  24473. * Creates a un-shared specific occurence of the geometry for the mesh.
  24474. * @returns the current mesh
  24475. */
  24476. makeGeometryUnique(): Mesh;
  24477. /**
  24478. * Set the index buffer of this mesh
  24479. * @param indices defines the source data
  24480. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24481. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24482. * @returns the current mesh
  24483. */
  24484. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24485. /**
  24486. * Update the current index buffer
  24487. * @param indices defines the source data
  24488. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24489. * @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)
  24490. * @returns the current mesh
  24491. */
  24492. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24493. /**
  24494. * Invert the geometry to move from a right handed system to a left handed one.
  24495. * @returns the current mesh
  24496. */
  24497. toLeftHanded(): Mesh;
  24498. /** @hidden */
  24499. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24500. /** @hidden */
  24501. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24502. /**
  24503. * Registers for this mesh a javascript function called just before the rendering process
  24504. * @param func defines the function to call before rendering this mesh
  24505. * @returns the current mesh
  24506. */
  24507. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24508. /**
  24509. * Disposes a previously registered javascript function called before the rendering
  24510. * @param func defines the function to remove
  24511. * @returns the current mesh
  24512. */
  24513. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24514. /**
  24515. * Registers for this mesh a javascript function called just after the rendering is complete
  24516. * @param func defines the function to call after rendering this mesh
  24517. * @returns the current mesh
  24518. */
  24519. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24520. /**
  24521. * Disposes a previously registered javascript function called after the rendering.
  24522. * @param func defines the function to remove
  24523. * @returns the current mesh
  24524. */
  24525. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24526. /** @hidden */
  24527. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24528. /** @hidden */
  24529. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24530. /** @hidden */
  24531. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24532. /** @hidden */
  24533. _rebuild(): void;
  24534. /** @hidden */
  24535. _freeze(): void;
  24536. /** @hidden */
  24537. _unFreeze(): void;
  24538. /**
  24539. * 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
  24540. * @param subMesh defines the subMesh to render
  24541. * @param enableAlphaMode defines if alpha mode can be changed
  24542. * @returns the current mesh
  24543. */
  24544. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24545. private _onBeforeDraw;
  24546. /**
  24547. * Renormalize the mesh and patch it up if there are no weights
  24548. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24549. * However in the case of zero weights then we set just a single influence to 1.
  24550. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24551. */
  24552. cleanMatrixWeights(): void;
  24553. private normalizeSkinFourWeights;
  24554. private normalizeSkinWeightsAndExtra;
  24555. /**
  24556. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24557. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24558. * the user know there was an issue with importing the mesh
  24559. * @returns a validation object with skinned, valid and report string
  24560. */
  24561. validateSkinning(): {
  24562. skinned: boolean;
  24563. valid: boolean;
  24564. report: string;
  24565. };
  24566. /** @hidden */
  24567. _checkDelayState(): Mesh;
  24568. private _queueLoad;
  24569. /**
  24570. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24571. * A mesh is in the frustum if its bounding box intersects the frustum
  24572. * @param frustumPlanes defines the frustum to test
  24573. * @returns true if the mesh is in the frustum planes
  24574. */
  24575. isInFrustum(frustumPlanes: Plane[]): boolean;
  24576. /**
  24577. * Sets the mesh material by the material or multiMaterial `id` property
  24578. * @param id is a string identifying the material or the multiMaterial
  24579. * @returns the current mesh
  24580. */
  24581. setMaterialByID(id: string): Mesh;
  24582. /**
  24583. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24584. * @returns an array of IAnimatable
  24585. */
  24586. getAnimatables(): IAnimatable[];
  24587. /**
  24588. * Modifies the mesh geometry according to the passed transformation matrix.
  24589. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24590. * The mesh normals are modified using the same transformation.
  24591. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24592. * @param transform defines the transform matrix to use
  24593. * @see http://doc.babylonjs.com/resources/baking_transformations
  24594. * @returns the current mesh
  24595. */
  24596. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24597. /**
  24598. * Modifies the mesh geometry according to its own current World Matrix.
  24599. * The mesh World Matrix is then reset.
  24600. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24601. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24602. * @see http://doc.babylonjs.com/resources/baking_transformations
  24603. * @returns the current mesh
  24604. */
  24605. bakeCurrentTransformIntoVertices(): Mesh;
  24606. /** @hidden */
  24607. readonly _positions: Nullable<Vector3[]>;
  24608. /** @hidden */
  24609. _resetPointsArrayCache(): Mesh;
  24610. /** @hidden */
  24611. _generatePointsArray(): boolean;
  24612. /**
  24613. * Returns a new Mesh object generated from the current mesh properties.
  24614. * This method must not get confused with createInstance()
  24615. * @param name is a string, the name given to the new mesh
  24616. * @param newParent can be any Node object (default `null`)
  24617. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24618. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24619. * @returns a new mesh
  24620. */
  24621. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24622. /**
  24623. * Releases resources associated with this mesh.
  24624. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24625. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24626. */
  24627. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24628. /**
  24629. * Modifies the mesh geometry according to a displacement map.
  24630. * 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.
  24631. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24632. * @param url is a string, the URL from the image file is to be downloaded.
  24633. * @param minHeight is the lower limit of the displacement.
  24634. * @param maxHeight is the upper limit of the displacement.
  24635. * @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.
  24636. * @param uvOffset is an optional vector2 used to offset UV.
  24637. * @param uvScale is an optional vector2 used to scale UV.
  24638. * @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.
  24639. * @returns the Mesh.
  24640. */
  24641. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24642. /**
  24643. * Modifies the mesh geometry according to a displacementMap buffer.
  24644. * 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.
  24645. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24646. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24647. * @param heightMapWidth is the width of the buffer image.
  24648. * @param heightMapHeight is the height of the buffer image.
  24649. * @param minHeight is the lower limit of the displacement.
  24650. * @param maxHeight is the upper limit of the displacement.
  24651. * @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.
  24652. * @param uvOffset is an optional vector2 used to offset UV.
  24653. * @param uvScale is an optional vector2 used to scale UV.
  24654. * @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.
  24655. * @returns the Mesh.
  24656. */
  24657. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24658. /**
  24659. * Modify the mesh to get a flat shading rendering.
  24660. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24661. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24662. * @returns current mesh
  24663. */
  24664. convertToFlatShadedMesh(): Mesh;
  24665. /**
  24666. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24667. * In other words, more vertices, no more indices and a single bigger VBO.
  24668. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24669. * @returns current mesh
  24670. */
  24671. convertToUnIndexedMesh(): Mesh;
  24672. /**
  24673. * Inverses facet orientations.
  24674. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24675. * @param flipNormals will also inverts the normals
  24676. * @returns current mesh
  24677. */
  24678. flipFaces(flipNormals?: boolean): Mesh;
  24679. /**
  24680. * Increase the number of facets and hence vertices in a mesh
  24681. * Vertex normals are interpolated from existing vertex normals
  24682. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24683. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24684. */
  24685. increaseVertices(numberPerEdge: number): void;
  24686. /**
  24687. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24688. * This will undo any application of covertToFlatShadedMesh
  24689. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24690. */
  24691. forceSharedVertices(): void;
  24692. /** @hidden */
  24693. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24694. /** @hidden */
  24695. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24696. /**
  24697. * Creates a new InstancedMesh object from the mesh model.
  24698. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24699. * @param name defines the name of the new instance
  24700. * @returns a new InstancedMesh
  24701. */
  24702. createInstance(name: string): InstancedMesh;
  24703. /**
  24704. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24705. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24706. * @returns the current mesh
  24707. */
  24708. synchronizeInstances(): Mesh;
  24709. /**
  24710. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24711. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24712. * This should be used together with the simplification to avoid disappearing triangles.
  24713. * @param successCallback an optional success callback to be called after the optimization finished.
  24714. * @returns the current mesh
  24715. */
  24716. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24717. /**
  24718. * Serialize current mesh
  24719. * @param serializationObject defines the object which will receive the serialization data
  24720. */
  24721. serialize(serializationObject: any): void;
  24722. /** @hidden */
  24723. _syncGeometryWithMorphTargetManager(): void;
  24724. /** @hidden */
  24725. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24726. /**
  24727. * Returns a new Mesh object parsed from the source provided.
  24728. * @param parsedMesh is the source
  24729. * @param scene defines the hosting scene
  24730. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24731. * @returns a new Mesh
  24732. */
  24733. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24734. /**
  24735. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24736. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24737. * @param name defines the name of the mesh to create
  24738. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24739. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24740. * @param closePath creates a seam between the first and the last points of each path of the path array
  24741. * @param offset is taken in account only if the `pathArray` is containing a single path
  24742. * @param scene defines the hosting scene
  24743. * @param updatable defines if the mesh must be flagged as updatable
  24744. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24745. * @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)
  24746. * @returns a new Mesh
  24747. */
  24748. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24749. /**
  24750. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24751. * @param name defines the name of the mesh to create
  24752. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24753. * @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
  24754. * @param scene defines the hosting scene
  24755. * @param updatable defines if the mesh must be flagged as updatable
  24756. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24757. * @returns a new Mesh
  24758. */
  24759. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24760. /**
  24761. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24762. * @param name defines the name of the mesh to create
  24763. * @param size sets the size (float) of each box side (default 1)
  24764. * @param scene defines the hosting scene
  24765. * @param updatable defines if the mesh must be flagged as updatable
  24766. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24767. * @returns a new Mesh
  24768. */
  24769. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24770. /**
  24771. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24772. * @param name defines the name of the mesh to create
  24773. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24774. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24775. * @param scene defines the hosting scene
  24776. * @param updatable defines if the mesh must be flagged as updatable
  24777. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24778. * @returns a new Mesh
  24779. */
  24780. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24781. /**
  24782. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24783. * @param name defines the name of the mesh to create
  24784. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24785. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24786. * @param scene defines the hosting scene
  24787. * @returns a new Mesh
  24788. */
  24789. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24790. /**
  24791. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24792. * @param name defines the name of the mesh to create
  24793. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24794. * @param diameterTop set the top cap diameter (floats, default 1)
  24795. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24796. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24797. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24798. * @param scene defines the hosting scene
  24799. * @param updatable defines if the mesh must be flagged as updatable
  24800. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24801. * @returns a new Mesh
  24802. */
  24803. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24804. /**
  24805. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24806. * @param name defines the name of the mesh to create
  24807. * @param diameter sets the diameter size (float) of the torus (default 1)
  24808. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24809. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24810. * @param scene defines the hosting scene
  24811. * @param updatable defines if the mesh must be flagged as updatable
  24812. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24813. * @returns a new Mesh
  24814. */
  24815. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24816. /**
  24817. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24818. * @param name defines the name of the mesh to create
  24819. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24820. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24821. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24822. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24823. * @param p the number of windings on X axis (positive integers, default 2)
  24824. * @param q the number of windings on Y axis (positive integers, default 3)
  24825. * @param scene defines the hosting scene
  24826. * @param updatable defines if the mesh must be flagged as updatable
  24827. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24828. * @returns a new Mesh
  24829. */
  24830. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24831. /**
  24832. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24833. * @param name defines the name of the mesh to create
  24834. * @param points is an array successive Vector3
  24835. * @param scene defines the hosting scene
  24836. * @param updatable defines if the mesh must be flagged as updatable
  24837. * @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).
  24838. * @returns a new Mesh
  24839. */
  24840. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24841. /**
  24842. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24843. * @param name defines the name of the mesh to create
  24844. * @param points is an array successive Vector3
  24845. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24846. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24847. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24848. * @param scene defines the hosting scene
  24849. * @param updatable defines if the mesh must be flagged as updatable
  24850. * @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)
  24851. * @returns a new Mesh
  24852. */
  24853. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24854. /**
  24855. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24856. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24857. * 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.
  24858. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24859. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24860. * Remember you can only change the shape positions, not their number when updating a polygon.
  24861. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24862. * @param name defines the name of the mesh to create
  24863. * @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
  24864. * @param scene defines the hosting scene
  24865. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24866. * @param updatable defines if the mesh must be flagged as updatable
  24867. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24868. * @param earcutInjection can be used to inject your own earcut reference
  24869. * @returns a new Mesh
  24870. */
  24871. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24872. /**
  24873. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24874. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24875. * @param name defines the name of the mesh to create
  24876. * @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
  24877. * @param depth defines the height of extrusion
  24878. * @param scene defines the hosting scene
  24879. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24880. * @param updatable defines if the mesh must be flagged as updatable
  24881. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24882. * @param earcutInjection can be used to inject your own earcut reference
  24883. * @returns a new Mesh
  24884. */
  24885. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24886. /**
  24887. * Creates an extruded shape mesh.
  24888. * 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
  24889. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24890. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24891. * @param name defines the name of the mesh to create
  24892. * @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
  24893. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24894. * @param scale is the value to scale the shape
  24895. * @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
  24896. * @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
  24897. * @param scene defines the hosting scene
  24898. * @param updatable defines if the mesh must be flagged as updatable
  24899. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24900. * @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)
  24901. * @returns a new Mesh
  24902. */
  24903. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24904. /**
  24905. * Creates an custom extruded shape mesh.
  24906. * The custom extrusion is a parametric shape.
  24907. * It has no predefined shape. Its final shape will depend on the input parameters.
  24908. * Please consider using the same method from the MeshBuilder class instead
  24909. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24910. * @param name defines the name of the mesh to create
  24911. * @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
  24912. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24913. * @param scaleFunction is a custom Javascript function called on each path point
  24914. * @param rotationFunction is a custom Javascript function called on each path point
  24915. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24916. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24917. * @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
  24918. * @param scene defines the hosting scene
  24919. * @param updatable defines if the mesh must be flagged as updatable
  24920. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24921. * @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)
  24922. * @returns a new Mesh
  24923. */
  24924. 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;
  24925. /**
  24926. * Creates lathe mesh.
  24927. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24928. * Please consider using the same method from the MeshBuilder class instead
  24929. * @param name defines the name of the mesh to create
  24930. * @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
  24931. * @param radius is the radius value of the lathe
  24932. * @param tessellation is the side number of the lathe.
  24933. * @param scene defines the hosting scene
  24934. * @param updatable defines if the mesh must be flagged as updatable
  24935. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24936. * @returns a new Mesh
  24937. */
  24938. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24939. /**
  24940. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24941. * @param name defines the name of the mesh to create
  24942. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24943. * @param scene defines the hosting scene
  24944. * @param updatable defines if the mesh must be flagged as updatable
  24945. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24946. * @returns a new Mesh
  24947. */
  24948. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24949. /**
  24950. * Creates a ground mesh.
  24951. * Please consider using the same method from the MeshBuilder class instead
  24952. * @param name defines the name of the mesh to create
  24953. * @param width set the width of the ground
  24954. * @param height set the height of the ground
  24955. * @param subdivisions sets the number of subdivisions per side
  24956. * @param scene defines the hosting scene
  24957. * @param updatable defines if the mesh must be flagged as updatable
  24958. * @returns a new Mesh
  24959. */
  24960. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24961. /**
  24962. * Creates a tiled ground mesh.
  24963. * Please consider using the same method from the MeshBuilder class instead
  24964. * @param name defines the name of the mesh to create
  24965. * @param xmin set the ground minimum X coordinate
  24966. * @param zmin set the ground minimum Y coordinate
  24967. * @param xmax set the ground maximum X coordinate
  24968. * @param zmax set the ground maximum Z coordinate
  24969. * @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
  24970. * @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
  24971. * @param scene defines the hosting scene
  24972. * @param updatable defines if the mesh must be flagged as updatable
  24973. * @returns a new Mesh
  24974. */
  24975. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24976. w: number;
  24977. h: number;
  24978. }, precision: {
  24979. w: number;
  24980. h: number;
  24981. }, scene: Scene, updatable?: boolean): Mesh;
  24982. /**
  24983. * Creates a ground mesh from a height map.
  24984. * Please consider using the same method from the MeshBuilder class instead
  24985. * @see http://doc.babylonjs.com/babylon101/height_map
  24986. * @param name defines the name of the mesh to create
  24987. * @param url sets the URL of the height map image resource
  24988. * @param width set the ground width size
  24989. * @param height set the ground height size
  24990. * @param subdivisions sets the number of subdivision per side
  24991. * @param minHeight is the minimum altitude on the ground
  24992. * @param maxHeight is the maximum altitude on the ground
  24993. * @param scene defines the hosting scene
  24994. * @param updatable defines if the mesh must be flagged as updatable
  24995. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24996. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24997. * @returns a new Mesh
  24998. */
  24999. 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;
  25000. /**
  25001. * Creates a tube mesh.
  25002. * The tube is a parametric shape.
  25003. * It has no predefined shape. Its final shape will depend on the input parameters.
  25004. * Please consider using the same method from the MeshBuilder class instead
  25005. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25006. * @param name defines the name of the mesh to create
  25007. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25008. * @param radius sets the tube radius size
  25009. * @param tessellation is the number of sides on the tubular surface
  25010. * @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
  25011. * @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
  25012. * @param scene defines the hosting scene
  25013. * @param updatable defines if the mesh must be flagged as updatable
  25014. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25015. * @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)
  25016. * @returns a new Mesh
  25017. */
  25018. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25019. (i: number, distance: number): number;
  25020. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25021. /**
  25022. * Creates a polyhedron mesh.
  25023. * Please consider using the same method from the MeshBuilder class instead.
  25024. * * 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
  25025. * * The parameter `size` (positive float, default 1) sets the polygon size
  25026. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25027. * * 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`
  25028. * * 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
  25029. * * 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)`)
  25030. * * 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
  25031. * * 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
  25032. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25033. * * If you create a double-sided mesh, you can choose what parts of 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
  25034. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25035. * @param name defines the name of the mesh to create
  25036. * @param options defines the options used to create the mesh
  25037. * @param scene defines the hosting scene
  25038. * @returns a new Mesh
  25039. */
  25040. static CreatePolyhedron(name: string, options: {
  25041. type?: number;
  25042. size?: number;
  25043. sizeX?: number;
  25044. sizeY?: number;
  25045. sizeZ?: number;
  25046. custom?: any;
  25047. faceUV?: Vector4[];
  25048. faceColors?: Color4[];
  25049. updatable?: boolean;
  25050. sideOrientation?: number;
  25051. }, scene: Scene): Mesh;
  25052. /**
  25053. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25054. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25055. * * 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`)
  25056. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25057. * * 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
  25058. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25059. * * If you create a double-sided mesh, you can choose what parts of 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
  25060. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25061. * @param name defines the name of the mesh
  25062. * @param options defines the options used to create the mesh
  25063. * @param scene defines the hosting scene
  25064. * @returns a new Mesh
  25065. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25066. */
  25067. static CreateIcoSphere(name: string, options: {
  25068. radius?: number;
  25069. flat?: boolean;
  25070. subdivisions?: number;
  25071. sideOrientation?: number;
  25072. updatable?: boolean;
  25073. }, scene: Scene): Mesh;
  25074. /**
  25075. * Creates a decal mesh.
  25076. * Please consider using the same method from the MeshBuilder class instead.
  25077. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25078. * @param name defines the name of the mesh
  25079. * @param sourceMesh defines the mesh receiving the decal
  25080. * @param position sets the position of the decal in world coordinates
  25081. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25082. * @param size sets the decal scaling
  25083. * @param angle sets the angle to rotate the decal
  25084. * @returns a new Mesh
  25085. */
  25086. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25087. /**
  25088. * Prepare internal position array for software CPU skinning
  25089. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25090. */
  25091. setPositionsForCPUSkinning(): Float32Array;
  25092. /**
  25093. * Prepare internal normal array for software CPU skinning
  25094. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25095. */
  25096. setNormalsForCPUSkinning(): Float32Array;
  25097. /**
  25098. * Updates the vertex buffer by applying transformation from the bones
  25099. * @param skeleton defines the skeleton to apply to current mesh
  25100. * @returns the current mesh
  25101. */
  25102. applySkeleton(skeleton: Skeleton): Mesh;
  25103. /**
  25104. * 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
  25105. * @param meshes defines the list of meshes to scan
  25106. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25107. */
  25108. static MinMax(meshes: AbstractMesh[]): {
  25109. min: Vector3;
  25110. max: Vector3;
  25111. };
  25112. /**
  25113. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25114. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25115. * @returns a vector3
  25116. */
  25117. static Center(meshesOrMinMaxVector: {
  25118. min: Vector3;
  25119. max: Vector3;
  25120. } | AbstractMesh[]): Vector3;
  25121. /**
  25122. * Merge the array of meshes into a single mesh for performance reasons.
  25123. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25124. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25125. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25126. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25127. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25128. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25129. * @returns a new mesh
  25130. */
  25131. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25132. /** @hidden */
  25133. addInstance(instance: InstancedMesh): void;
  25134. /** @hidden */
  25135. removeInstance(instance: InstancedMesh): void;
  25136. }
  25137. }
  25138. declare module "babylonjs/Cameras/camera" {
  25139. import { SmartArray } from "babylonjs/Misc/smartArray";
  25140. import { Observable } from "babylonjs/Misc/observable";
  25141. import { Nullable } from "babylonjs/types";
  25142. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25143. import { Scene } from "babylonjs/scene";
  25144. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25145. import { Node } from "babylonjs/node";
  25146. import { Mesh } from "babylonjs/Meshes/mesh";
  25147. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25148. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25149. import { Viewport } from "babylonjs/Maths/math.viewport";
  25150. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25151. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25152. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25153. import { Ray } from "babylonjs/Culling/ray";
  25154. /**
  25155. * This is the base class of all the camera used in the application.
  25156. * @see http://doc.babylonjs.com/features/cameras
  25157. */
  25158. export class Camera extends Node {
  25159. /** @hidden */
  25160. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25161. /**
  25162. * This is the default projection mode used by the cameras.
  25163. * It helps recreating a feeling of perspective and better appreciate depth.
  25164. * This is the best way to simulate real life cameras.
  25165. */
  25166. static readonly PERSPECTIVE_CAMERA: number;
  25167. /**
  25168. * This helps creating camera with an orthographic mode.
  25169. * 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.
  25170. */
  25171. static readonly ORTHOGRAPHIC_CAMERA: number;
  25172. /**
  25173. * This is the default FOV mode for perspective cameras.
  25174. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25175. */
  25176. static readonly FOVMODE_VERTICAL_FIXED: number;
  25177. /**
  25178. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25179. */
  25180. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25181. /**
  25182. * This specifies ther is no need for a camera rig.
  25183. * Basically only one eye is rendered corresponding to the camera.
  25184. */
  25185. static readonly RIG_MODE_NONE: number;
  25186. /**
  25187. * Simulates a camera Rig with one blue eye and one red eye.
  25188. * This can be use with 3d blue and red glasses.
  25189. */
  25190. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25191. /**
  25192. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25193. */
  25194. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25195. /**
  25196. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25197. */
  25198. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25199. /**
  25200. * Defines that both eyes of the camera will be rendered over under each other.
  25201. */
  25202. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25203. /**
  25204. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25205. */
  25206. static readonly RIG_MODE_VR: number;
  25207. /**
  25208. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25209. */
  25210. static readonly RIG_MODE_WEBVR: number;
  25211. /**
  25212. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25213. */
  25214. static readonly RIG_MODE_CUSTOM: number;
  25215. /**
  25216. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25217. */
  25218. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25219. /**
  25220. * Define the input manager associated with the camera.
  25221. */
  25222. inputs: CameraInputsManager<Camera>;
  25223. /** @hidden */
  25224. _position: Vector3;
  25225. /**
  25226. * Define the current local position of the camera in the scene
  25227. */
  25228. position: Vector3;
  25229. /**
  25230. * The vector the camera should consider as up.
  25231. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25232. */
  25233. upVector: Vector3;
  25234. /**
  25235. * Define the current limit on the left side for an orthographic camera
  25236. * In scene unit
  25237. */
  25238. orthoLeft: Nullable<number>;
  25239. /**
  25240. * Define the current limit on the right side for an orthographic camera
  25241. * In scene unit
  25242. */
  25243. orthoRight: Nullable<number>;
  25244. /**
  25245. * Define the current limit on the bottom side for an orthographic camera
  25246. * In scene unit
  25247. */
  25248. orthoBottom: Nullable<number>;
  25249. /**
  25250. * Define the current limit on the top side for an orthographic camera
  25251. * In scene unit
  25252. */
  25253. orthoTop: Nullable<number>;
  25254. /**
  25255. * Field Of View is set in Radians. (default is 0.8)
  25256. */
  25257. fov: number;
  25258. /**
  25259. * Define the minimum distance the camera can see from.
  25260. * This is important to note that the depth buffer are not infinite and the closer it starts
  25261. * the more your scene might encounter depth fighting issue.
  25262. */
  25263. minZ: number;
  25264. /**
  25265. * Define the maximum distance the camera can see to.
  25266. * This is important to note that the depth buffer are not infinite and the further it end
  25267. * the more your scene might encounter depth fighting issue.
  25268. */
  25269. maxZ: number;
  25270. /**
  25271. * Define the default inertia of the camera.
  25272. * This helps giving a smooth feeling to the camera movement.
  25273. */
  25274. inertia: number;
  25275. /**
  25276. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25277. */
  25278. mode: number;
  25279. /**
  25280. * Define wether the camera is intermediate.
  25281. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25282. */
  25283. isIntermediate: boolean;
  25284. /**
  25285. * Define the viewport of the camera.
  25286. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25287. */
  25288. viewport: Viewport;
  25289. /**
  25290. * Restricts the camera to viewing objects with the same layerMask.
  25291. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25292. */
  25293. layerMask: number;
  25294. /**
  25295. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25296. */
  25297. fovMode: number;
  25298. /**
  25299. * Rig mode of the camera.
  25300. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25301. * This is normally controlled byt the camera themselves as internal use.
  25302. */
  25303. cameraRigMode: number;
  25304. /**
  25305. * Defines the distance between both "eyes" in case of a RIG
  25306. */
  25307. interaxialDistance: number;
  25308. /**
  25309. * Defines if stereoscopic rendering is done side by side or over under.
  25310. */
  25311. isStereoscopicSideBySide: boolean;
  25312. /**
  25313. * 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
  25314. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25315. * else in the scene. (Eg. security camera)
  25316. *
  25317. * 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)
  25318. */
  25319. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25320. /**
  25321. * When set, the camera will render to this render target instead of the default canvas
  25322. *
  25323. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25324. */
  25325. outputRenderTarget: Nullable<RenderTargetTexture>;
  25326. /**
  25327. * Observable triggered when the camera view matrix has changed.
  25328. */
  25329. onViewMatrixChangedObservable: Observable<Camera>;
  25330. /**
  25331. * Observable triggered when the camera Projection matrix has changed.
  25332. */
  25333. onProjectionMatrixChangedObservable: Observable<Camera>;
  25334. /**
  25335. * Observable triggered when the inputs have been processed.
  25336. */
  25337. onAfterCheckInputsObservable: Observable<Camera>;
  25338. /**
  25339. * Observable triggered when reset has been called and applied to the camera.
  25340. */
  25341. onRestoreStateObservable: Observable<Camera>;
  25342. /** @hidden */
  25343. _cameraRigParams: any;
  25344. /** @hidden */
  25345. _rigCameras: Camera[];
  25346. /** @hidden */
  25347. _rigPostProcess: Nullable<PostProcess>;
  25348. protected _webvrViewMatrix: Matrix;
  25349. /** @hidden */
  25350. _skipRendering: boolean;
  25351. /** @hidden */
  25352. _projectionMatrix: Matrix;
  25353. /** @hidden */
  25354. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25355. /** @hidden */
  25356. _activeMeshes: SmartArray<AbstractMesh>;
  25357. protected _globalPosition: Vector3;
  25358. /** @hidden */
  25359. _computedViewMatrix: Matrix;
  25360. private _doNotComputeProjectionMatrix;
  25361. private _transformMatrix;
  25362. private _frustumPlanes;
  25363. private _refreshFrustumPlanes;
  25364. private _storedFov;
  25365. private _stateStored;
  25366. /**
  25367. * Instantiates a new camera object.
  25368. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25369. * @see http://doc.babylonjs.com/features/cameras
  25370. * @param name Defines the name of the camera in the scene
  25371. * @param position Defines the position of the camera
  25372. * @param scene Defines the scene the camera belongs too
  25373. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25374. */
  25375. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25376. /**
  25377. * Store current camera state (fov, position, etc..)
  25378. * @returns the camera
  25379. */
  25380. storeState(): Camera;
  25381. /**
  25382. * Restores the camera state values if it has been stored. You must call storeState() first
  25383. */
  25384. protected _restoreStateValues(): boolean;
  25385. /**
  25386. * Restored camera state. You must call storeState() first.
  25387. * @returns true if restored and false otherwise
  25388. */
  25389. restoreState(): boolean;
  25390. /**
  25391. * Gets the class name of the camera.
  25392. * @returns the class name
  25393. */
  25394. getClassName(): string;
  25395. /** @hidden */
  25396. readonly _isCamera: boolean;
  25397. /**
  25398. * Gets a string representation of the camera useful for debug purpose.
  25399. * @param fullDetails Defines that a more verboe level of logging is required
  25400. * @returns the string representation
  25401. */
  25402. toString(fullDetails?: boolean): string;
  25403. /**
  25404. * Gets the current world space position of the camera.
  25405. */
  25406. readonly globalPosition: Vector3;
  25407. /**
  25408. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25409. * @returns the active meshe list
  25410. */
  25411. getActiveMeshes(): SmartArray<AbstractMesh>;
  25412. /**
  25413. * Check wether a mesh is part of the current active mesh list of the camera
  25414. * @param mesh Defines the mesh to check
  25415. * @returns true if active, false otherwise
  25416. */
  25417. isActiveMesh(mesh: Mesh): boolean;
  25418. /**
  25419. * Is this camera ready to be used/rendered
  25420. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25421. * @return true if the camera is ready
  25422. */
  25423. isReady(completeCheck?: boolean): boolean;
  25424. /** @hidden */
  25425. _initCache(): void;
  25426. /** @hidden */
  25427. _updateCache(ignoreParentClass?: boolean): void;
  25428. /** @hidden */
  25429. _isSynchronized(): boolean;
  25430. /** @hidden */
  25431. _isSynchronizedViewMatrix(): boolean;
  25432. /** @hidden */
  25433. _isSynchronizedProjectionMatrix(): boolean;
  25434. /**
  25435. * Attach the input controls to a specific dom element to get the input from.
  25436. * @param element Defines the element the controls should be listened from
  25437. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25438. */
  25439. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25440. /**
  25441. * Detach the current controls from the specified dom element.
  25442. * @param element Defines the element to stop listening the inputs from
  25443. */
  25444. detachControl(element: HTMLElement): void;
  25445. /**
  25446. * Update the camera state according to the different inputs gathered during the frame.
  25447. */
  25448. update(): void;
  25449. /** @hidden */
  25450. _checkInputs(): void;
  25451. /** @hidden */
  25452. readonly rigCameras: Camera[];
  25453. /**
  25454. * Gets the post process used by the rig cameras
  25455. */
  25456. readonly rigPostProcess: Nullable<PostProcess>;
  25457. /**
  25458. * Internal, gets the first post proces.
  25459. * @returns the first post process to be run on this camera.
  25460. */
  25461. _getFirstPostProcess(): Nullable<PostProcess>;
  25462. private _cascadePostProcessesToRigCams;
  25463. /**
  25464. * Attach a post process to the camera.
  25465. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25466. * @param postProcess The post process to attach to the camera
  25467. * @param insertAt The position of the post process in case several of them are in use in the scene
  25468. * @returns the position the post process has been inserted at
  25469. */
  25470. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25471. /**
  25472. * Detach a post process to the camera.
  25473. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25474. * @param postProcess The post process to detach from the camera
  25475. */
  25476. detachPostProcess(postProcess: PostProcess): void;
  25477. /**
  25478. * Gets the current world matrix of the camera
  25479. */
  25480. getWorldMatrix(): Matrix;
  25481. /** @hidden */
  25482. _getViewMatrix(): Matrix;
  25483. /**
  25484. * Gets the current view matrix of the camera.
  25485. * @param force forces the camera to recompute the matrix without looking at the cached state
  25486. * @returns the view matrix
  25487. */
  25488. getViewMatrix(force?: boolean): Matrix;
  25489. /**
  25490. * Freeze the projection matrix.
  25491. * It will prevent the cache check of the camera projection compute and can speed up perf
  25492. * if no parameter of the camera are meant to change
  25493. * @param projection Defines manually a projection if necessary
  25494. */
  25495. freezeProjectionMatrix(projection?: Matrix): void;
  25496. /**
  25497. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25498. */
  25499. unfreezeProjectionMatrix(): void;
  25500. /**
  25501. * Gets the current projection matrix of the camera.
  25502. * @param force forces the camera to recompute the matrix without looking at the cached state
  25503. * @returns the projection matrix
  25504. */
  25505. getProjectionMatrix(force?: boolean): Matrix;
  25506. /**
  25507. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25508. * @returns a Matrix
  25509. */
  25510. getTransformationMatrix(): Matrix;
  25511. private _updateFrustumPlanes;
  25512. /**
  25513. * Checks if a cullable object (mesh...) is in the camera frustum
  25514. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25515. * @param target The object to check
  25516. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25517. * @returns true if the object is in frustum otherwise false
  25518. */
  25519. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25520. /**
  25521. * Checks if a cullable object (mesh...) is in the camera frustum
  25522. * Unlike isInFrustum this cheks the full bounding box
  25523. * @param target The object to check
  25524. * @returns true if the object is in frustum otherwise false
  25525. */
  25526. isCompletelyInFrustum(target: ICullable): boolean;
  25527. /**
  25528. * Gets a ray in the forward direction from the camera.
  25529. * @param length Defines the length of the ray to create
  25530. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25531. * @param origin Defines the start point of the ray which defaults to the camera position
  25532. * @returns the forward ray
  25533. */
  25534. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25535. /**
  25536. * Releases resources associated with this node.
  25537. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25538. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25539. */
  25540. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25541. /** @hidden */
  25542. _isLeftCamera: boolean;
  25543. /**
  25544. * Gets the left camera of a rig setup in case of Rigged Camera
  25545. */
  25546. readonly isLeftCamera: boolean;
  25547. /** @hidden */
  25548. _isRightCamera: boolean;
  25549. /**
  25550. * Gets the right camera of a rig setup in case of Rigged Camera
  25551. */
  25552. readonly isRightCamera: boolean;
  25553. /**
  25554. * Gets the left camera of a rig setup in case of Rigged Camera
  25555. */
  25556. readonly leftCamera: Nullable<FreeCamera>;
  25557. /**
  25558. * Gets the right camera of a rig setup in case of Rigged Camera
  25559. */
  25560. readonly rightCamera: Nullable<FreeCamera>;
  25561. /**
  25562. * Gets the left camera target of a rig setup in case of Rigged Camera
  25563. * @returns the target position
  25564. */
  25565. getLeftTarget(): Nullable<Vector3>;
  25566. /**
  25567. * Gets the right camera target of a rig setup in case of Rigged Camera
  25568. * @returns the target position
  25569. */
  25570. getRightTarget(): Nullable<Vector3>;
  25571. /**
  25572. * @hidden
  25573. */
  25574. setCameraRigMode(mode: number, rigParams: any): void;
  25575. /** @hidden */
  25576. static _setStereoscopicRigMode(camera: Camera): void;
  25577. /** @hidden */
  25578. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25579. /** @hidden */
  25580. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25581. /** @hidden */
  25582. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25583. /** @hidden */
  25584. _getVRProjectionMatrix(): Matrix;
  25585. protected _updateCameraRotationMatrix(): void;
  25586. protected _updateWebVRCameraRotationMatrix(): void;
  25587. /**
  25588. * This function MUST be overwritten by the different WebVR cameras available.
  25589. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25590. * @hidden
  25591. */
  25592. _getWebVRProjectionMatrix(): Matrix;
  25593. /**
  25594. * This function MUST be overwritten by the different WebVR cameras available.
  25595. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25596. * @hidden
  25597. */
  25598. _getWebVRViewMatrix(): Matrix;
  25599. /** @hidden */
  25600. setCameraRigParameter(name: string, value: any): void;
  25601. /**
  25602. * needs to be overridden by children so sub has required properties to be copied
  25603. * @hidden
  25604. */
  25605. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25606. /**
  25607. * May need to be overridden by children
  25608. * @hidden
  25609. */
  25610. _updateRigCameras(): void;
  25611. /** @hidden */
  25612. _setupInputs(): void;
  25613. /**
  25614. * Serialiaze the camera setup to a json represention
  25615. * @returns the JSON representation
  25616. */
  25617. serialize(): any;
  25618. /**
  25619. * Clones the current camera.
  25620. * @param name The cloned camera name
  25621. * @returns the cloned camera
  25622. */
  25623. clone(name: string): Camera;
  25624. /**
  25625. * Gets the direction of the camera relative to a given local axis.
  25626. * @param localAxis Defines the reference axis to provide a relative direction.
  25627. * @return the direction
  25628. */
  25629. getDirection(localAxis: Vector3): Vector3;
  25630. /**
  25631. * Returns the current camera absolute rotation
  25632. */
  25633. readonly absoluteRotation: Quaternion;
  25634. /**
  25635. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25636. * @param localAxis Defines the reference axis to provide a relative direction.
  25637. * @param result Defines the vector to store the result in
  25638. */
  25639. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25640. /**
  25641. * Gets a camera constructor for a given camera type
  25642. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25643. * @param name The name of the camera the result will be able to instantiate
  25644. * @param scene The scene the result will construct the camera in
  25645. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25646. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25647. * @returns a factory method to construc the camera
  25648. */
  25649. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25650. /**
  25651. * Compute the world matrix of the camera.
  25652. * @returns the camera workd matrix
  25653. */
  25654. computeWorldMatrix(): Matrix;
  25655. /**
  25656. * Parse a JSON and creates the camera from the parsed information
  25657. * @param parsedCamera The JSON to parse
  25658. * @param scene The scene to instantiate the camera in
  25659. * @returns the newly constructed camera
  25660. */
  25661. static Parse(parsedCamera: any, scene: Scene): Camera;
  25662. }
  25663. }
  25664. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25665. import { Nullable } from "babylonjs/types";
  25666. import { Scene } from "babylonjs/scene";
  25667. import { Vector4 } from "babylonjs/Maths/math.vector";
  25668. import { Mesh } from "babylonjs/Meshes/mesh";
  25669. /**
  25670. * Class containing static functions to help procedurally build meshes
  25671. */
  25672. export class DiscBuilder {
  25673. /**
  25674. * Creates a plane polygonal mesh. By default, this is a disc
  25675. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25676. * * 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
  25677. * * 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
  25678. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25679. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25681. * @param name defines the name of the mesh
  25682. * @param options defines the options used to create the mesh
  25683. * @param scene defines the hosting scene
  25684. * @returns the plane polygonal mesh
  25685. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25686. */
  25687. static CreateDisc(name: string, options: {
  25688. radius?: number;
  25689. tessellation?: number;
  25690. arc?: number;
  25691. updatable?: boolean;
  25692. sideOrientation?: number;
  25693. frontUVs?: Vector4;
  25694. backUVs?: Vector4;
  25695. }, scene?: Nullable<Scene>): Mesh;
  25696. }
  25697. }
  25698. declare module "babylonjs/Particles/solidParticleSystem" {
  25699. import { Vector3 } from "babylonjs/Maths/math.vector";
  25700. import { Mesh } from "babylonjs/Meshes/mesh";
  25701. import { Scene, IDisposable } from "babylonjs/scene";
  25702. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25703. /**
  25704. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25705. *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.
  25706. * The SPS is also a particle system. It provides some methods to manage the particles.
  25707. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25708. *
  25709. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25710. */
  25711. export class SolidParticleSystem implements IDisposable {
  25712. /**
  25713. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25714. * Example : var p = SPS.particles[i];
  25715. */
  25716. particles: SolidParticle[];
  25717. /**
  25718. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25719. */
  25720. nbParticles: number;
  25721. /**
  25722. * If the particles must ever face the camera (default false). Useful for planar particles.
  25723. */
  25724. billboard: boolean;
  25725. /**
  25726. * Recompute normals when adding a shape
  25727. */
  25728. recomputeNormals: boolean;
  25729. /**
  25730. * This a counter ofr your own usage. It's not set by any SPS functions.
  25731. */
  25732. counter: number;
  25733. /**
  25734. * The SPS name. This name is also given to the underlying mesh.
  25735. */
  25736. name: string;
  25737. /**
  25738. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25739. */
  25740. mesh: Mesh;
  25741. /**
  25742. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25743. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25744. */
  25745. vars: any;
  25746. /**
  25747. * This array is populated when the SPS is set as 'pickable'.
  25748. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25749. * Each element of this array is an object `{idx: int, faceId: int}`.
  25750. * `idx` is the picked particle index in the `SPS.particles` array
  25751. * `faceId` is the picked face index counted within this particle.
  25752. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25753. */
  25754. pickedParticles: {
  25755. idx: number;
  25756. faceId: number;
  25757. }[];
  25758. /**
  25759. * This array is populated when `enableDepthSort` is set to true.
  25760. * Each element of this array is an instance of the class DepthSortedParticle.
  25761. */
  25762. depthSortedParticles: DepthSortedParticle[];
  25763. /**
  25764. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25765. * @hidden
  25766. */
  25767. _bSphereOnly: boolean;
  25768. /**
  25769. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25770. * @hidden
  25771. */
  25772. _bSphereRadiusFactor: number;
  25773. private _scene;
  25774. private _positions;
  25775. private _indices;
  25776. private _normals;
  25777. private _colors;
  25778. private _uvs;
  25779. private _indices32;
  25780. private _positions32;
  25781. private _normals32;
  25782. private _fixedNormal32;
  25783. private _colors32;
  25784. private _uvs32;
  25785. private _index;
  25786. private _updatable;
  25787. private _pickable;
  25788. private _isVisibilityBoxLocked;
  25789. private _alwaysVisible;
  25790. private _depthSort;
  25791. private _shapeCounter;
  25792. private _copy;
  25793. private _color;
  25794. private _computeParticleColor;
  25795. private _computeParticleTexture;
  25796. private _computeParticleRotation;
  25797. private _computeParticleVertex;
  25798. private _computeBoundingBox;
  25799. private _depthSortParticles;
  25800. private _camera;
  25801. private _mustUnrotateFixedNormals;
  25802. private _particlesIntersect;
  25803. private _needs32Bits;
  25804. /**
  25805. * Creates a SPS (Solid Particle System) object.
  25806. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25807. * @param scene (Scene) is the scene in which the SPS is added.
  25808. * @param options defines the options of the sps e.g.
  25809. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25810. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25811. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25812. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25813. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25814. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25815. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25816. */
  25817. constructor(name: string, scene: Scene, options?: {
  25818. updatable?: boolean;
  25819. isPickable?: boolean;
  25820. enableDepthSort?: boolean;
  25821. particleIntersection?: boolean;
  25822. boundingSphereOnly?: boolean;
  25823. bSphereRadiusFactor?: number;
  25824. });
  25825. /**
  25826. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25827. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25828. * @returns the created mesh
  25829. */
  25830. buildMesh(): Mesh;
  25831. /**
  25832. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25833. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25834. * Thus the particles generated from `digest()` have their property `position` set yet.
  25835. * @param mesh ( Mesh ) is the mesh to be digested
  25836. * @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
  25837. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25838. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25839. * @returns the current SPS
  25840. */
  25841. digest(mesh: Mesh, options?: {
  25842. facetNb?: number;
  25843. number?: number;
  25844. delta?: number;
  25845. }): SolidParticleSystem;
  25846. private _unrotateFixedNormals;
  25847. private _resetCopy;
  25848. private _meshBuilder;
  25849. private _posToShape;
  25850. private _uvsToShapeUV;
  25851. private _addParticle;
  25852. /**
  25853. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25854. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25855. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25856. * @param nb (positive integer) the number of particles to be created from this model
  25857. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25858. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25859. * @returns the number of shapes in the system
  25860. */
  25861. addShape(mesh: Mesh, nb: number, options?: {
  25862. positionFunction?: any;
  25863. vertexFunction?: any;
  25864. }): number;
  25865. private _rebuildParticle;
  25866. /**
  25867. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25868. * @returns the SPS.
  25869. */
  25870. rebuildMesh(): SolidParticleSystem;
  25871. /**
  25872. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25873. * This method calls `updateParticle()` for each particle of the SPS.
  25874. * For an animated SPS, it is usually called within the render loop.
  25875. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25876. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25877. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25878. * @returns the SPS.
  25879. */
  25880. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25881. /**
  25882. * Disposes the SPS.
  25883. */
  25884. dispose(): void;
  25885. /**
  25886. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25887. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25888. * @returns the SPS.
  25889. */
  25890. refreshVisibleSize(): SolidParticleSystem;
  25891. /**
  25892. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25893. * @param size the size (float) of the visibility box
  25894. * note : this doesn't lock the SPS mesh bounding box.
  25895. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25896. */
  25897. setVisibilityBox(size: number): void;
  25898. /**
  25899. * Gets whether the SPS as always visible or not
  25900. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25901. */
  25902. /**
  25903. * Sets the SPS as always visible or not
  25904. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25905. */
  25906. isAlwaysVisible: boolean;
  25907. /**
  25908. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25909. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25910. */
  25911. /**
  25912. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25913. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25914. */
  25915. isVisibilityBoxLocked: boolean;
  25916. /**
  25917. * Tells to `setParticles()` to compute the particle rotations or not.
  25918. * Default value : true. The SPS is faster when it's set to false.
  25919. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25920. */
  25921. /**
  25922. * Gets if `setParticles()` computes the particle rotations or not.
  25923. * Default value : true. The SPS is faster when it's set to false.
  25924. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25925. */
  25926. computeParticleRotation: boolean;
  25927. /**
  25928. * Tells to `setParticles()` to compute the particle colors or not.
  25929. * Default value : true. The SPS is faster when it's set to false.
  25930. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25931. */
  25932. /**
  25933. * Gets if `setParticles()` computes the particle colors or not.
  25934. * Default value : true. The SPS is faster when it's set to false.
  25935. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25936. */
  25937. computeParticleColor: boolean;
  25938. /**
  25939. * Gets if `setParticles()` computes the particle textures or not.
  25940. * Default value : true. The SPS is faster when it's set to false.
  25941. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25942. */
  25943. computeParticleTexture: boolean;
  25944. /**
  25945. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25946. * Default value : false. The SPS is faster when it's set to false.
  25947. * Note : the particle custom vertex positions aren't stored values.
  25948. */
  25949. /**
  25950. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25951. * Default value : false. The SPS is faster when it's set to false.
  25952. * Note : the particle custom vertex positions aren't stored values.
  25953. */
  25954. computeParticleVertex: boolean;
  25955. /**
  25956. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25957. */
  25958. /**
  25959. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25960. */
  25961. computeBoundingBox: boolean;
  25962. /**
  25963. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25964. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25965. * Default : `true`
  25966. */
  25967. /**
  25968. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25969. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25970. * Default : `true`
  25971. */
  25972. depthSortParticles: boolean;
  25973. /**
  25974. * This function does nothing. It may be overwritten to set all the particle first values.
  25975. * The SPS doesn't call this function, you may have to call it by your own.
  25976. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25977. */
  25978. initParticles(): void;
  25979. /**
  25980. * This function does nothing. It may be overwritten to recycle a particle.
  25981. * The SPS doesn't call this function, you may have to call it by your own.
  25982. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25983. * @param particle The particle to recycle
  25984. * @returns the recycled particle
  25985. */
  25986. recycleParticle(particle: SolidParticle): SolidParticle;
  25987. /**
  25988. * Updates a particle : this function should be overwritten by the user.
  25989. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25990. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25991. * @example : just set a particle position or velocity and recycle conditions
  25992. * @param particle The particle to update
  25993. * @returns the updated particle
  25994. */
  25995. updateParticle(particle: SolidParticle): SolidParticle;
  25996. /**
  25997. * Updates a vertex of a particle : it can be overwritten by the user.
  25998. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25999. * @param particle the current particle
  26000. * @param vertex the current index of the current particle
  26001. * @param pt the index of the current vertex in the particle shape
  26002. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26003. * @example : just set a vertex particle position
  26004. * @returns the updated vertex
  26005. */
  26006. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26007. /**
  26008. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26009. * This does nothing and may be overwritten by the user.
  26010. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26011. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26012. * @param update the boolean update value actually passed to setParticles()
  26013. */
  26014. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26015. /**
  26016. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26017. * This will be passed three parameters.
  26018. * This does nothing and may be overwritten by the user.
  26019. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26020. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26021. * @param update the boolean update value actually passed to setParticles()
  26022. */
  26023. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26024. }
  26025. }
  26026. declare module "babylonjs/Particles/solidParticle" {
  26027. import { Nullable } from "babylonjs/types";
  26028. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26029. import { Color4 } from "babylonjs/Maths/math.color";
  26030. import { Mesh } from "babylonjs/Meshes/mesh";
  26031. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26032. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26033. import { Plane } from "babylonjs/Maths/math.plane";
  26034. /**
  26035. * Represents one particle of a solid particle system.
  26036. */
  26037. export class SolidParticle {
  26038. /**
  26039. * particle global index
  26040. */
  26041. idx: number;
  26042. /**
  26043. * The color of the particle
  26044. */
  26045. color: Nullable<Color4>;
  26046. /**
  26047. * The world space position of the particle.
  26048. */
  26049. position: Vector3;
  26050. /**
  26051. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26052. */
  26053. rotation: Vector3;
  26054. /**
  26055. * The world space rotation quaternion of the particle.
  26056. */
  26057. rotationQuaternion: Nullable<Quaternion>;
  26058. /**
  26059. * The scaling of the particle.
  26060. */
  26061. scaling: Vector3;
  26062. /**
  26063. * The uvs of the particle.
  26064. */
  26065. uvs: Vector4;
  26066. /**
  26067. * The current speed of the particle.
  26068. */
  26069. velocity: Vector3;
  26070. /**
  26071. * The pivot point in the particle local space.
  26072. */
  26073. pivot: Vector3;
  26074. /**
  26075. * Must the particle be translated from its pivot point in its local space ?
  26076. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26077. * Default : false
  26078. */
  26079. translateFromPivot: boolean;
  26080. /**
  26081. * Is the particle active or not ?
  26082. */
  26083. alive: boolean;
  26084. /**
  26085. * Is the particle visible or not ?
  26086. */
  26087. isVisible: boolean;
  26088. /**
  26089. * Index of this particle in the global "positions" array (Internal use)
  26090. * @hidden
  26091. */
  26092. _pos: number;
  26093. /**
  26094. * @hidden Index of this particle in the global "indices" array (Internal use)
  26095. */
  26096. _ind: number;
  26097. /**
  26098. * @hidden ModelShape of this particle (Internal use)
  26099. */
  26100. _model: ModelShape;
  26101. /**
  26102. * ModelShape id of this particle
  26103. */
  26104. shapeId: number;
  26105. /**
  26106. * Index of the particle in its shape id
  26107. */
  26108. idxInShape: number;
  26109. /**
  26110. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26111. */
  26112. _modelBoundingInfo: BoundingInfo;
  26113. /**
  26114. * @hidden Particle BoundingInfo object (Internal use)
  26115. */
  26116. _boundingInfo: BoundingInfo;
  26117. /**
  26118. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26119. */
  26120. _sps: SolidParticleSystem;
  26121. /**
  26122. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26123. */
  26124. _stillInvisible: boolean;
  26125. /**
  26126. * @hidden Last computed particle rotation matrix
  26127. */
  26128. _rotationMatrix: number[];
  26129. /**
  26130. * Parent particle Id, if any.
  26131. * Default null.
  26132. */
  26133. parentId: Nullable<number>;
  26134. /**
  26135. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26136. * The possible values are :
  26137. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26138. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26139. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26140. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26141. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26142. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26143. * */
  26144. cullingStrategy: number;
  26145. /**
  26146. * @hidden Internal global position in the SPS.
  26147. */
  26148. _globalPosition: Vector3;
  26149. /**
  26150. * Creates a Solid Particle object.
  26151. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26152. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26153. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26154. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26155. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26156. * @param shapeId (integer) is the model shape identifier in the SPS.
  26157. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26158. * @param sps defines the sps it is associated to
  26159. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26160. */
  26161. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26162. /**
  26163. * Legacy support, changed scale to scaling
  26164. */
  26165. /**
  26166. * Legacy support, changed scale to scaling
  26167. */
  26168. scale: Vector3;
  26169. /**
  26170. * Legacy support, changed quaternion to rotationQuaternion
  26171. */
  26172. /**
  26173. * Legacy support, changed quaternion to rotationQuaternion
  26174. */
  26175. quaternion: Nullable<Quaternion>;
  26176. /**
  26177. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26178. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26179. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26180. * @returns true if it intersects
  26181. */
  26182. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26183. /**
  26184. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26185. * A particle is in the frustum if its bounding box intersects the frustum
  26186. * @param frustumPlanes defines the frustum to test
  26187. * @returns true if the particle is in the frustum planes
  26188. */
  26189. isInFrustum(frustumPlanes: Plane[]): boolean;
  26190. /**
  26191. * get the rotation matrix of the particle
  26192. * @hidden
  26193. */
  26194. getRotationMatrix(m: Matrix): void;
  26195. }
  26196. /**
  26197. * Represents the shape of the model used by one particle of a solid particle system.
  26198. * SPS internal tool, don't use it manually.
  26199. */
  26200. export class ModelShape {
  26201. /**
  26202. * The shape id
  26203. * @hidden
  26204. */
  26205. shapeID: number;
  26206. /**
  26207. * flat array of model positions (internal use)
  26208. * @hidden
  26209. */
  26210. _shape: Vector3[];
  26211. /**
  26212. * flat array of model UVs (internal use)
  26213. * @hidden
  26214. */
  26215. _shapeUV: number[];
  26216. /**
  26217. * length of the shape in the model indices array (internal use)
  26218. * @hidden
  26219. */
  26220. _indicesLength: number;
  26221. /**
  26222. * Custom position function (internal use)
  26223. * @hidden
  26224. */
  26225. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26226. /**
  26227. * Custom vertex function (internal use)
  26228. * @hidden
  26229. */
  26230. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26231. /**
  26232. * 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.
  26233. * SPS internal tool, don't use it manually.
  26234. * @hidden
  26235. */
  26236. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  26237. }
  26238. /**
  26239. * Represents a Depth Sorted Particle in the solid particle system.
  26240. */
  26241. export class DepthSortedParticle {
  26242. /**
  26243. * Index of the particle in the "indices" array
  26244. */
  26245. ind: number;
  26246. /**
  26247. * Length of the particle shape in the "indices" array
  26248. */
  26249. indicesLength: number;
  26250. /**
  26251. * Squared distance from the particle to the camera
  26252. */
  26253. sqDistance: number;
  26254. }
  26255. }
  26256. declare module "babylonjs/Collisions/meshCollisionData" {
  26257. import { Collider } from "babylonjs/Collisions/collider";
  26258. import { Vector3 } from "babylonjs/Maths/math.vector";
  26259. import { Nullable } from "babylonjs/types";
  26260. import { Observer } from "babylonjs/Misc/observable";
  26261. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26262. /**
  26263. * @hidden
  26264. */
  26265. export class _MeshCollisionData {
  26266. _checkCollisions: boolean;
  26267. _collisionMask: number;
  26268. _collisionGroup: number;
  26269. _collider: Nullable<Collider>;
  26270. _oldPositionForCollisions: Vector3;
  26271. _diffPositionForCollisions: Vector3;
  26272. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26273. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26274. }
  26275. }
  26276. declare module "babylonjs/Meshes/abstractMesh" {
  26277. import { Observable } from "babylonjs/Misc/observable";
  26278. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26279. import { Camera } from "babylonjs/Cameras/camera";
  26280. import { Scene, IDisposable } from "babylonjs/scene";
  26281. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26282. import { Node } from "babylonjs/node";
  26283. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26284. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26285. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26286. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26287. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26288. import { Material } from "babylonjs/Materials/material";
  26289. import { Light } from "babylonjs/Lights/light";
  26290. import { Skeleton } from "babylonjs/Bones/skeleton";
  26291. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26292. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26293. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26294. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26295. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26296. import { Plane } from "babylonjs/Maths/math.plane";
  26297. import { Ray } from "babylonjs/Culling/ray";
  26298. import { Collider } from "babylonjs/Collisions/collider";
  26299. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26300. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26301. /** @hidden */
  26302. class _FacetDataStorage {
  26303. facetPositions: Vector3[];
  26304. facetNormals: Vector3[];
  26305. facetPartitioning: number[][];
  26306. facetNb: number;
  26307. partitioningSubdivisions: number;
  26308. partitioningBBoxRatio: number;
  26309. facetDataEnabled: boolean;
  26310. facetParameters: any;
  26311. bbSize: Vector3;
  26312. subDiv: {
  26313. max: number;
  26314. X: number;
  26315. Y: number;
  26316. Z: number;
  26317. };
  26318. facetDepthSort: boolean;
  26319. facetDepthSortEnabled: boolean;
  26320. depthSortedIndices: IndicesArray;
  26321. depthSortedFacets: {
  26322. ind: number;
  26323. sqDistance: number;
  26324. }[];
  26325. facetDepthSortFunction: (f1: {
  26326. ind: number;
  26327. sqDistance: number;
  26328. }, f2: {
  26329. ind: number;
  26330. sqDistance: number;
  26331. }) => number;
  26332. facetDepthSortFrom: Vector3;
  26333. facetDepthSortOrigin: Vector3;
  26334. invertedMatrix: Matrix;
  26335. }
  26336. /**
  26337. * @hidden
  26338. **/
  26339. class _InternalAbstractMeshDataInfo {
  26340. _hasVertexAlpha: boolean;
  26341. _useVertexColors: boolean;
  26342. _numBoneInfluencers: number;
  26343. _applyFog: boolean;
  26344. _receiveShadows: boolean;
  26345. _facetData: _FacetDataStorage;
  26346. _visibility: number;
  26347. _skeleton: Nullable<Skeleton>;
  26348. _layerMask: number;
  26349. _computeBonesUsingShaders: boolean;
  26350. _isActive: boolean;
  26351. _onlyForInstances: boolean;
  26352. _isActiveIntermediate: boolean;
  26353. _onlyForInstancesIntermediate: boolean;
  26354. }
  26355. /**
  26356. * Class used to store all common mesh properties
  26357. */
  26358. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26359. /** No occlusion */
  26360. static OCCLUSION_TYPE_NONE: number;
  26361. /** Occlusion set to optimisitic */
  26362. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26363. /** Occlusion set to strict */
  26364. static OCCLUSION_TYPE_STRICT: number;
  26365. /** Use an accurante occlusion algorithm */
  26366. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26367. /** Use a conservative occlusion algorithm */
  26368. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26369. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26370. * Test order :
  26371. * Is the bounding sphere outside the frustum ?
  26372. * If not, are the bounding box vertices outside the frustum ?
  26373. * It not, then the cullable object is in the frustum.
  26374. */
  26375. static readonly CULLINGSTRATEGY_STANDARD: number;
  26376. /** Culling strategy : Bounding Sphere Only.
  26377. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26378. * It's also less accurate than the standard because some not visible objects can still be selected.
  26379. * Test : is the bounding sphere outside the frustum ?
  26380. * If not, then the cullable object is in the frustum.
  26381. */
  26382. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26383. /** Culling strategy : Optimistic Inclusion.
  26384. * This in an inclusion test first, then the standard exclusion test.
  26385. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26386. * 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.
  26387. * Anyway, it's as accurate as the standard strategy.
  26388. * Test :
  26389. * Is the cullable object bounding sphere center in the frustum ?
  26390. * If not, apply the default culling strategy.
  26391. */
  26392. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26393. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26394. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26395. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26396. * 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.
  26397. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26398. * Test :
  26399. * Is the cullable object bounding sphere center in the frustum ?
  26400. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26401. */
  26402. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26403. /**
  26404. * No billboard
  26405. */
  26406. static readonly BILLBOARDMODE_NONE: number;
  26407. /** Billboard on X axis */
  26408. static readonly BILLBOARDMODE_X: number;
  26409. /** Billboard on Y axis */
  26410. static readonly BILLBOARDMODE_Y: number;
  26411. /** Billboard on Z axis */
  26412. static readonly BILLBOARDMODE_Z: number;
  26413. /** Billboard on all axes */
  26414. static readonly BILLBOARDMODE_ALL: number;
  26415. /** Billboard on using position instead of orientation */
  26416. static readonly BILLBOARDMODE_USE_POSITION: number;
  26417. /** @hidden */
  26418. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26419. /**
  26420. * The culling strategy to use to check whether the mesh must be rendered or not.
  26421. * This value can be changed at any time and will be used on the next render mesh selection.
  26422. * The possible values are :
  26423. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26424. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26425. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26426. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26427. * Please read each static variable documentation to get details about the culling process.
  26428. * */
  26429. cullingStrategy: number;
  26430. /**
  26431. * Gets the number of facets in the mesh
  26432. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26433. */
  26434. readonly facetNb: number;
  26435. /**
  26436. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26437. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26438. */
  26439. partitioningSubdivisions: number;
  26440. /**
  26441. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26442. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26443. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26444. */
  26445. partitioningBBoxRatio: number;
  26446. /**
  26447. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26448. * Works only for updatable meshes.
  26449. * Doesn't work with multi-materials
  26450. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26451. */
  26452. mustDepthSortFacets: boolean;
  26453. /**
  26454. * The location (Vector3) where the facet depth sort must be computed from.
  26455. * By default, the active camera position.
  26456. * Used only when facet depth sort is enabled
  26457. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26458. */
  26459. facetDepthSortFrom: Vector3;
  26460. /**
  26461. * gets a boolean indicating if facetData is enabled
  26462. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26463. */
  26464. readonly isFacetDataEnabled: boolean;
  26465. /** @hidden */
  26466. _updateNonUniformScalingState(value: boolean): boolean;
  26467. /**
  26468. * An event triggered when this mesh collides with another one
  26469. */
  26470. onCollideObservable: Observable<AbstractMesh>;
  26471. /** Set a function to call when this mesh collides with another one */
  26472. onCollide: () => void;
  26473. /**
  26474. * An event triggered when the collision's position changes
  26475. */
  26476. onCollisionPositionChangeObservable: Observable<Vector3>;
  26477. /** Set a function to call when the collision's position changes */
  26478. onCollisionPositionChange: () => void;
  26479. /**
  26480. * An event triggered when material is changed
  26481. */
  26482. onMaterialChangedObservable: Observable<AbstractMesh>;
  26483. /**
  26484. * Gets or sets the orientation for POV movement & rotation
  26485. */
  26486. definedFacingForward: boolean;
  26487. /** @hidden */
  26488. _occlusionQuery: Nullable<WebGLQuery>;
  26489. /** @hidden */
  26490. _renderingGroup: Nullable<RenderingGroup>;
  26491. /**
  26492. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26493. */
  26494. /**
  26495. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26496. */
  26497. visibility: number;
  26498. /** Gets or sets the alpha index used to sort transparent meshes
  26499. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26500. */
  26501. alphaIndex: number;
  26502. /**
  26503. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26504. */
  26505. isVisible: boolean;
  26506. /**
  26507. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26508. */
  26509. isPickable: boolean;
  26510. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26511. showSubMeshesBoundingBox: boolean;
  26512. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26513. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26514. */
  26515. isBlocker: boolean;
  26516. /**
  26517. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26518. */
  26519. enablePointerMoveEvents: boolean;
  26520. /**
  26521. * Specifies the rendering group id for this mesh (0 by default)
  26522. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26523. */
  26524. renderingGroupId: number;
  26525. private _material;
  26526. /** Gets or sets current material */
  26527. material: Nullable<Material>;
  26528. /**
  26529. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26530. * @see http://doc.babylonjs.com/babylon101/shadows
  26531. */
  26532. receiveShadows: boolean;
  26533. /** Defines color to use when rendering outline */
  26534. outlineColor: Color3;
  26535. /** Define width to use when rendering outline */
  26536. outlineWidth: number;
  26537. /** Defines color to use when rendering overlay */
  26538. overlayColor: Color3;
  26539. /** Defines alpha to use when rendering overlay */
  26540. overlayAlpha: number;
  26541. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26542. hasVertexAlpha: boolean;
  26543. /** 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) */
  26544. useVertexColors: boolean;
  26545. /**
  26546. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26547. */
  26548. computeBonesUsingShaders: boolean;
  26549. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26550. numBoneInfluencers: number;
  26551. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26552. applyFog: boolean;
  26553. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26554. useOctreeForRenderingSelection: boolean;
  26555. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26556. useOctreeForPicking: boolean;
  26557. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26558. useOctreeForCollisions: boolean;
  26559. /**
  26560. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26561. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26562. */
  26563. layerMask: number;
  26564. /**
  26565. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26566. */
  26567. alwaysSelectAsActiveMesh: boolean;
  26568. /**
  26569. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26570. */
  26571. doNotSyncBoundingInfo: boolean;
  26572. /**
  26573. * Gets or sets the current action manager
  26574. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26575. */
  26576. actionManager: Nullable<AbstractActionManager>;
  26577. private _meshCollisionData;
  26578. /**
  26579. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26580. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26581. */
  26582. ellipsoid: Vector3;
  26583. /**
  26584. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26585. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26586. */
  26587. ellipsoidOffset: Vector3;
  26588. /**
  26589. * Gets or sets a collision mask used to mask collisions (default is -1).
  26590. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26591. */
  26592. collisionMask: number;
  26593. /**
  26594. * Gets or sets the current collision group mask (-1 by default).
  26595. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26596. */
  26597. collisionGroup: number;
  26598. /**
  26599. * Defines edge width used when edgesRenderer is enabled
  26600. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26601. */
  26602. edgesWidth: number;
  26603. /**
  26604. * Defines edge color used when edgesRenderer is enabled
  26605. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26606. */
  26607. edgesColor: Color4;
  26608. /** @hidden */
  26609. _edgesRenderer: Nullable<IEdgesRenderer>;
  26610. /** @hidden */
  26611. _masterMesh: Nullable<AbstractMesh>;
  26612. /** @hidden */
  26613. _boundingInfo: Nullable<BoundingInfo>;
  26614. /** @hidden */
  26615. _renderId: number;
  26616. /**
  26617. * Gets or sets the list of subMeshes
  26618. * @see http://doc.babylonjs.com/how_to/multi_materials
  26619. */
  26620. subMeshes: SubMesh[];
  26621. /** @hidden */
  26622. _intersectionsInProgress: AbstractMesh[];
  26623. /** @hidden */
  26624. _unIndexed: boolean;
  26625. /** @hidden */
  26626. _lightSources: Light[];
  26627. /** Gets the list of lights affecting that mesh */
  26628. readonly lightSources: Light[];
  26629. /** @hidden */
  26630. readonly _positions: Nullable<Vector3[]>;
  26631. /** @hidden */
  26632. _waitingData: {
  26633. lods: Nullable<any>;
  26634. actions: Nullable<any>;
  26635. freezeWorldMatrix: Nullable<boolean>;
  26636. };
  26637. /** @hidden */
  26638. _bonesTransformMatrices: Nullable<Float32Array>;
  26639. /** @hidden */
  26640. _transformMatrixTexture: Nullable<RawTexture>;
  26641. /**
  26642. * Gets or sets a skeleton to apply skining transformations
  26643. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26644. */
  26645. skeleton: Nullable<Skeleton>;
  26646. /**
  26647. * An event triggered when the mesh is rebuilt.
  26648. */
  26649. onRebuildObservable: Observable<AbstractMesh>;
  26650. /**
  26651. * Creates a new AbstractMesh
  26652. * @param name defines the name of the mesh
  26653. * @param scene defines the hosting scene
  26654. */
  26655. constructor(name: string, scene?: Nullable<Scene>);
  26656. /**
  26657. * Returns the string "AbstractMesh"
  26658. * @returns "AbstractMesh"
  26659. */
  26660. getClassName(): string;
  26661. /**
  26662. * Gets a string representation of the current mesh
  26663. * @param fullDetails defines a boolean indicating if full details must be included
  26664. * @returns a string representation of the current mesh
  26665. */
  26666. toString(fullDetails?: boolean): string;
  26667. /**
  26668. * @hidden
  26669. */
  26670. protected _getEffectiveParent(): Nullable<Node>;
  26671. /** @hidden */
  26672. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26673. /** @hidden */
  26674. _rebuild(): void;
  26675. /** @hidden */
  26676. _resyncLightSources(): void;
  26677. /** @hidden */
  26678. _resyncLighSource(light: Light): void;
  26679. /** @hidden */
  26680. _unBindEffect(): void;
  26681. /** @hidden */
  26682. _removeLightSource(light: Light, dispose: boolean): void;
  26683. private _markSubMeshesAsDirty;
  26684. /** @hidden */
  26685. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26686. /** @hidden */
  26687. _markSubMeshesAsAttributesDirty(): void;
  26688. /** @hidden */
  26689. _markSubMeshesAsMiscDirty(): void;
  26690. /**
  26691. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26692. */
  26693. scaling: Vector3;
  26694. /**
  26695. * Returns true if the mesh is blocked. Implemented by child classes
  26696. */
  26697. readonly isBlocked: boolean;
  26698. /**
  26699. * Returns the mesh itself by default. Implemented by child classes
  26700. * @param camera defines the camera to use to pick the right LOD level
  26701. * @returns the currentAbstractMesh
  26702. */
  26703. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26704. /**
  26705. * Returns 0 by default. Implemented by child classes
  26706. * @returns an integer
  26707. */
  26708. getTotalVertices(): number;
  26709. /**
  26710. * Returns a positive integer : the total number of indices in this mesh geometry.
  26711. * @returns the numner of indices or zero if the mesh has no geometry.
  26712. */
  26713. getTotalIndices(): number;
  26714. /**
  26715. * Returns null by default. Implemented by child classes
  26716. * @returns null
  26717. */
  26718. getIndices(): Nullable<IndicesArray>;
  26719. /**
  26720. * Returns the array of the requested vertex data kind. Implemented by child classes
  26721. * @param kind defines the vertex data kind to use
  26722. * @returns null
  26723. */
  26724. getVerticesData(kind: string): Nullable<FloatArray>;
  26725. /**
  26726. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26727. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26728. * Note that a new underlying VertexBuffer object is created each call.
  26729. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26730. * @param kind defines vertex data kind:
  26731. * * VertexBuffer.PositionKind
  26732. * * VertexBuffer.UVKind
  26733. * * VertexBuffer.UV2Kind
  26734. * * VertexBuffer.UV3Kind
  26735. * * VertexBuffer.UV4Kind
  26736. * * VertexBuffer.UV5Kind
  26737. * * VertexBuffer.UV6Kind
  26738. * * VertexBuffer.ColorKind
  26739. * * VertexBuffer.MatricesIndicesKind
  26740. * * VertexBuffer.MatricesIndicesExtraKind
  26741. * * VertexBuffer.MatricesWeightsKind
  26742. * * VertexBuffer.MatricesWeightsExtraKind
  26743. * @param data defines the data source
  26744. * @param updatable defines if the data must be flagged as updatable (or static)
  26745. * @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
  26746. * @returns the current mesh
  26747. */
  26748. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26749. /**
  26750. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26751. * If the mesh has no geometry, it is simply returned as it is.
  26752. * @param kind defines vertex data kind:
  26753. * * VertexBuffer.PositionKind
  26754. * * VertexBuffer.UVKind
  26755. * * VertexBuffer.UV2Kind
  26756. * * VertexBuffer.UV3Kind
  26757. * * VertexBuffer.UV4Kind
  26758. * * VertexBuffer.UV5Kind
  26759. * * VertexBuffer.UV6Kind
  26760. * * VertexBuffer.ColorKind
  26761. * * VertexBuffer.MatricesIndicesKind
  26762. * * VertexBuffer.MatricesIndicesExtraKind
  26763. * * VertexBuffer.MatricesWeightsKind
  26764. * * VertexBuffer.MatricesWeightsExtraKind
  26765. * @param data defines the data source
  26766. * @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
  26767. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26768. * @returns the current mesh
  26769. */
  26770. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26771. /**
  26772. * Sets the mesh indices,
  26773. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26774. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26775. * @param totalVertices Defines the total number of vertices
  26776. * @returns the current mesh
  26777. */
  26778. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26779. /**
  26780. * Gets a boolean indicating if specific vertex data is present
  26781. * @param kind defines the vertex data kind to use
  26782. * @returns true is data kind is present
  26783. */
  26784. isVerticesDataPresent(kind: string): boolean;
  26785. /**
  26786. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26787. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26788. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26789. * @returns a BoundingInfo
  26790. */
  26791. getBoundingInfo(): BoundingInfo;
  26792. /**
  26793. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26794. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26795. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26796. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26797. * @returns the current mesh
  26798. */
  26799. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26800. /**
  26801. * Overwrite the current bounding info
  26802. * @param boundingInfo defines the new bounding info
  26803. * @returns the current mesh
  26804. */
  26805. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26806. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26807. readonly useBones: boolean;
  26808. /** @hidden */
  26809. _preActivate(): void;
  26810. /** @hidden */
  26811. _preActivateForIntermediateRendering(renderId: number): void;
  26812. /** @hidden */
  26813. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26814. /** @hidden */
  26815. _postActivate(): void;
  26816. /** @hidden */
  26817. _freeze(): void;
  26818. /** @hidden */
  26819. _unFreeze(): void;
  26820. /**
  26821. * Gets the current world matrix
  26822. * @returns a Matrix
  26823. */
  26824. getWorldMatrix(): Matrix;
  26825. /** @hidden */
  26826. _getWorldMatrixDeterminant(): number;
  26827. /**
  26828. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26829. */
  26830. readonly isAnInstance: boolean;
  26831. /**
  26832. * Gets a boolean indicating if this mesh has instances
  26833. */
  26834. readonly hasInstances: boolean;
  26835. /**
  26836. * Perform relative position change from the point of view of behind the front of the mesh.
  26837. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26838. * Supports definition of mesh facing forward or backward
  26839. * @param amountRight defines the distance on the right axis
  26840. * @param amountUp defines the distance on the up axis
  26841. * @param amountForward defines the distance on the forward axis
  26842. * @returns the current mesh
  26843. */
  26844. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26845. /**
  26846. * Calculate relative position change from the point of view of behind the front of the mesh.
  26847. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26848. * Supports definition of mesh facing forward or backward
  26849. * @param amountRight defines the distance on the right axis
  26850. * @param amountUp defines the distance on the up axis
  26851. * @param amountForward defines the distance on the forward axis
  26852. * @returns the new displacement vector
  26853. */
  26854. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26855. /**
  26856. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26857. * Supports definition of mesh facing forward or backward
  26858. * @param flipBack defines the flip
  26859. * @param twirlClockwise defines the twirl
  26860. * @param tiltRight defines the tilt
  26861. * @returns the current mesh
  26862. */
  26863. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26864. /**
  26865. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26866. * Supports definition of mesh facing forward or backward.
  26867. * @param flipBack defines the flip
  26868. * @param twirlClockwise defines the twirl
  26869. * @param tiltRight defines the tilt
  26870. * @returns the new rotation vector
  26871. */
  26872. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26873. /**
  26874. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26875. * This means the mesh underlying bounding box and sphere are recomputed.
  26876. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26877. * @returns the current mesh
  26878. */
  26879. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26880. /** @hidden */
  26881. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26882. /** @hidden */
  26883. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26884. /** @hidden */
  26885. _updateBoundingInfo(): AbstractMesh;
  26886. /** @hidden */
  26887. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26888. /** @hidden */
  26889. protected _afterComputeWorldMatrix(): void;
  26890. /** @hidden */
  26891. readonly _effectiveMesh: AbstractMesh;
  26892. /**
  26893. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26894. * A mesh is in the frustum if its bounding box intersects the frustum
  26895. * @param frustumPlanes defines the frustum to test
  26896. * @returns true if the mesh is in the frustum planes
  26897. */
  26898. isInFrustum(frustumPlanes: Plane[]): boolean;
  26899. /**
  26900. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26901. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26902. * @param frustumPlanes defines the frustum to test
  26903. * @returns true if the mesh is completely in the frustum planes
  26904. */
  26905. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26906. /**
  26907. * True if the mesh intersects another mesh or a SolidParticle object
  26908. * @param mesh defines a target mesh or SolidParticle to test
  26909. * @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)
  26910. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26911. * @returns true if there is an intersection
  26912. */
  26913. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26914. /**
  26915. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26916. * @param point defines the point to test
  26917. * @returns true if there is an intersection
  26918. */
  26919. intersectsPoint(point: Vector3): boolean;
  26920. /**
  26921. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26922. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26923. */
  26924. checkCollisions: boolean;
  26925. /**
  26926. * Gets Collider object used to compute collisions (not physics)
  26927. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26928. */
  26929. readonly collider: Nullable<Collider>;
  26930. /**
  26931. * Move the mesh using collision engine
  26932. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26933. * @param displacement defines the requested displacement vector
  26934. * @returns the current mesh
  26935. */
  26936. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26937. private _onCollisionPositionChange;
  26938. /** @hidden */
  26939. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26940. /** @hidden */
  26941. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26942. /** @hidden */
  26943. _checkCollision(collider: Collider): AbstractMesh;
  26944. /** @hidden */
  26945. _generatePointsArray(): boolean;
  26946. /**
  26947. * Checks if the passed Ray intersects with the mesh
  26948. * @param ray defines the ray to use
  26949. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26950. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26951. * @returns the picking info
  26952. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26953. */
  26954. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26955. /**
  26956. * Clones the current mesh
  26957. * @param name defines the mesh name
  26958. * @param newParent defines the new mesh parent
  26959. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26960. * @returns the new mesh
  26961. */
  26962. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26963. /**
  26964. * Disposes all the submeshes of the current meshnp
  26965. * @returns the current mesh
  26966. */
  26967. releaseSubMeshes(): AbstractMesh;
  26968. /**
  26969. * Releases resources associated with this abstract mesh.
  26970. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26971. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26972. */
  26973. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26974. /**
  26975. * Adds the passed mesh as a child to the current mesh
  26976. * @param mesh defines the child mesh
  26977. * @returns the current mesh
  26978. */
  26979. addChild(mesh: AbstractMesh): AbstractMesh;
  26980. /**
  26981. * Removes the passed mesh from the current mesh children list
  26982. * @param mesh defines the child mesh
  26983. * @returns the current mesh
  26984. */
  26985. removeChild(mesh: AbstractMesh): AbstractMesh;
  26986. /** @hidden */
  26987. private _initFacetData;
  26988. /**
  26989. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26990. * This method can be called within the render loop.
  26991. * 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
  26992. * @returns the current mesh
  26993. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26994. */
  26995. updateFacetData(): AbstractMesh;
  26996. /**
  26997. * Returns the facetLocalNormals array.
  26998. * The normals are expressed in the mesh local spac
  26999. * @returns an array of Vector3
  27000. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27001. */
  27002. getFacetLocalNormals(): Vector3[];
  27003. /**
  27004. * Returns the facetLocalPositions array.
  27005. * The facet positions are expressed in the mesh local space
  27006. * @returns an array of Vector3
  27007. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27008. */
  27009. getFacetLocalPositions(): Vector3[];
  27010. /**
  27011. * Returns the facetLocalPartioning array
  27012. * @returns an array of array of numbers
  27013. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27014. */
  27015. getFacetLocalPartitioning(): number[][];
  27016. /**
  27017. * Returns the i-th facet position in the world system.
  27018. * This method allocates a new Vector3 per call
  27019. * @param i defines the facet index
  27020. * @returns a new Vector3
  27021. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27022. */
  27023. getFacetPosition(i: number): Vector3;
  27024. /**
  27025. * Sets the reference Vector3 with the i-th facet position in the world system
  27026. * @param i defines the facet index
  27027. * @param ref defines the target vector
  27028. * @returns the current mesh
  27029. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27030. */
  27031. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27032. /**
  27033. * Returns the i-th facet normal in the world system.
  27034. * This method allocates a new Vector3 per call
  27035. * @param i defines the facet index
  27036. * @returns a new Vector3
  27037. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27038. */
  27039. getFacetNormal(i: number): Vector3;
  27040. /**
  27041. * Sets the reference Vector3 with the i-th facet normal in the world system
  27042. * @param i defines the facet index
  27043. * @param ref defines the target vector
  27044. * @returns the current mesh
  27045. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27046. */
  27047. getFacetNormalToRef(i: number, ref: Vector3): this;
  27048. /**
  27049. * 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)
  27050. * @param x defines x coordinate
  27051. * @param y defines y coordinate
  27052. * @param z defines z coordinate
  27053. * @returns the array of facet indexes
  27054. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27055. */
  27056. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27057. /**
  27058. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27059. * @param projected sets as the (x,y,z) world projection on the facet
  27060. * @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
  27061. * @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
  27062. * @param x defines x coordinate
  27063. * @param y defines y coordinate
  27064. * @param z defines z coordinate
  27065. * @returns the face index if found (or null instead)
  27066. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27067. */
  27068. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27069. /**
  27070. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27071. * @param projected sets as the (x,y,z) local projection on the facet
  27072. * @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
  27073. * @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
  27074. * @param x defines x coordinate
  27075. * @param y defines y coordinate
  27076. * @param z defines z coordinate
  27077. * @returns the face index if found (or null instead)
  27078. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27079. */
  27080. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27081. /**
  27082. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27083. * @returns the parameters
  27084. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27085. */
  27086. getFacetDataParameters(): any;
  27087. /**
  27088. * Disables the feature FacetData and frees the related memory
  27089. * @returns the current mesh
  27090. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27091. */
  27092. disableFacetData(): AbstractMesh;
  27093. /**
  27094. * Updates the AbstractMesh indices array
  27095. * @param indices defines the data source
  27096. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27097. * @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)
  27098. * @returns the current mesh
  27099. */
  27100. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27101. /**
  27102. * Creates new normals data for the mesh
  27103. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27104. * @returns the current mesh
  27105. */
  27106. createNormals(updatable: boolean): AbstractMesh;
  27107. /**
  27108. * Align the mesh with a normal
  27109. * @param normal defines the normal to use
  27110. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27111. * @returns the current mesh
  27112. */
  27113. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27114. /** @hidden */
  27115. _checkOcclusionQuery(): boolean;
  27116. /**
  27117. * Disables the mesh edge rendering mode
  27118. * @returns the currentAbstractMesh
  27119. */
  27120. disableEdgesRendering(): AbstractMesh;
  27121. /**
  27122. * Enables the edge rendering mode on the mesh.
  27123. * This mode makes the mesh edges visible
  27124. * @param epsilon defines the maximal distance between two angles to detect a face
  27125. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27126. * @returns the currentAbstractMesh
  27127. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27128. */
  27129. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27130. }
  27131. }
  27132. declare module "babylonjs/Actions/actionEvent" {
  27133. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27134. import { Nullable } from "babylonjs/types";
  27135. import { Sprite } from "babylonjs/Sprites/sprite";
  27136. import { Scene } from "babylonjs/scene";
  27137. import { Vector2 } from "babylonjs/Maths/math.vector";
  27138. /**
  27139. * Interface used to define ActionEvent
  27140. */
  27141. export interface IActionEvent {
  27142. /** The mesh or sprite that triggered the action */
  27143. source: any;
  27144. /** The X mouse cursor position at the time of the event */
  27145. pointerX: number;
  27146. /** The Y mouse cursor position at the time of the event */
  27147. pointerY: number;
  27148. /** The mesh that is currently pointed at (can be null) */
  27149. meshUnderPointer: Nullable<AbstractMesh>;
  27150. /** the original (browser) event that triggered the ActionEvent */
  27151. sourceEvent?: any;
  27152. /** additional data for the event */
  27153. additionalData?: any;
  27154. }
  27155. /**
  27156. * ActionEvent is the event being sent when an action is triggered.
  27157. */
  27158. export class ActionEvent implements IActionEvent {
  27159. /** The mesh or sprite that triggered the action */
  27160. source: any;
  27161. /** The X mouse cursor position at the time of the event */
  27162. pointerX: number;
  27163. /** The Y mouse cursor position at the time of the event */
  27164. pointerY: number;
  27165. /** The mesh that is currently pointed at (can be null) */
  27166. meshUnderPointer: Nullable<AbstractMesh>;
  27167. /** the original (browser) event that triggered the ActionEvent */
  27168. sourceEvent?: any;
  27169. /** additional data for the event */
  27170. additionalData?: any;
  27171. /**
  27172. * Creates a new ActionEvent
  27173. * @param source The mesh or sprite that triggered the action
  27174. * @param pointerX The X mouse cursor position at the time of the event
  27175. * @param pointerY The Y mouse cursor position at the time of the event
  27176. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27177. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27178. * @param additionalData additional data for the event
  27179. */
  27180. constructor(
  27181. /** The mesh or sprite that triggered the action */
  27182. source: any,
  27183. /** The X mouse cursor position at the time of the event */
  27184. pointerX: number,
  27185. /** The Y mouse cursor position at the time of the event */
  27186. pointerY: number,
  27187. /** The mesh that is currently pointed at (can be null) */
  27188. meshUnderPointer: Nullable<AbstractMesh>,
  27189. /** the original (browser) event that triggered the ActionEvent */
  27190. sourceEvent?: any,
  27191. /** additional data for the event */
  27192. additionalData?: any);
  27193. /**
  27194. * Helper function to auto-create an ActionEvent from a source mesh.
  27195. * @param source The source mesh that triggered the event
  27196. * @param evt The original (browser) event
  27197. * @param additionalData additional data for the event
  27198. * @returns the new ActionEvent
  27199. */
  27200. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27201. /**
  27202. * Helper function to auto-create an ActionEvent from a source sprite
  27203. * @param source The source sprite that triggered the event
  27204. * @param scene Scene associated with the sprite
  27205. * @param evt The original (browser) event
  27206. * @param additionalData additional data for the event
  27207. * @returns the new ActionEvent
  27208. */
  27209. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27210. /**
  27211. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27212. * @param scene the scene where the event occurred
  27213. * @param evt The original (browser) event
  27214. * @returns the new ActionEvent
  27215. */
  27216. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27217. /**
  27218. * Helper function to auto-create an ActionEvent from a primitive
  27219. * @param prim defines the target primitive
  27220. * @param pointerPos defines the pointer position
  27221. * @param evt The original (browser) event
  27222. * @param additionalData additional data for the event
  27223. * @returns the new ActionEvent
  27224. */
  27225. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27226. }
  27227. }
  27228. declare module "babylonjs/Actions/abstractActionManager" {
  27229. import { IDisposable } from "babylonjs/scene";
  27230. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27231. import { IAction } from "babylonjs/Actions/action";
  27232. import { Nullable } from "babylonjs/types";
  27233. /**
  27234. * Abstract class used to decouple action Manager from scene and meshes.
  27235. * Do not instantiate.
  27236. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27237. */
  27238. export abstract class AbstractActionManager implements IDisposable {
  27239. /** Gets the list of active triggers */
  27240. static Triggers: {
  27241. [key: string]: number;
  27242. };
  27243. /** Gets the cursor to use when hovering items */
  27244. hoverCursor: string;
  27245. /** Gets the list of actions */
  27246. actions: IAction[];
  27247. /**
  27248. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27249. */
  27250. isRecursive: boolean;
  27251. /**
  27252. * Releases all associated resources
  27253. */
  27254. abstract dispose(): void;
  27255. /**
  27256. * Does this action manager has pointer triggers
  27257. */
  27258. abstract readonly hasPointerTriggers: boolean;
  27259. /**
  27260. * Does this action manager has pick triggers
  27261. */
  27262. abstract readonly hasPickTriggers: boolean;
  27263. /**
  27264. * Process a specific trigger
  27265. * @param trigger defines the trigger to process
  27266. * @param evt defines the event details to be processed
  27267. */
  27268. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27269. /**
  27270. * Does this action manager handles actions of any of the given triggers
  27271. * @param triggers defines the triggers to be tested
  27272. * @return a boolean indicating whether one (or more) of the triggers is handled
  27273. */
  27274. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27275. /**
  27276. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27277. * speed.
  27278. * @param triggerA defines the trigger to be tested
  27279. * @param triggerB defines the trigger to be tested
  27280. * @return a boolean indicating whether one (or more) of the triggers is handled
  27281. */
  27282. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27283. /**
  27284. * Does this action manager handles actions of a given trigger
  27285. * @param trigger defines the trigger to be tested
  27286. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27287. * @return whether the trigger is handled
  27288. */
  27289. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27290. /**
  27291. * Serialize this manager to a JSON object
  27292. * @param name defines the property name to store this manager
  27293. * @returns a JSON representation of this manager
  27294. */
  27295. abstract serialize(name: string): any;
  27296. /**
  27297. * Registers an action to this action manager
  27298. * @param action defines the action to be registered
  27299. * @return the action amended (prepared) after registration
  27300. */
  27301. abstract registerAction(action: IAction): Nullable<IAction>;
  27302. /**
  27303. * Unregisters an action to this action manager
  27304. * @param action defines the action to be unregistered
  27305. * @return a boolean indicating whether the action has been unregistered
  27306. */
  27307. abstract unregisterAction(action: IAction): Boolean;
  27308. /**
  27309. * Does exist one action manager with at least one trigger
  27310. **/
  27311. static readonly HasTriggers: boolean;
  27312. /**
  27313. * Does exist one action manager with at least one pick trigger
  27314. **/
  27315. static readonly HasPickTriggers: boolean;
  27316. /**
  27317. * Does exist one action manager that handles actions of a given trigger
  27318. * @param trigger defines the trigger to be tested
  27319. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27320. **/
  27321. static HasSpecificTrigger(trigger: number): boolean;
  27322. }
  27323. }
  27324. declare module "babylonjs/node" {
  27325. import { Scene } from "babylonjs/scene";
  27326. import { Nullable } from "babylonjs/types";
  27327. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27328. import { Engine } from "babylonjs/Engines/engine";
  27329. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27330. import { Observable } from "babylonjs/Misc/observable";
  27331. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27332. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27333. import { Animatable } from "babylonjs/Animations/animatable";
  27334. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27335. import { Animation } from "babylonjs/Animations/animation";
  27336. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27338. /**
  27339. * Defines how a node can be built from a string name.
  27340. */
  27341. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27342. /**
  27343. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27344. */
  27345. export class Node implements IBehaviorAware<Node> {
  27346. /** @hidden */
  27347. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27348. private static _NodeConstructors;
  27349. /**
  27350. * Add a new node constructor
  27351. * @param type defines the type name of the node to construct
  27352. * @param constructorFunc defines the constructor function
  27353. */
  27354. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27355. /**
  27356. * Returns a node constructor based on type name
  27357. * @param type defines the type name
  27358. * @param name defines the new node name
  27359. * @param scene defines the hosting scene
  27360. * @param options defines optional options to transmit to constructors
  27361. * @returns the new constructor or null
  27362. */
  27363. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27364. /**
  27365. * Gets or sets the name of the node
  27366. */
  27367. name: string;
  27368. /**
  27369. * Gets or sets the id of the node
  27370. */
  27371. id: string;
  27372. /**
  27373. * Gets or sets the unique id of the node
  27374. */
  27375. uniqueId: number;
  27376. /**
  27377. * Gets or sets a string used to store user defined state for the node
  27378. */
  27379. state: string;
  27380. /**
  27381. * Gets or sets an object used to store user defined information for the node
  27382. */
  27383. metadata: any;
  27384. /**
  27385. * For internal use only. Please do not use.
  27386. */
  27387. reservedDataStore: any;
  27388. /**
  27389. * List of inspectable custom properties (used by the Inspector)
  27390. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27391. */
  27392. inspectableCustomProperties: IInspectable[];
  27393. /**
  27394. * Gets or sets a boolean used to define if the node must be serialized
  27395. */
  27396. doNotSerialize: boolean;
  27397. /** @hidden */
  27398. _isDisposed: boolean;
  27399. /**
  27400. * Gets a list of Animations associated with the node
  27401. */
  27402. animations: import("babylonjs/Animations/animation").Animation[];
  27403. protected _ranges: {
  27404. [name: string]: Nullable<AnimationRange>;
  27405. };
  27406. /**
  27407. * Callback raised when the node is ready to be used
  27408. */
  27409. onReady: Nullable<(node: Node) => void>;
  27410. private _isEnabled;
  27411. private _isParentEnabled;
  27412. private _isReady;
  27413. /** @hidden */
  27414. _currentRenderId: number;
  27415. private _parentUpdateId;
  27416. /** @hidden */
  27417. _childUpdateId: number;
  27418. /** @hidden */
  27419. _waitingParentId: Nullable<string>;
  27420. /** @hidden */
  27421. _scene: Scene;
  27422. /** @hidden */
  27423. _cache: any;
  27424. private _parentNode;
  27425. private _children;
  27426. /** @hidden */
  27427. _worldMatrix: Matrix;
  27428. /** @hidden */
  27429. _worldMatrixDeterminant: number;
  27430. /** @hidden */
  27431. _worldMatrixDeterminantIsDirty: boolean;
  27432. /** @hidden */
  27433. private _sceneRootNodesIndex;
  27434. /**
  27435. * Gets a boolean indicating if the node has been disposed
  27436. * @returns true if the node was disposed
  27437. */
  27438. isDisposed(): boolean;
  27439. /**
  27440. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27441. * @see https://doc.babylonjs.com/how_to/parenting
  27442. */
  27443. parent: Nullable<Node>;
  27444. private addToSceneRootNodes;
  27445. private removeFromSceneRootNodes;
  27446. private _animationPropertiesOverride;
  27447. /**
  27448. * Gets or sets the animation properties override
  27449. */
  27450. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27451. /**
  27452. * Gets a string idenfifying the name of the class
  27453. * @returns "Node" string
  27454. */
  27455. getClassName(): string;
  27456. /** @hidden */
  27457. readonly _isNode: boolean;
  27458. /**
  27459. * An event triggered when the mesh is disposed
  27460. */
  27461. onDisposeObservable: Observable<Node>;
  27462. private _onDisposeObserver;
  27463. /**
  27464. * Sets a callback that will be raised when the node will be disposed
  27465. */
  27466. onDispose: () => void;
  27467. /**
  27468. * Creates a new Node
  27469. * @param name the name and id to be given to this node
  27470. * @param scene the scene this node will be added to
  27471. * @param addToRootNodes the node will be added to scene.rootNodes
  27472. */
  27473. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27474. /**
  27475. * Gets the scene of the node
  27476. * @returns a scene
  27477. */
  27478. getScene(): Scene;
  27479. /**
  27480. * Gets the engine of the node
  27481. * @returns a Engine
  27482. */
  27483. getEngine(): Engine;
  27484. private _behaviors;
  27485. /**
  27486. * Attach a behavior to the node
  27487. * @see http://doc.babylonjs.com/features/behaviour
  27488. * @param behavior defines the behavior to attach
  27489. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27490. * @returns the current Node
  27491. */
  27492. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27493. /**
  27494. * Remove an attached behavior
  27495. * @see http://doc.babylonjs.com/features/behaviour
  27496. * @param behavior defines the behavior to attach
  27497. * @returns the current Node
  27498. */
  27499. removeBehavior(behavior: Behavior<Node>): Node;
  27500. /**
  27501. * Gets the list of attached behaviors
  27502. * @see http://doc.babylonjs.com/features/behaviour
  27503. */
  27504. readonly behaviors: Behavior<Node>[];
  27505. /**
  27506. * Gets an attached behavior by name
  27507. * @param name defines the name of the behavior to look for
  27508. * @see http://doc.babylonjs.com/features/behaviour
  27509. * @returns null if behavior was not found else the requested behavior
  27510. */
  27511. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27512. /**
  27513. * Returns the latest update of the World matrix
  27514. * @returns a Matrix
  27515. */
  27516. getWorldMatrix(): Matrix;
  27517. /** @hidden */
  27518. _getWorldMatrixDeterminant(): number;
  27519. /**
  27520. * Returns directly the latest state of the mesh World matrix.
  27521. * A Matrix is returned.
  27522. */
  27523. readonly worldMatrixFromCache: Matrix;
  27524. /** @hidden */
  27525. _initCache(): void;
  27526. /** @hidden */
  27527. updateCache(force?: boolean): void;
  27528. /** @hidden */
  27529. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27530. /** @hidden */
  27531. _updateCache(ignoreParentClass?: boolean): void;
  27532. /** @hidden */
  27533. _isSynchronized(): boolean;
  27534. /** @hidden */
  27535. _markSyncedWithParent(): void;
  27536. /** @hidden */
  27537. isSynchronizedWithParent(): boolean;
  27538. /** @hidden */
  27539. isSynchronized(): boolean;
  27540. /**
  27541. * Is this node ready to be used/rendered
  27542. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27543. * @return true if the node is ready
  27544. */
  27545. isReady(completeCheck?: boolean): boolean;
  27546. /**
  27547. * Is this node enabled?
  27548. * 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
  27549. * @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
  27550. * @return whether this node (and its parent) is enabled
  27551. */
  27552. isEnabled(checkAncestors?: boolean): boolean;
  27553. /** @hidden */
  27554. protected _syncParentEnabledState(): void;
  27555. /**
  27556. * Set the enabled state of this node
  27557. * @param value defines the new enabled state
  27558. */
  27559. setEnabled(value: boolean): void;
  27560. /**
  27561. * Is this node a descendant of the given node?
  27562. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27563. * @param ancestor defines the parent node to inspect
  27564. * @returns a boolean indicating if this node is a descendant of the given node
  27565. */
  27566. isDescendantOf(ancestor: Node): boolean;
  27567. /** @hidden */
  27568. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27569. /**
  27570. * Will return all nodes that have this node as ascendant
  27571. * @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
  27572. * @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
  27573. * @return all children nodes of all types
  27574. */
  27575. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27576. /**
  27577. * Get all child-meshes of this node
  27578. * @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)
  27579. * @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
  27580. * @returns an array of AbstractMesh
  27581. */
  27582. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27583. /**
  27584. * Get all direct children of this node
  27585. * @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
  27586. * @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)
  27587. * @returns an array of Node
  27588. */
  27589. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27590. /** @hidden */
  27591. _setReady(state: boolean): void;
  27592. /**
  27593. * Get an animation by name
  27594. * @param name defines the name of the animation to look for
  27595. * @returns null if not found else the requested animation
  27596. */
  27597. getAnimationByName(name: string): Nullable<Animation>;
  27598. /**
  27599. * Creates an animation range for this node
  27600. * @param name defines the name of the range
  27601. * @param from defines the starting key
  27602. * @param to defines the end key
  27603. */
  27604. createAnimationRange(name: string, from: number, to: number): void;
  27605. /**
  27606. * Delete a specific animation range
  27607. * @param name defines the name of the range to delete
  27608. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27609. */
  27610. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27611. /**
  27612. * Get an animation range by name
  27613. * @param name defines the name of the animation range to look for
  27614. * @returns null if not found else the requested animation range
  27615. */
  27616. getAnimationRange(name: string): Nullable<AnimationRange>;
  27617. /**
  27618. * Gets the list of all animation ranges defined on this node
  27619. * @returns an array
  27620. */
  27621. getAnimationRanges(): Nullable<AnimationRange>[];
  27622. /**
  27623. * Will start the animation sequence
  27624. * @param name defines the range frames for animation sequence
  27625. * @param loop defines if the animation should loop (false by default)
  27626. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27627. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27628. * @returns the object created for this animation. If range does not exist, it will return null
  27629. */
  27630. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27631. /**
  27632. * Serialize animation ranges into a JSON compatible object
  27633. * @returns serialization object
  27634. */
  27635. serializeAnimationRanges(): any;
  27636. /**
  27637. * Computes the world matrix of the node
  27638. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27639. * @returns the world matrix
  27640. */
  27641. computeWorldMatrix(force?: boolean): Matrix;
  27642. /**
  27643. * Releases resources associated with this node.
  27644. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27645. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27646. */
  27647. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27648. /**
  27649. * Parse animation range data from a serialization object and store them into a given node
  27650. * @param node defines where to store the animation ranges
  27651. * @param parsedNode defines the serialization object to read data from
  27652. * @param scene defines the hosting scene
  27653. */
  27654. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27655. /**
  27656. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27657. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27658. * @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
  27659. * @returns the new bounding vectors
  27660. */
  27661. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27662. min: Vector3;
  27663. max: Vector3;
  27664. };
  27665. }
  27666. }
  27667. declare module "babylonjs/Animations/animation" {
  27668. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27669. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27670. import { Color3 } from "babylonjs/Maths/math.color";
  27671. import { Nullable } from "babylonjs/types";
  27672. import { Scene } from "babylonjs/scene";
  27673. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27674. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27675. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27676. import { Node } from "babylonjs/node";
  27677. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27678. import { Size } from "babylonjs/Maths/math.size";
  27679. import { Animatable } from "babylonjs/Animations/animatable";
  27680. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27681. /**
  27682. * @hidden
  27683. */
  27684. export class _IAnimationState {
  27685. key: number;
  27686. repeatCount: number;
  27687. workValue?: any;
  27688. loopMode?: number;
  27689. offsetValue?: any;
  27690. highLimitValue?: any;
  27691. }
  27692. /**
  27693. * Class used to store any kind of animation
  27694. */
  27695. export class Animation {
  27696. /**Name of the animation */
  27697. name: string;
  27698. /**Property to animate */
  27699. targetProperty: string;
  27700. /**The frames per second of the animation */
  27701. framePerSecond: number;
  27702. /**The data type of the animation */
  27703. dataType: number;
  27704. /**The loop mode of the animation */
  27705. loopMode?: number | undefined;
  27706. /**Specifies if blending should be enabled */
  27707. enableBlending?: boolean | undefined;
  27708. /**
  27709. * Use matrix interpolation instead of using direct key value when animating matrices
  27710. */
  27711. static AllowMatricesInterpolation: boolean;
  27712. /**
  27713. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27714. */
  27715. static AllowMatrixDecomposeForInterpolation: boolean;
  27716. /**
  27717. * Stores the key frames of the animation
  27718. */
  27719. private _keys;
  27720. /**
  27721. * Stores the easing function of the animation
  27722. */
  27723. private _easingFunction;
  27724. /**
  27725. * @hidden Internal use only
  27726. */
  27727. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27728. /**
  27729. * The set of event that will be linked to this animation
  27730. */
  27731. private _events;
  27732. /**
  27733. * Stores an array of target property paths
  27734. */
  27735. targetPropertyPath: string[];
  27736. /**
  27737. * Stores the blending speed of the animation
  27738. */
  27739. blendingSpeed: number;
  27740. /**
  27741. * Stores the animation ranges for the animation
  27742. */
  27743. private _ranges;
  27744. /**
  27745. * @hidden Internal use
  27746. */
  27747. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27748. /**
  27749. * Sets up an animation
  27750. * @param property The property to animate
  27751. * @param animationType The animation type to apply
  27752. * @param framePerSecond The frames per second of the animation
  27753. * @param easingFunction The easing function used in the animation
  27754. * @returns The created animation
  27755. */
  27756. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27757. /**
  27758. * Create and start an animation on a node
  27759. * @param name defines the name of the global animation that will be run on all nodes
  27760. * @param node defines the root node where the animation will take place
  27761. * @param targetProperty defines property to animate
  27762. * @param framePerSecond defines the number of frame per second yo use
  27763. * @param totalFrame defines the number of frames in total
  27764. * @param from defines the initial value
  27765. * @param to defines the final value
  27766. * @param loopMode defines which loop mode you want to use (off by default)
  27767. * @param easingFunction defines the easing function to use (linear by default)
  27768. * @param onAnimationEnd defines the callback to call when animation end
  27769. * @returns the animatable created for this animation
  27770. */
  27771. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27772. /**
  27773. * Create and start an animation on a node and its descendants
  27774. * @param name defines the name of the global animation that will be run on all nodes
  27775. * @param node defines the root node where the animation will take place
  27776. * @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
  27777. * @param targetProperty defines property to animate
  27778. * @param framePerSecond defines the number of frame per second to use
  27779. * @param totalFrame defines the number of frames in total
  27780. * @param from defines the initial value
  27781. * @param to defines the final value
  27782. * @param loopMode defines which loop mode you want to use (off by default)
  27783. * @param easingFunction defines the easing function to use (linear by default)
  27784. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27785. * @returns the list of animatables created for all nodes
  27786. * @example https://www.babylonjs-playground.com/#MH0VLI
  27787. */
  27788. 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[]>;
  27789. /**
  27790. * Creates a new animation, merges it with the existing animations and starts it
  27791. * @param name Name of the animation
  27792. * @param node Node which contains the scene that begins the animations
  27793. * @param targetProperty Specifies which property to animate
  27794. * @param framePerSecond The frames per second of the animation
  27795. * @param totalFrame The total number of frames
  27796. * @param from The frame at the beginning of the animation
  27797. * @param to The frame at the end of the animation
  27798. * @param loopMode Specifies the loop mode of the animation
  27799. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27800. * @param onAnimationEnd Callback to run once the animation is complete
  27801. * @returns Nullable animation
  27802. */
  27803. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27804. /**
  27805. * Transition property of an host to the target Value
  27806. * @param property The property to transition
  27807. * @param targetValue The target Value of the property
  27808. * @param host The object where the property to animate belongs
  27809. * @param scene Scene used to run the animation
  27810. * @param frameRate Framerate (in frame/s) to use
  27811. * @param transition The transition type we want to use
  27812. * @param duration The duration of the animation, in milliseconds
  27813. * @param onAnimationEnd Callback trigger at the end of the animation
  27814. * @returns Nullable animation
  27815. */
  27816. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27817. /**
  27818. * Return the array of runtime animations currently using this animation
  27819. */
  27820. readonly runtimeAnimations: RuntimeAnimation[];
  27821. /**
  27822. * Specifies if any of the runtime animations are currently running
  27823. */
  27824. readonly hasRunningRuntimeAnimations: boolean;
  27825. /**
  27826. * Initializes the animation
  27827. * @param name Name of the animation
  27828. * @param targetProperty Property to animate
  27829. * @param framePerSecond The frames per second of the animation
  27830. * @param dataType The data type of the animation
  27831. * @param loopMode The loop mode of the animation
  27832. * @param enableBlending Specifies if blending should be enabled
  27833. */
  27834. constructor(
  27835. /**Name of the animation */
  27836. name: string,
  27837. /**Property to animate */
  27838. targetProperty: string,
  27839. /**The frames per second of the animation */
  27840. framePerSecond: number,
  27841. /**The data type of the animation */
  27842. dataType: number,
  27843. /**The loop mode of the animation */
  27844. loopMode?: number | undefined,
  27845. /**Specifies if blending should be enabled */
  27846. enableBlending?: boolean | undefined);
  27847. /**
  27848. * Converts the animation to a string
  27849. * @param fullDetails support for multiple levels of logging within scene loading
  27850. * @returns String form of the animation
  27851. */
  27852. toString(fullDetails?: boolean): string;
  27853. /**
  27854. * Add an event to this animation
  27855. * @param event Event to add
  27856. */
  27857. addEvent(event: AnimationEvent): void;
  27858. /**
  27859. * Remove all events found at the given frame
  27860. * @param frame The frame to remove events from
  27861. */
  27862. removeEvents(frame: number): void;
  27863. /**
  27864. * Retrieves all the events from the animation
  27865. * @returns Events from the animation
  27866. */
  27867. getEvents(): AnimationEvent[];
  27868. /**
  27869. * Creates an animation range
  27870. * @param name Name of the animation range
  27871. * @param from Starting frame of the animation range
  27872. * @param to Ending frame of the animation
  27873. */
  27874. createRange(name: string, from: number, to: number): void;
  27875. /**
  27876. * Deletes an animation range by name
  27877. * @param name Name of the animation range to delete
  27878. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27879. */
  27880. deleteRange(name: string, deleteFrames?: boolean): void;
  27881. /**
  27882. * Gets the animation range by name, or null if not defined
  27883. * @param name Name of the animation range
  27884. * @returns Nullable animation range
  27885. */
  27886. getRange(name: string): Nullable<AnimationRange>;
  27887. /**
  27888. * Gets the key frames from the animation
  27889. * @returns The key frames of the animation
  27890. */
  27891. getKeys(): Array<IAnimationKey>;
  27892. /**
  27893. * Gets the highest frame rate of the animation
  27894. * @returns Highest frame rate of the animation
  27895. */
  27896. getHighestFrame(): number;
  27897. /**
  27898. * Gets the easing function of the animation
  27899. * @returns Easing function of the animation
  27900. */
  27901. getEasingFunction(): IEasingFunction;
  27902. /**
  27903. * Sets the easing function of the animation
  27904. * @param easingFunction A custom mathematical formula for animation
  27905. */
  27906. setEasingFunction(easingFunction: EasingFunction): void;
  27907. /**
  27908. * Interpolates a scalar linearly
  27909. * @param startValue Start value of the animation curve
  27910. * @param endValue End value of the animation curve
  27911. * @param gradient Scalar amount to interpolate
  27912. * @returns Interpolated scalar value
  27913. */
  27914. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27915. /**
  27916. * Interpolates a scalar cubically
  27917. * @param startValue Start value of the animation curve
  27918. * @param outTangent End tangent of the animation
  27919. * @param endValue End value of the animation curve
  27920. * @param inTangent Start tangent of the animation curve
  27921. * @param gradient Scalar amount to interpolate
  27922. * @returns Interpolated scalar value
  27923. */
  27924. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27925. /**
  27926. * Interpolates a quaternion using a spherical linear interpolation
  27927. * @param startValue Start value of the animation curve
  27928. * @param endValue End value of the animation curve
  27929. * @param gradient Scalar amount to interpolate
  27930. * @returns Interpolated quaternion value
  27931. */
  27932. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27933. /**
  27934. * Interpolates a quaternion cubically
  27935. * @param startValue Start value of the animation curve
  27936. * @param outTangent End tangent of the animation curve
  27937. * @param endValue End value of the animation curve
  27938. * @param inTangent Start tangent of the animation curve
  27939. * @param gradient Scalar amount to interpolate
  27940. * @returns Interpolated quaternion value
  27941. */
  27942. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27943. /**
  27944. * Interpolates a Vector3 linearl
  27945. * @param startValue Start value of the animation curve
  27946. * @param endValue End value of the animation curve
  27947. * @param gradient Scalar amount to interpolate
  27948. * @returns Interpolated scalar value
  27949. */
  27950. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27951. /**
  27952. * Interpolates a Vector3 cubically
  27953. * @param startValue Start value of the animation curve
  27954. * @param outTangent End tangent of the animation
  27955. * @param endValue End value of the animation curve
  27956. * @param inTangent Start tangent of the animation curve
  27957. * @param gradient Scalar amount to interpolate
  27958. * @returns InterpolatedVector3 value
  27959. */
  27960. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27961. /**
  27962. * Interpolates a Vector2 linearly
  27963. * @param startValue Start value of the animation curve
  27964. * @param endValue End value of the animation curve
  27965. * @param gradient Scalar amount to interpolate
  27966. * @returns Interpolated Vector2 value
  27967. */
  27968. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27969. /**
  27970. * Interpolates a Vector2 cubically
  27971. * @param startValue Start value of the animation curve
  27972. * @param outTangent End tangent of the animation
  27973. * @param endValue End value of the animation curve
  27974. * @param inTangent Start tangent of the animation curve
  27975. * @param gradient Scalar amount to interpolate
  27976. * @returns Interpolated Vector2 value
  27977. */
  27978. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27979. /**
  27980. * Interpolates a size linearly
  27981. * @param startValue Start value of the animation curve
  27982. * @param endValue End value of the animation curve
  27983. * @param gradient Scalar amount to interpolate
  27984. * @returns Interpolated Size value
  27985. */
  27986. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27987. /**
  27988. * Interpolates a Color3 linearly
  27989. * @param startValue Start value of the animation curve
  27990. * @param endValue End value of the animation curve
  27991. * @param gradient Scalar amount to interpolate
  27992. * @returns Interpolated Color3 value
  27993. */
  27994. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27995. /**
  27996. * @hidden Internal use only
  27997. */
  27998. _getKeyValue(value: any): any;
  27999. /**
  28000. * @hidden Internal use only
  28001. */
  28002. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28003. /**
  28004. * Defines the function to use to interpolate matrices
  28005. * @param startValue defines the start matrix
  28006. * @param endValue defines the end matrix
  28007. * @param gradient defines the gradient between both matrices
  28008. * @param result defines an optional target matrix where to store the interpolation
  28009. * @returns the interpolated matrix
  28010. */
  28011. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28012. /**
  28013. * Makes a copy of the animation
  28014. * @returns Cloned animation
  28015. */
  28016. clone(): Animation;
  28017. /**
  28018. * Sets the key frames of the animation
  28019. * @param values The animation key frames to set
  28020. */
  28021. setKeys(values: Array<IAnimationKey>): void;
  28022. /**
  28023. * Serializes the animation to an object
  28024. * @returns Serialized object
  28025. */
  28026. serialize(): any;
  28027. /**
  28028. * Float animation type
  28029. */
  28030. private static _ANIMATIONTYPE_FLOAT;
  28031. /**
  28032. * Vector3 animation type
  28033. */
  28034. private static _ANIMATIONTYPE_VECTOR3;
  28035. /**
  28036. * Quaternion animation type
  28037. */
  28038. private static _ANIMATIONTYPE_QUATERNION;
  28039. /**
  28040. * Matrix animation type
  28041. */
  28042. private static _ANIMATIONTYPE_MATRIX;
  28043. /**
  28044. * Color3 animation type
  28045. */
  28046. private static _ANIMATIONTYPE_COLOR3;
  28047. /**
  28048. * Vector2 animation type
  28049. */
  28050. private static _ANIMATIONTYPE_VECTOR2;
  28051. /**
  28052. * Size animation type
  28053. */
  28054. private static _ANIMATIONTYPE_SIZE;
  28055. /**
  28056. * Relative Loop Mode
  28057. */
  28058. private static _ANIMATIONLOOPMODE_RELATIVE;
  28059. /**
  28060. * Cycle Loop Mode
  28061. */
  28062. private static _ANIMATIONLOOPMODE_CYCLE;
  28063. /**
  28064. * Constant Loop Mode
  28065. */
  28066. private static _ANIMATIONLOOPMODE_CONSTANT;
  28067. /**
  28068. * Get the float animation type
  28069. */
  28070. static readonly ANIMATIONTYPE_FLOAT: number;
  28071. /**
  28072. * Get the Vector3 animation type
  28073. */
  28074. static readonly ANIMATIONTYPE_VECTOR3: number;
  28075. /**
  28076. * Get the Vector2 animation type
  28077. */
  28078. static readonly ANIMATIONTYPE_VECTOR2: number;
  28079. /**
  28080. * Get the Size animation type
  28081. */
  28082. static readonly ANIMATIONTYPE_SIZE: number;
  28083. /**
  28084. * Get the Quaternion animation type
  28085. */
  28086. static readonly ANIMATIONTYPE_QUATERNION: number;
  28087. /**
  28088. * Get the Matrix animation type
  28089. */
  28090. static readonly ANIMATIONTYPE_MATRIX: number;
  28091. /**
  28092. * Get the Color3 animation type
  28093. */
  28094. static readonly ANIMATIONTYPE_COLOR3: number;
  28095. /**
  28096. * Get the Relative Loop Mode
  28097. */
  28098. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28099. /**
  28100. * Get the Cycle Loop Mode
  28101. */
  28102. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28103. /**
  28104. * Get the Constant Loop Mode
  28105. */
  28106. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28107. /** @hidden */
  28108. static _UniversalLerp(left: any, right: any, amount: number): any;
  28109. /**
  28110. * Parses an animation object and creates an animation
  28111. * @param parsedAnimation Parsed animation object
  28112. * @returns Animation object
  28113. */
  28114. static Parse(parsedAnimation: any): Animation;
  28115. /**
  28116. * Appends the serialized animations from the source animations
  28117. * @param source Source containing the animations
  28118. * @param destination Target to store the animations
  28119. */
  28120. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28121. }
  28122. }
  28123. declare module "babylonjs/Animations/animatable.interface" {
  28124. import { Nullable } from "babylonjs/types";
  28125. import { Animation } from "babylonjs/Animations/animation";
  28126. /**
  28127. * Interface containing an array of animations
  28128. */
  28129. export interface IAnimatable {
  28130. /**
  28131. * Array of animations
  28132. */
  28133. animations: Nullable<Array<Animation>>;
  28134. }
  28135. }
  28136. declare module "babylonjs/Materials/fresnelParameters" {
  28137. import { Color3 } from "babylonjs/Maths/math.color";
  28138. /**
  28139. * This represents all the required information to add a fresnel effect on a material:
  28140. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28141. */
  28142. export class FresnelParameters {
  28143. private _isEnabled;
  28144. /**
  28145. * Define if the fresnel effect is enable or not.
  28146. */
  28147. isEnabled: boolean;
  28148. /**
  28149. * Define the color used on edges (grazing angle)
  28150. */
  28151. leftColor: Color3;
  28152. /**
  28153. * Define the color used on center
  28154. */
  28155. rightColor: Color3;
  28156. /**
  28157. * Define bias applied to computed fresnel term
  28158. */
  28159. bias: number;
  28160. /**
  28161. * Defined the power exponent applied to fresnel term
  28162. */
  28163. power: number;
  28164. /**
  28165. * Clones the current fresnel and its valuues
  28166. * @returns a clone fresnel configuration
  28167. */
  28168. clone(): FresnelParameters;
  28169. /**
  28170. * Serializes the current fresnel parameters to a JSON representation.
  28171. * @return the JSON serialization
  28172. */
  28173. serialize(): any;
  28174. /**
  28175. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28176. * @param parsedFresnelParameters Define the JSON representation
  28177. * @returns the parsed parameters
  28178. */
  28179. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28180. }
  28181. }
  28182. declare module "babylonjs/Misc/decorators" {
  28183. import { Nullable } from "babylonjs/types";
  28184. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28185. import { Scene } from "babylonjs/scene";
  28186. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28187. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28188. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28189. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28190. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28191. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28192. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28193. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28194. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28195. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28196. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28197. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28198. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28199. /**
  28200. * Decorator used to define property that can be serialized as reference to a camera
  28201. * @param sourceName defines the name of the property to decorate
  28202. */
  28203. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28204. /**
  28205. * Class used to help serialization objects
  28206. */
  28207. export class SerializationHelper {
  28208. /** @hidden */
  28209. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28210. /** @hidden */
  28211. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28212. /** @hidden */
  28213. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28214. /** @hidden */
  28215. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28216. /**
  28217. * Appends the serialized animations from the source animations
  28218. * @param source Source containing the animations
  28219. * @param destination Target to store the animations
  28220. */
  28221. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28222. /**
  28223. * Static function used to serialized a specific entity
  28224. * @param entity defines the entity to serialize
  28225. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28226. * @returns a JSON compatible object representing the serialization of the entity
  28227. */
  28228. static Serialize<T>(entity: T, serializationObject?: any): any;
  28229. /**
  28230. * Creates a new entity from a serialization data object
  28231. * @param creationFunction defines a function used to instanciated the new entity
  28232. * @param source defines the source serialization data
  28233. * @param scene defines the hosting scene
  28234. * @param rootUrl defines the root url for resources
  28235. * @returns a new entity
  28236. */
  28237. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28238. /**
  28239. * Clones an object
  28240. * @param creationFunction defines the function used to instanciate the new object
  28241. * @param source defines the source object
  28242. * @returns the cloned object
  28243. */
  28244. static Clone<T>(creationFunction: () => T, source: T): T;
  28245. /**
  28246. * Instanciates a new object based on a source one (some data will be shared between both object)
  28247. * @param creationFunction defines the function used to instanciate the new object
  28248. * @param source defines the source object
  28249. * @returns the new object
  28250. */
  28251. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28252. }
  28253. }
  28254. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28255. import { Nullable } from "babylonjs/types";
  28256. /**
  28257. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28258. */
  28259. export interface CubeMapInfo {
  28260. /**
  28261. * The pixel array for the front face.
  28262. * This is stored in format, left to right, up to down format.
  28263. */
  28264. front: Nullable<ArrayBufferView>;
  28265. /**
  28266. * The pixel array for the back face.
  28267. * This is stored in format, left to right, up to down format.
  28268. */
  28269. back: Nullable<ArrayBufferView>;
  28270. /**
  28271. * The pixel array for the left face.
  28272. * This is stored in format, left to right, up to down format.
  28273. */
  28274. left: Nullable<ArrayBufferView>;
  28275. /**
  28276. * The pixel array for the right face.
  28277. * This is stored in format, left to right, up to down format.
  28278. */
  28279. right: Nullable<ArrayBufferView>;
  28280. /**
  28281. * The pixel array for the up face.
  28282. * This is stored in format, left to right, up to down format.
  28283. */
  28284. up: Nullable<ArrayBufferView>;
  28285. /**
  28286. * The pixel array for the down face.
  28287. * This is stored in format, left to right, up to down format.
  28288. */
  28289. down: Nullable<ArrayBufferView>;
  28290. /**
  28291. * The size of the cubemap stored.
  28292. *
  28293. * Each faces will be size * size pixels.
  28294. */
  28295. size: number;
  28296. /**
  28297. * The format of the texture.
  28298. *
  28299. * RGBA, RGB.
  28300. */
  28301. format: number;
  28302. /**
  28303. * The type of the texture data.
  28304. *
  28305. * UNSIGNED_INT, FLOAT.
  28306. */
  28307. type: number;
  28308. /**
  28309. * Specifies whether the texture is in gamma space.
  28310. */
  28311. gammaSpace: boolean;
  28312. }
  28313. /**
  28314. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28315. */
  28316. export class PanoramaToCubeMapTools {
  28317. private static FACE_FRONT;
  28318. private static FACE_BACK;
  28319. private static FACE_RIGHT;
  28320. private static FACE_LEFT;
  28321. private static FACE_DOWN;
  28322. private static FACE_UP;
  28323. /**
  28324. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28325. *
  28326. * @param float32Array The source data.
  28327. * @param inputWidth The width of the input panorama.
  28328. * @param inputHeight The height of the input panorama.
  28329. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28330. * @return The cubemap data
  28331. */
  28332. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28333. private static CreateCubemapTexture;
  28334. private static CalcProjectionSpherical;
  28335. }
  28336. }
  28337. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28338. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28339. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28340. import { Nullable } from "babylonjs/types";
  28341. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28342. /**
  28343. * Helper class dealing with the extraction of spherical polynomial dataArray
  28344. * from a cube map.
  28345. */
  28346. export class CubeMapToSphericalPolynomialTools {
  28347. private static FileFaces;
  28348. /**
  28349. * Converts a texture to the according Spherical Polynomial data.
  28350. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28351. *
  28352. * @param texture The texture to extract the information from.
  28353. * @return The Spherical Polynomial data.
  28354. */
  28355. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28356. /**
  28357. * Converts a cubemap to the according Spherical Polynomial data.
  28358. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28359. *
  28360. * @param cubeInfo The Cube map to extract the information from.
  28361. * @return The Spherical Polynomial data.
  28362. */
  28363. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28364. }
  28365. }
  28366. declare module "babylonjs/Misc/guid" {
  28367. /**
  28368. * Class used to manipulate GUIDs
  28369. */
  28370. export class GUID {
  28371. /**
  28372. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28373. * Be aware Math.random() could cause collisions, but:
  28374. * "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"
  28375. * @returns a pseudo random id
  28376. */
  28377. static RandomId(): string;
  28378. }
  28379. }
  28380. declare module "babylonjs/Materials/Textures/baseTexture" {
  28381. import { Observable } from "babylonjs/Misc/observable";
  28382. import { Nullable } from "babylonjs/types";
  28383. import { Scene } from "babylonjs/scene";
  28384. import { Matrix } from "babylonjs/Maths/math.vector";
  28385. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28386. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28387. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28388. import { ISize } from "babylonjs/Maths/math.size";
  28389. /**
  28390. * Base class of all the textures in babylon.
  28391. * It groups all the common properties the materials, post process, lights... might need
  28392. * in order to make a correct use of the texture.
  28393. */
  28394. export class BaseTexture implements IAnimatable {
  28395. /**
  28396. * Default anisotropic filtering level for the application.
  28397. * It is set to 4 as a good tradeoff between perf and quality.
  28398. */
  28399. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28400. /**
  28401. * Gets or sets the unique id of the texture
  28402. */
  28403. uniqueId: number;
  28404. /**
  28405. * Define the name of the texture.
  28406. */
  28407. name: string;
  28408. /**
  28409. * Gets or sets an object used to store user defined information.
  28410. */
  28411. metadata: any;
  28412. /**
  28413. * For internal use only. Please do not use.
  28414. */
  28415. reservedDataStore: any;
  28416. private _hasAlpha;
  28417. /**
  28418. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28419. */
  28420. hasAlpha: boolean;
  28421. /**
  28422. * Defines if the alpha value should be determined via the rgb values.
  28423. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28424. */
  28425. getAlphaFromRGB: boolean;
  28426. /**
  28427. * Intensity or strength of the texture.
  28428. * It is commonly used by materials to fine tune the intensity of the texture
  28429. */
  28430. level: number;
  28431. /**
  28432. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28433. * This is part of the texture as textures usually maps to one uv set.
  28434. */
  28435. coordinatesIndex: number;
  28436. private _coordinatesMode;
  28437. /**
  28438. * How a texture is mapped.
  28439. *
  28440. * | Value | Type | Description |
  28441. * | ----- | ----------------------------------- | ----------- |
  28442. * | 0 | EXPLICIT_MODE | |
  28443. * | 1 | SPHERICAL_MODE | |
  28444. * | 2 | PLANAR_MODE | |
  28445. * | 3 | CUBIC_MODE | |
  28446. * | 4 | PROJECTION_MODE | |
  28447. * | 5 | SKYBOX_MODE | |
  28448. * | 6 | INVCUBIC_MODE | |
  28449. * | 7 | EQUIRECTANGULAR_MODE | |
  28450. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28451. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28452. */
  28453. coordinatesMode: number;
  28454. /**
  28455. * | Value | Type | Description |
  28456. * | ----- | ------------------ | ----------- |
  28457. * | 0 | CLAMP_ADDRESSMODE | |
  28458. * | 1 | WRAP_ADDRESSMODE | |
  28459. * | 2 | MIRROR_ADDRESSMODE | |
  28460. */
  28461. wrapU: number;
  28462. /**
  28463. * | Value | Type | Description |
  28464. * | ----- | ------------------ | ----------- |
  28465. * | 0 | CLAMP_ADDRESSMODE | |
  28466. * | 1 | WRAP_ADDRESSMODE | |
  28467. * | 2 | MIRROR_ADDRESSMODE | |
  28468. */
  28469. wrapV: number;
  28470. /**
  28471. * | Value | Type | Description |
  28472. * | ----- | ------------------ | ----------- |
  28473. * | 0 | CLAMP_ADDRESSMODE | |
  28474. * | 1 | WRAP_ADDRESSMODE | |
  28475. * | 2 | MIRROR_ADDRESSMODE | |
  28476. */
  28477. wrapR: number;
  28478. /**
  28479. * With compliant hardware and browser (supporting anisotropic filtering)
  28480. * this defines the level of anisotropic filtering in the texture.
  28481. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28482. */
  28483. anisotropicFilteringLevel: number;
  28484. /**
  28485. * Define if the texture is a cube texture or if false a 2d texture.
  28486. */
  28487. isCube: boolean;
  28488. /**
  28489. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28490. */
  28491. is3D: boolean;
  28492. /**
  28493. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28494. * HDR texture are usually stored in linear space.
  28495. * This only impacts the PBR and Background materials
  28496. */
  28497. gammaSpace: boolean;
  28498. /**
  28499. * Gets or sets whether or not the texture contains RGBD data.
  28500. */
  28501. isRGBD: boolean;
  28502. /**
  28503. * Is Z inverted in the texture (useful in a cube texture).
  28504. */
  28505. invertZ: boolean;
  28506. /**
  28507. * Are mip maps generated for this texture or not.
  28508. */
  28509. readonly noMipmap: boolean;
  28510. /**
  28511. * @hidden
  28512. */
  28513. lodLevelInAlpha: boolean;
  28514. /**
  28515. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28516. */
  28517. lodGenerationOffset: number;
  28518. /**
  28519. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28520. */
  28521. lodGenerationScale: number;
  28522. /**
  28523. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28524. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28525. * average roughness values.
  28526. */
  28527. linearSpecularLOD: boolean;
  28528. /**
  28529. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28530. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28531. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28532. */
  28533. irradianceTexture: Nullable<BaseTexture>;
  28534. /**
  28535. * Define if the texture is a render target.
  28536. */
  28537. isRenderTarget: boolean;
  28538. /**
  28539. * Define the unique id of the texture in the scene.
  28540. */
  28541. readonly uid: string;
  28542. /**
  28543. * Return a string representation of the texture.
  28544. * @returns the texture as a string
  28545. */
  28546. toString(): string;
  28547. /**
  28548. * Get the class name of the texture.
  28549. * @returns "BaseTexture"
  28550. */
  28551. getClassName(): string;
  28552. /**
  28553. * Define the list of animation attached to the texture.
  28554. */
  28555. animations: import("babylonjs/Animations/animation").Animation[];
  28556. /**
  28557. * An event triggered when the texture is disposed.
  28558. */
  28559. onDisposeObservable: Observable<BaseTexture>;
  28560. private _onDisposeObserver;
  28561. /**
  28562. * Callback triggered when the texture has been disposed.
  28563. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28564. */
  28565. onDispose: () => void;
  28566. /**
  28567. * Define the current state of the loading sequence when in delayed load mode.
  28568. */
  28569. delayLoadState: number;
  28570. private _scene;
  28571. /** @hidden */
  28572. _texture: Nullable<InternalTexture>;
  28573. private _uid;
  28574. /**
  28575. * Define if the texture is preventinga material to render or not.
  28576. * If not and the texture is not ready, the engine will use a default black texture instead.
  28577. */
  28578. readonly isBlocking: boolean;
  28579. /**
  28580. * Instantiates a new BaseTexture.
  28581. * Base class of all the textures in babylon.
  28582. * It groups all the common properties the materials, post process, lights... might need
  28583. * in order to make a correct use of the texture.
  28584. * @param scene Define the scene the texture blongs to
  28585. */
  28586. constructor(scene: Nullable<Scene>);
  28587. /**
  28588. * Get the scene the texture belongs to.
  28589. * @returns the scene or null if undefined
  28590. */
  28591. getScene(): Nullable<Scene>;
  28592. /**
  28593. * Get the texture transform matrix used to offset tile the texture for istance.
  28594. * @returns the transformation matrix
  28595. */
  28596. getTextureMatrix(): Matrix;
  28597. /**
  28598. * Get the texture reflection matrix used to rotate/transform the reflection.
  28599. * @returns the reflection matrix
  28600. */
  28601. getReflectionTextureMatrix(): Matrix;
  28602. /**
  28603. * Get the underlying lower level texture from Babylon.
  28604. * @returns the insternal texture
  28605. */
  28606. getInternalTexture(): Nullable<InternalTexture>;
  28607. /**
  28608. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28609. * @returns true if ready or not blocking
  28610. */
  28611. isReadyOrNotBlocking(): boolean;
  28612. /**
  28613. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28614. * @returns true if fully ready
  28615. */
  28616. isReady(): boolean;
  28617. private _cachedSize;
  28618. /**
  28619. * Get the size of the texture.
  28620. * @returns the texture size.
  28621. */
  28622. getSize(): ISize;
  28623. /**
  28624. * Get the base size of the texture.
  28625. * It can be different from the size if the texture has been resized for POT for instance
  28626. * @returns the base size
  28627. */
  28628. getBaseSize(): ISize;
  28629. /**
  28630. * Update the sampling mode of the texture.
  28631. * Default is Trilinear mode.
  28632. *
  28633. * | Value | Type | Description |
  28634. * | ----- | ------------------ | ----------- |
  28635. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28636. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28637. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28638. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28639. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28640. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28641. * | 7 | NEAREST_LINEAR | |
  28642. * | 8 | NEAREST_NEAREST | |
  28643. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28644. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28645. * | 11 | LINEAR_LINEAR | |
  28646. * | 12 | LINEAR_NEAREST | |
  28647. *
  28648. * > _mag_: magnification filter (close to the viewer)
  28649. * > _min_: minification filter (far from the viewer)
  28650. * > _mip_: filter used between mip map levels
  28651. *@param samplingMode Define the new sampling mode of the texture
  28652. */
  28653. updateSamplingMode(samplingMode: number): void;
  28654. /**
  28655. * Scales the texture if is `canRescale()`
  28656. * @param ratio the resize factor we want to use to rescale
  28657. */
  28658. scale(ratio: number): void;
  28659. /**
  28660. * Get if the texture can rescale.
  28661. */
  28662. readonly canRescale: boolean;
  28663. /** @hidden */
  28664. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28665. /** @hidden */
  28666. _rebuild(): void;
  28667. /**
  28668. * Triggers the load sequence in delayed load mode.
  28669. */
  28670. delayLoad(): void;
  28671. /**
  28672. * Clones the texture.
  28673. * @returns the cloned texture
  28674. */
  28675. clone(): Nullable<BaseTexture>;
  28676. /**
  28677. * Get the texture underlying type (INT, FLOAT...)
  28678. */
  28679. readonly textureType: number;
  28680. /**
  28681. * Get the texture underlying format (RGB, RGBA...)
  28682. */
  28683. readonly textureFormat: number;
  28684. /**
  28685. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28686. * This will returns an RGBA array buffer containing either in values (0-255) or
  28687. * float values (0-1) depending of the underlying buffer type.
  28688. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28689. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28690. * @param buffer defines a user defined buffer to fill with data (can be null)
  28691. * @returns The Array buffer containing the pixels data.
  28692. */
  28693. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28694. /**
  28695. * Release and destroy the underlying lower level texture aka internalTexture.
  28696. */
  28697. releaseInternalTexture(): void;
  28698. /**
  28699. * Get the polynomial representation of the texture data.
  28700. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28701. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28702. */
  28703. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28704. /** @hidden */
  28705. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28706. /** @hidden */
  28707. readonly _lodTextureMid: Nullable<BaseTexture>;
  28708. /** @hidden */
  28709. readonly _lodTextureLow: Nullable<BaseTexture>;
  28710. /**
  28711. * Dispose the texture and release its associated resources.
  28712. */
  28713. dispose(): void;
  28714. /**
  28715. * Serialize the texture into a JSON representation that can be parsed later on.
  28716. * @returns the JSON representation of the texture
  28717. */
  28718. serialize(): any;
  28719. /**
  28720. * Helper function to be called back once a list of texture contains only ready textures.
  28721. * @param textures Define the list of textures to wait for
  28722. * @param callback Define the callback triggered once the entire list will be ready
  28723. */
  28724. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28725. }
  28726. }
  28727. declare module "babylonjs/Materials/Textures/internalTexture" {
  28728. import { Observable } from "babylonjs/Misc/observable";
  28729. import { Nullable, int } from "babylonjs/types";
  28730. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28731. import { Engine } from "babylonjs/Engines/engine";
  28732. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28733. /**
  28734. * Class used to store data associated with WebGL texture data for the engine
  28735. * This class should not be used directly
  28736. */
  28737. export class InternalTexture {
  28738. /** @hidden */
  28739. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28740. /**
  28741. * The source of the texture data is unknown
  28742. */
  28743. static DATASOURCE_UNKNOWN: number;
  28744. /**
  28745. * Texture data comes from an URL
  28746. */
  28747. static DATASOURCE_URL: number;
  28748. /**
  28749. * Texture data is only used for temporary storage
  28750. */
  28751. static DATASOURCE_TEMP: number;
  28752. /**
  28753. * Texture data comes from raw data (ArrayBuffer)
  28754. */
  28755. static DATASOURCE_RAW: number;
  28756. /**
  28757. * Texture content is dynamic (video or dynamic texture)
  28758. */
  28759. static DATASOURCE_DYNAMIC: number;
  28760. /**
  28761. * Texture content is generated by rendering to it
  28762. */
  28763. static DATASOURCE_RENDERTARGET: number;
  28764. /**
  28765. * Texture content is part of a multi render target process
  28766. */
  28767. static DATASOURCE_MULTIRENDERTARGET: number;
  28768. /**
  28769. * Texture data comes from a cube data file
  28770. */
  28771. static DATASOURCE_CUBE: number;
  28772. /**
  28773. * Texture data comes from a raw cube data
  28774. */
  28775. static DATASOURCE_CUBERAW: number;
  28776. /**
  28777. * Texture data come from a prefiltered cube data file
  28778. */
  28779. static DATASOURCE_CUBEPREFILTERED: number;
  28780. /**
  28781. * Texture content is raw 3D data
  28782. */
  28783. static DATASOURCE_RAW3D: number;
  28784. /**
  28785. * Texture content is a depth texture
  28786. */
  28787. static DATASOURCE_DEPTHTEXTURE: number;
  28788. /**
  28789. * Texture data comes from a raw cube data encoded with RGBD
  28790. */
  28791. static DATASOURCE_CUBERAW_RGBD: number;
  28792. /**
  28793. * Defines if the texture is ready
  28794. */
  28795. isReady: boolean;
  28796. /**
  28797. * Defines if the texture is a cube texture
  28798. */
  28799. isCube: boolean;
  28800. /**
  28801. * Defines if the texture contains 3D data
  28802. */
  28803. is3D: boolean;
  28804. /**
  28805. * Defines if the texture contains multiview data
  28806. */
  28807. isMultiview: boolean;
  28808. /**
  28809. * Gets the URL used to load this texture
  28810. */
  28811. url: string;
  28812. /**
  28813. * Gets the sampling mode of the texture
  28814. */
  28815. samplingMode: number;
  28816. /**
  28817. * Gets a boolean indicating if the texture needs mipmaps generation
  28818. */
  28819. generateMipMaps: boolean;
  28820. /**
  28821. * Gets the number of samples used by the texture (WebGL2+ only)
  28822. */
  28823. samples: number;
  28824. /**
  28825. * Gets the type of the texture (int, float...)
  28826. */
  28827. type: number;
  28828. /**
  28829. * Gets the format of the texture (RGB, RGBA...)
  28830. */
  28831. format: number;
  28832. /**
  28833. * Observable called when the texture is loaded
  28834. */
  28835. onLoadedObservable: Observable<InternalTexture>;
  28836. /**
  28837. * Gets the width of the texture
  28838. */
  28839. width: number;
  28840. /**
  28841. * Gets the height of the texture
  28842. */
  28843. height: number;
  28844. /**
  28845. * Gets the depth of the texture
  28846. */
  28847. depth: number;
  28848. /**
  28849. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28850. */
  28851. baseWidth: number;
  28852. /**
  28853. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28854. */
  28855. baseHeight: number;
  28856. /**
  28857. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28858. */
  28859. baseDepth: number;
  28860. /**
  28861. * Gets a boolean indicating if the texture is inverted on Y axis
  28862. */
  28863. invertY: boolean;
  28864. /** @hidden */
  28865. _invertVScale: boolean;
  28866. /** @hidden */
  28867. _associatedChannel: number;
  28868. /** @hidden */
  28869. _dataSource: number;
  28870. /** @hidden */
  28871. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  28872. /** @hidden */
  28873. _bufferView: Nullable<ArrayBufferView>;
  28874. /** @hidden */
  28875. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28876. /** @hidden */
  28877. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28878. /** @hidden */
  28879. _size: number;
  28880. /** @hidden */
  28881. _extension: string;
  28882. /** @hidden */
  28883. _files: Nullable<string[]>;
  28884. /** @hidden */
  28885. _workingCanvas: Nullable<HTMLCanvasElement>;
  28886. /** @hidden */
  28887. _workingContext: Nullable<CanvasRenderingContext2D>;
  28888. /** @hidden */
  28889. _framebuffer: Nullable<WebGLFramebuffer>;
  28890. /** @hidden */
  28891. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28892. /** @hidden */
  28893. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28894. /** @hidden */
  28895. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28896. /** @hidden */
  28897. _attachments: Nullable<number[]>;
  28898. /** @hidden */
  28899. _cachedCoordinatesMode: Nullable<number>;
  28900. /** @hidden */
  28901. _cachedWrapU: Nullable<number>;
  28902. /** @hidden */
  28903. _cachedWrapV: Nullable<number>;
  28904. /** @hidden */
  28905. _cachedWrapR: Nullable<number>;
  28906. /** @hidden */
  28907. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28908. /** @hidden */
  28909. _isDisabled: boolean;
  28910. /** @hidden */
  28911. _compression: Nullable<string>;
  28912. /** @hidden */
  28913. _generateStencilBuffer: boolean;
  28914. /** @hidden */
  28915. _generateDepthBuffer: boolean;
  28916. /** @hidden */
  28917. _comparisonFunction: number;
  28918. /** @hidden */
  28919. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28920. /** @hidden */
  28921. _lodGenerationScale: number;
  28922. /** @hidden */
  28923. _lodGenerationOffset: number;
  28924. /** @hidden */
  28925. _colorTextureArray: Nullable<WebGLTexture>;
  28926. /** @hidden */
  28927. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28928. /** @hidden */
  28929. _lodTextureHigh: Nullable<BaseTexture>;
  28930. /** @hidden */
  28931. _lodTextureMid: Nullable<BaseTexture>;
  28932. /** @hidden */
  28933. _lodTextureLow: Nullable<BaseTexture>;
  28934. /** @hidden */
  28935. _isRGBD: boolean;
  28936. /** @hidden */
  28937. _linearSpecularLOD: boolean;
  28938. /** @hidden */
  28939. _irradianceTexture: Nullable<BaseTexture>;
  28940. /** @hidden */
  28941. _webGLTexture: Nullable<WebGLTexture>;
  28942. /** @hidden */
  28943. _references: number;
  28944. private _engine;
  28945. /**
  28946. * Gets the Engine the texture belongs to.
  28947. * @returns The babylon engine
  28948. */
  28949. getEngine(): Engine;
  28950. /**
  28951. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28952. */
  28953. readonly dataSource: number;
  28954. /**
  28955. * Creates a new InternalTexture
  28956. * @param engine defines the engine to use
  28957. * @param dataSource defines the type of data that will be used
  28958. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28959. */
  28960. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28961. /**
  28962. * Increments the number of references (ie. the number of Texture that point to it)
  28963. */
  28964. incrementReferences(): void;
  28965. /**
  28966. * Change the size of the texture (not the size of the content)
  28967. * @param width defines the new width
  28968. * @param height defines the new height
  28969. * @param depth defines the new depth (1 by default)
  28970. */
  28971. updateSize(width: int, height: int, depth?: int): void;
  28972. /** @hidden */
  28973. _rebuild(): void;
  28974. /** @hidden */
  28975. _swapAndDie(target: InternalTexture): void;
  28976. /**
  28977. * Dispose the current allocated resources
  28978. */
  28979. dispose(): void;
  28980. }
  28981. }
  28982. declare module "babylonjs/Materials/effect" {
  28983. import { Observable } from "babylonjs/Misc/observable";
  28984. import { Nullable } from "babylonjs/types";
  28985. import { IDisposable } from "babylonjs/scene";
  28986. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28987. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28988. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28989. import { Engine } from "babylonjs/Engines/engine";
  28990. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28991. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28992. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28993. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28994. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28995. /**
  28996. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28997. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28998. */
  28999. export class EffectFallbacks {
  29000. private _defines;
  29001. private _currentRank;
  29002. private _maxRank;
  29003. private _mesh;
  29004. /**
  29005. * Removes the fallback from the bound mesh.
  29006. */
  29007. unBindMesh(): void;
  29008. /**
  29009. * Adds a fallback on the specified property.
  29010. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29011. * @param define The name of the define in the shader
  29012. */
  29013. addFallback(rank: number, define: string): void;
  29014. /**
  29015. * Sets the mesh to use CPU skinning when needing to fallback.
  29016. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29017. * @param mesh The mesh to use the fallbacks.
  29018. */
  29019. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29020. /**
  29021. * Checks to see if more fallbacks are still availible.
  29022. */
  29023. readonly hasMoreFallbacks: boolean;
  29024. /**
  29025. * Removes the defines that should be removed when falling back.
  29026. * @param currentDefines defines the current define statements for the shader.
  29027. * @param effect defines the current effect we try to compile
  29028. * @returns The resulting defines with defines of the current rank removed.
  29029. */
  29030. reduce(currentDefines: string, effect: Effect): string;
  29031. }
  29032. /**
  29033. * Options to be used when creating an effect.
  29034. */
  29035. export class EffectCreationOptions {
  29036. /**
  29037. * Atrributes that will be used in the shader.
  29038. */
  29039. attributes: string[];
  29040. /**
  29041. * Uniform varible names that will be set in the shader.
  29042. */
  29043. uniformsNames: string[];
  29044. /**
  29045. * Uniform buffer varible names that will be set in the shader.
  29046. */
  29047. uniformBuffersNames: string[];
  29048. /**
  29049. * Sampler texture variable names that will be set in the shader.
  29050. */
  29051. samplers: string[];
  29052. /**
  29053. * Define statements that will be set in the shader.
  29054. */
  29055. defines: any;
  29056. /**
  29057. * Possible fallbacks for this effect to improve performance when needed.
  29058. */
  29059. fallbacks: Nullable<EffectFallbacks>;
  29060. /**
  29061. * Callback that will be called when the shader is compiled.
  29062. */
  29063. onCompiled: Nullable<(effect: Effect) => void>;
  29064. /**
  29065. * Callback that will be called if an error occurs during shader compilation.
  29066. */
  29067. onError: Nullable<(effect: Effect, errors: string) => void>;
  29068. /**
  29069. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29070. */
  29071. indexParameters: any;
  29072. /**
  29073. * Max number of lights that can be used in the shader.
  29074. */
  29075. maxSimultaneousLights: number;
  29076. /**
  29077. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29078. */
  29079. transformFeedbackVaryings: Nullable<string[]>;
  29080. }
  29081. /**
  29082. * Effect containing vertex and fragment shader that can be executed on an object.
  29083. */
  29084. export class Effect implements IDisposable {
  29085. /**
  29086. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29087. */
  29088. static ShadersRepository: string;
  29089. /**
  29090. * Name of the effect.
  29091. */
  29092. name: any;
  29093. /**
  29094. * String container all the define statements that should be set on the shader.
  29095. */
  29096. defines: string;
  29097. /**
  29098. * Callback that will be called when the shader is compiled.
  29099. */
  29100. onCompiled: Nullable<(effect: Effect) => void>;
  29101. /**
  29102. * Callback that will be called if an error occurs during shader compilation.
  29103. */
  29104. onError: Nullable<(effect: Effect, errors: string) => void>;
  29105. /**
  29106. * Callback that will be called when effect is bound.
  29107. */
  29108. onBind: Nullable<(effect: Effect) => void>;
  29109. /**
  29110. * Unique ID of the effect.
  29111. */
  29112. uniqueId: number;
  29113. /**
  29114. * Observable that will be called when the shader is compiled.
  29115. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29116. */
  29117. onCompileObservable: Observable<Effect>;
  29118. /**
  29119. * Observable that will be called if an error occurs during shader compilation.
  29120. */
  29121. onErrorObservable: Observable<Effect>;
  29122. /** @hidden */
  29123. _onBindObservable: Nullable<Observable<Effect>>;
  29124. /**
  29125. * Observable that will be called when effect is bound.
  29126. */
  29127. readonly onBindObservable: Observable<Effect>;
  29128. /** @hidden */
  29129. _bonesComputationForcedToCPU: boolean;
  29130. private static _uniqueIdSeed;
  29131. private _engine;
  29132. private _uniformBuffersNames;
  29133. private _uniformsNames;
  29134. private _samplerList;
  29135. private _samplers;
  29136. private _isReady;
  29137. private _compilationError;
  29138. private _attributesNames;
  29139. private _attributes;
  29140. private _uniforms;
  29141. /**
  29142. * Key for the effect.
  29143. * @hidden
  29144. */
  29145. _key: string;
  29146. private _indexParameters;
  29147. private _fallbacks;
  29148. private _vertexSourceCode;
  29149. private _fragmentSourceCode;
  29150. private _vertexSourceCodeOverride;
  29151. private _fragmentSourceCodeOverride;
  29152. private _transformFeedbackVaryings;
  29153. /**
  29154. * Compiled shader to webGL program.
  29155. * @hidden
  29156. */
  29157. _pipelineContext: Nullable<IPipelineContext>;
  29158. private _valueCache;
  29159. private static _baseCache;
  29160. /**
  29161. * Instantiates an effect.
  29162. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29163. * @param baseName Name of the effect.
  29164. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29165. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29166. * @param samplers List of sampler variables that will be passed to the shader.
  29167. * @param engine Engine to be used to render the effect
  29168. * @param defines Define statements to be added to the shader.
  29169. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29170. * @param onCompiled Callback that will be called when the shader is compiled.
  29171. * @param onError Callback that will be called if an error occurs during shader compilation.
  29172. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29173. */
  29174. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  29175. private _useFinalCode;
  29176. /**
  29177. * Unique key for this effect
  29178. */
  29179. readonly key: string;
  29180. /**
  29181. * If the effect has been compiled and prepared.
  29182. * @returns if the effect is compiled and prepared.
  29183. */
  29184. isReady(): boolean;
  29185. private _isReadyInternal;
  29186. /**
  29187. * The engine the effect was initialized with.
  29188. * @returns the engine.
  29189. */
  29190. getEngine(): Engine;
  29191. /**
  29192. * The pipeline context for this effect
  29193. * @returns the associated pipeline context
  29194. */
  29195. getPipelineContext(): Nullable<IPipelineContext>;
  29196. /**
  29197. * The set of names of attribute variables for the shader.
  29198. * @returns An array of attribute names.
  29199. */
  29200. getAttributesNames(): string[];
  29201. /**
  29202. * Returns the attribute at the given index.
  29203. * @param index The index of the attribute.
  29204. * @returns The location of the attribute.
  29205. */
  29206. getAttributeLocation(index: number): number;
  29207. /**
  29208. * Returns the attribute based on the name of the variable.
  29209. * @param name of the attribute to look up.
  29210. * @returns the attribute location.
  29211. */
  29212. getAttributeLocationByName(name: string): number;
  29213. /**
  29214. * The number of attributes.
  29215. * @returns the numnber of attributes.
  29216. */
  29217. getAttributesCount(): number;
  29218. /**
  29219. * Gets the index of a uniform variable.
  29220. * @param uniformName of the uniform to look up.
  29221. * @returns the index.
  29222. */
  29223. getUniformIndex(uniformName: string): number;
  29224. /**
  29225. * Returns the attribute based on the name of the variable.
  29226. * @param uniformName of the uniform to look up.
  29227. * @returns the location of the uniform.
  29228. */
  29229. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29230. /**
  29231. * Returns an array of sampler variable names
  29232. * @returns The array of sampler variable neames.
  29233. */
  29234. getSamplers(): string[];
  29235. /**
  29236. * The error from the last compilation.
  29237. * @returns the error string.
  29238. */
  29239. getCompilationError(): string;
  29240. /**
  29241. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29242. * @param func The callback to be used.
  29243. */
  29244. executeWhenCompiled(func: (effect: Effect) => void): void;
  29245. private _checkIsReady;
  29246. /** @hidden */
  29247. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29248. /** @hidden */
  29249. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29250. /** @hidden */
  29251. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29252. /**
  29253. * Recompiles the webGL program
  29254. * @param vertexSourceCode The source code for the vertex shader.
  29255. * @param fragmentSourceCode The source code for the fragment shader.
  29256. * @param onCompiled Callback called when completed.
  29257. * @param onError Callback called on error.
  29258. * @hidden
  29259. */
  29260. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29261. /**
  29262. * Prepares the effect
  29263. * @hidden
  29264. */
  29265. _prepareEffect(): void;
  29266. private _processCompilationErrors;
  29267. /**
  29268. * Checks if the effect is supported. (Must be called after compilation)
  29269. */
  29270. readonly isSupported: boolean;
  29271. /**
  29272. * Binds a texture to the engine to be used as output of the shader.
  29273. * @param channel Name of the output variable.
  29274. * @param texture Texture to bind.
  29275. * @hidden
  29276. */
  29277. _bindTexture(channel: string, texture: InternalTexture): void;
  29278. /**
  29279. * Sets a texture on the engine to be used in the shader.
  29280. * @param channel Name of the sampler variable.
  29281. * @param texture Texture to set.
  29282. */
  29283. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29284. /**
  29285. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29286. * @param channel Name of the sampler variable.
  29287. * @param texture Texture to set.
  29288. */
  29289. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29290. /**
  29291. * Sets an array of textures on the engine to be used in the shader.
  29292. * @param channel Name of the variable.
  29293. * @param textures Textures to set.
  29294. */
  29295. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29296. /**
  29297. * 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)
  29298. * @param channel Name of the sampler variable.
  29299. * @param postProcess Post process to get the input texture from.
  29300. */
  29301. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29302. /**
  29303. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29304. * 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)
  29305. * @param channel Name of the sampler variable.
  29306. * @param postProcess Post process to get the output texture from.
  29307. */
  29308. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29309. /** @hidden */
  29310. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29311. /** @hidden */
  29312. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29313. /** @hidden */
  29314. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29315. /** @hidden */
  29316. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29317. /**
  29318. * Binds a buffer to a uniform.
  29319. * @param buffer Buffer to bind.
  29320. * @param name Name of the uniform variable to bind to.
  29321. */
  29322. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29323. /**
  29324. * Binds block to a uniform.
  29325. * @param blockName Name of the block to bind.
  29326. * @param index Index to bind.
  29327. */
  29328. bindUniformBlock(blockName: string, index: number): void;
  29329. /**
  29330. * Sets an interger value on a uniform variable.
  29331. * @param uniformName Name of the variable.
  29332. * @param value Value to be set.
  29333. * @returns this effect.
  29334. */
  29335. setInt(uniformName: string, value: number): Effect;
  29336. /**
  29337. * Sets an int array on a uniform variable.
  29338. * @param uniformName Name of the variable.
  29339. * @param array array to be set.
  29340. * @returns this effect.
  29341. */
  29342. setIntArray(uniformName: string, array: Int32Array): Effect;
  29343. /**
  29344. * 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)
  29345. * @param uniformName Name of the variable.
  29346. * @param array array to be set.
  29347. * @returns this effect.
  29348. */
  29349. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29350. /**
  29351. * 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)
  29352. * @param uniformName Name of the variable.
  29353. * @param array array to be set.
  29354. * @returns this effect.
  29355. */
  29356. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29357. /**
  29358. * 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)
  29359. * @param uniformName Name of the variable.
  29360. * @param array array to be set.
  29361. * @returns this effect.
  29362. */
  29363. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29364. /**
  29365. * Sets an float array on a uniform variable.
  29366. * @param uniformName Name of the variable.
  29367. * @param array array to be set.
  29368. * @returns this effect.
  29369. */
  29370. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29371. /**
  29372. * 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)
  29373. * @param uniformName Name of the variable.
  29374. * @param array array to be set.
  29375. * @returns this effect.
  29376. */
  29377. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29378. /**
  29379. * 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)
  29380. * @param uniformName Name of the variable.
  29381. * @param array array to be set.
  29382. * @returns this effect.
  29383. */
  29384. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29385. /**
  29386. * 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)
  29387. * @param uniformName Name of the variable.
  29388. * @param array array to be set.
  29389. * @returns this effect.
  29390. */
  29391. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29392. /**
  29393. * Sets an array on a uniform variable.
  29394. * @param uniformName Name of the variable.
  29395. * @param array array to be set.
  29396. * @returns this effect.
  29397. */
  29398. setArray(uniformName: string, array: number[]): Effect;
  29399. /**
  29400. * 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)
  29401. * @param uniformName Name of the variable.
  29402. * @param array array to be set.
  29403. * @returns this effect.
  29404. */
  29405. setArray2(uniformName: string, array: number[]): Effect;
  29406. /**
  29407. * 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)
  29408. * @param uniformName Name of the variable.
  29409. * @param array array to be set.
  29410. * @returns this effect.
  29411. */
  29412. setArray3(uniformName: string, array: number[]): Effect;
  29413. /**
  29414. * 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)
  29415. * @param uniformName Name of the variable.
  29416. * @param array array to be set.
  29417. * @returns this effect.
  29418. */
  29419. setArray4(uniformName: string, array: number[]): Effect;
  29420. /**
  29421. * Sets matrices on a uniform variable.
  29422. * @param uniformName Name of the variable.
  29423. * @param matrices matrices to be set.
  29424. * @returns this effect.
  29425. */
  29426. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29427. /**
  29428. * Sets matrix on a uniform variable.
  29429. * @param uniformName Name of the variable.
  29430. * @param matrix matrix to be set.
  29431. * @returns this effect.
  29432. */
  29433. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29434. /**
  29435. * 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)
  29436. * @param uniformName Name of the variable.
  29437. * @param matrix matrix to be set.
  29438. * @returns this effect.
  29439. */
  29440. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29441. /**
  29442. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29443. * @param uniformName Name of the variable.
  29444. * @param matrix matrix to be set.
  29445. * @returns this effect.
  29446. */
  29447. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29448. /**
  29449. * Sets a float on a uniform variable.
  29450. * @param uniformName Name of the variable.
  29451. * @param value value to be set.
  29452. * @returns this effect.
  29453. */
  29454. setFloat(uniformName: string, value: number): Effect;
  29455. /**
  29456. * Sets a boolean on a uniform variable.
  29457. * @param uniformName Name of the variable.
  29458. * @param bool value to be set.
  29459. * @returns this effect.
  29460. */
  29461. setBool(uniformName: string, bool: boolean): Effect;
  29462. /**
  29463. * Sets a Vector2 on a uniform variable.
  29464. * @param uniformName Name of the variable.
  29465. * @param vector2 vector2 to be set.
  29466. * @returns this effect.
  29467. */
  29468. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29469. /**
  29470. * Sets a float2 on a uniform variable.
  29471. * @param uniformName Name of the variable.
  29472. * @param x First float in float2.
  29473. * @param y Second float in float2.
  29474. * @returns this effect.
  29475. */
  29476. setFloat2(uniformName: string, x: number, y: number): Effect;
  29477. /**
  29478. * Sets a Vector3 on a uniform variable.
  29479. * @param uniformName Name of the variable.
  29480. * @param vector3 Value to be set.
  29481. * @returns this effect.
  29482. */
  29483. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29484. /**
  29485. * Sets a float3 on a uniform variable.
  29486. * @param uniformName Name of the variable.
  29487. * @param x First float in float3.
  29488. * @param y Second float in float3.
  29489. * @param z Third float in float3.
  29490. * @returns this effect.
  29491. */
  29492. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29493. /**
  29494. * Sets a Vector4 on a uniform variable.
  29495. * @param uniformName Name of the variable.
  29496. * @param vector4 Value to be set.
  29497. * @returns this effect.
  29498. */
  29499. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29500. /**
  29501. * Sets a float4 on a uniform variable.
  29502. * @param uniformName Name of the variable.
  29503. * @param x First float in float4.
  29504. * @param y Second float in float4.
  29505. * @param z Third float in float4.
  29506. * @param w Fourth float in float4.
  29507. * @returns this effect.
  29508. */
  29509. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29510. /**
  29511. * Sets a Color3 on a uniform variable.
  29512. * @param uniformName Name of the variable.
  29513. * @param color3 Value to be set.
  29514. * @returns this effect.
  29515. */
  29516. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29517. /**
  29518. * Sets a Color4 on a uniform variable.
  29519. * @param uniformName Name of the variable.
  29520. * @param color3 Value to be set.
  29521. * @param alpha Alpha value to be set.
  29522. * @returns this effect.
  29523. */
  29524. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29525. /**
  29526. * Sets a Color4 on a uniform variable
  29527. * @param uniformName defines the name of the variable
  29528. * @param color4 defines the value to be set
  29529. * @returns this effect.
  29530. */
  29531. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29532. /** Release all associated resources */
  29533. dispose(): void;
  29534. /**
  29535. * This function will add a new shader to the shader store
  29536. * @param name the name of the shader
  29537. * @param pixelShader optional pixel shader content
  29538. * @param vertexShader optional vertex shader content
  29539. */
  29540. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29541. /**
  29542. * Store of each shader (The can be looked up using effect.key)
  29543. */
  29544. static ShadersStore: {
  29545. [key: string]: string;
  29546. };
  29547. /**
  29548. * Store of each included file for a shader (The can be looked up using effect.key)
  29549. */
  29550. static IncludesShadersStore: {
  29551. [key: string]: string;
  29552. };
  29553. /**
  29554. * Resets the cache of effects.
  29555. */
  29556. static ResetCache(): void;
  29557. }
  29558. }
  29559. declare module "babylonjs/Materials/uniformBuffer" {
  29560. import { Nullable, FloatArray } from "babylonjs/types";
  29561. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  29562. import { Engine } from "babylonjs/Engines/engine";
  29563. import { Effect } from "babylonjs/Materials/effect";
  29564. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29565. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29566. import { Color3 } from "babylonjs/Maths/math.color";
  29567. /**
  29568. * Uniform buffer objects.
  29569. *
  29570. * Handles blocks of uniform on the GPU.
  29571. *
  29572. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29573. *
  29574. * For more information, please refer to :
  29575. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29576. */
  29577. export class UniformBuffer {
  29578. private _engine;
  29579. private _buffer;
  29580. private _data;
  29581. private _bufferData;
  29582. private _dynamic?;
  29583. private _uniformLocations;
  29584. private _uniformSizes;
  29585. private _uniformLocationPointer;
  29586. private _needSync;
  29587. private _noUBO;
  29588. private _currentEffect;
  29589. private static _MAX_UNIFORM_SIZE;
  29590. private static _tempBuffer;
  29591. /**
  29592. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  29593. * This is dynamic to allow compat with webgl 1 and 2.
  29594. * You will need to pass the name of the uniform as well as the value.
  29595. */
  29596. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  29597. /**
  29598. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  29599. * This is dynamic to allow compat with webgl 1 and 2.
  29600. * You will need to pass the name of the uniform as well as the value.
  29601. */
  29602. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  29603. /**
  29604. * Lambda to Update a single float in a uniform buffer.
  29605. * This is dynamic to allow compat with webgl 1 and 2.
  29606. * You will need to pass the name of the uniform as well as the value.
  29607. */
  29608. updateFloat: (name: string, x: number) => void;
  29609. /**
  29610. * Lambda to Update a vec2 of float in a uniform buffer.
  29611. * This is dynamic to allow compat with webgl 1 and 2.
  29612. * You will need to pass the name of the uniform as well as the value.
  29613. */
  29614. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  29615. /**
  29616. * Lambda to Update a vec3 of float in a uniform buffer.
  29617. * This is dynamic to allow compat with webgl 1 and 2.
  29618. * You will need to pass the name of the uniform as well as the value.
  29619. */
  29620. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  29621. /**
  29622. * Lambda to Update a vec4 of float in a uniform buffer.
  29623. * This is dynamic to allow compat with webgl 1 and 2.
  29624. * You will need to pass the name of the uniform as well as the value.
  29625. */
  29626. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  29627. /**
  29628. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  29629. * This is dynamic to allow compat with webgl 1 and 2.
  29630. * You will need to pass the name of the uniform as well as the value.
  29631. */
  29632. updateMatrix: (name: string, mat: Matrix) => void;
  29633. /**
  29634. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  29635. * This is dynamic to allow compat with webgl 1 and 2.
  29636. * You will need to pass the name of the uniform as well as the value.
  29637. */
  29638. updateVector3: (name: string, vector: Vector3) => void;
  29639. /**
  29640. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  29641. * This is dynamic to allow compat with webgl 1 and 2.
  29642. * You will need to pass the name of the uniform as well as the value.
  29643. */
  29644. updateVector4: (name: string, vector: Vector4) => void;
  29645. /**
  29646. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  29647. * This is dynamic to allow compat with webgl 1 and 2.
  29648. * You will need to pass the name of the uniform as well as the value.
  29649. */
  29650. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  29651. /**
  29652. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  29653. * This is dynamic to allow compat with webgl 1 and 2.
  29654. * You will need to pass the name of the uniform as well as the value.
  29655. */
  29656. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  29657. /**
  29658. * Instantiates a new Uniform buffer objects.
  29659. *
  29660. * Handles blocks of uniform on the GPU.
  29661. *
  29662. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29663. *
  29664. * For more information, please refer to :
  29665. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29666. * @param engine Define the engine the buffer is associated with
  29667. * @param data Define the data contained in the buffer
  29668. * @param dynamic Define if the buffer is updatable
  29669. */
  29670. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  29671. /**
  29672. * Indicates if the buffer is using the WebGL2 UBO implementation,
  29673. * or just falling back on setUniformXXX calls.
  29674. */
  29675. readonly useUbo: boolean;
  29676. /**
  29677. * Indicates if the WebGL underlying uniform buffer is in sync
  29678. * with the javascript cache data.
  29679. */
  29680. readonly isSync: boolean;
  29681. /**
  29682. * Indicates if the WebGL underlying uniform buffer is dynamic.
  29683. * Also, a dynamic UniformBuffer will disable cache verification and always
  29684. * update the underlying WebGL uniform buffer to the GPU.
  29685. * @returns if Dynamic, otherwise false
  29686. */
  29687. isDynamic(): boolean;
  29688. /**
  29689. * The data cache on JS side.
  29690. * @returns the underlying data as a float array
  29691. */
  29692. getData(): Float32Array;
  29693. /**
  29694. * The underlying WebGL Uniform buffer.
  29695. * @returns the webgl buffer
  29696. */
  29697. getBuffer(): Nullable<DataBuffer>;
  29698. /**
  29699. * std140 layout specifies how to align data within an UBO structure.
  29700. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  29701. * for specs.
  29702. */
  29703. private _fillAlignment;
  29704. /**
  29705. * Adds an uniform in the buffer.
  29706. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  29707. * for the layout to be correct !
  29708. * @param name Name of the uniform, as used in the uniform block in the shader.
  29709. * @param size Data size, or data directly.
  29710. */
  29711. addUniform(name: string, size: number | number[]): void;
  29712. /**
  29713. * Adds a Matrix 4x4 to the uniform buffer.
  29714. * @param name Name of the uniform, as used in the uniform block in the shader.
  29715. * @param mat A 4x4 matrix.
  29716. */
  29717. addMatrix(name: string, mat: Matrix): void;
  29718. /**
  29719. * Adds a vec2 to the uniform buffer.
  29720. * @param name Name of the uniform, as used in the uniform block in the shader.
  29721. * @param x Define the x component value of the vec2
  29722. * @param y Define the y component value of the vec2
  29723. */
  29724. addFloat2(name: string, x: number, y: number): void;
  29725. /**
  29726. * Adds a vec3 to the uniform buffer.
  29727. * @param name Name of the uniform, as used in the uniform block in the shader.
  29728. * @param x Define the x component value of the vec3
  29729. * @param y Define the y component value of the vec3
  29730. * @param z Define the z component value of the vec3
  29731. */
  29732. addFloat3(name: string, x: number, y: number, z: number): void;
  29733. /**
  29734. * Adds a vec3 to the uniform buffer.
  29735. * @param name Name of the uniform, as used in the uniform block in the shader.
  29736. * @param color Define the vec3 from a Color
  29737. */
  29738. addColor3(name: string, color: Color3): void;
  29739. /**
  29740. * Adds a vec4 to the uniform buffer.
  29741. * @param name Name of the uniform, as used in the uniform block in the shader.
  29742. * @param color Define the rgb components from a Color
  29743. * @param alpha Define the a component of the vec4
  29744. */
  29745. addColor4(name: string, color: Color3, alpha: number): void;
  29746. /**
  29747. * Adds a vec3 to the uniform buffer.
  29748. * @param name Name of the uniform, as used in the uniform block in the shader.
  29749. * @param vector Define the vec3 components from a Vector
  29750. */
  29751. addVector3(name: string, vector: Vector3): void;
  29752. /**
  29753. * Adds a Matrix 3x3 to the uniform buffer.
  29754. * @param name Name of the uniform, as used in the uniform block in the shader.
  29755. */
  29756. addMatrix3x3(name: string): void;
  29757. /**
  29758. * Adds a Matrix 2x2 to the uniform buffer.
  29759. * @param name Name of the uniform, as used in the uniform block in the shader.
  29760. */
  29761. addMatrix2x2(name: string): void;
  29762. /**
  29763. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  29764. */
  29765. create(): void;
  29766. /** @hidden */
  29767. _rebuild(): void;
  29768. /**
  29769. * Updates the WebGL Uniform Buffer on the GPU.
  29770. * If the `dynamic` flag is set to true, no cache comparison is done.
  29771. * Otherwise, the buffer will be updated only if the cache differs.
  29772. */
  29773. update(): void;
  29774. /**
  29775. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  29776. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29777. * @param data Define the flattened data
  29778. * @param size Define the size of the data.
  29779. */
  29780. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  29781. private _valueCache;
  29782. private _cacheMatrix;
  29783. private _updateMatrix3x3ForUniform;
  29784. private _updateMatrix3x3ForEffect;
  29785. private _updateMatrix2x2ForEffect;
  29786. private _updateMatrix2x2ForUniform;
  29787. private _updateFloatForEffect;
  29788. private _updateFloatForUniform;
  29789. private _updateFloat2ForEffect;
  29790. private _updateFloat2ForUniform;
  29791. private _updateFloat3ForEffect;
  29792. private _updateFloat3ForUniform;
  29793. private _updateFloat4ForEffect;
  29794. private _updateFloat4ForUniform;
  29795. private _updateMatrixForEffect;
  29796. private _updateMatrixForUniform;
  29797. private _updateVector3ForEffect;
  29798. private _updateVector3ForUniform;
  29799. private _updateVector4ForEffect;
  29800. private _updateVector4ForUniform;
  29801. private _updateColor3ForEffect;
  29802. private _updateColor3ForUniform;
  29803. private _updateColor4ForEffect;
  29804. private _updateColor4ForUniform;
  29805. /**
  29806. * Sets a sampler uniform on the effect.
  29807. * @param name Define the name of the sampler.
  29808. * @param texture Define the texture to set in the sampler
  29809. */
  29810. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  29811. /**
  29812. * Directly updates the value of the uniform in the cache AND on the GPU.
  29813. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29814. * @param data Define the flattened data
  29815. */
  29816. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  29817. /**
  29818. * Binds this uniform buffer to an effect.
  29819. * @param effect Define the effect to bind the buffer to
  29820. * @param name Name of the uniform block in the shader.
  29821. */
  29822. bindToEffect(effect: Effect, name: string): void;
  29823. /**
  29824. * Disposes the uniform buffer.
  29825. */
  29826. dispose(): void;
  29827. }
  29828. }
  29829. declare module "babylonjs/Audio/analyser" {
  29830. import { Scene } from "babylonjs/scene";
  29831. /**
  29832. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29833. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29834. */
  29835. export class Analyser {
  29836. /**
  29837. * Gets or sets the smoothing
  29838. * @ignorenaming
  29839. */
  29840. SMOOTHING: number;
  29841. /**
  29842. * Gets or sets the FFT table size
  29843. * @ignorenaming
  29844. */
  29845. FFT_SIZE: number;
  29846. /**
  29847. * Gets or sets the bar graph amplitude
  29848. * @ignorenaming
  29849. */
  29850. BARGRAPHAMPLITUDE: number;
  29851. /**
  29852. * Gets or sets the position of the debug canvas
  29853. * @ignorenaming
  29854. */
  29855. DEBUGCANVASPOS: {
  29856. x: number;
  29857. y: number;
  29858. };
  29859. /**
  29860. * Gets or sets the debug canvas size
  29861. * @ignorenaming
  29862. */
  29863. DEBUGCANVASSIZE: {
  29864. width: number;
  29865. height: number;
  29866. };
  29867. private _byteFreqs;
  29868. private _byteTime;
  29869. private _floatFreqs;
  29870. private _webAudioAnalyser;
  29871. private _debugCanvas;
  29872. private _debugCanvasContext;
  29873. private _scene;
  29874. private _registerFunc;
  29875. private _audioEngine;
  29876. /**
  29877. * Creates a new analyser
  29878. * @param scene defines hosting scene
  29879. */
  29880. constructor(scene: Scene);
  29881. /**
  29882. * Get the number of data values you will have to play with for the visualization
  29883. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29884. * @returns a number
  29885. */
  29886. getFrequencyBinCount(): number;
  29887. /**
  29888. * Gets the current frequency data as a byte array
  29889. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29890. * @returns a Uint8Array
  29891. */
  29892. getByteFrequencyData(): Uint8Array;
  29893. /**
  29894. * Gets the current waveform as a byte array
  29895. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29896. * @returns a Uint8Array
  29897. */
  29898. getByteTimeDomainData(): Uint8Array;
  29899. /**
  29900. * Gets the current frequency data as a float array
  29901. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29902. * @returns a Float32Array
  29903. */
  29904. getFloatFrequencyData(): Float32Array;
  29905. /**
  29906. * Renders the debug canvas
  29907. */
  29908. drawDebugCanvas(): void;
  29909. /**
  29910. * Stops rendering the debug canvas and removes it
  29911. */
  29912. stopDebugCanvas(): void;
  29913. /**
  29914. * Connects two audio nodes
  29915. * @param inputAudioNode defines first node to connect
  29916. * @param outputAudioNode defines second node to connect
  29917. */
  29918. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29919. /**
  29920. * Releases all associated resources
  29921. */
  29922. dispose(): void;
  29923. }
  29924. }
  29925. declare module "babylonjs/Audio/audioEngine" {
  29926. import { IDisposable } from "babylonjs/scene";
  29927. import { Analyser } from "babylonjs/Audio/analyser";
  29928. import { Nullable } from "babylonjs/types";
  29929. import { Observable } from "babylonjs/Misc/observable";
  29930. /**
  29931. * This represents an audio engine and it is responsible
  29932. * to play, synchronize and analyse sounds throughout the application.
  29933. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29934. */
  29935. export interface IAudioEngine extends IDisposable {
  29936. /**
  29937. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29938. */
  29939. readonly canUseWebAudio: boolean;
  29940. /**
  29941. * Gets the current AudioContext if available.
  29942. */
  29943. readonly audioContext: Nullable<AudioContext>;
  29944. /**
  29945. * The master gain node defines the global audio volume of your audio engine.
  29946. */
  29947. readonly masterGain: GainNode;
  29948. /**
  29949. * Gets whether or not mp3 are supported by your browser.
  29950. */
  29951. readonly isMP3supported: boolean;
  29952. /**
  29953. * Gets whether or not ogg are supported by your browser.
  29954. */
  29955. readonly isOGGsupported: boolean;
  29956. /**
  29957. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29958. * @ignoreNaming
  29959. */
  29960. WarnedWebAudioUnsupported: boolean;
  29961. /**
  29962. * Defines if the audio engine relies on a custom unlocked button.
  29963. * In this case, the embedded button will not be displayed.
  29964. */
  29965. useCustomUnlockedButton: boolean;
  29966. /**
  29967. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29968. */
  29969. readonly unlocked: boolean;
  29970. /**
  29971. * Event raised when audio has been unlocked on the browser.
  29972. */
  29973. onAudioUnlockedObservable: Observable<AudioEngine>;
  29974. /**
  29975. * Event raised when audio has been locked on the browser.
  29976. */
  29977. onAudioLockedObservable: Observable<AudioEngine>;
  29978. /**
  29979. * Flags the audio engine in Locked state.
  29980. * This happens due to new browser policies preventing audio to autoplay.
  29981. */
  29982. lock(): void;
  29983. /**
  29984. * Unlocks the audio engine once a user action has been done on the dom.
  29985. * This is helpful to resume play once browser policies have been satisfied.
  29986. */
  29987. unlock(): void;
  29988. }
  29989. /**
  29990. * This represents the default audio engine used in babylon.
  29991. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29992. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29993. */
  29994. export class AudioEngine implements IAudioEngine {
  29995. private _audioContext;
  29996. private _audioContextInitialized;
  29997. private _muteButton;
  29998. private _hostElement;
  29999. /**
  30000. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30001. */
  30002. canUseWebAudio: boolean;
  30003. /**
  30004. * The master gain node defines the global audio volume of your audio engine.
  30005. */
  30006. masterGain: GainNode;
  30007. /**
  30008. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30009. * @ignoreNaming
  30010. */
  30011. WarnedWebAudioUnsupported: boolean;
  30012. /**
  30013. * Gets whether or not mp3 are supported by your browser.
  30014. */
  30015. isMP3supported: boolean;
  30016. /**
  30017. * Gets whether or not ogg are supported by your browser.
  30018. */
  30019. isOGGsupported: boolean;
  30020. /**
  30021. * Gets whether audio has been unlocked on the device.
  30022. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30023. * a user interaction has happened.
  30024. */
  30025. unlocked: boolean;
  30026. /**
  30027. * Defines if the audio engine relies on a custom unlocked button.
  30028. * In this case, the embedded button will not be displayed.
  30029. */
  30030. useCustomUnlockedButton: boolean;
  30031. /**
  30032. * Event raised when audio has been unlocked on the browser.
  30033. */
  30034. onAudioUnlockedObservable: Observable<AudioEngine>;
  30035. /**
  30036. * Event raised when audio has been locked on the browser.
  30037. */
  30038. onAudioLockedObservable: Observable<AudioEngine>;
  30039. /**
  30040. * Gets the current AudioContext if available.
  30041. */
  30042. readonly audioContext: Nullable<AudioContext>;
  30043. private _connectedAnalyser;
  30044. /**
  30045. * Instantiates a new audio engine.
  30046. *
  30047. * There should be only one per page as some browsers restrict the number
  30048. * of audio contexts you can create.
  30049. * @param hostElement defines the host element where to display the mute icon if necessary
  30050. */
  30051. constructor(hostElement?: Nullable<HTMLElement>);
  30052. /**
  30053. * Flags the audio engine in Locked state.
  30054. * This happens due to new browser policies preventing audio to autoplay.
  30055. */
  30056. lock(): void;
  30057. /**
  30058. * Unlocks the audio engine once a user action has been done on the dom.
  30059. * This is helpful to resume play once browser policies have been satisfied.
  30060. */
  30061. unlock(): void;
  30062. private _resumeAudioContext;
  30063. private _initializeAudioContext;
  30064. private _tryToRun;
  30065. private _triggerRunningState;
  30066. private _triggerSuspendedState;
  30067. private _displayMuteButton;
  30068. private _moveButtonToTopLeft;
  30069. private _onResize;
  30070. private _hideMuteButton;
  30071. /**
  30072. * Destroy and release the resources associated with the audio ccontext.
  30073. */
  30074. dispose(): void;
  30075. /**
  30076. * Gets the global volume sets on the master gain.
  30077. * @returns the global volume if set or -1 otherwise
  30078. */
  30079. getGlobalVolume(): number;
  30080. /**
  30081. * Sets the global volume of your experience (sets on the master gain).
  30082. * @param newVolume Defines the new global volume of the application
  30083. */
  30084. setGlobalVolume(newVolume: number): void;
  30085. /**
  30086. * Connect the audio engine to an audio analyser allowing some amazing
  30087. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30088. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30089. * @param analyser The analyser to connect to the engine
  30090. */
  30091. connectToAnalyser(analyser: Analyser): void;
  30092. }
  30093. }
  30094. declare module "babylonjs/Loading/loadingScreen" {
  30095. /**
  30096. * Interface used to present a loading screen while loading a scene
  30097. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30098. */
  30099. export interface ILoadingScreen {
  30100. /**
  30101. * Function called to display the loading screen
  30102. */
  30103. displayLoadingUI: () => void;
  30104. /**
  30105. * Function called to hide the loading screen
  30106. */
  30107. hideLoadingUI: () => void;
  30108. /**
  30109. * Gets or sets the color to use for the background
  30110. */
  30111. loadingUIBackgroundColor: string;
  30112. /**
  30113. * Gets or sets the text to display while loading
  30114. */
  30115. loadingUIText: string;
  30116. }
  30117. /**
  30118. * Class used for the default loading screen
  30119. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30120. */
  30121. export class DefaultLoadingScreen implements ILoadingScreen {
  30122. private _renderingCanvas;
  30123. private _loadingText;
  30124. private _loadingDivBackgroundColor;
  30125. private _loadingDiv;
  30126. private _loadingTextDiv;
  30127. /** Gets or sets the logo url to use for the default loading screen */
  30128. static DefaultLogoUrl: string;
  30129. /** Gets or sets the spinner url to use for the default loading screen */
  30130. static DefaultSpinnerUrl: string;
  30131. /**
  30132. * Creates a new default loading screen
  30133. * @param _renderingCanvas defines the canvas used to render the scene
  30134. * @param _loadingText defines the default text to display
  30135. * @param _loadingDivBackgroundColor defines the default background color
  30136. */
  30137. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30138. /**
  30139. * Function called to display the loading screen
  30140. */
  30141. displayLoadingUI(): void;
  30142. /**
  30143. * Function called to hide the loading screen
  30144. */
  30145. hideLoadingUI(): void;
  30146. /**
  30147. * Gets or sets the text to display while loading
  30148. */
  30149. loadingUIText: string;
  30150. /**
  30151. * Gets or sets the color to use for the background
  30152. */
  30153. loadingUIBackgroundColor: string;
  30154. private _resizeLoadingUI;
  30155. }
  30156. }
  30157. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  30158. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30159. import { Engine } from "babylonjs/Engines/engine";
  30160. import { Nullable } from "babylonjs/types";
  30161. /** @hidden */
  30162. export class WebGLPipelineContext implements IPipelineContext {
  30163. engine: Engine;
  30164. program: Nullable<WebGLProgram>;
  30165. context?: WebGLRenderingContext;
  30166. vertexShader?: WebGLShader;
  30167. fragmentShader?: WebGLShader;
  30168. isParallelCompiled: boolean;
  30169. onCompiled?: () => void;
  30170. transformFeedback?: WebGLTransformFeedback | null;
  30171. readonly isAsync: boolean;
  30172. readonly isReady: boolean;
  30173. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  30174. }
  30175. }
  30176. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  30177. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30178. /** @hidden */
  30179. export class WebGLDataBuffer extends DataBuffer {
  30180. private _buffer;
  30181. constructor(resource: WebGLBuffer);
  30182. readonly underlyingResource: any;
  30183. }
  30184. }
  30185. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30186. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30187. /** @hidden */
  30188. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30189. attributeProcessor(attribute: string): string;
  30190. varyingProcessor(varying: string, isFragment: boolean): string;
  30191. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30192. }
  30193. }
  30194. declare module "babylonjs/Misc/perfCounter" {
  30195. /**
  30196. * This class is used to track a performance counter which is number based.
  30197. * The user has access to many properties which give statistics of different nature.
  30198. *
  30199. * The implementer can track two kinds of Performance Counter: time and count.
  30200. * 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.
  30201. * 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.
  30202. */
  30203. export class PerfCounter {
  30204. /**
  30205. * Gets or sets a global boolean to turn on and off all the counters
  30206. */
  30207. static Enabled: boolean;
  30208. /**
  30209. * Returns the smallest value ever
  30210. */
  30211. readonly min: number;
  30212. /**
  30213. * Returns the biggest value ever
  30214. */
  30215. readonly max: number;
  30216. /**
  30217. * Returns the average value since the performance counter is running
  30218. */
  30219. readonly average: number;
  30220. /**
  30221. * Returns the average value of the last second the counter was monitored
  30222. */
  30223. readonly lastSecAverage: number;
  30224. /**
  30225. * Returns the current value
  30226. */
  30227. readonly current: number;
  30228. /**
  30229. * Gets the accumulated total
  30230. */
  30231. readonly total: number;
  30232. /**
  30233. * Gets the total value count
  30234. */
  30235. readonly count: number;
  30236. /**
  30237. * Creates a new counter
  30238. */
  30239. constructor();
  30240. /**
  30241. * Call this method to start monitoring a new frame.
  30242. * 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.
  30243. */
  30244. fetchNewFrame(): void;
  30245. /**
  30246. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30247. * @param newCount the count value to add to the monitored count
  30248. * @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.
  30249. */
  30250. addCount(newCount: number, fetchResult: boolean): void;
  30251. /**
  30252. * Start monitoring this performance counter
  30253. */
  30254. beginMonitoring(): void;
  30255. /**
  30256. * Compute the time lapsed since the previous beginMonitoring() call.
  30257. * @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
  30258. */
  30259. endMonitoring(newFrame?: boolean): void;
  30260. private _fetchResult;
  30261. private _startMonitoringTime;
  30262. private _min;
  30263. private _max;
  30264. private _average;
  30265. private _current;
  30266. private _totalValueCount;
  30267. private _totalAccumulated;
  30268. private _lastSecAverage;
  30269. private _lastSecAccumulated;
  30270. private _lastSecTime;
  30271. private _lastSecValueCount;
  30272. }
  30273. }
  30274. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  30275. /**
  30276. * Interface for any object that can request an animation frame
  30277. */
  30278. export interface ICustomAnimationFrameRequester {
  30279. /**
  30280. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30281. */
  30282. renderFunction?: Function;
  30283. /**
  30284. * Called to request the next frame to render to
  30285. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30286. */
  30287. requestAnimationFrame: Function;
  30288. /**
  30289. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30290. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30291. */
  30292. requestID?: number;
  30293. }
  30294. }
  30295. declare module "babylonjs/Materials/Textures/videoTexture" {
  30296. import { Observable } from "babylonjs/Misc/observable";
  30297. import { Nullable } from "babylonjs/types";
  30298. import { Scene } from "babylonjs/scene";
  30299. import { Texture } from "babylonjs/Materials/Textures/texture";
  30300. /**
  30301. * Settings for finer control over video usage
  30302. */
  30303. export interface VideoTextureSettings {
  30304. /**
  30305. * Applies `autoplay` to video, if specified
  30306. */
  30307. autoPlay?: boolean;
  30308. /**
  30309. * Applies `loop` to video, if specified
  30310. */
  30311. loop?: boolean;
  30312. /**
  30313. * Automatically updates internal texture from video at every frame in the render loop
  30314. */
  30315. autoUpdateTexture: boolean;
  30316. /**
  30317. * Image src displayed during the video loading or until the user interacts with the video.
  30318. */
  30319. poster?: string;
  30320. }
  30321. /**
  30322. * If you want to display a video in your scene, this is the special texture for that.
  30323. * This special texture works similar to other textures, with the exception of a few parameters.
  30324. * @see https://doc.babylonjs.com/how_to/video_texture
  30325. */
  30326. export class VideoTexture extends Texture {
  30327. /**
  30328. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30329. */
  30330. readonly autoUpdateTexture: boolean;
  30331. /**
  30332. * The video instance used by the texture internally
  30333. */
  30334. readonly video: HTMLVideoElement;
  30335. private _onUserActionRequestedObservable;
  30336. /**
  30337. * Event triggerd when a dom action is required by the user to play the video.
  30338. * This happens due to recent changes in browser policies preventing video to auto start.
  30339. */
  30340. readonly onUserActionRequestedObservable: Observable<Texture>;
  30341. private _generateMipMaps;
  30342. private _engine;
  30343. private _stillImageCaptured;
  30344. private _displayingPosterTexture;
  30345. private _settings;
  30346. private _createInternalTextureOnEvent;
  30347. private _frameId;
  30348. /**
  30349. * Creates a video texture.
  30350. * If you want to display a video in your scene, this is the special texture for that.
  30351. * This special texture works similar to other textures, with the exception of a few parameters.
  30352. * @see https://doc.babylonjs.com/how_to/video_texture
  30353. * @param name optional name, will detect from video source, if not defined
  30354. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30355. * @param scene is obviously the current scene.
  30356. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30357. * @param invertY is false by default but can be used to invert video on Y axis
  30358. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30359. * @param settings allows finer control over video usage
  30360. */
  30361. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30362. private _getName;
  30363. private _getVideo;
  30364. private _createInternalTexture;
  30365. private reset;
  30366. /**
  30367. * @hidden Internal method to initiate `update`.
  30368. */
  30369. _rebuild(): void;
  30370. /**
  30371. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30372. */
  30373. update(): void;
  30374. /**
  30375. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30376. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30377. */
  30378. updateTexture(isVisible: boolean): void;
  30379. protected _updateInternalTexture: () => void;
  30380. /**
  30381. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30382. * @param url New url.
  30383. */
  30384. updateURL(url: string): void;
  30385. /**
  30386. * Dispose the texture and release its associated resources.
  30387. */
  30388. dispose(): void;
  30389. /**
  30390. * Creates a video texture straight from a stream.
  30391. * @param scene Define the scene the texture should be created in
  30392. * @param stream Define the stream the texture should be created from
  30393. * @returns The created video texture as a promise
  30394. */
  30395. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30396. /**
  30397. * Creates a video texture straight from your WebCam video feed.
  30398. * @param scene Define the scene the texture should be created in
  30399. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30400. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30401. * @returns The created video texture as a promise
  30402. */
  30403. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30404. minWidth: number;
  30405. maxWidth: number;
  30406. minHeight: number;
  30407. maxHeight: number;
  30408. deviceId: string;
  30409. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30410. /**
  30411. * Creates a video texture straight from your WebCam video feed.
  30412. * @param scene Define the scene the texture should be created in
  30413. * @param onReady Define a callback to triggered once the texture will be ready
  30414. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30415. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30416. */
  30417. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30418. minWidth: number;
  30419. maxWidth: number;
  30420. minHeight: number;
  30421. maxHeight: number;
  30422. deviceId: string;
  30423. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30424. }
  30425. }
  30426. declare module "babylonjs/Engines/engine" {
  30427. import { Observable } from "babylonjs/Misc/observable";
  30428. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  30429. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30430. import { Scene } from "babylonjs/scene";
  30431. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30432. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30433. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  30434. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30435. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30436. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30437. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  30438. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30439. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  30440. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  30441. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  30442. import { WebRequest } from "babylonjs/Misc/webRequest";
  30443. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30444. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30445. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30446. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30447. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30448. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  30449. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30450. import { Material } from "babylonjs/Materials/material";
  30451. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30452. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30453. /**
  30454. * Defines the interface used by objects containing a viewport (like a camera)
  30455. */
  30456. interface IViewportOwnerLike {
  30457. /**
  30458. * Gets or sets the viewport
  30459. */
  30460. viewport: IViewportLike;
  30461. }
  30462. /**
  30463. * Interface for attribute information associated with buffer instanciation
  30464. */
  30465. export class InstancingAttributeInfo {
  30466. /**
  30467. * Index/offset of the attribute in the vertex shader
  30468. */
  30469. index: number;
  30470. /**
  30471. * size of the attribute, 1, 2, 3 or 4
  30472. */
  30473. attributeSize: number;
  30474. /**
  30475. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30476. * default is FLOAT
  30477. */
  30478. attribyteType: number;
  30479. /**
  30480. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30481. */
  30482. normalized: boolean;
  30483. /**
  30484. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30485. */
  30486. offset: number;
  30487. /**
  30488. * Name of the GLSL attribute, for debugging purpose only
  30489. */
  30490. attributeName: string;
  30491. }
  30492. /**
  30493. * Define options used to create a depth texture
  30494. */
  30495. export class DepthTextureCreationOptions {
  30496. /** Specifies whether or not a stencil should be allocated in the texture */
  30497. generateStencil?: boolean;
  30498. /** Specifies whether or not bilinear filtering is enable on the texture */
  30499. bilinearFiltering?: boolean;
  30500. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  30501. comparisonFunction?: number;
  30502. /** Specifies if the created texture is a cube texture */
  30503. isCube?: boolean;
  30504. }
  30505. /**
  30506. * Class used to describe the capabilities of the engine relatively to the current browser
  30507. */
  30508. export class EngineCapabilities {
  30509. /** Maximum textures units per fragment shader */
  30510. maxTexturesImageUnits: number;
  30511. /** Maximum texture units per vertex shader */
  30512. maxVertexTextureImageUnits: number;
  30513. /** Maximum textures units in the entire pipeline */
  30514. maxCombinedTexturesImageUnits: number;
  30515. /** Maximum texture size */
  30516. maxTextureSize: number;
  30517. /** Maximum cube texture size */
  30518. maxCubemapTextureSize: number;
  30519. /** Maximum render texture size */
  30520. maxRenderTextureSize: number;
  30521. /** Maximum number of vertex attributes */
  30522. maxVertexAttribs: number;
  30523. /** Maximum number of varyings */
  30524. maxVaryingVectors: number;
  30525. /** Maximum number of uniforms per vertex shader */
  30526. maxVertexUniformVectors: number;
  30527. /** Maximum number of uniforms per fragment shader */
  30528. maxFragmentUniformVectors: number;
  30529. /** Defines if standard derivates (dx/dy) are supported */
  30530. standardDerivatives: boolean;
  30531. /** Defines if s3tc texture compression is supported */
  30532. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  30533. /** Defines if pvrtc texture compression is supported */
  30534. pvrtc: any;
  30535. /** Defines if etc1 texture compression is supported */
  30536. etc1: any;
  30537. /** Defines if etc2 texture compression is supported */
  30538. etc2: any;
  30539. /** Defines if astc texture compression is supported */
  30540. astc: any;
  30541. /** Defines if float textures are supported */
  30542. textureFloat: boolean;
  30543. /** Defines if vertex array objects are supported */
  30544. vertexArrayObject: boolean;
  30545. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30546. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  30547. /** Gets the maximum level of anisotropy supported */
  30548. maxAnisotropy: number;
  30549. /** Defines if instancing is supported */
  30550. instancedArrays: boolean;
  30551. /** Defines if 32 bits indices are supported */
  30552. uintIndices: boolean;
  30553. /** Defines if high precision shaders are supported */
  30554. highPrecisionShaderSupported: boolean;
  30555. /** Defines if depth reading in the fragment shader is supported */
  30556. fragmentDepthSupported: boolean;
  30557. /** Defines if float texture linear filtering is supported*/
  30558. textureFloatLinearFiltering: boolean;
  30559. /** Defines if rendering to float textures is supported */
  30560. textureFloatRender: boolean;
  30561. /** Defines if half float textures are supported*/
  30562. textureHalfFloat: boolean;
  30563. /** Defines if half float texture linear filtering is supported*/
  30564. textureHalfFloatLinearFiltering: boolean;
  30565. /** Defines if rendering to half float textures is supported */
  30566. textureHalfFloatRender: boolean;
  30567. /** Defines if textureLOD shader command is supported */
  30568. textureLOD: boolean;
  30569. /** Defines if draw buffers extension is supported */
  30570. drawBuffersExtension: boolean;
  30571. /** Defines if depth textures are supported */
  30572. depthTextureExtension: boolean;
  30573. /** Defines if float color buffer are supported */
  30574. colorBufferFloat: boolean;
  30575. /** Gets disjoint timer query extension (null if not supported) */
  30576. timerQuery: EXT_disjoint_timer_query;
  30577. /** Defines if timestamp can be used with timer query */
  30578. canUseTimestampForTimerQuery: boolean;
  30579. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30580. multiview: any;
  30581. /** Function used to let the system compiles shaders in background */
  30582. parallelShaderCompile: {
  30583. COMPLETION_STATUS_KHR: number;
  30584. };
  30585. /** Max number of texture samples for MSAA */
  30586. maxMSAASamples: number;
  30587. }
  30588. /** Interface defining initialization parameters for Engine class */
  30589. export interface EngineOptions extends WebGLContextAttributes {
  30590. /**
  30591. * Defines if the engine should no exceed a specified device ratio
  30592. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30593. */
  30594. limitDeviceRatio?: number;
  30595. /**
  30596. * Defines if webvr should be enabled automatically
  30597. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30598. */
  30599. autoEnableWebVR?: boolean;
  30600. /**
  30601. * Defines if webgl2 should be turned off even if supported
  30602. * @see http://doc.babylonjs.com/features/webgl2
  30603. */
  30604. disableWebGL2Support?: boolean;
  30605. /**
  30606. * Defines if webaudio should be initialized as well
  30607. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30608. */
  30609. audioEngine?: boolean;
  30610. /**
  30611. * Defines if animations should run using a deterministic lock step
  30612. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30613. */
  30614. deterministicLockstep?: boolean;
  30615. /** Defines the maximum steps to use with deterministic lock step mode */
  30616. lockstepMaxSteps?: number;
  30617. /**
  30618. * Defines that engine should ignore context lost events
  30619. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30620. */
  30621. doNotHandleContextLost?: boolean;
  30622. /**
  30623. * Defines that engine should ignore modifying touch action attribute and style
  30624. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30625. */
  30626. doNotHandleTouchAction?: boolean;
  30627. /**
  30628. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30629. */
  30630. useHighPrecisionFloats?: boolean;
  30631. }
  30632. /**
  30633. * Defines the interface used by display changed events
  30634. */
  30635. export interface IDisplayChangedEventArgs {
  30636. /** Gets the vrDisplay object (if any) */
  30637. vrDisplay: Nullable<any>;
  30638. /** Gets a boolean indicating if webVR is supported */
  30639. vrSupported: boolean;
  30640. }
  30641. /**
  30642. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30643. */
  30644. export class Engine {
  30645. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30646. static ExceptionList: ({
  30647. key: string;
  30648. capture: string;
  30649. captureConstraint: number;
  30650. targets: string[];
  30651. } | {
  30652. key: string;
  30653. capture: null;
  30654. captureConstraint: null;
  30655. targets: string[];
  30656. })[];
  30657. /** Gets the list of created engines */
  30658. static readonly Instances: Engine[];
  30659. /**
  30660. * Gets the latest created engine
  30661. */
  30662. static readonly LastCreatedEngine: Nullable<Engine>;
  30663. /**
  30664. * Gets the latest created scene
  30665. */
  30666. static readonly LastCreatedScene: Nullable<Scene>;
  30667. /**
  30668. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30669. * @param flag defines which part of the materials must be marked as dirty
  30670. * @param predicate defines a predicate used to filter which materials should be affected
  30671. */
  30672. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30673. /** @hidden */
  30674. static _TextureLoaders: IInternalTextureLoader[];
  30675. /** Defines that alpha blending is disabled */
  30676. static readonly ALPHA_DISABLE: number;
  30677. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30678. static readonly ALPHA_ADD: number;
  30679. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30680. static readonly ALPHA_COMBINE: number;
  30681. /** Defines that alpha blending to DEST - SRC * DEST */
  30682. static readonly ALPHA_SUBTRACT: number;
  30683. /** Defines that alpha blending to SRC * DEST */
  30684. static readonly ALPHA_MULTIPLY: number;
  30685. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30686. static readonly ALPHA_MAXIMIZED: number;
  30687. /** Defines that alpha blending to SRC + DEST */
  30688. static readonly ALPHA_ONEONE: number;
  30689. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30690. static readonly ALPHA_PREMULTIPLIED: number;
  30691. /**
  30692. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30693. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30694. */
  30695. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30696. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30697. static readonly ALPHA_INTERPOLATE: number;
  30698. /**
  30699. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30700. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30701. */
  30702. static readonly ALPHA_SCREENMODE: number;
  30703. /** Defines that the ressource is not delayed*/
  30704. static readonly DELAYLOADSTATE_NONE: number;
  30705. /** Defines that the ressource was successfully delay loaded */
  30706. static readonly DELAYLOADSTATE_LOADED: number;
  30707. /** Defines that the ressource is currently delay loading */
  30708. static readonly DELAYLOADSTATE_LOADING: number;
  30709. /** Defines that the ressource is delayed and has not started loading */
  30710. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30711. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30712. static readonly NEVER: number;
  30713. /** 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 */
  30714. static readonly ALWAYS: number;
  30715. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30716. static readonly LESS: number;
  30717. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30718. static readonly EQUAL: number;
  30719. /** 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 */
  30720. static readonly LEQUAL: number;
  30721. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30722. static readonly GREATER: number;
  30723. /** 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 */
  30724. static readonly GEQUAL: number;
  30725. /** 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 */
  30726. static readonly NOTEQUAL: number;
  30727. /** Passed to stencilOperation to specify that stencil value must be kept */
  30728. static readonly KEEP: number;
  30729. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30730. static readonly REPLACE: number;
  30731. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30732. static readonly INCR: number;
  30733. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30734. static readonly DECR: number;
  30735. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30736. static readonly INVERT: number;
  30737. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30738. static readonly INCR_WRAP: number;
  30739. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30740. static readonly DECR_WRAP: number;
  30741. /** Texture is not repeating outside of 0..1 UVs */
  30742. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30743. /** Texture is repeating outside of 0..1 UVs */
  30744. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30745. /** Texture is repeating and mirrored */
  30746. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30747. /** ALPHA */
  30748. static readonly TEXTUREFORMAT_ALPHA: number;
  30749. /** LUMINANCE */
  30750. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30751. /** LUMINANCE_ALPHA */
  30752. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30753. /** RGB */
  30754. static readonly TEXTUREFORMAT_RGB: number;
  30755. /** RGBA */
  30756. static readonly TEXTUREFORMAT_RGBA: number;
  30757. /** RED */
  30758. static readonly TEXTUREFORMAT_RED: number;
  30759. /** RED (2nd reference) */
  30760. static readonly TEXTUREFORMAT_R: number;
  30761. /** RG */
  30762. static readonly TEXTUREFORMAT_RG: number;
  30763. /** RED_INTEGER */
  30764. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30765. /** RED_INTEGER (2nd reference) */
  30766. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30767. /** RG_INTEGER */
  30768. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30769. /** RGB_INTEGER */
  30770. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30771. /** RGBA_INTEGER */
  30772. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30773. /** UNSIGNED_BYTE */
  30774. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30775. /** UNSIGNED_BYTE (2nd reference) */
  30776. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30777. /** FLOAT */
  30778. static readonly TEXTURETYPE_FLOAT: number;
  30779. /** HALF_FLOAT */
  30780. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30781. /** BYTE */
  30782. static readonly TEXTURETYPE_BYTE: number;
  30783. /** SHORT */
  30784. static readonly TEXTURETYPE_SHORT: number;
  30785. /** UNSIGNED_SHORT */
  30786. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30787. /** INT */
  30788. static readonly TEXTURETYPE_INT: number;
  30789. /** UNSIGNED_INT */
  30790. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30791. /** UNSIGNED_SHORT_4_4_4_4 */
  30792. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30793. /** UNSIGNED_SHORT_5_5_5_1 */
  30794. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30795. /** UNSIGNED_SHORT_5_6_5 */
  30796. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30797. /** UNSIGNED_INT_2_10_10_10_REV */
  30798. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30799. /** UNSIGNED_INT_24_8 */
  30800. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30801. /** UNSIGNED_INT_10F_11F_11F_REV */
  30802. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30803. /** UNSIGNED_INT_5_9_9_9_REV */
  30804. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30805. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30806. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30807. /** nearest is mag = nearest and min = nearest and mip = linear */
  30808. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30809. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30810. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30811. /** Trilinear is mag = linear and min = linear and mip = linear */
  30812. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30813. /** nearest is mag = nearest and min = nearest and mip = linear */
  30814. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30815. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30816. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30817. /** Trilinear is mag = linear and min = linear and mip = linear */
  30818. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30819. /** mag = nearest and min = nearest and mip = nearest */
  30820. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30821. /** mag = nearest and min = linear and mip = nearest */
  30822. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30823. /** mag = nearest and min = linear and mip = linear */
  30824. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30825. /** mag = nearest and min = linear and mip = none */
  30826. static readonly TEXTURE_NEAREST_LINEAR: number;
  30827. /** mag = nearest and min = nearest and mip = none */
  30828. static readonly TEXTURE_NEAREST_NEAREST: number;
  30829. /** mag = linear and min = nearest and mip = nearest */
  30830. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30831. /** mag = linear and min = nearest and mip = linear */
  30832. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30833. /** mag = linear and min = linear and mip = none */
  30834. static readonly TEXTURE_LINEAR_LINEAR: number;
  30835. /** mag = linear and min = nearest and mip = none */
  30836. static readonly TEXTURE_LINEAR_NEAREST: number;
  30837. /** Explicit coordinates mode */
  30838. static readonly TEXTURE_EXPLICIT_MODE: number;
  30839. /** Spherical coordinates mode */
  30840. static readonly TEXTURE_SPHERICAL_MODE: number;
  30841. /** Planar coordinates mode */
  30842. static readonly TEXTURE_PLANAR_MODE: number;
  30843. /** Cubic coordinates mode */
  30844. static readonly TEXTURE_CUBIC_MODE: number;
  30845. /** Projection coordinates mode */
  30846. static readonly TEXTURE_PROJECTION_MODE: number;
  30847. /** Skybox coordinates mode */
  30848. static readonly TEXTURE_SKYBOX_MODE: number;
  30849. /** Inverse Cubic coordinates mode */
  30850. static readonly TEXTURE_INVCUBIC_MODE: number;
  30851. /** Equirectangular coordinates mode */
  30852. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30853. /** Equirectangular Fixed coordinates mode */
  30854. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30855. /** Equirectangular Fixed Mirrored coordinates mode */
  30856. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30857. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30858. static readonly SCALEMODE_FLOOR: number;
  30859. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30860. static readonly SCALEMODE_NEAREST: number;
  30861. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30862. static readonly SCALEMODE_CEILING: number;
  30863. /**
  30864. * Returns the current npm package of the sdk
  30865. */
  30866. static readonly NpmPackage: string;
  30867. /**
  30868. * Returns the current version of the framework
  30869. */
  30870. static readonly Version: string;
  30871. /**
  30872. * Returns a string describing the current engine
  30873. */
  30874. readonly description: string;
  30875. /**
  30876. * Gets or sets the epsilon value used by collision engine
  30877. */
  30878. static CollisionsEpsilon: number;
  30879. /**
  30880. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30881. */
  30882. static ShadersRepository: string;
  30883. /**
  30884. * Method called to create the default loading screen.
  30885. * This can be overriden in your own app.
  30886. * @param canvas The rendering canvas element
  30887. * @returns The loading screen
  30888. */
  30889. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30890. /**
  30891. * Method called to create the default rescale post process on each engine.
  30892. */
  30893. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30894. /** @hidden */
  30895. _shaderProcessor: IShaderProcessor;
  30896. /**
  30897. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30898. */
  30899. forcePOTTextures: boolean;
  30900. /**
  30901. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30902. */
  30903. isFullscreen: boolean;
  30904. /**
  30905. * Gets a boolean indicating if the pointer is currently locked
  30906. */
  30907. isPointerLock: boolean;
  30908. /**
  30909. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30910. */
  30911. cullBackFaces: boolean;
  30912. /**
  30913. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30914. */
  30915. renderEvenInBackground: boolean;
  30916. /**
  30917. * Gets or sets a boolean indicating that cache can be kept between frames
  30918. */
  30919. preventCacheWipeBetweenFrames: boolean;
  30920. /**
  30921. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30922. **/
  30923. enableOfflineSupport: boolean;
  30924. /**
  30925. * 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)
  30926. **/
  30927. disableManifestCheck: boolean;
  30928. /**
  30929. * Gets the list of created scenes
  30930. */
  30931. scenes: Scene[];
  30932. /**
  30933. * Event raised when a new scene is created
  30934. */
  30935. onNewSceneAddedObservable: Observable<Scene>;
  30936. /**
  30937. * Gets the list of created postprocesses
  30938. */
  30939. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  30940. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30941. validateShaderPrograms: boolean;
  30942. /**
  30943. * Observable event triggered each time the rendering canvas is resized
  30944. */
  30945. onResizeObservable: Observable<Engine>;
  30946. /**
  30947. * Observable event triggered each time the canvas loses focus
  30948. */
  30949. onCanvasBlurObservable: Observable<Engine>;
  30950. /**
  30951. * Observable event triggered each time the canvas gains focus
  30952. */
  30953. onCanvasFocusObservable: Observable<Engine>;
  30954. /**
  30955. * Observable event triggered each time the canvas receives pointerout event
  30956. */
  30957. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30958. /**
  30959. * Observable event triggered before each texture is initialized
  30960. */
  30961. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30962. /**
  30963. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30964. */
  30965. disableUniformBuffers: boolean;
  30966. /** @hidden */
  30967. _uniformBuffers: UniformBuffer[];
  30968. /**
  30969. * Gets a boolean indicating that the engine supports uniform buffers
  30970. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30971. */
  30972. readonly supportsUniformBuffers: boolean;
  30973. /**
  30974. * Observable raised when the engine begins a new frame
  30975. */
  30976. onBeginFrameObservable: Observable<Engine>;
  30977. /**
  30978. * If set, will be used to request the next animation frame for the render loop
  30979. */
  30980. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30981. /**
  30982. * Observable raised when the engine ends the current frame
  30983. */
  30984. onEndFrameObservable: Observable<Engine>;
  30985. /**
  30986. * Observable raised when the engine is about to compile a shader
  30987. */
  30988. onBeforeShaderCompilationObservable: Observable<Engine>;
  30989. /**
  30990. * Observable raised when the engine has jsut compiled a shader
  30991. */
  30992. onAfterShaderCompilationObservable: Observable<Engine>;
  30993. /** @hidden */
  30994. _gl: WebGLRenderingContext;
  30995. private _renderingCanvas;
  30996. private _windowIsBackground;
  30997. protected _webGLVersion: number;
  30998. protected _highPrecisionShadersAllowed: boolean;
  30999. /** @hidden */
  31000. readonly _shouldUseHighPrecisionShader: boolean;
  31001. /**
  31002. * Gets a boolean indicating that only power of 2 textures are supported
  31003. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31004. */
  31005. readonly needPOTTextures: boolean;
  31006. /** @hidden */
  31007. _badOS: boolean;
  31008. /** @hidden */
  31009. _badDesktopOS: boolean;
  31010. /**
  31011. * Gets the audio engine
  31012. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31013. * @ignorenaming
  31014. */
  31015. static audioEngine: IAudioEngine;
  31016. /**
  31017. * Default AudioEngine factory responsible of creating the Audio Engine.
  31018. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31019. */
  31020. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31021. /**
  31022. * Default offline support factory responsible of creating a tool used to store data locally.
  31023. * By default, this will create a Database object if the workload has been embedded.
  31024. */
  31025. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31026. private _onFocus;
  31027. private _onBlur;
  31028. private _onCanvasPointerOut;
  31029. private _onCanvasBlur;
  31030. private _onCanvasFocus;
  31031. private _onFullscreenChange;
  31032. private _onPointerLockChange;
  31033. private _hardwareScalingLevel;
  31034. /** @hidden */
  31035. _caps: EngineCapabilities;
  31036. private _pointerLockRequested;
  31037. private _isStencilEnable;
  31038. protected _colorWrite: boolean;
  31039. private _loadingScreen;
  31040. /** @hidden */
  31041. _drawCalls: PerfCounter;
  31042. private _glVersion;
  31043. private _glRenderer;
  31044. private _glVendor;
  31045. private _videoTextureSupported;
  31046. private _renderingQueueLaunched;
  31047. private _activeRenderLoops;
  31048. private _deterministicLockstep;
  31049. private _lockstepMaxSteps;
  31050. /**
  31051. * Observable signaled when a context lost event is raised
  31052. */
  31053. onContextLostObservable: Observable<Engine>;
  31054. /**
  31055. * Observable signaled when a context restored event is raised
  31056. */
  31057. onContextRestoredObservable: Observable<Engine>;
  31058. private _onContextLost;
  31059. private _onContextRestored;
  31060. private _contextWasLost;
  31061. /** @hidden */
  31062. _doNotHandleContextLost: boolean;
  31063. /**
  31064. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31065. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31066. */
  31067. doNotHandleContextLost: boolean;
  31068. private _performanceMonitor;
  31069. private _fps;
  31070. private _deltaTime;
  31071. /**
  31072. * Turn this value on if you want to pause FPS computation when in background
  31073. */
  31074. disablePerformanceMonitorInBackground: boolean;
  31075. /**
  31076. * Gets the performance monitor attached to this engine
  31077. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31078. */
  31079. readonly performanceMonitor: PerformanceMonitor;
  31080. /**
  31081. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31082. */
  31083. disableVertexArrayObjects: boolean;
  31084. /** @hidden */
  31085. protected _depthCullingState: _DepthCullingState;
  31086. /** @hidden */
  31087. protected _stencilState: _StencilState;
  31088. /** @hidden */
  31089. protected _alphaState: _AlphaState;
  31090. /** @hidden */
  31091. protected _alphaMode: number;
  31092. /** @hidden */
  31093. _internalTexturesCache: InternalTexture[];
  31094. /** @hidden */
  31095. protected _activeChannel: number;
  31096. private _currentTextureChannel;
  31097. /** @hidden */
  31098. protected _boundTexturesCache: {
  31099. [key: string]: Nullable<InternalTexture>;
  31100. };
  31101. /** @hidden */
  31102. protected _currentEffect: Nullable<Effect>;
  31103. /** @hidden */
  31104. protected _currentProgram: Nullable<WebGLProgram>;
  31105. private _compiledEffects;
  31106. private _vertexAttribArraysEnabled;
  31107. /** @hidden */
  31108. protected _cachedViewport: Nullable<IViewportLike>;
  31109. private _cachedVertexArrayObject;
  31110. /** @hidden */
  31111. protected _cachedVertexBuffers: any;
  31112. /** @hidden */
  31113. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31114. /** @hidden */
  31115. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31116. /** @hidden */
  31117. _currentRenderTarget: Nullable<InternalTexture>;
  31118. private _uintIndicesCurrentlySet;
  31119. private _currentBoundBuffer;
  31120. /** @hidden */
  31121. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31122. private _currentBufferPointers;
  31123. private _currentInstanceLocations;
  31124. private _currentInstanceBuffers;
  31125. private _textureUnits;
  31126. /** @hidden */
  31127. _workingCanvas: Nullable<HTMLCanvasElement>;
  31128. /** @hidden */
  31129. _workingContext: Nullable<CanvasRenderingContext2D>;
  31130. private _rescalePostProcess;
  31131. private _dummyFramebuffer;
  31132. private _externalData;
  31133. /** @hidden */
  31134. _bindedRenderFunction: any;
  31135. private _vaoRecordInProgress;
  31136. private _mustWipeVertexAttributes;
  31137. private _emptyTexture;
  31138. private _emptyCubeTexture;
  31139. private _emptyTexture3D;
  31140. /** @hidden */
  31141. _frameHandler: number;
  31142. private _nextFreeTextureSlots;
  31143. private _maxSimultaneousTextures;
  31144. private _activeRequests;
  31145. private _texturesSupported;
  31146. /** @hidden */
  31147. _textureFormatInUse: Nullable<string>;
  31148. /**
  31149. * Gets the list of texture formats supported
  31150. */
  31151. readonly texturesSupported: Array<string>;
  31152. /**
  31153. * Gets the list of texture formats in use
  31154. */
  31155. readonly textureFormatInUse: Nullable<string>;
  31156. /**
  31157. * Gets the current viewport
  31158. */
  31159. readonly currentViewport: Nullable<IViewportLike>;
  31160. /**
  31161. * Gets the default empty texture
  31162. */
  31163. readonly emptyTexture: InternalTexture;
  31164. /**
  31165. * Gets the default empty 3D texture
  31166. */
  31167. readonly emptyTexture3D: InternalTexture;
  31168. /**
  31169. * Gets the default empty cube texture
  31170. */
  31171. readonly emptyCubeTexture: InternalTexture;
  31172. /**
  31173. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31174. */
  31175. readonly premultipliedAlpha: boolean;
  31176. /**
  31177. * Creates a new engine
  31178. * @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
  31179. * @param antialias defines enable antialiasing (default: false)
  31180. * @param options defines further options to be sent to the getContext() function
  31181. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31182. */
  31183. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31184. /**
  31185. * Initializes a webVR display and starts listening to display change events
  31186. * The onVRDisplayChangedObservable will be notified upon these changes
  31187. * @returns The onVRDisplayChangedObservable
  31188. */
  31189. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31190. /** @hidden */
  31191. _prepareVRComponent(): void;
  31192. /** @hidden */
  31193. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  31194. /** @hidden */
  31195. _submitVRFrame(): void;
  31196. /**
  31197. * Call this function to leave webVR mode
  31198. * Will do nothing if webVR is not supported or if there is no webVR device
  31199. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31200. */
  31201. disableVR(): void;
  31202. /**
  31203. * Gets a boolean indicating that the system is in VR mode and is presenting
  31204. * @returns true if VR mode is engaged
  31205. */
  31206. isVRPresenting(): boolean;
  31207. /** @hidden */
  31208. _requestVRFrame(): void;
  31209. private _disableTouchAction;
  31210. private _rebuildInternalTextures;
  31211. private _rebuildEffects;
  31212. /**
  31213. * Gets a boolean indicating if all created effects are ready
  31214. * @returns true if all effects are ready
  31215. */
  31216. areAllEffectsReady(): boolean;
  31217. private _rebuildBuffers;
  31218. private _initGLContext;
  31219. /**
  31220. * Gets version of the current webGL context
  31221. */
  31222. readonly webGLVersion: number;
  31223. /**
  31224. * Gets a string idenfifying the name of the class
  31225. * @returns "Engine" string
  31226. */
  31227. getClassName(): string;
  31228. /**
  31229. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31230. */
  31231. readonly isStencilEnable: boolean;
  31232. /** @hidden */
  31233. _prepareWorkingCanvas(): void;
  31234. /**
  31235. * Reset the texture cache to empty state
  31236. */
  31237. resetTextureCache(): void;
  31238. /**
  31239. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31240. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31241. * @returns true if engine is in deterministic lock step mode
  31242. */
  31243. isDeterministicLockStep(): boolean;
  31244. /**
  31245. * Gets the max steps when engine is running in deterministic lock step
  31246. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31247. * @returns the max steps
  31248. */
  31249. getLockstepMaxSteps(): number;
  31250. /**
  31251. * Gets an object containing information about the current webGL context
  31252. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31253. */
  31254. getGlInfo(): {
  31255. vendor: string;
  31256. renderer: string;
  31257. version: string;
  31258. };
  31259. /**
  31260. * Gets current aspect ratio
  31261. * @param viewportOwner defines the camera to use to get the aspect ratio
  31262. * @param useScreen defines if screen size must be used (or the current render target if any)
  31263. * @returns a number defining the aspect ratio
  31264. */
  31265. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31266. /**
  31267. * Gets current screen aspect ratio
  31268. * @returns a number defining the aspect ratio
  31269. */
  31270. getScreenAspectRatio(): number;
  31271. /**
  31272. * Gets the current render width
  31273. * @param useScreen defines if screen size must be used (or the current render target if any)
  31274. * @returns a number defining the current render width
  31275. */
  31276. getRenderWidth(useScreen?: boolean): number;
  31277. /**
  31278. * Gets the current render height
  31279. * @param useScreen defines if screen size must be used (or the current render target if any)
  31280. * @returns a number defining the current render height
  31281. */
  31282. getRenderHeight(useScreen?: boolean): number;
  31283. /**
  31284. * Gets the HTML canvas attached with the current webGL context
  31285. * @returns a HTML canvas
  31286. */
  31287. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31288. /**
  31289. * Gets host window
  31290. * @returns the host window object
  31291. */
  31292. getHostWindow(): Window;
  31293. /**
  31294. * Gets host document
  31295. * @returns the host document object
  31296. */
  31297. getHostDocument(): Document;
  31298. /**
  31299. * Gets the client rect of the HTML canvas attached with the current webGL context
  31300. * @returns a client rectanglee
  31301. */
  31302. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31303. /**
  31304. * Defines the hardware scaling level.
  31305. * By default the hardware scaling level is computed from the window device ratio.
  31306. * 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.
  31307. * @param level defines the level to use
  31308. */
  31309. setHardwareScalingLevel(level: number): void;
  31310. /**
  31311. * Gets the current hardware scaling level.
  31312. * By default the hardware scaling level is computed from the window device ratio.
  31313. * 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.
  31314. * @returns a number indicating the current hardware scaling level
  31315. */
  31316. getHardwareScalingLevel(): number;
  31317. /**
  31318. * Gets the list of loaded textures
  31319. * @returns an array containing all loaded textures
  31320. */
  31321. getLoadedTexturesCache(): InternalTexture[];
  31322. /**
  31323. * Gets the object containing all engine capabilities
  31324. * @returns the EngineCapabilities object
  31325. */
  31326. getCaps(): EngineCapabilities;
  31327. /**
  31328. * Gets the current depth function
  31329. * @returns a number defining the depth function
  31330. */
  31331. getDepthFunction(): Nullable<number>;
  31332. /**
  31333. * Sets the current depth function
  31334. * @param depthFunc defines the function to use
  31335. */
  31336. setDepthFunction(depthFunc: number): void;
  31337. /**
  31338. * Sets the current depth function to GREATER
  31339. */
  31340. setDepthFunctionToGreater(): void;
  31341. /**
  31342. * Sets the current depth function to GEQUAL
  31343. */
  31344. setDepthFunctionToGreaterOrEqual(): void;
  31345. /**
  31346. * Sets the current depth function to LESS
  31347. */
  31348. setDepthFunctionToLess(): void;
  31349. private _cachedStencilBuffer;
  31350. private _cachedStencilFunction;
  31351. private _cachedStencilMask;
  31352. private _cachedStencilOperationPass;
  31353. private _cachedStencilOperationFail;
  31354. private _cachedStencilOperationDepthFail;
  31355. private _cachedStencilReference;
  31356. /**
  31357. * Caches the the state of the stencil buffer
  31358. */
  31359. cacheStencilState(): void;
  31360. /**
  31361. * Restores the state of the stencil buffer
  31362. */
  31363. restoreStencilState(): void;
  31364. /**
  31365. * Sets the current depth function to LEQUAL
  31366. */
  31367. setDepthFunctionToLessOrEqual(): void;
  31368. /**
  31369. * Gets a boolean indicating if stencil buffer is enabled
  31370. * @returns the current stencil buffer state
  31371. */
  31372. getStencilBuffer(): boolean;
  31373. /**
  31374. * Enable or disable the stencil buffer
  31375. * @param enable defines if the stencil buffer must be enabled or disabled
  31376. */
  31377. setStencilBuffer(enable: boolean): void;
  31378. /**
  31379. * Gets the current stencil mask
  31380. * @returns a number defining the new stencil mask to use
  31381. */
  31382. getStencilMask(): number;
  31383. /**
  31384. * Sets the current stencil mask
  31385. * @param mask defines the new stencil mask to use
  31386. */
  31387. setStencilMask(mask: number): void;
  31388. /**
  31389. * Gets the current stencil function
  31390. * @returns a number defining the stencil function to use
  31391. */
  31392. getStencilFunction(): number;
  31393. /**
  31394. * Gets the current stencil reference value
  31395. * @returns a number defining the stencil reference value to use
  31396. */
  31397. getStencilFunctionReference(): number;
  31398. /**
  31399. * Gets the current stencil mask
  31400. * @returns a number defining the stencil mask to use
  31401. */
  31402. getStencilFunctionMask(): number;
  31403. /**
  31404. * Sets the current stencil function
  31405. * @param stencilFunc defines the new stencil function to use
  31406. */
  31407. setStencilFunction(stencilFunc: number): void;
  31408. /**
  31409. * Sets the current stencil reference
  31410. * @param reference defines the new stencil reference to use
  31411. */
  31412. setStencilFunctionReference(reference: number): void;
  31413. /**
  31414. * Sets the current stencil mask
  31415. * @param mask defines the new stencil mask to use
  31416. */
  31417. setStencilFunctionMask(mask: number): void;
  31418. /**
  31419. * Gets the current stencil operation when stencil fails
  31420. * @returns a number defining stencil operation to use when stencil fails
  31421. */
  31422. getStencilOperationFail(): number;
  31423. /**
  31424. * Gets the current stencil operation when depth fails
  31425. * @returns a number defining stencil operation to use when depth fails
  31426. */
  31427. getStencilOperationDepthFail(): number;
  31428. /**
  31429. * Gets the current stencil operation when stencil passes
  31430. * @returns a number defining stencil operation to use when stencil passes
  31431. */
  31432. getStencilOperationPass(): number;
  31433. /**
  31434. * Sets the stencil operation to use when stencil fails
  31435. * @param operation defines the stencil operation to use when stencil fails
  31436. */
  31437. setStencilOperationFail(operation: number): void;
  31438. /**
  31439. * Sets the stencil operation to use when depth fails
  31440. * @param operation defines the stencil operation to use when depth fails
  31441. */
  31442. setStencilOperationDepthFail(operation: number): void;
  31443. /**
  31444. * Sets the stencil operation to use when stencil passes
  31445. * @param operation defines the stencil operation to use when stencil passes
  31446. */
  31447. setStencilOperationPass(operation: number): void;
  31448. /**
  31449. * Sets a boolean indicating if the dithering state is enabled or disabled
  31450. * @param value defines the dithering state
  31451. */
  31452. setDitheringState(value: boolean): void;
  31453. /**
  31454. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31455. * @param value defines the rasterizer state
  31456. */
  31457. setRasterizerState(value: boolean): void;
  31458. /**
  31459. * stop executing a render loop function and remove it from the execution array
  31460. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31461. */
  31462. stopRenderLoop(renderFunction?: () => void): void;
  31463. /** @hidden */
  31464. _renderLoop(): void;
  31465. /**
  31466. * Can be used to override the current requestAnimationFrame requester.
  31467. * @hidden
  31468. */
  31469. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31470. /**
  31471. * Register and execute a render loop. The engine can have more than one render function
  31472. * @param renderFunction defines the function to continuously execute
  31473. */
  31474. runRenderLoop(renderFunction: () => void): void;
  31475. /**
  31476. * Toggle full screen mode
  31477. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31478. */
  31479. switchFullscreen(requestPointerLock: boolean): void;
  31480. /**
  31481. * Enters full screen mode
  31482. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31483. */
  31484. enterFullscreen(requestPointerLock: boolean): void;
  31485. /**
  31486. * Exits full screen mode
  31487. */
  31488. exitFullscreen(): void;
  31489. /**
  31490. * Enters Pointerlock mode
  31491. */
  31492. enterPointerlock(): void;
  31493. /**
  31494. * Exits Pointerlock mode
  31495. */
  31496. exitPointerlock(): void;
  31497. /**
  31498. * Clear the current render buffer or the current render target (if any is set up)
  31499. * @param color defines the color to use
  31500. * @param backBuffer defines if the back buffer must be cleared
  31501. * @param depth defines if the depth buffer must be cleared
  31502. * @param stencil defines if the stencil buffer must be cleared
  31503. */
  31504. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31505. /**
  31506. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31507. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31508. * @param y defines the y-coordinate of the corner of the clear rectangle
  31509. * @param width defines the width of the clear rectangle
  31510. * @param height defines the height of the clear rectangle
  31511. * @param clearColor defines the clear color
  31512. */
  31513. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31514. /**
  31515. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31516. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31517. * @param y defines the y-coordinate of the corner of the clear rectangle
  31518. * @param width defines the width of the clear rectangle
  31519. * @param height defines the height of the clear rectangle
  31520. */
  31521. enableScissor(x: number, y: number, width: number, height: number): void;
  31522. /**
  31523. * Disable previously set scissor test rectangle
  31524. */
  31525. disableScissor(): void;
  31526. private _viewportCached;
  31527. /** @hidden */
  31528. _viewport(x: number, y: number, width: number, height: number): void;
  31529. /**
  31530. * Set the WebGL's viewport
  31531. * @param viewport defines the viewport element to be used
  31532. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31533. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31534. */
  31535. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31536. /**
  31537. * Directly set the WebGL Viewport
  31538. * @param x defines the x coordinate of the viewport (in screen space)
  31539. * @param y defines the y coordinate of the viewport (in screen space)
  31540. * @param width defines the width of the viewport (in screen space)
  31541. * @param height defines the height of the viewport (in screen space)
  31542. * @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
  31543. */
  31544. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31545. /**
  31546. * Begin a new frame
  31547. */
  31548. beginFrame(): void;
  31549. /**
  31550. * Enf the current frame
  31551. */
  31552. endFrame(): void;
  31553. /**
  31554. * Resize the view according to the canvas' size
  31555. */
  31556. resize(): void;
  31557. /**
  31558. * Force a specific size of the canvas
  31559. * @param width defines the new canvas' width
  31560. * @param height defines the new canvas' height
  31561. */
  31562. setSize(width: number, height: number): void;
  31563. /**
  31564. * Binds the frame buffer to the specified texture.
  31565. * @param texture The texture to render to or null for the default canvas
  31566. * @param faceIndex The face of the texture to render to in case of cube texture
  31567. * @param requiredWidth The width of the target to render to
  31568. * @param requiredHeight The height of the target to render to
  31569. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31570. * @param depthStencilTexture The depth stencil texture to use to render
  31571. * @param lodLevel defines le lod level to bind to the frame buffer
  31572. */
  31573. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31574. /** @hidden */
  31575. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31576. /**
  31577. * Unbind the current render target texture from the webGL context
  31578. * @param texture defines the render target texture to unbind
  31579. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31580. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31581. */
  31582. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31583. /**
  31584. * Force the mipmap generation for the given render target texture
  31585. * @param texture defines the render target texture to use
  31586. */
  31587. generateMipMapsForCubemap(texture: InternalTexture): void;
  31588. /**
  31589. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31590. */
  31591. flushFramebuffer(): void;
  31592. /**
  31593. * Unbind the current render target and bind the default framebuffer
  31594. */
  31595. restoreDefaultFramebuffer(): void;
  31596. /**
  31597. * Create an uniform buffer
  31598. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31599. * @param elements defines the content of the uniform buffer
  31600. * @returns the webGL uniform buffer
  31601. */
  31602. createUniformBuffer(elements: FloatArray): DataBuffer;
  31603. /**
  31604. * Create a dynamic uniform buffer
  31605. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31606. * @param elements defines the content of the uniform buffer
  31607. * @returns the webGL uniform buffer
  31608. */
  31609. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  31610. /**
  31611. * Update an existing uniform buffer
  31612. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31613. * @param uniformBuffer defines the target uniform buffer
  31614. * @param elements defines the content to update
  31615. * @param offset defines the offset in the uniform buffer where update should start
  31616. * @param count defines the size of the data to update
  31617. */
  31618. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  31619. private _resetVertexBufferBinding;
  31620. /**
  31621. * Creates a vertex buffer
  31622. * @param data the data for the vertex buffer
  31623. * @returns the new WebGL static buffer
  31624. */
  31625. createVertexBuffer(data: DataArray): DataBuffer;
  31626. /**
  31627. * Creates a dynamic vertex buffer
  31628. * @param data the data for the dynamic vertex buffer
  31629. * @returns the new WebGL dynamic buffer
  31630. */
  31631. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31632. /**
  31633. * Update a dynamic index buffer
  31634. * @param indexBuffer defines the target index buffer
  31635. * @param indices defines the data to update
  31636. * @param offset defines the offset in the target index buffer where update should start
  31637. */
  31638. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31639. /**
  31640. * Updates a dynamic vertex buffer.
  31641. * @param vertexBuffer the vertex buffer to update
  31642. * @param data the data used to update the vertex buffer
  31643. * @param byteOffset the byte offset of the data
  31644. * @param byteLength the byte length of the data
  31645. */
  31646. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31647. private _resetIndexBufferBinding;
  31648. /**
  31649. * Creates a new index buffer
  31650. * @param indices defines the content of the index buffer
  31651. * @param updatable defines if the index buffer must be updatable
  31652. * @returns a new webGL buffer
  31653. */
  31654. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31655. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31656. /**
  31657. * Bind a webGL buffer to the webGL context
  31658. * @param buffer defines the buffer to bind
  31659. */
  31660. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31661. /**
  31662. * Bind an uniform buffer to the current webGL context
  31663. * @param buffer defines the buffer to bind
  31664. */
  31665. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  31666. /**
  31667. * Bind a buffer to the current webGL context at a given location
  31668. * @param buffer defines the buffer to bind
  31669. * @param location defines the index where to bind the buffer
  31670. */
  31671. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  31672. /**
  31673. * Bind a specific block at a given index in a specific shader program
  31674. * @param pipelineContext defines the pipeline context to use
  31675. * @param blockName defines the block name
  31676. * @param index defines the index where to bind the block
  31677. */
  31678. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  31679. private bindIndexBuffer;
  31680. private bindBuffer;
  31681. /**
  31682. * update the bound buffer with the given data
  31683. * @param data defines the data to update
  31684. */
  31685. updateArrayBuffer(data: Float32Array): void;
  31686. private _vertexAttribPointer;
  31687. private _bindIndexBufferWithCache;
  31688. private _bindVertexBuffersAttributes;
  31689. /**
  31690. * Records a vertex array object
  31691. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31692. * @param vertexBuffers defines the list of vertex buffers to store
  31693. * @param indexBuffer defines the index buffer to store
  31694. * @param effect defines the effect to store
  31695. * @returns the new vertex array object
  31696. */
  31697. recordVertexArrayObject(vertexBuffers: {
  31698. [key: string]: VertexBuffer;
  31699. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31700. /**
  31701. * Bind a specific vertex array object
  31702. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31703. * @param vertexArrayObject defines the vertex array object to bind
  31704. * @param indexBuffer defines the index buffer to bind
  31705. */
  31706. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31707. /**
  31708. * Bind webGl buffers directly to the webGL context
  31709. * @param vertexBuffer defines the vertex buffer to bind
  31710. * @param indexBuffer defines the index buffer to bind
  31711. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31712. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31713. * @param effect defines the effect associated with the vertex buffer
  31714. */
  31715. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31716. private _unbindVertexArrayObject;
  31717. /**
  31718. * Bind a list of vertex buffers to the webGL context
  31719. * @param vertexBuffers defines the list of vertex buffers to bind
  31720. * @param indexBuffer defines the index buffer to bind
  31721. * @param effect defines the effect associated with the vertex buffers
  31722. */
  31723. bindBuffers(vertexBuffers: {
  31724. [key: string]: Nullable<VertexBuffer>;
  31725. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31726. /**
  31727. * Unbind all instance attributes
  31728. */
  31729. unbindInstanceAttributes(): void;
  31730. /**
  31731. * Release and free the memory of a vertex array object
  31732. * @param vao defines the vertex array object to delete
  31733. */
  31734. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31735. /** @hidden */
  31736. _releaseBuffer(buffer: DataBuffer): boolean;
  31737. protected _deleteBuffer(buffer: DataBuffer): void;
  31738. /**
  31739. * Creates a webGL buffer to use with instanciation
  31740. * @param capacity defines the size of the buffer
  31741. * @returns the webGL buffer
  31742. */
  31743. createInstancesBuffer(capacity: number): DataBuffer;
  31744. /**
  31745. * Delete a webGL buffer used with instanciation
  31746. * @param buffer defines the webGL buffer to delete
  31747. */
  31748. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31749. /**
  31750. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31751. * @param instancesBuffer defines the webGL buffer to update and bind
  31752. * @param data defines the data to store in the buffer
  31753. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31754. */
  31755. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31756. /**
  31757. * Apply all cached states (depth, culling, stencil and alpha)
  31758. */
  31759. applyStates(): void;
  31760. /**
  31761. * Send a draw order
  31762. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31763. * @param indexStart defines the starting index
  31764. * @param indexCount defines the number of index to draw
  31765. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31766. */
  31767. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31768. /**
  31769. * Draw a list of points
  31770. * @param verticesStart defines the index of first vertex to draw
  31771. * @param verticesCount defines the count of vertices to draw
  31772. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31773. */
  31774. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31775. /**
  31776. * Draw a list of unindexed primitives
  31777. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31778. * @param verticesStart defines the index of first vertex to draw
  31779. * @param verticesCount defines the count of vertices to draw
  31780. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31781. */
  31782. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31783. /**
  31784. * Draw a list of indexed primitives
  31785. * @param fillMode defines the primitive to use
  31786. * @param indexStart defines the starting index
  31787. * @param indexCount defines the number of index to draw
  31788. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31789. */
  31790. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31791. /**
  31792. * Draw a list of unindexed primitives
  31793. * @param fillMode defines the primitive to use
  31794. * @param verticesStart defines the index of first vertex to draw
  31795. * @param verticesCount defines the count of vertices to draw
  31796. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31797. */
  31798. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31799. private _drawMode;
  31800. /** @hidden */
  31801. _releaseEffect(effect: Effect): void;
  31802. /** @hidden */
  31803. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31804. /**
  31805. * Create a new effect (used to store vertex/fragment shaders)
  31806. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31807. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31808. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31809. * @param samplers defines an array of string used to represent textures
  31810. * @param defines defines the string containing the defines to use to compile the shaders
  31811. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31812. * @param onCompiled defines a function to call when the effect creation is successful
  31813. * @param onError defines a function to call when the effect creation has failed
  31814. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31815. * @returns the new Effect
  31816. */
  31817. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  31818. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31819. private _compileShader;
  31820. private _compileRawShader;
  31821. /**
  31822. * Directly creates a webGL program
  31823. * @param pipelineContext defines the pipeline context to attach to
  31824. * @param vertexCode defines the vertex shader code to use
  31825. * @param fragmentCode defines the fragment shader code to use
  31826. * @param context defines the webGL context to use (if not set, the current one will be used)
  31827. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31828. * @returns the new webGL program
  31829. */
  31830. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31831. /**
  31832. * Creates a webGL program
  31833. * @param pipelineContext defines the pipeline context to attach to
  31834. * @param vertexCode defines the vertex shader code to use
  31835. * @param fragmentCode defines the fragment shader code to use
  31836. * @param defines defines the string containing the defines to use to compile the shaders
  31837. * @param context defines the webGL context to use (if not set, the current one will be used)
  31838. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31839. * @returns the new webGL program
  31840. */
  31841. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31842. /**
  31843. * Creates a new pipeline context
  31844. * @returns the new pipeline
  31845. */
  31846. createPipelineContext(): IPipelineContext;
  31847. private _createShaderProgram;
  31848. private _finalizePipelineContext;
  31849. /** @hidden */
  31850. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31851. /** @hidden */
  31852. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31853. /** @hidden */
  31854. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31855. /**
  31856. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31857. * @param pipelineContext defines the pipeline context to use
  31858. * @param uniformsNames defines the list of uniform names
  31859. * @returns an array of webGL uniform locations
  31860. */
  31861. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31862. /**
  31863. * Gets the lsit of active attributes for a given webGL program
  31864. * @param pipelineContext defines the pipeline context to use
  31865. * @param attributesNames defines the list of attribute names to get
  31866. * @returns an array of indices indicating the offset of each attribute
  31867. */
  31868. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31869. /**
  31870. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31871. * @param effect defines the effect to activate
  31872. */
  31873. enableEffect(effect: Nullable<Effect>): void;
  31874. /**
  31875. * Set the value of an uniform to an array of int32
  31876. * @param uniform defines the webGL uniform location where to store the value
  31877. * @param array defines the array of int32 to store
  31878. */
  31879. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31880. /**
  31881. * Set the value of an uniform to an array of int32 (stored as vec2)
  31882. * @param uniform defines the webGL uniform location where to store the value
  31883. * @param array defines the array of int32 to store
  31884. */
  31885. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31886. /**
  31887. * Set the value of an uniform to an array of int32 (stored as vec3)
  31888. * @param uniform defines the webGL uniform location where to store the value
  31889. * @param array defines the array of int32 to store
  31890. */
  31891. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31892. /**
  31893. * Set the value of an uniform to an array of int32 (stored as vec4)
  31894. * @param uniform defines the webGL uniform location where to store the value
  31895. * @param array defines the array of int32 to store
  31896. */
  31897. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31898. /**
  31899. * Set the value of an uniform to an array of float32
  31900. * @param uniform defines the webGL uniform location where to store the value
  31901. * @param array defines the array of float32 to store
  31902. */
  31903. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31904. /**
  31905. * Set the value of an uniform to an array of float32 (stored as vec2)
  31906. * @param uniform defines the webGL uniform location where to store the value
  31907. * @param array defines the array of float32 to store
  31908. */
  31909. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31910. /**
  31911. * Set the value of an uniform to an array of float32 (stored as vec3)
  31912. * @param uniform defines the webGL uniform location where to store the value
  31913. * @param array defines the array of float32 to store
  31914. */
  31915. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31916. /**
  31917. * Set the value of an uniform to an array of float32 (stored as vec4)
  31918. * @param uniform defines the webGL uniform location where to store the value
  31919. * @param array defines the array of float32 to store
  31920. */
  31921. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31922. /**
  31923. * Set the value of an uniform to an array of number
  31924. * @param uniform defines the webGL uniform location where to store the value
  31925. * @param array defines the array of number to store
  31926. */
  31927. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31928. /**
  31929. * Set the value of an uniform to an array of number (stored as vec2)
  31930. * @param uniform defines the webGL uniform location where to store the value
  31931. * @param array defines the array of number to store
  31932. */
  31933. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31934. /**
  31935. * Set the value of an uniform to an array of number (stored as vec3)
  31936. * @param uniform defines the webGL uniform location where to store the value
  31937. * @param array defines the array of number to store
  31938. */
  31939. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31940. /**
  31941. * Set the value of an uniform to an array of number (stored as vec4)
  31942. * @param uniform defines the webGL uniform location where to store the value
  31943. * @param array defines the array of number to store
  31944. */
  31945. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31946. /**
  31947. * Set the value of an uniform to an array of float32 (stored as matrices)
  31948. * @param uniform defines the webGL uniform location where to store the value
  31949. * @param matrices defines the array of float32 to store
  31950. */
  31951. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31952. /**
  31953. * Set the value of an uniform to a matrix (3x3)
  31954. * @param uniform defines the webGL uniform location where to store the value
  31955. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31956. */
  31957. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31958. /**
  31959. * Set the value of an uniform to a matrix (2x2)
  31960. * @param uniform defines the webGL uniform location where to store the value
  31961. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31962. */
  31963. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31964. /**
  31965. * Set the value of an uniform to a number (int)
  31966. * @param uniform defines the webGL uniform location where to store the value
  31967. * @param value defines the int number to store
  31968. */
  31969. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31970. /**
  31971. * Set the value of an uniform to a number (float)
  31972. * @param uniform defines the webGL uniform location where to store the value
  31973. * @param value defines the float number to store
  31974. */
  31975. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31976. /**
  31977. * Set the value of an uniform to a vec2
  31978. * @param uniform defines the webGL uniform location where to store the value
  31979. * @param x defines the 1st component of the value
  31980. * @param y defines the 2nd component of the value
  31981. */
  31982. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31983. /**
  31984. * Set the value of an uniform to a vec3
  31985. * @param uniform defines the webGL uniform location where to store the value
  31986. * @param x defines the 1st component of the value
  31987. * @param y defines the 2nd component of the value
  31988. * @param z defines the 3rd component of the value
  31989. */
  31990. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31991. /**
  31992. * Set the value of an uniform to a boolean
  31993. * @param uniform defines the webGL uniform location where to store the value
  31994. * @param bool defines the boolean to store
  31995. */
  31996. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31997. /**
  31998. * Set the value of an uniform to a vec4
  31999. * @param uniform defines the webGL uniform location where to store the value
  32000. * @param x defines the 1st component of the value
  32001. * @param y defines the 2nd component of the value
  32002. * @param z defines the 3rd component of the value
  32003. * @param w defines the 4th component of the value
  32004. */
  32005. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32006. /**
  32007. * Sets a Color4 on a uniform variable
  32008. * @param uniform defines the uniform location
  32009. * @param color4 defines the value to be set
  32010. */
  32011. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  32012. /**
  32013. * Set various states to the webGL context
  32014. * @param culling defines backface culling state
  32015. * @param zOffset defines the value to apply to zOffset (0 by default)
  32016. * @param force defines if states must be applied even if cache is up to date
  32017. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32018. */
  32019. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32020. /**
  32021. * Set the z offset to apply to current rendering
  32022. * @param value defines the offset to apply
  32023. */
  32024. setZOffset(value: number): void;
  32025. /**
  32026. * Gets the current value of the zOffset
  32027. * @returns the current zOffset state
  32028. */
  32029. getZOffset(): number;
  32030. /**
  32031. * Enable or disable depth buffering
  32032. * @param enable defines the state to set
  32033. */
  32034. setDepthBuffer(enable: boolean): void;
  32035. /**
  32036. * Gets a boolean indicating if depth writing is enabled
  32037. * @returns the current depth writing state
  32038. */
  32039. getDepthWrite(): boolean;
  32040. /**
  32041. * Enable or disable depth writing
  32042. * @param enable defines the state to set
  32043. */
  32044. setDepthWrite(enable: boolean): void;
  32045. /**
  32046. * Enable or disable color writing
  32047. * @param enable defines the state to set
  32048. */
  32049. setColorWrite(enable: boolean): void;
  32050. /**
  32051. * Gets a boolean indicating if color writing is enabled
  32052. * @returns the current color writing state
  32053. */
  32054. getColorWrite(): boolean;
  32055. /**
  32056. * Sets alpha constants used by some alpha blending modes
  32057. * @param r defines the red component
  32058. * @param g defines the green component
  32059. * @param b defines the blue component
  32060. * @param a defines the alpha component
  32061. */
  32062. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32063. /**
  32064. * Sets the current alpha mode
  32065. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32066. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32067. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32068. */
  32069. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32070. /**
  32071. * Gets the current alpha mode
  32072. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32073. * @returns the current alpha mode
  32074. */
  32075. getAlphaMode(): number;
  32076. /**
  32077. * Clears the list of texture accessible through engine.
  32078. * This can help preventing texture load conflict due to name collision.
  32079. */
  32080. clearInternalTexturesCache(): void;
  32081. /**
  32082. * Force the entire cache to be cleared
  32083. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32084. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32085. */
  32086. wipeCaches(bruteForce?: boolean): void;
  32087. /**
  32088. * Set the compressed texture format to use, based on the formats you have, and the formats
  32089. * supported by the hardware / browser.
  32090. *
  32091. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32092. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32093. * to API arguments needed to compressed textures. This puts the burden on the container
  32094. * generator to house the arcane code for determining these for current & future formats.
  32095. *
  32096. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32097. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32098. *
  32099. * Note: The result of this call is not taken into account when a texture is base64.
  32100. *
  32101. * @param formatsAvailable defines the list of those format families you have created
  32102. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32103. *
  32104. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32105. * @returns The extension selected.
  32106. */
  32107. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32108. /** @hidden */
  32109. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32110. min: number;
  32111. mag: number;
  32112. };
  32113. /** @hidden */
  32114. _createTexture(): WebGLTexture;
  32115. /**
  32116. * Usually called from Texture.ts.
  32117. * Passed information to create a WebGLTexture
  32118. * @param urlArg defines a value which contains one of the following:
  32119. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32120. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32121. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32122. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32123. * @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)
  32124. * @param scene needed for loading to the correct scene
  32125. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32126. * @param onLoad optional callback to be called upon successful completion
  32127. * @param onError optional callback to be called upon failure
  32128. * @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
  32129. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32130. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32131. * @param forcedExtension defines the extension to use to pick the right loader
  32132. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32133. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32134. */
  32135. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  32136. /**
  32137. * @hidden
  32138. * Rescales a texture
  32139. * @param source input texutre
  32140. * @param destination destination texture
  32141. * @param scene scene to use to render the resize
  32142. * @param internalFormat format to use when resizing
  32143. * @param onComplete callback to be called when resize has completed
  32144. */
  32145. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  32146. private _unpackFlipYCached;
  32147. /**
  32148. * In case you are sharing the context with other applications, it might
  32149. * be interested to not cache the unpack flip y state to ensure a consistent
  32150. * value would be set.
  32151. */
  32152. enableUnpackFlipYCached: boolean;
  32153. /** @hidden */
  32154. _unpackFlipY(value: boolean): void;
  32155. /** @hidden */
  32156. _getUnpackAlignement(): number;
  32157. /**
  32158. * Creates a dynamic texture
  32159. * @param width defines the width of the texture
  32160. * @param height defines the height of the texture
  32161. * @param generateMipMaps defines if the engine should generate the mip levels
  32162. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32163. * @returns the dynamic texture inside an InternalTexture
  32164. */
  32165. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  32166. /**
  32167. * Update the sampling mode of a given texture
  32168. * @param samplingMode defines the required sampling mode
  32169. * @param texture defines the texture to update
  32170. */
  32171. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32172. /**
  32173. * Update the content of a dynamic texture
  32174. * @param texture defines the texture to update
  32175. * @param canvas defines the canvas containing the source
  32176. * @param invertY defines if data must be stored with Y axis inverted
  32177. * @param premulAlpha defines if alpha is stored as premultiplied
  32178. * @param format defines the format of the data
  32179. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32180. */
  32181. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  32182. /**
  32183. * Update a video texture
  32184. * @param texture defines the texture to update
  32185. * @param video defines the video element to use
  32186. * @param invertY defines if data must be stored with Y axis inverted
  32187. */
  32188. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32189. /**
  32190. * Updates a depth texture Comparison Mode and Function.
  32191. * If the comparison Function is equal to 0, the mode will be set to none.
  32192. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32193. * @param texture The texture to set the comparison function for
  32194. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32195. */
  32196. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32197. /** @hidden */
  32198. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32199. width: number;
  32200. height: number;
  32201. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32202. /**
  32203. * Creates a depth stencil texture.
  32204. * This is only available in WebGL 2 or with the depth texture extension available.
  32205. * @param size The size of face edge in the texture.
  32206. * @param options The options defining the texture.
  32207. * @returns The texture
  32208. */
  32209. createDepthStencilTexture(size: number | {
  32210. width: number;
  32211. height: number;
  32212. }, options: DepthTextureCreationOptions): InternalTexture;
  32213. /**
  32214. * Creates a depth stencil texture.
  32215. * This is only available in WebGL 2 or with the depth texture extension available.
  32216. * @param size The size of face edge in the texture.
  32217. * @param options The options defining the texture.
  32218. * @returns The texture
  32219. */
  32220. private _createDepthStencilTexture;
  32221. /**
  32222. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32223. * @param renderTarget The render target to set the frame buffer for
  32224. */
  32225. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32226. /**
  32227. * Creates a new render target texture
  32228. * @param size defines the size of the texture
  32229. * @param options defines the options used to create the texture
  32230. * @returns a new render target texture stored in an InternalTexture
  32231. */
  32232. createRenderTargetTexture(size: number | {
  32233. width: number;
  32234. height: number;
  32235. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32236. /** @hidden */
  32237. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32238. /**
  32239. * Updates the sample count of a render target texture
  32240. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32241. * @param texture defines the texture to update
  32242. * @param samples defines the sample count to set
  32243. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32244. */
  32245. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32246. /** @hidden */
  32247. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32248. /** @hidden */
  32249. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32250. /** @hidden */
  32251. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32252. /** @hidden */
  32253. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  32254. /**
  32255. * @hidden
  32256. */
  32257. _setCubeMapTextureParams(loadMipmap: boolean): void;
  32258. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32259. private _prepareWebGLTexture;
  32260. /** @hidden */
  32261. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32262. /** @hidden */
  32263. _releaseFramebufferObjects(texture: InternalTexture): void;
  32264. /** @hidden */
  32265. _releaseTexture(texture: InternalTexture): void;
  32266. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32267. protected _setProgram(program: WebGLProgram): void;
  32268. protected _boundUniforms: {
  32269. [key: number]: WebGLUniformLocation;
  32270. };
  32271. /**
  32272. * Binds an effect to the webGL context
  32273. * @param effect defines the effect to bind
  32274. */
  32275. bindSamplers(effect: Effect): void;
  32276. private _activateCurrentTexture;
  32277. /** @hidden */
  32278. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32279. /** @hidden */
  32280. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32281. /**
  32282. * Sets a texture to the webGL context from a postprocess
  32283. * @param channel defines the channel to use
  32284. * @param postProcess defines the source postprocess
  32285. */
  32286. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32287. /**
  32288. * Binds the output of the passed in post process to the texture channel specified
  32289. * @param channel The channel the texture should be bound to
  32290. * @param postProcess The post process which's output should be bound
  32291. */
  32292. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32293. /**
  32294. * Unbind all textures from the webGL context
  32295. */
  32296. unbindAllTextures(): void;
  32297. /**
  32298. * Sets a texture to the according uniform.
  32299. * @param channel The texture channel
  32300. * @param uniform The uniform to set
  32301. * @param texture The texture to apply
  32302. */
  32303. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32304. /**
  32305. * Sets a depth stencil texture from a render target to the according uniform.
  32306. * @param channel The texture channel
  32307. * @param uniform The uniform to set
  32308. * @param texture The render target texture containing the depth stencil texture to apply
  32309. */
  32310. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32311. private _bindSamplerUniformToChannel;
  32312. private _getTextureWrapMode;
  32313. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32314. /**
  32315. * Sets an array of texture to the webGL context
  32316. * @param channel defines the channel where the texture array must be set
  32317. * @param uniform defines the associated uniform location
  32318. * @param textures defines the array of textures to bind
  32319. */
  32320. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32321. /** @hidden */
  32322. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32323. private _setTextureParameterFloat;
  32324. private _setTextureParameterInteger;
  32325. /**
  32326. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32327. * @param x defines the x coordinate of the rectangle where pixels must be read
  32328. * @param y defines the y coordinate of the rectangle where pixels must be read
  32329. * @param width defines the width of the rectangle where pixels must be read
  32330. * @param height defines the height of the rectangle where pixels must be read
  32331. * @returns a Uint8Array containing RGBA colors
  32332. */
  32333. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32334. /**
  32335. * Add an externaly attached data from its key.
  32336. * This method call will fail and return false, if such key already exists.
  32337. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32338. * @param key the unique key that identifies the data
  32339. * @param data the data object to associate to the key for this Engine instance
  32340. * @return true if no such key were already present and the data was added successfully, false otherwise
  32341. */
  32342. addExternalData<T>(key: string, data: T): boolean;
  32343. /**
  32344. * Get an externaly attached data from its key
  32345. * @param key the unique key that identifies the data
  32346. * @return the associated data, if present (can be null), or undefined if not present
  32347. */
  32348. getExternalData<T>(key: string): T;
  32349. /**
  32350. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32351. * @param key the unique key that identifies the data
  32352. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32353. * @return the associated data, can be null if the factory returned null.
  32354. */
  32355. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32356. /**
  32357. * Remove an externaly attached data from the Engine instance
  32358. * @param key the unique key that identifies the data
  32359. * @return true if the data was successfully removed, false if it doesn't exist
  32360. */
  32361. removeExternalData(key: string): boolean;
  32362. /**
  32363. * Unbind all vertex attributes from the webGL context
  32364. */
  32365. unbindAllAttributes(): void;
  32366. /**
  32367. * 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
  32368. */
  32369. releaseEffects(): void;
  32370. /**
  32371. * Dispose and release all associated resources
  32372. */
  32373. dispose(): void;
  32374. /**
  32375. * Display the loading screen
  32376. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32377. */
  32378. displayLoadingUI(): void;
  32379. /**
  32380. * Hide the loading screen
  32381. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32382. */
  32383. hideLoadingUI(): void;
  32384. /**
  32385. * Gets the current loading screen object
  32386. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32387. */
  32388. /**
  32389. * Sets the current loading screen object
  32390. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32391. */
  32392. loadingScreen: ILoadingScreen;
  32393. /**
  32394. * Sets the current loading screen text
  32395. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32396. */
  32397. loadingUIText: string;
  32398. /**
  32399. * Sets the current loading screen background color
  32400. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32401. */
  32402. loadingUIBackgroundColor: string;
  32403. /**
  32404. * Attach a new callback raised when context lost event is fired
  32405. * @param callback defines the callback to call
  32406. */
  32407. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32408. /**
  32409. * Attach a new callback raised when context restored event is fired
  32410. * @param callback defines the callback to call
  32411. */
  32412. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32413. /**
  32414. * Gets the source code of the vertex shader associated with a specific webGL program
  32415. * @param program defines the program to use
  32416. * @returns a string containing the source code of the vertex shader associated with the program
  32417. */
  32418. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32419. /**
  32420. * Gets the source code of the fragment shader associated with a specific webGL program
  32421. * @param program defines the program to use
  32422. * @returns a string containing the source code of the fragment shader associated with the program
  32423. */
  32424. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32425. /**
  32426. * Get the current error code of the webGL context
  32427. * @returns the error code
  32428. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32429. */
  32430. getError(): number;
  32431. /**
  32432. * Gets the current framerate
  32433. * @returns a number representing the framerate
  32434. */
  32435. getFps(): number;
  32436. /**
  32437. * Gets the time spent between current and previous frame
  32438. * @returns a number representing the delta time in ms
  32439. */
  32440. getDeltaTime(): number;
  32441. private _measureFps;
  32442. /** @hidden */
  32443. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32444. private _canRenderToFloatFramebuffer;
  32445. private _canRenderToHalfFloatFramebuffer;
  32446. private _canRenderToFramebuffer;
  32447. /** @hidden */
  32448. _getWebGLTextureType(type: number): number;
  32449. /** @hidden */
  32450. _getInternalFormat(format: number): number;
  32451. /** @hidden */
  32452. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32453. /** @hidden */
  32454. _getRGBAMultiSampleBufferFormat(type: number): number;
  32455. /** @hidden */
  32456. _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;
  32457. /** @hidden */
  32458. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32459. /**
  32460. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32461. * @returns true if the engine can be created
  32462. * @ignorenaming
  32463. */
  32464. static isSupported(): boolean;
  32465. /**
  32466. * Find the next highest power of two.
  32467. * @param x Number to start search from.
  32468. * @return Next highest power of two.
  32469. */
  32470. static CeilingPOT(x: number): number;
  32471. /**
  32472. * Find the next lowest power of two.
  32473. * @param x Number to start search from.
  32474. * @return Next lowest power of two.
  32475. */
  32476. static FloorPOT(x: number): number;
  32477. /**
  32478. * Find the nearest power of two.
  32479. * @param x Number to start search from.
  32480. * @return Next nearest power of two.
  32481. */
  32482. static NearestPOT(x: number): number;
  32483. /**
  32484. * Get the closest exponent of two
  32485. * @param value defines the value to approximate
  32486. * @param max defines the maximum value to return
  32487. * @param mode defines how to define the closest value
  32488. * @returns closest exponent of two of the given value
  32489. */
  32490. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32491. /**
  32492. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32493. * @param func - the function to be called
  32494. * @param requester - the object that will request the next frame. Falls back to window.
  32495. * @returns frame number
  32496. */
  32497. static QueueNewFrame(func: () => void, requester?: any): number;
  32498. /**
  32499. * Ask the browser to promote the current element to pointerlock mode
  32500. * @param element defines the DOM element to promote
  32501. */
  32502. static _RequestPointerlock(element: HTMLElement): void;
  32503. /**
  32504. * Asks the browser to exit pointerlock mode
  32505. */
  32506. static _ExitPointerlock(): void;
  32507. /**
  32508. * Ask the browser to promote the current element to fullscreen rendering mode
  32509. * @param element defines the DOM element to promote
  32510. */
  32511. static _RequestFullscreen(element: HTMLElement): void;
  32512. /**
  32513. * Asks the browser to exit fullscreen mode
  32514. */
  32515. static _ExitFullscreen(): void;
  32516. }
  32517. }
  32518. declare module "babylonjs/Engines/engineStore" {
  32519. import { Nullable } from "babylonjs/types";
  32520. import { Engine } from "babylonjs/Engines/engine";
  32521. import { Scene } from "babylonjs/scene";
  32522. /**
  32523. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32524. * during the life time of the application.
  32525. */
  32526. export class EngineStore {
  32527. /** Gets the list of created engines */
  32528. static Instances: import("babylonjs/Engines/engine").Engine[];
  32529. /** @hidden */
  32530. static _LastCreatedScene: Nullable<Scene>;
  32531. /**
  32532. * Gets the latest created engine
  32533. */
  32534. static readonly LastCreatedEngine: Nullable<Engine>;
  32535. /**
  32536. * Gets the latest created scene
  32537. */
  32538. static readonly LastCreatedScene: Nullable<Scene>;
  32539. /**
  32540. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32541. * @ignorenaming
  32542. */
  32543. static UseFallbackTexture: boolean;
  32544. /**
  32545. * Texture content used if a texture cannot loaded
  32546. * @ignorenaming
  32547. */
  32548. static FallbackTexture: string;
  32549. }
  32550. }
  32551. declare module "babylonjs/Misc/promise" {
  32552. /**
  32553. * Helper class that provides a small promise polyfill
  32554. */
  32555. export class PromisePolyfill {
  32556. /**
  32557. * Static function used to check if the polyfill is required
  32558. * If this is the case then the function will inject the polyfill to window.Promise
  32559. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32560. */
  32561. static Apply(force?: boolean): void;
  32562. }
  32563. }
  32564. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32565. /**
  32566. * Interface for screenshot methods with describe argument called `size` as object with options
  32567. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32568. */
  32569. export interface IScreenshotSize {
  32570. /**
  32571. * number in pixels for canvas height
  32572. */
  32573. height?: number;
  32574. /**
  32575. * multiplier allowing render at a higher or lower resolution
  32576. * If value is defined then height and width will be ignored and taken from camera
  32577. */
  32578. precision?: number;
  32579. /**
  32580. * number in pixels for canvas width
  32581. */
  32582. width?: number;
  32583. }
  32584. }
  32585. declare module "babylonjs/Misc/tools" {
  32586. import { Nullable, float } from "babylonjs/types";
  32587. import { DomManagement } from "babylonjs/Misc/domManagement";
  32588. import { WebRequest } from "babylonjs/Misc/webRequest";
  32589. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32590. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32591. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32592. import { Camera } from "babylonjs/Cameras/camera";
  32593. import { Engine } from "babylonjs/Engines/engine";
  32594. interface IColor4Like {
  32595. r: float;
  32596. g: float;
  32597. b: float;
  32598. a: float;
  32599. }
  32600. /**
  32601. * Class containing a set of static utilities functions
  32602. */
  32603. export class Tools {
  32604. /**
  32605. * Gets or sets the base URL to use to load assets
  32606. */
  32607. static BaseUrl: string;
  32608. /**
  32609. * Enable/Disable Custom HTTP Request Headers globally.
  32610. * default = false
  32611. * @see CustomRequestHeaders
  32612. */
  32613. static UseCustomRequestHeaders: boolean;
  32614. /**
  32615. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32616. * i.e. when loading files, where the server/service expects an Authorization header
  32617. */
  32618. static CustomRequestHeaders: {
  32619. [key: string]: string;
  32620. };
  32621. /**
  32622. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32623. */
  32624. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32625. /**
  32626. * Default behaviour for cors in the application.
  32627. * It can be a string if the expected behavior is identical in the entire app.
  32628. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32629. */
  32630. static CorsBehavior: string | ((url: string | string[]) => string);
  32631. /**
  32632. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32633. * @ignorenaming
  32634. */
  32635. static UseFallbackTexture: boolean;
  32636. /**
  32637. * Use this object to register external classes like custom textures or material
  32638. * to allow the laoders to instantiate them
  32639. */
  32640. static RegisteredExternalClasses: {
  32641. [key: string]: Object;
  32642. };
  32643. /**
  32644. * Texture content used if a texture cannot loaded
  32645. * @ignorenaming
  32646. */
  32647. static fallbackTexture: string;
  32648. /**
  32649. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32650. * @param u defines the coordinate on X axis
  32651. * @param v defines the coordinate on Y axis
  32652. * @param width defines the width of the source data
  32653. * @param height defines the height of the source data
  32654. * @param pixels defines the source byte array
  32655. * @param color defines the output color
  32656. */
  32657. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32658. /**
  32659. * Interpolates between a and b via alpha
  32660. * @param a The lower value (returned when alpha = 0)
  32661. * @param b The upper value (returned when alpha = 1)
  32662. * @param alpha The interpolation-factor
  32663. * @return The mixed value
  32664. */
  32665. static Mix(a: number, b: number, alpha: number): number;
  32666. /**
  32667. * Tries to instantiate a new object from a given class name
  32668. * @param className defines the class name to instantiate
  32669. * @returns the new object or null if the system was not able to do the instantiation
  32670. */
  32671. static Instantiate(className: string): any;
  32672. /**
  32673. * Provides a slice function that will work even on IE
  32674. * @param data defines the array to slice
  32675. * @param start defines the start of the data (optional)
  32676. * @param end defines the end of the data (optional)
  32677. * @returns the new sliced array
  32678. */
  32679. static Slice<T>(data: T, start?: number, end?: number): T;
  32680. /**
  32681. * Polyfill for setImmediate
  32682. * @param action defines the action to execute after the current execution block
  32683. */
  32684. static SetImmediate(action: () => void): void;
  32685. /**
  32686. * Function indicating if a number is an exponent of 2
  32687. * @param value defines the value to test
  32688. * @returns true if the value is an exponent of 2
  32689. */
  32690. static IsExponentOfTwo(value: number): boolean;
  32691. private static _tmpFloatArray;
  32692. /**
  32693. * Returns the nearest 32-bit single precision float representation of a Number
  32694. * @param value A Number. If the parameter is of a different type, it will get converted
  32695. * to a number or to NaN if it cannot be converted
  32696. * @returns number
  32697. */
  32698. static FloatRound(value: number): number;
  32699. /**
  32700. * Extracts the filename from a path
  32701. * @param path defines the path to use
  32702. * @returns the filename
  32703. */
  32704. static GetFilename(path: string): string;
  32705. /**
  32706. * Extracts the "folder" part of a path (everything before the filename).
  32707. * @param uri The URI to extract the info from
  32708. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32709. * @returns The "folder" part of the path
  32710. */
  32711. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32712. /**
  32713. * Extracts text content from a DOM element hierarchy
  32714. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32715. */
  32716. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32717. /**
  32718. * Convert an angle in radians to degrees
  32719. * @param angle defines the angle to convert
  32720. * @returns the angle in degrees
  32721. */
  32722. static ToDegrees(angle: number): number;
  32723. /**
  32724. * Convert an angle in degrees to radians
  32725. * @param angle defines the angle to convert
  32726. * @returns the angle in radians
  32727. */
  32728. static ToRadians(angle: number): number;
  32729. /**
  32730. * Encode a buffer to a base64 string
  32731. * @param buffer defines the buffer to encode
  32732. * @returns the encoded string
  32733. */
  32734. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32735. /**
  32736. * Returns an array if obj is not an array
  32737. * @param obj defines the object to evaluate as an array
  32738. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32739. * @returns either obj directly if obj is an array or a new array containing obj
  32740. */
  32741. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32742. /**
  32743. * Gets the pointer prefix to use
  32744. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32745. */
  32746. static GetPointerPrefix(): string;
  32747. /**
  32748. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32749. * @param url define the url we are trying
  32750. * @param element define the dom element where to configure the cors policy
  32751. */
  32752. static SetCorsBehavior(url: string | string[], element: {
  32753. crossOrigin: string | null;
  32754. }): void;
  32755. /**
  32756. * Removes unwanted characters from an url
  32757. * @param url defines the url to clean
  32758. * @returns the cleaned url
  32759. */
  32760. static CleanUrl(url: string): string;
  32761. /**
  32762. * Gets or sets a function used to pre-process url before using them to load assets
  32763. */
  32764. static PreprocessUrl: (url: string) => string;
  32765. /**
  32766. * Loads an image as an HTMLImageElement.
  32767. * @param input url string, ArrayBuffer, or Blob to load
  32768. * @param onLoad callback called when the image successfully loads
  32769. * @param onError callback called when the image fails to load
  32770. * @param offlineProvider offline provider for caching
  32771. * @returns the HTMLImageElement of the loaded image
  32772. */
  32773. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32774. /**
  32775. * Loads a file
  32776. * @param url url string, ArrayBuffer, or Blob to load
  32777. * @param onSuccess callback called when the file successfully loads
  32778. * @param onProgress callback called while file is loading (if the server supports this mode)
  32779. * @param offlineProvider defines the offline provider for caching
  32780. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32781. * @param onError callback called when the file fails to load
  32782. * @returns a file request object
  32783. */
  32784. 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;
  32785. /**
  32786. * Loads a file from a url
  32787. * @param url the file url to load
  32788. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32789. */
  32790. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32791. /**
  32792. * Load a script (identified by an url). When the url returns, the
  32793. * content of this file is added into a new script element, attached to the DOM (body element)
  32794. * @param scriptUrl defines the url of the script to laod
  32795. * @param onSuccess defines the callback called when the script is loaded
  32796. * @param onError defines the callback to call if an error occurs
  32797. * @param scriptId defines the id of the script element
  32798. */
  32799. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32800. /**
  32801. * Load an asynchronous script (identified by an url). When the url returns, the
  32802. * content of this file is added into a new script element, attached to the DOM (body element)
  32803. * @param scriptUrl defines the url of the script to laod
  32804. * @param scriptId defines the id of the script element
  32805. * @returns a promise request object
  32806. */
  32807. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32808. /**
  32809. * Loads a file from a blob
  32810. * @param fileToLoad defines the blob to use
  32811. * @param callback defines the callback to call when data is loaded
  32812. * @param progressCallback defines the callback to call during loading process
  32813. * @returns a file request object
  32814. */
  32815. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32816. /**
  32817. * Loads a file
  32818. * @param fileToLoad defines the file to load
  32819. * @param callback defines the callback to call when data is loaded
  32820. * @param progressCallBack defines the callback to call during loading process
  32821. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32822. * @returns a file request object
  32823. */
  32824. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32825. /**
  32826. * Creates a data url from a given string content
  32827. * @param content defines the content to convert
  32828. * @returns the new data url link
  32829. */
  32830. static FileAsURL(content: string): string;
  32831. /**
  32832. * Format the given number to a specific decimal format
  32833. * @param value defines the number to format
  32834. * @param decimals defines the number of decimals to use
  32835. * @returns the formatted string
  32836. */
  32837. static Format(value: number, decimals?: number): string;
  32838. /**
  32839. * Tries to copy an object by duplicating every property
  32840. * @param source defines the source object
  32841. * @param destination defines the target object
  32842. * @param doNotCopyList defines a list of properties to avoid
  32843. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32844. */
  32845. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32846. /**
  32847. * Gets a boolean indicating if the given object has no own property
  32848. * @param obj defines the object to test
  32849. * @returns true if object has no own property
  32850. */
  32851. static IsEmpty(obj: any): boolean;
  32852. /**
  32853. * Function used to register events at window level
  32854. * @param windowElement defines the Window object to use
  32855. * @param events defines the events to register
  32856. */
  32857. static RegisterTopRootEvents(windowElement: Window, events: {
  32858. name: string;
  32859. handler: Nullable<(e: FocusEvent) => any>;
  32860. }[]): void;
  32861. /**
  32862. * Function used to unregister events from window level
  32863. * @param windowElement defines the Window object to use
  32864. * @param events defines the events to unregister
  32865. */
  32866. static UnregisterTopRootEvents(windowElement: Window, events: {
  32867. name: string;
  32868. handler: Nullable<(e: FocusEvent) => any>;
  32869. }[]): void;
  32870. /**
  32871. * @ignore
  32872. */
  32873. static _ScreenshotCanvas: HTMLCanvasElement;
  32874. /**
  32875. * Dumps the current bound framebuffer
  32876. * @param width defines the rendering width
  32877. * @param height defines the rendering height
  32878. * @param engine defines the hosting engine
  32879. * @param successCallback defines the callback triggered once the data are available
  32880. * @param mimeType defines the mime type of the result
  32881. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32882. */
  32883. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32884. /**
  32885. * Converts the canvas data to blob.
  32886. * This acts as a polyfill for browsers not supporting the to blob function.
  32887. * @param canvas Defines the canvas to extract the data from
  32888. * @param successCallback Defines the callback triggered once the data are available
  32889. * @param mimeType Defines the mime type of the result
  32890. */
  32891. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32892. /**
  32893. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32894. * @param successCallback defines the callback triggered once the data are available
  32895. * @param mimeType defines the mime type of the result
  32896. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32897. */
  32898. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32899. /**
  32900. * Downloads a blob in the browser
  32901. * @param blob defines the blob to download
  32902. * @param fileName defines the name of the downloaded file
  32903. */
  32904. static Download(blob: Blob, fileName: string): void;
  32905. /**
  32906. * Captures a screenshot of the current rendering
  32907. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32908. * @param engine defines the rendering engine
  32909. * @param camera defines the source camera
  32910. * @param size This parameter can be set to a single number or to an object with the
  32911. * following (optional) properties: precision, width, height. If a single number is passed,
  32912. * it will be used for both width and height. If an object is passed, the screenshot size
  32913. * will be derived from the parameters. The precision property is a multiplier allowing
  32914. * rendering at a higher or lower resolution
  32915. * @param successCallback defines the callback receives a single parameter which contains the
  32916. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32917. * src parameter of an <img> to display it
  32918. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32919. * Check your browser for supported MIME types
  32920. */
  32921. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32922. /**
  32923. * Captures a screenshot of the current rendering
  32924. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32925. * @param engine defines the rendering engine
  32926. * @param camera defines the source camera
  32927. * @param size This parameter can be set to a single number or to an object with the
  32928. * following (optional) properties: precision, width, height. If a single number is passed,
  32929. * it will be used for both width and height. If an object is passed, the screenshot size
  32930. * will be derived from the parameters. The precision property is a multiplier allowing
  32931. * rendering at a higher or lower resolution
  32932. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32933. * Check your browser for supported MIME types
  32934. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32935. * to the src parameter of an <img> to display it
  32936. */
  32937. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32938. /**
  32939. * Generates an image screenshot from the specified camera.
  32940. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32941. * @param engine The engine to use for rendering
  32942. * @param camera The camera to use for rendering
  32943. * @param size This parameter can be set to a single number or to an object with the
  32944. * following (optional) properties: precision, width, height. If a single number is passed,
  32945. * it will be used for both width and height. If an object is passed, the screenshot size
  32946. * will be derived from the parameters. The precision property is a multiplier allowing
  32947. * rendering at a higher or lower resolution
  32948. * @param successCallback The callback receives a single parameter which contains the
  32949. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32950. * src parameter of an <img> to display it
  32951. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32952. * Check your browser for supported MIME types
  32953. * @param samples Texture samples (default: 1)
  32954. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32955. * @param fileName A name for for the downloaded file.
  32956. */
  32957. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32958. /**
  32959. * Generates an image screenshot from the specified camera.
  32960. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32961. * @param engine The engine to use for rendering
  32962. * @param camera The camera to use for rendering
  32963. * @param size This parameter can be set to a single number or to an object with the
  32964. * following (optional) properties: precision, width, height. If a single number is passed,
  32965. * it will be used for both width and height. If an object is passed, the screenshot size
  32966. * will be derived from the parameters. The precision property is a multiplier allowing
  32967. * rendering at a higher or lower resolution
  32968. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32969. * Check your browser for supported MIME types
  32970. * @param samples Texture samples (default: 1)
  32971. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32972. * @param fileName A name for for the downloaded file.
  32973. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32974. * to the src parameter of an <img> to display it
  32975. */
  32976. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32977. /**
  32978. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32979. * Be aware Math.random() could cause collisions, but:
  32980. * "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"
  32981. * @returns a pseudo random id
  32982. */
  32983. static RandomId(): string;
  32984. /**
  32985. * Test if the given uri is a base64 string
  32986. * @param uri The uri to test
  32987. * @return True if the uri is a base64 string or false otherwise
  32988. */
  32989. static IsBase64(uri: string): boolean;
  32990. /**
  32991. * Decode the given base64 uri.
  32992. * @param uri The uri to decode
  32993. * @return The decoded base64 data.
  32994. */
  32995. static DecodeBase64(uri: string): ArrayBuffer;
  32996. /**
  32997. * Gets the absolute url.
  32998. * @param url the input url
  32999. * @return the absolute url
  33000. */
  33001. static GetAbsoluteUrl(url: string): string;
  33002. /**
  33003. * No log
  33004. */
  33005. static readonly NoneLogLevel: number;
  33006. /**
  33007. * Only message logs
  33008. */
  33009. static readonly MessageLogLevel: number;
  33010. /**
  33011. * Only warning logs
  33012. */
  33013. static readonly WarningLogLevel: number;
  33014. /**
  33015. * Only error logs
  33016. */
  33017. static readonly ErrorLogLevel: number;
  33018. /**
  33019. * All logs
  33020. */
  33021. static readonly AllLogLevel: number;
  33022. /**
  33023. * Gets a value indicating the number of loading errors
  33024. * @ignorenaming
  33025. */
  33026. static readonly errorsCount: number;
  33027. /**
  33028. * Callback called when a new log is added
  33029. */
  33030. static OnNewCacheEntry: (entry: string) => void;
  33031. /**
  33032. * Log a message to the console
  33033. * @param message defines the message to log
  33034. */
  33035. static Log(message: string): void;
  33036. /**
  33037. * Write a warning message to the console
  33038. * @param message defines the message to log
  33039. */
  33040. static Warn(message: string): void;
  33041. /**
  33042. * Write an error message to the console
  33043. * @param message defines the message to log
  33044. */
  33045. static Error(message: string): void;
  33046. /**
  33047. * Gets current log cache (list of logs)
  33048. */
  33049. static readonly LogCache: string;
  33050. /**
  33051. * Clears the log cache
  33052. */
  33053. static ClearLogCache(): void;
  33054. /**
  33055. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33056. */
  33057. static LogLevels: number;
  33058. /**
  33059. * Checks if the window object exists
  33060. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33061. */
  33062. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33063. /**
  33064. * No performance log
  33065. */
  33066. static readonly PerformanceNoneLogLevel: number;
  33067. /**
  33068. * Use user marks to log performance
  33069. */
  33070. static readonly PerformanceUserMarkLogLevel: number;
  33071. /**
  33072. * Log performance to the console
  33073. */
  33074. static readonly PerformanceConsoleLogLevel: number;
  33075. private static _performance;
  33076. /**
  33077. * Sets the current performance log level
  33078. */
  33079. static PerformanceLogLevel: number;
  33080. private static _StartPerformanceCounterDisabled;
  33081. private static _EndPerformanceCounterDisabled;
  33082. private static _StartUserMark;
  33083. private static _EndUserMark;
  33084. private static _StartPerformanceConsole;
  33085. private static _EndPerformanceConsole;
  33086. /**
  33087. * Starts a performance counter
  33088. */
  33089. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33090. /**
  33091. * Ends a specific performance coutner
  33092. */
  33093. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33094. /**
  33095. * Gets either window.performance.now() if supported or Date.now() else
  33096. */
  33097. static readonly Now: number;
  33098. /**
  33099. * This method will return the name of the class used to create the instance of the given object.
  33100. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33101. * @param object the object to get the class name from
  33102. * @param isType defines if the object is actually a type
  33103. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33104. */
  33105. static GetClassName(object: any, isType?: boolean): string;
  33106. /**
  33107. * Gets the first element of an array satisfying a given predicate
  33108. * @param array defines the array to browse
  33109. * @param predicate defines the predicate to use
  33110. * @returns null if not found or the element
  33111. */
  33112. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33113. /**
  33114. * This method will return the name of the full name of the class, including its owning module (if any).
  33115. * 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).
  33116. * @param object the object to get the class name from
  33117. * @param isType defines if the object is actually a type
  33118. * @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.
  33119. * @ignorenaming
  33120. */
  33121. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33122. /**
  33123. * Returns a promise that resolves after the given amount of time.
  33124. * @param delay Number of milliseconds to delay
  33125. * @returns Promise that resolves after the given amount of time
  33126. */
  33127. static DelayAsync(delay: number): Promise<void>;
  33128. }
  33129. /**
  33130. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33131. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33132. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33133. * @param name The name of the class, case should be preserved
  33134. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33135. */
  33136. export function className(name: string, module?: string): (target: Object) => void;
  33137. /**
  33138. * An implementation of a loop for asynchronous functions.
  33139. */
  33140. export class AsyncLoop {
  33141. /**
  33142. * Defines the number of iterations for the loop
  33143. */
  33144. iterations: number;
  33145. /**
  33146. * Defines the current index of the loop.
  33147. */
  33148. index: number;
  33149. private _done;
  33150. private _fn;
  33151. private _successCallback;
  33152. /**
  33153. * Constructor.
  33154. * @param iterations the number of iterations.
  33155. * @param func the function to run each iteration
  33156. * @param successCallback the callback that will be called upon succesful execution
  33157. * @param offset starting offset.
  33158. */
  33159. constructor(
  33160. /**
  33161. * Defines the number of iterations for the loop
  33162. */
  33163. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33164. /**
  33165. * Execute the next iteration. Must be called after the last iteration was finished.
  33166. */
  33167. executeNext(): void;
  33168. /**
  33169. * Break the loop and run the success callback.
  33170. */
  33171. breakLoop(): void;
  33172. /**
  33173. * Create and run an async loop.
  33174. * @param iterations the number of iterations.
  33175. * @param fn the function to run each iteration
  33176. * @param successCallback the callback that will be called upon succesful execution
  33177. * @param offset starting offset.
  33178. * @returns the created async loop object
  33179. */
  33180. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33181. /**
  33182. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33183. * @param iterations total number of iterations
  33184. * @param syncedIterations number of synchronous iterations in each async iteration.
  33185. * @param fn the function to call each iteration.
  33186. * @param callback a success call back that will be called when iterating stops.
  33187. * @param breakFunction a break condition (optional)
  33188. * @param timeout timeout settings for the setTimeout function. default - 0.
  33189. * @returns the created async loop object
  33190. */
  33191. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33192. }
  33193. }
  33194. declare module "babylonjs/Collisions/collisionCoordinator" {
  33195. import { Nullable } from "babylonjs/types";
  33196. import { Scene } from "babylonjs/scene";
  33197. import { Vector3 } from "babylonjs/Maths/math.vector";
  33198. import { Collider } from "babylonjs/Collisions/collider";
  33199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33200. /** @hidden */
  33201. export interface ICollisionCoordinator {
  33202. createCollider(): Collider;
  33203. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33204. init(scene: Scene): void;
  33205. }
  33206. /** @hidden */
  33207. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33208. private _scene;
  33209. private _scaledPosition;
  33210. private _scaledVelocity;
  33211. private _finalPosition;
  33212. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33213. createCollider(): Collider;
  33214. init(scene: Scene): void;
  33215. private _collideWithWorld;
  33216. }
  33217. }
  33218. declare module "babylonjs/Inputs/scene.inputManager" {
  33219. import { Nullable } from "babylonjs/types";
  33220. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33221. import { Vector2 } from "babylonjs/Maths/math.vector";
  33222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33223. import { Scene } from "babylonjs/scene";
  33224. /**
  33225. * Class used to manage all inputs for the scene.
  33226. */
  33227. export class InputManager {
  33228. /** The distance in pixel that you have to move to prevent some events */
  33229. static DragMovementThreshold: number;
  33230. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33231. static LongPressDelay: number;
  33232. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33233. static DoubleClickDelay: number;
  33234. /** If you need to check double click without raising a single click at first click, enable this flag */
  33235. static ExclusiveDoubleClickMode: boolean;
  33236. private _wheelEventName;
  33237. private _onPointerMove;
  33238. private _onPointerDown;
  33239. private _onPointerUp;
  33240. private _initClickEvent;
  33241. private _initActionManager;
  33242. private _delayedSimpleClick;
  33243. private _delayedSimpleClickTimeout;
  33244. private _previousDelayedSimpleClickTimeout;
  33245. private _meshPickProceed;
  33246. private _previousButtonPressed;
  33247. private _currentPickResult;
  33248. private _previousPickResult;
  33249. private _totalPointersPressed;
  33250. private _doubleClickOccured;
  33251. private _pointerOverMesh;
  33252. private _pickedDownMesh;
  33253. private _pickedUpMesh;
  33254. private _pointerX;
  33255. private _pointerY;
  33256. private _unTranslatedPointerX;
  33257. private _unTranslatedPointerY;
  33258. private _startingPointerPosition;
  33259. private _previousStartingPointerPosition;
  33260. private _startingPointerTime;
  33261. private _previousStartingPointerTime;
  33262. private _pointerCaptures;
  33263. private _onKeyDown;
  33264. private _onKeyUp;
  33265. private _onCanvasFocusObserver;
  33266. private _onCanvasBlurObserver;
  33267. private _scene;
  33268. /**
  33269. * Creates a new InputManager
  33270. * @param scene defines the hosting scene
  33271. */
  33272. constructor(scene: Scene);
  33273. /**
  33274. * Gets the mesh that is currently under the pointer
  33275. */
  33276. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33277. /**
  33278. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33279. */
  33280. readonly unTranslatedPointer: Vector2;
  33281. /**
  33282. * Gets or sets the current on-screen X position of the pointer
  33283. */
  33284. pointerX: number;
  33285. /**
  33286. * Gets or sets the current on-screen Y position of the pointer
  33287. */
  33288. pointerY: number;
  33289. private _updatePointerPosition;
  33290. private _processPointerMove;
  33291. private _setRayOnPointerInfo;
  33292. private _checkPrePointerObservable;
  33293. /**
  33294. * Use this method to simulate a pointer move on a mesh
  33295. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33296. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33297. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33298. */
  33299. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33300. /**
  33301. * Use this method to simulate a pointer down on a mesh
  33302. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33303. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33304. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33305. */
  33306. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33307. private _processPointerDown;
  33308. /** @hidden */
  33309. _isPointerSwiping(): boolean;
  33310. /**
  33311. * Use this method to simulate a pointer up on a mesh
  33312. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33313. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33314. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33315. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33316. */
  33317. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33318. private _processPointerUp;
  33319. /**
  33320. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33321. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33322. * @returns true if the pointer was captured
  33323. */
  33324. isPointerCaptured(pointerId?: number): boolean;
  33325. /**
  33326. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33327. * @param attachUp defines if you want to attach events to pointerup
  33328. * @param attachDown defines if you want to attach events to pointerdown
  33329. * @param attachMove defines if you want to attach events to pointermove
  33330. */
  33331. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33332. /**
  33333. * Detaches all event handlers
  33334. */
  33335. detachControl(): void;
  33336. /**
  33337. * Force the value of meshUnderPointer
  33338. * @param mesh defines the mesh to use
  33339. */
  33340. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33341. /**
  33342. * Gets the mesh under the pointer
  33343. * @returns a Mesh or null if no mesh is under the pointer
  33344. */
  33345. getPointerOverMesh(): Nullable<AbstractMesh>;
  33346. }
  33347. }
  33348. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33349. /**
  33350. * Helper class used to generate session unique ID
  33351. */
  33352. export class UniqueIdGenerator {
  33353. private static _UniqueIdCounter;
  33354. /**
  33355. * Gets an unique (relatively to the current scene) Id
  33356. */
  33357. static readonly UniqueId: number;
  33358. }
  33359. }
  33360. declare module "babylonjs/Animations/animationGroup" {
  33361. import { Animatable } from "babylonjs/Animations/animatable";
  33362. import { Animation } from "babylonjs/Animations/animation";
  33363. import { Scene, IDisposable } from "babylonjs/scene";
  33364. import { Observable } from "babylonjs/Misc/observable";
  33365. import { Nullable } from "babylonjs/types";
  33366. import "babylonjs/Animations/animatable";
  33367. /**
  33368. * This class defines the direct association between an animation and a target
  33369. */
  33370. export class TargetedAnimation {
  33371. /**
  33372. * Animation to perform
  33373. */
  33374. animation: Animation;
  33375. /**
  33376. * Target to animate
  33377. */
  33378. target: any;
  33379. /**
  33380. * Serialize the object
  33381. * @returns the JSON object representing the current entity
  33382. */
  33383. serialize(): any;
  33384. }
  33385. /**
  33386. * Use this class to create coordinated animations on multiple targets
  33387. */
  33388. export class AnimationGroup implements IDisposable {
  33389. /** The name of the animation group */
  33390. name: string;
  33391. private _scene;
  33392. private _targetedAnimations;
  33393. private _animatables;
  33394. private _from;
  33395. private _to;
  33396. private _isStarted;
  33397. private _isPaused;
  33398. private _speedRatio;
  33399. private _loopAnimation;
  33400. /**
  33401. * Gets or sets the unique id of the node
  33402. */
  33403. uniqueId: number;
  33404. /**
  33405. * This observable will notify when one animation have ended
  33406. */
  33407. onAnimationEndObservable: Observable<TargetedAnimation>;
  33408. /**
  33409. * Observer raised when one animation loops
  33410. */
  33411. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33412. /**
  33413. * This observable will notify when all animations have ended.
  33414. */
  33415. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33416. /**
  33417. * This observable will notify when all animations have paused.
  33418. */
  33419. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33420. /**
  33421. * This observable will notify when all animations are playing.
  33422. */
  33423. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33424. /**
  33425. * Gets the first frame
  33426. */
  33427. readonly from: number;
  33428. /**
  33429. * Gets the last frame
  33430. */
  33431. readonly to: number;
  33432. /**
  33433. * Define if the animations are started
  33434. */
  33435. readonly isStarted: boolean;
  33436. /**
  33437. * Gets a value indicating that the current group is playing
  33438. */
  33439. readonly isPlaying: boolean;
  33440. /**
  33441. * Gets or sets the speed ratio to use for all animations
  33442. */
  33443. /**
  33444. * Gets or sets the speed ratio to use for all animations
  33445. */
  33446. speedRatio: number;
  33447. /**
  33448. * Gets or sets if all animations should loop or not
  33449. */
  33450. loopAnimation: boolean;
  33451. /**
  33452. * Gets the targeted animations for this animation group
  33453. */
  33454. readonly targetedAnimations: Array<TargetedAnimation>;
  33455. /**
  33456. * returning the list of animatables controlled by this animation group.
  33457. */
  33458. readonly animatables: Array<Animatable>;
  33459. /**
  33460. * Instantiates a new Animation Group.
  33461. * This helps managing several animations at once.
  33462. * @see http://doc.babylonjs.com/how_to/group
  33463. * @param name Defines the name of the group
  33464. * @param scene Defines the scene the group belongs to
  33465. */
  33466. constructor(
  33467. /** The name of the animation group */
  33468. name: string, scene?: Nullable<Scene>);
  33469. /**
  33470. * Add an animation (with its target) in the group
  33471. * @param animation defines the animation we want to add
  33472. * @param target defines the target of the animation
  33473. * @returns the TargetedAnimation object
  33474. */
  33475. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33476. /**
  33477. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33478. * It can add constant keys at begin or end
  33479. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33480. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33481. * @returns the animation group
  33482. */
  33483. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33484. /**
  33485. * Start all animations on given targets
  33486. * @param loop defines if animations must loop
  33487. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33488. * @param from defines the from key (optional)
  33489. * @param to defines the to key (optional)
  33490. * @returns the current animation group
  33491. */
  33492. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33493. /**
  33494. * Pause all animations
  33495. * @returns the animation group
  33496. */
  33497. pause(): AnimationGroup;
  33498. /**
  33499. * Play all animations to initial state
  33500. * This function will start() the animations if they were not started or will restart() them if they were paused
  33501. * @param loop defines if animations must loop
  33502. * @returns the animation group
  33503. */
  33504. play(loop?: boolean): AnimationGroup;
  33505. /**
  33506. * Reset all animations to initial state
  33507. * @returns the animation group
  33508. */
  33509. reset(): AnimationGroup;
  33510. /**
  33511. * Restart animations from key 0
  33512. * @returns the animation group
  33513. */
  33514. restart(): AnimationGroup;
  33515. /**
  33516. * Stop all animations
  33517. * @returns the animation group
  33518. */
  33519. stop(): AnimationGroup;
  33520. /**
  33521. * Set animation weight for all animatables
  33522. * @param weight defines the weight to use
  33523. * @return the animationGroup
  33524. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33525. */
  33526. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33527. /**
  33528. * Synchronize and normalize all animatables with a source animatable
  33529. * @param root defines the root animatable to synchronize with
  33530. * @return the animationGroup
  33531. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33532. */
  33533. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33534. /**
  33535. * Goes to a specific frame in this animation group
  33536. * @param frame the frame number to go to
  33537. * @return the animationGroup
  33538. */
  33539. goToFrame(frame: number): AnimationGroup;
  33540. /**
  33541. * Dispose all associated resources
  33542. */
  33543. dispose(): void;
  33544. private _checkAnimationGroupEnded;
  33545. /**
  33546. * Clone the current animation group and returns a copy
  33547. * @param newName defines the name of the new group
  33548. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33549. * @returns the new aniamtion group
  33550. */
  33551. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33552. /**
  33553. * Serializes the animationGroup to an object
  33554. * @returns Serialized object
  33555. */
  33556. serialize(): any;
  33557. /**
  33558. * Returns a new AnimationGroup object parsed from the source provided.
  33559. * @param parsedAnimationGroup defines the source
  33560. * @param scene defines the scene that will receive the animationGroup
  33561. * @returns a new AnimationGroup
  33562. */
  33563. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33564. /**
  33565. * Returns the string "AnimationGroup"
  33566. * @returns "AnimationGroup"
  33567. */
  33568. getClassName(): string;
  33569. /**
  33570. * Creates a detailled string about the object
  33571. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33572. * @returns a string representing the object
  33573. */
  33574. toString(fullDetails?: boolean): string;
  33575. }
  33576. }
  33577. declare module "babylonjs/scene" {
  33578. import { Nullable } from "babylonjs/types";
  33579. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33580. import { Observable } from "babylonjs/Misc/observable";
  33581. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33582. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33583. import { Geometry } from "babylonjs/Meshes/geometry";
  33584. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33585. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33587. import { Mesh } from "babylonjs/Meshes/mesh";
  33588. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33589. import { Bone } from "babylonjs/Bones/bone";
  33590. import { Skeleton } from "babylonjs/Bones/skeleton";
  33591. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33592. import { Camera } from "babylonjs/Cameras/camera";
  33593. import { AbstractScene } from "babylonjs/abstractScene";
  33594. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33595. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33596. import { Material } from "babylonjs/Materials/material";
  33597. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33598. import { Effect } from "babylonjs/Materials/effect";
  33599. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33600. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33601. import { Light } from "babylonjs/Lights/light";
  33602. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33603. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33604. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33605. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33606. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33607. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33608. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33609. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33610. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33611. import { Engine } from "babylonjs/Engines/engine";
  33612. import { Node } from "babylonjs/node";
  33613. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33614. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33615. import { WebRequest } from "babylonjs/Misc/webRequest";
  33616. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33617. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33618. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33619. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33620. import { Plane } from "babylonjs/Maths/math.plane";
  33621. import { Ray } from "babylonjs/Culling/ray";
  33622. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33623. import { Animation } from "babylonjs/Animations/animation";
  33624. import { Animatable } from "babylonjs/Animations/animatable";
  33625. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33626. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33627. import { Collider } from "babylonjs/Collisions/collider";
  33628. /**
  33629. * Define an interface for all classes that will hold resources
  33630. */
  33631. export interface IDisposable {
  33632. /**
  33633. * Releases all held resources
  33634. */
  33635. dispose(): void;
  33636. }
  33637. /** Interface defining initialization parameters for Scene class */
  33638. export interface SceneOptions {
  33639. /**
  33640. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33641. * It will improve performance when the number of geometries becomes important.
  33642. */
  33643. useGeometryUniqueIdsMap?: boolean;
  33644. /**
  33645. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33646. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33647. */
  33648. useMaterialMeshMap?: boolean;
  33649. /**
  33650. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33651. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33652. */
  33653. useClonedMeshhMap?: boolean;
  33654. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33655. virtual?: boolean;
  33656. }
  33657. /**
  33658. * Represents a scene to be rendered by the engine.
  33659. * @see http://doc.babylonjs.com/features/scene
  33660. */
  33661. export class Scene extends AbstractScene implements IAnimatable {
  33662. /** The fog is deactivated */
  33663. static readonly FOGMODE_NONE: number;
  33664. /** The fog density is following an exponential function */
  33665. static readonly FOGMODE_EXP: number;
  33666. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33667. static readonly FOGMODE_EXP2: number;
  33668. /** The fog density is following a linear function. */
  33669. static readonly FOGMODE_LINEAR: number;
  33670. /**
  33671. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33672. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33673. */
  33674. static MinDeltaTime: number;
  33675. /**
  33676. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33677. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33678. */
  33679. static MaxDeltaTime: number;
  33680. /**
  33681. * Factory used to create the default material.
  33682. * @param name The name of the material to create
  33683. * @param scene The scene to create the material for
  33684. * @returns The default material
  33685. */
  33686. static DefaultMaterialFactory(scene: Scene): Material;
  33687. /**
  33688. * Factory used to create the a collision coordinator.
  33689. * @returns The collision coordinator
  33690. */
  33691. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33692. /** @hidden */
  33693. _inputManager: InputManager;
  33694. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33695. cameraToUseForPointers: Nullable<Camera>;
  33696. /** @hidden */
  33697. readonly _isScene: boolean;
  33698. /**
  33699. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33700. */
  33701. autoClear: boolean;
  33702. /**
  33703. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33704. */
  33705. autoClearDepthAndStencil: boolean;
  33706. /**
  33707. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33708. */
  33709. clearColor: Color4;
  33710. /**
  33711. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33712. */
  33713. ambientColor: Color3;
  33714. /**
  33715. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33716. * It should only be one of the following (if not the default embedded one):
  33717. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33718. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33719. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33720. * The material properties need to be setup according to the type of texture in use.
  33721. */
  33722. environmentBRDFTexture: BaseTexture;
  33723. /** @hidden */
  33724. protected _environmentTexture: Nullable<BaseTexture>;
  33725. /**
  33726. * Texture used in all pbr material as the reflection texture.
  33727. * As in the majority of the scene they are the same (exception for multi room and so on),
  33728. * this is easier to reference from here than from all the materials.
  33729. */
  33730. /**
  33731. * Texture used in all pbr material as the reflection texture.
  33732. * As in the majority of the scene they are the same (exception for multi room and so on),
  33733. * this is easier to set here than in all the materials.
  33734. */
  33735. environmentTexture: Nullable<BaseTexture>;
  33736. /** @hidden */
  33737. protected _environmentIntensity: number;
  33738. /**
  33739. * Intensity of the environment in all pbr material.
  33740. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33741. * As in the majority of the scene they are the same (exception for multi room and so on),
  33742. * this is easier to reference from here than from all the materials.
  33743. */
  33744. /**
  33745. * Intensity of the environment in all pbr material.
  33746. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33747. * As in the majority of the scene they are the same (exception for multi room and so on),
  33748. * this is easier to set here than in all the materials.
  33749. */
  33750. environmentIntensity: number;
  33751. /** @hidden */
  33752. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33753. /**
  33754. * Default image processing configuration used either in the rendering
  33755. * Forward main pass or through the imageProcessingPostProcess if present.
  33756. * As in the majority of the scene they are the same (exception for multi camera),
  33757. * this is easier to reference from here than from all the materials and post process.
  33758. *
  33759. * No setter as we it is a shared configuration, you can set the values instead.
  33760. */
  33761. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33762. private _forceWireframe;
  33763. /**
  33764. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33765. */
  33766. forceWireframe: boolean;
  33767. private _forcePointsCloud;
  33768. /**
  33769. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33770. */
  33771. forcePointsCloud: boolean;
  33772. /**
  33773. * Gets or sets the active clipplane 1
  33774. */
  33775. clipPlane: Nullable<Plane>;
  33776. /**
  33777. * Gets or sets the active clipplane 2
  33778. */
  33779. clipPlane2: Nullable<Plane>;
  33780. /**
  33781. * Gets or sets the active clipplane 3
  33782. */
  33783. clipPlane3: Nullable<Plane>;
  33784. /**
  33785. * Gets or sets the active clipplane 4
  33786. */
  33787. clipPlane4: Nullable<Plane>;
  33788. /**
  33789. * Gets or sets a boolean indicating if animations are enabled
  33790. */
  33791. animationsEnabled: boolean;
  33792. private _animationPropertiesOverride;
  33793. /**
  33794. * Gets or sets the animation properties override
  33795. */
  33796. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33797. /**
  33798. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33799. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33800. */
  33801. useConstantAnimationDeltaTime: boolean;
  33802. /**
  33803. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33804. * Please note that it requires to run a ray cast through the scene on every frame
  33805. */
  33806. constantlyUpdateMeshUnderPointer: boolean;
  33807. /**
  33808. * Defines the HTML cursor to use when hovering over interactive elements
  33809. */
  33810. hoverCursor: string;
  33811. /**
  33812. * Defines the HTML default cursor to use (empty by default)
  33813. */
  33814. defaultCursor: string;
  33815. /**
  33816. * This is used to call preventDefault() on pointer down
  33817. * in order to block unwanted artifacts like system double clicks
  33818. */
  33819. preventDefaultOnPointerDown: boolean;
  33820. /**
  33821. * This is used to call preventDefault() on pointer up
  33822. * in order to block unwanted artifacts like system double clicks
  33823. */
  33824. preventDefaultOnPointerUp: boolean;
  33825. /**
  33826. * Gets or sets user defined metadata
  33827. */
  33828. metadata: any;
  33829. /**
  33830. * For internal use only. Please do not use.
  33831. */
  33832. reservedDataStore: any;
  33833. /**
  33834. * Gets the name of the plugin used to load this scene (null by default)
  33835. */
  33836. loadingPluginName: string;
  33837. /**
  33838. * Use this array to add regular expressions used to disable offline support for specific urls
  33839. */
  33840. disableOfflineSupportExceptionRules: RegExp[];
  33841. /**
  33842. * An event triggered when the scene is disposed.
  33843. */
  33844. onDisposeObservable: Observable<Scene>;
  33845. private _onDisposeObserver;
  33846. /** Sets a function to be executed when this scene is disposed. */
  33847. onDispose: () => void;
  33848. /**
  33849. * An event triggered before rendering the scene (right after animations and physics)
  33850. */
  33851. onBeforeRenderObservable: Observable<Scene>;
  33852. private _onBeforeRenderObserver;
  33853. /** Sets a function to be executed before rendering this scene */
  33854. beforeRender: Nullable<() => void>;
  33855. /**
  33856. * An event triggered after rendering the scene
  33857. */
  33858. onAfterRenderObservable: Observable<Scene>;
  33859. /**
  33860. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33861. */
  33862. onAfterRenderCameraObservable: Observable<Camera>;
  33863. private _onAfterRenderObserver;
  33864. /** Sets a function to be executed after rendering this scene */
  33865. afterRender: Nullable<() => void>;
  33866. /**
  33867. * An event triggered before animating the scene
  33868. */
  33869. onBeforeAnimationsObservable: Observable<Scene>;
  33870. /**
  33871. * An event triggered after animations processing
  33872. */
  33873. onAfterAnimationsObservable: Observable<Scene>;
  33874. /**
  33875. * An event triggered before draw calls are ready to be sent
  33876. */
  33877. onBeforeDrawPhaseObservable: Observable<Scene>;
  33878. /**
  33879. * An event triggered after draw calls have been sent
  33880. */
  33881. onAfterDrawPhaseObservable: Observable<Scene>;
  33882. /**
  33883. * An event triggered when the scene is ready
  33884. */
  33885. onReadyObservable: Observable<Scene>;
  33886. /**
  33887. * An event triggered before rendering a camera
  33888. */
  33889. onBeforeCameraRenderObservable: Observable<Camera>;
  33890. private _onBeforeCameraRenderObserver;
  33891. /** Sets a function to be executed before rendering a camera*/
  33892. beforeCameraRender: () => void;
  33893. /**
  33894. * An event triggered after rendering a camera
  33895. */
  33896. onAfterCameraRenderObservable: Observable<Camera>;
  33897. private _onAfterCameraRenderObserver;
  33898. /** Sets a function to be executed after rendering a camera*/
  33899. afterCameraRender: () => void;
  33900. /**
  33901. * An event triggered when active meshes evaluation is about to start
  33902. */
  33903. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33904. /**
  33905. * An event triggered when active meshes evaluation is done
  33906. */
  33907. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33908. /**
  33909. * An event triggered when particles rendering is about to start
  33910. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33911. */
  33912. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33913. /**
  33914. * An event triggered when particles rendering is done
  33915. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33916. */
  33917. onAfterParticlesRenderingObservable: Observable<Scene>;
  33918. /**
  33919. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33920. */
  33921. onDataLoadedObservable: Observable<Scene>;
  33922. /**
  33923. * An event triggered when a camera is created
  33924. */
  33925. onNewCameraAddedObservable: Observable<Camera>;
  33926. /**
  33927. * An event triggered when a camera is removed
  33928. */
  33929. onCameraRemovedObservable: Observable<Camera>;
  33930. /**
  33931. * An event triggered when a light is created
  33932. */
  33933. onNewLightAddedObservable: Observable<Light>;
  33934. /**
  33935. * An event triggered when a light is removed
  33936. */
  33937. onLightRemovedObservable: Observable<Light>;
  33938. /**
  33939. * An event triggered when a geometry is created
  33940. */
  33941. onNewGeometryAddedObservable: Observable<Geometry>;
  33942. /**
  33943. * An event triggered when a geometry is removed
  33944. */
  33945. onGeometryRemovedObservable: Observable<Geometry>;
  33946. /**
  33947. * An event triggered when a transform node is created
  33948. */
  33949. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33950. /**
  33951. * An event triggered when a transform node is removed
  33952. */
  33953. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33954. /**
  33955. * An event triggered when a mesh is created
  33956. */
  33957. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33958. /**
  33959. * An event triggered when a mesh is removed
  33960. */
  33961. onMeshRemovedObservable: Observable<AbstractMesh>;
  33962. /**
  33963. * An event triggered when a skeleton is created
  33964. */
  33965. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33966. /**
  33967. * An event triggered when a skeleton is removed
  33968. */
  33969. onSkeletonRemovedObservable: Observable<Skeleton>;
  33970. /**
  33971. * An event triggered when a material is created
  33972. */
  33973. onNewMaterialAddedObservable: Observable<Material>;
  33974. /**
  33975. * An event triggered when a material is removed
  33976. */
  33977. onMaterialRemovedObservable: Observable<Material>;
  33978. /**
  33979. * An event triggered when a texture is created
  33980. */
  33981. onNewTextureAddedObservable: Observable<BaseTexture>;
  33982. /**
  33983. * An event triggered when a texture is removed
  33984. */
  33985. onTextureRemovedObservable: Observable<BaseTexture>;
  33986. /**
  33987. * An event triggered when render targets are about to be rendered
  33988. * Can happen multiple times per frame.
  33989. */
  33990. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33991. /**
  33992. * An event triggered when render targets were rendered.
  33993. * Can happen multiple times per frame.
  33994. */
  33995. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33996. /**
  33997. * An event triggered before calculating deterministic simulation step
  33998. */
  33999. onBeforeStepObservable: Observable<Scene>;
  34000. /**
  34001. * An event triggered after calculating deterministic simulation step
  34002. */
  34003. onAfterStepObservable: Observable<Scene>;
  34004. /**
  34005. * An event triggered when the activeCamera property is updated
  34006. */
  34007. onActiveCameraChanged: Observable<Scene>;
  34008. /**
  34009. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34010. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34011. * 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)
  34012. */
  34013. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34014. /**
  34015. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34016. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34017. * 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)
  34018. */
  34019. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34020. /**
  34021. * This Observable will when a mesh has been imported into the scene.
  34022. */
  34023. onMeshImportedObservable: Observable<AbstractMesh>;
  34024. /**
  34025. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34026. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34027. */
  34028. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34029. /** @hidden */
  34030. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34031. /**
  34032. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34033. */
  34034. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34035. /**
  34036. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34037. */
  34038. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34039. /**
  34040. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34041. */
  34042. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34043. /** Callback called when a pointer move is detected */
  34044. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34045. /** Callback called when a pointer down is detected */
  34046. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34047. /** Callback called when a pointer up is detected */
  34048. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34049. /** Callback called when a pointer pick is detected */
  34050. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34051. /**
  34052. * 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).
  34053. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34054. */
  34055. onPrePointerObservable: Observable<PointerInfoPre>;
  34056. /**
  34057. * Observable event triggered each time an input event is received from the rendering canvas
  34058. */
  34059. onPointerObservable: Observable<PointerInfo>;
  34060. /**
  34061. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34062. */
  34063. readonly unTranslatedPointer: Vector2;
  34064. /**
  34065. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34066. */
  34067. static DragMovementThreshold: number;
  34068. /**
  34069. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34070. */
  34071. static LongPressDelay: number;
  34072. /**
  34073. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34074. */
  34075. static DoubleClickDelay: number;
  34076. /** If you need to check double click without raising a single click at first click, enable this flag */
  34077. static ExclusiveDoubleClickMode: boolean;
  34078. /** @hidden */
  34079. _mirroredCameraPosition: Nullable<Vector3>;
  34080. /**
  34081. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34082. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34083. */
  34084. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34085. /**
  34086. * Observable event triggered each time an keyboard event is received from the hosting window
  34087. */
  34088. onKeyboardObservable: Observable<KeyboardInfo>;
  34089. private _useRightHandedSystem;
  34090. /**
  34091. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34092. */
  34093. useRightHandedSystem: boolean;
  34094. private _timeAccumulator;
  34095. private _currentStepId;
  34096. private _currentInternalStep;
  34097. /**
  34098. * Sets the step Id used by deterministic lock step
  34099. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34100. * @param newStepId defines the step Id
  34101. */
  34102. setStepId(newStepId: number): void;
  34103. /**
  34104. * Gets the step Id used by deterministic lock step
  34105. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34106. * @returns the step Id
  34107. */
  34108. getStepId(): number;
  34109. /**
  34110. * Gets the internal step used by deterministic lock step
  34111. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34112. * @returns the internal step
  34113. */
  34114. getInternalStep(): number;
  34115. private _fogEnabled;
  34116. /**
  34117. * Gets or sets a boolean indicating if fog is enabled on this scene
  34118. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34119. * (Default is true)
  34120. */
  34121. fogEnabled: boolean;
  34122. private _fogMode;
  34123. /**
  34124. * Gets or sets the fog mode to use
  34125. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34126. * | mode | value |
  34127. * | --- | --- |
  34128. * | FOGMODE_NONE | 0 |
  34129. * | FOGMODE_EXP | 1 |
  34130. * | FOGMODE_EXP2 | 2 |
  34131. * | FOGMODE_LINEAR | 3 |
  34132. */
  34133. fogMode: number;
  34134. /**
  34135. * Gets or sets the fog color to use
  34136. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34137. * (Default is Color3(0.2, 0.2, 0.3))
  34138. */
  34139. fogColor: Color3;
  34140. /**
  34141. * Gets or sets the fog density to use
  34142. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34143. * (Default is 0.1)
  34144. */
  34145. fogDensity: number;
  34146. /**
  34147. * Gets or sets the fog start distance to use
  34148. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34149. * (Default is 0)
  34150. */
  34151. fogStart: number;
  34152. /**
  34153. * Gets or sets the fog end distance to use
  34154. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34155. * (Default is 1000)
  34156. */
  34157. fogEnd: number;
  34158. private _shadowsEnabled;
  34159. /**
  34160. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34161. */
  34162. shadowsEnabled: boolean;
  34163. private _lightsEnabled;
  34164. /**
  34165. * Gets or sets a boolean indicating if lights are enabled on this scene
  34166. */
  34167. lightsEnabled: boolean;
  34168. /** All of the active cameras added to this scene. */
  34169. activeCameras: Camera[];
  34170. /** @hidden */
  34171. _activeCamera: Nullable<Camera>;
  34172. /** Gets or sets the current active camera */
  34173. activeCamera: Nullable<Camera>;
  34174. private _defaultMaterial;
  34175. /** The default material used on meshes when no material is affected */
  34176. /** The default material used on meshes when no material is affected */
  34177. defaultMaterial: Material;
  34178. private _texturesEnabled;
  34179. /**
  34180. * Gets or sets a boolean indicating if textures are enabled on this scene
  34181. */
  34182. texturesEnabled: boolean;
  34183. /**
  34184. * Gets or sets a boolean indicating if particles are enabled on this scene
  34185. */
  34186. particlesEnabled: boolean;
  34187. /**
  34188. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34189. */
  34190. spritesEnabled: boolean;
  34191. private _skeletonsEnabled;
  34192. /**
  34193. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34194. */
  34195. skeletonsEnabled: boolean;
  34196. /**
  34197. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34198. */
  34199. lensFlaresEnabled: boolean;
  34200. /**
  34201. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34202. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34203. */
  34204. collisionsEnabled: boolean;
  34205. private _collisionCoordinator;
  34206. /** @hidden */
  34207. readonly collisionCoordinator: ICollisionCoordinator;
  34208. /**
  34209. * Defines the gravity applied to this scene (used only for collisions)
  34210. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34211. */
  34212. gravity: Vector3;
  34213. /**
  34214. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34215. */
  34216. postProcessesEnabled: boolean;
  34217. /**
  34218. * The list of postprocesses added to the scene
  34219. */
  34220. postProcesses: PostProcess[];
  34221. /**
  34222. * Gets the current postprocess manager
  34223. */
  34224. postProcessManager: PostProcessManager;
  34225. /**
  34226. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34227. */
  34228. renderTargetsEnabled: boolean;
  34229. /**
  34230. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34231. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34232. */
  34233. dumpNextRenderTargets: boolean;
  34234. /**
  34235. * The list of user defined render targets added to the scene
  34236. */
  34237. customRenderTargets: RenderTargetTexture[];
  34238. /**
  34239. * Defines if texture loading must be delayed
  34240. * If true, textures will only be loaded when they need to be rendered
  34241. */
  34242. useDelayedTextureLoading: boolean;
  34243. /**
  34244. * Gets the list of meshes imported to the scene through SceneLoader
  34245. */
  34246. importedMeshesFiles: String[];
  34247. /**
  34248. * Gets or sets a boolean indicating if probes are enabled on this scene
  34249. */
  34250. probesEnabled: boolean;
  34251. /**
  34252. * Gets or sets the current offline provider to use to store scene data
  34253. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34254. */
  34255. offlineProvider: IOfflineProvider;
  34256. /**
  34257. * Gets or sets the action manager associated with the scene
  34258. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34259. */
  34260. actionManager: AbstractActionManager;
  34261. private _meshesForIntersections;
  34262. /**
  34263. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34264. */
  34265. proceduralTexturesEnabled: boolean;
  34266. private _engine;
  34267. private _totalVertices;
  34268. /** @hidden */
  34269. _activeIndices: PerfCounter;
  34270. /** @hidden */
  34271. _activeParticles: PerfCounter;
  34272. /** @hidden */
  34273. _activeBones: PerfCounter;
  34274. private _animationRatio;
  34275. /** @hidden */
  34276. _animationTimeLast: number;
  34277. /** @hidden */
  34278. _animationTime: number;
  34279. /**
  34280. * Gets or sets a general scale for animation speed
  34281. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34282. */
  34283. animationTimeScale: number;
  34284. /** @hidden */
  34285. _cachedMaterial: Nullable<Material>;
  34286. /** @hidden */
  34287. _cachedEffect: Nullable<Effect>;
  34288. /** @hidden */
  34289. _cachedVisibility: Nullable<number>;
  34290. private _renderId;
  34291. private _frameId;
  34292. private _executeWhenReadyTimeoutId;
  34293. private _intermediateRendering;
  34294. private _viewUpdateFlag;
  34295. private _projectionUpdateFlag;
  34296. /** @hidden */
  34297. _toBeDisposed: Nullable<IDisposable>[];
  34298. private _activeRequests;
  34299. /** @hidden */
  34300. _pendingData: any[];
  34301. private _isDisposed;
  34302. /**
  34303. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34304. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34305. */
  34306. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34307. private _activeMeshes;
  34308. private _processedMaterials;
  34309. private _renderTargets;
  34310. /** @hidden */
  34311. _activeParticleSystems: SmartArray<IParticleSystem>;
  34312. private _activeSkeletons;
  34313. private _softwareSkinnedMeshes;
  34314. private _renderingManager;
  34315. /** @hidden */
  34316. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34317. private _transformMatrix;
  34318. private _sceneUbo;
  34319. /** @hidden */
  34320. _viewMatrix: Matrix;
  34321. private _projectionMatrix;
  34322. /** @hidden */
  34323. _forcedViewPosition: Nullable<Vector3>;
  34324. /** @hidden */
  34325. _frustumPlanes: Plane[];
  34326. /**
  34327. * Gets the list of frustum planes (built from the active camera)
  34328. */
  34329. readonly frustumPlanes: Plane[];
  34330. /**
  34331. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34332. * This is useful if there are more lights that the maximum simulteanous authorized
  34333. */
  34334. requireLightSorting: boolean;
  34335. /** @hidden */
  34336. readonly useMaterialMeshMap: boolean;
  34337. /** @hidden */
  34338. readonly useClonedMeshhMap: boolean;
  34339. private _externalData;
  34340. private _uid;
  34341. /**
  34342. * @hidden
  34343. * Backing store of defined scene components.
  34344. */
  34345. _components: ISceneComponent[];
  34346. /**
  34347. * @hidden
  34348. * Backing store of defined scene components.
  34349. */
  34350. _serializableComponents: ISceneSerializableComponent[];
  34351. /**
  34352. * List of components to register on the next registration step.
  34353. */
  34354. private _transientComponents;
  34355. /**
  34356. * Registers the transient components if needed.
  34357. */
  34358. private _registerTransientComponents;
  34359. /**
  34360. * @hidden
  34361. * Add a component to the scene.
  34362. * Note that the ccomponent could be registered on th next frame if this is called after
  34363. * the register component stage.
  34364. * @param component Defines the component to add to the scene
  34365. */
  34366. _addComponent(component: ISceneComponent): void;
  34367. /**
  34368. * @hidden
  34369. * Gets a component from the scene.
  34370. * @param name defines the name of the component to retrieve
  34371. * @returns the component or null if not present
  34372. */
  34373. _getComponent(name: string): Nullable<ISceneComponent>;
  34374. /**
  34375. * @hidden
  34376. * Defines the actions happening before camera updates.
  34377. */
  34378. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34379. /**
  34380. * @hidden
  34381. * Defines the actions happening before clear the canvas.
  34382. */
  34383. _beforeClearStage: Stage<SimpleStageAction>;
  34384. /**
  34385. * @hidden
  34386. * Defines the actions when collecting render targets for the frame.
  34387. */
  34388. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34389. /**
  34390. * @hidden
  34391. * Defines the actions happening for one camera in the frame.
  34392. */
  34393. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34394. /**
  34395. * @hidden
  34396. * Defines the actions happening during the per mesh ready checks.
  34397. */
  34398. _isReadyForMeshStage: Stage<MeshStageAction>;
  34399. /**
  34400. * @hidden
  34401. * Defines the actions happening before evaluate active mesh checks.
  34402. */
  34403. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34404. /**
  34405. * @hidden
  34406. * Defines the actions happening during the evaluate sub mesh checks.
  34407. */
  34408. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34409. /**
  34410. * @hidden
  34411. * Defines the actions happening during the active mesh stage.
  34412. */
  34413. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34414. /**
  34415. * @hidden
  34416. * Defines the actions happening during the per camera render target step.
  34417. */
  34418. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34419. /**
  34420. * @hidden
  34421. * Defines the actions happening just before the active camera is drawing.
  34422. */
  34423. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34424. /**
  34425. * @hidden
  34426. * Defines the actions happening just before a render target is drawing.
  34427. */
  34428. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34429. /**
  34430. * @hidden
  34431. * Defines the actions happening just before a rendering group is drawing.
  34432. */
  34433. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34434. /**
  34435. * @hidden
  34436. * Defines the actions happening just before a mesh is drawing.
  34437. */
  34438. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34439. /**
  34440. * @hidden
  34441. * Defines the actions happening just after a mesh has been drawn.
  34442. */
  34443. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34444. /**
  34445. * @hidden
  34446. * Defines the actions happening just after a rendering group has been drawn.
  34447. */
  34448. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34449. /**
  34450. * @hidden
  34451. * Defines the actions happening just after the active camera has been drawn.
  34452. */
  34453. _afterCameraDrawStage: Stage<CameraStageAction>;
  34454. /**
  34455. * @hidden
  34456. * Defines the actions happening just after a render target has been drawn.
  34457. */
  34458. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34459. /**
  34460. * @hidden
  34461. * Defines the actions happening just after rendering all cameras and computing intersections.
  34462. */
  34463. _afterRenderStage: Stage<SimpleStageAction>;
  34464. /**
  34465. * @hidden
  34466. * Defines the actions happening when a pointer move event happens.
  34467. */
  34468. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34469. /**
  34470. * @hidden
  34471. * Defines the actions happening when a pointer down event happens.
  34472. */
  34473. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34474. /**
  34475. * @hidden
  34476. * Defines the actions happening when a pointer up event happens.
  34477. */
  34478. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34479. /**
  34480. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34481. */
  34482. private geometriesByUniqueId;
  34483. /**
  34484. * Creates a new Scene
  34485. * @param engine defines the engine to use to render this scene
  34486. * @param options defines the scene options
  34487. */
  34488. constructor(engine: Engine, options?: SceneOptions);
  34489. /**
  34490. * Gets a string idenfifying the name of the class
  34491. * @returns "Scene" string
  34492. */
  34493. getClassName(): string;
  34494. private _defaultMeshCandidates;
  34495. /**
  34496. * @hidden
  34497. */
  34498. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34499. private _defaultSubMeshCandidates;
  34500. /**
  34501. * @hidden
  34502. */
  34503. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34504. /**
  34505. * Sets the default candidate providers for the scene.
  34506. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34507. * and getCollidingSubMeshCandidates to their default function
  34508. */
  34509. setDefaultCandidateProviders(): void;
  34510. /**
  34511. * Gets the mesh that is currently under the pointer
  34512. */
  34513. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34514. /**
  34515. * Gets or sets the current on-screen X position of the pointer
  34516. */
  34517. pointerX: number;
  34518. /**
  34519. * Gets or sets the current on-screen Y position of the pointer
  34520. */
  34521. pointerY: number;
  34522. /**
  34523. * Gets the cached material (ie. the latest rendered one)
  34524. * @returns the cached material
  34525. */
  34526. getCachedMaterial(): Nullable<Material>;
  34527. /**
  34528. * Gets the cached effect (ie. the latest rendered one)
  34529. * @returns the cached effect
  34530. */
  34531. getCachedEffect(): Nullable<Effect>;
  34532. /**
  34533. * Gets the cached visibility state (ie. the latest rendered one)
  34534. * @returns the cached visibility state
  34535. */
  34536. getCachedVisibility(): Nullable<number>;
  34537. /**
  34538. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34539. * @param material defines the current material
  34540. * @param effect defines the current effect
  34541. * @param visibility defines the current visibility state
  34542. * @returns true if one parameter is not cached
  34543. */
  34544. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34545. /**
  34546. * Gets the engine associated with the scene
  34547. * @returns an Engine
  34548. */
  34549. getEngine(): Engine;
  34550. /**
  34551. * Gets the total number of vertices rendered per frame
  34552. * @returns the total number of vertices rendered per frame
  34553. */
  34554. getTotalVertices(): number;
  34555. /**
  34556. * Gets the performance counter for total vertices
  34557. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34558. */
  34559. readonly totalVerticesPerfCounter: PerfCounter;
  34560. /**
  34561. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34562. * @returns the total number of active indices rendered per frame
  34563. */
  34564. getActiveIndices(): number;
  34565. /**
  34566. * Gets the performance counter for active indices
  34567. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34568. */
  34569. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34570. /**
  34571. * Gets the total number of active particles rendered per frame
  34572. * @returns the total number of active particles rendered per frame
  34573. */
  34574. getActiveParticles(): number;
  34575. /**
  34576. * Gets the performance counter for active particles
  34577. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34578. */
  34579. readonly activeParticlesPerfCounter: PerfCounter;
  34580. /**
  34581. * Gets the total number of active bones rendered per frame
  34582. * @returns the total number of active bones rendered per frame
  34583. */
  34584. getActiveBones(): number;
  34585. /**
  34586. * Gets the performance counter for active bones
  34587. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34588. */
  34589. readonly activeBonesPerfCounter: PerfCounter;
  34590. /**
  34591. * Gets the array of active meshes
  34592. * @returns an array of AbstractMesh
  34593. */
  34594. getActiveMeshes(): SmartArray<AbstractMesh>;
  34595. /**
  34596. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34597. * @returns a number
  34598. */
  34599. getAnimationRatio(): number;
  34600. /**
  34601. * Gets an unique Id for the current render phase
  34602. * @returns a number
  34603. */
  34604. getRenderId(): number;
  34605. /**
  34606. * Gets an unique Id for the current frame
  34607. * @returns a number
  34608. */
  34609. getFrameId(): number;
  34610. /** Call this function if you want to manually increment the render Id*/
  34611. incrementRenderId(): void;
  34612. private _createUbo;
  34613. /**
  34614. * Use this method to simulate a pointer move on a mesh
  34615. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34616. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34617. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34618. * @returns the current scene
  34619. */
  34620. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34621. /**
  34622. * Use this method to simulate a pointer down on a mesh
  34623. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34624. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34625. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34626. * @returns the current scene
  34627. */
  34628. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34629. /**
  34630. * Use this method to simulate a pointer up on a mesh
  34631. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34632. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34633. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34634. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34635. * @returns the current scene
  34636. */
  34637. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34638. /**
  34639. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34640. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34641. * @returns true if the pointer was captured
  34642. */
  34643. isPointerCaptured(pointerId?: number): boolean;
  34644. /**
  34645. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34646. * @param attachUp defines if you want to attach events to pointerup
  34647. * @param attachDown defines if you want to attach events to pointerdown
  34648. * @param attachMove defines if you want to attach events to pointermove
  34649. */
  34650. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34651. /** Detaches all event handlers*/
  34652. detachControl(): void;
  34653. /**
  34654. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34655. * Delay loaded resources are not taking in account
  34656. * @return true if all required resources are ready
  34657. */
  34658. isReady(): boolean;
  34659. /** Resets all cached information relative to material (including effect and visibility) */
  34660. resetCachedMaterial(): void;
  34661. /**
  34662. * Registers a function to be called before every frame render
  34663. * @param func defines the function to register
  34664. */
  34665. registerBeforeRender(func: () => void): void;
  34666. /**
  34667. * Unregisters a function called before every frame render
  34668. * @param func defines the function to unregister
  34669. */
  34670. unregisterBeforeRender(func: () => void): void;
  34671. /**
  34672. * Registers a function to be called after every frame render
  34673. * @param func defines the function to register
  34674. */
  34675. registerAfterRender(func: () => void): void;
  34676. /**
  34677. * Unregisters a function called after every frame render
  34678. * @param func defines the function to unregister
  34679. */
  34680. unregisterAfterRender(func: () => void): void;
  34681. private _executeOnceBeforeRender;
  34682. /**
  34683. * The provided function will run before render once and will be disposed afterwards.
  34684. * A timeout delay can be provided so that the function will be executed in N ms.
  34685. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34686. * @param func The function to be executed.
  34687. * @param timeout optional delay in ms
  34688. */
  34689. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34690. /** @hidden */
  34691. _addPendingData(data: any): void;
  34692. /** @hidden */
  34693. _removePendingData(data: any): void;
  34694. /**
  34695. * Returns the number of items waiting to be loaded
  34696. * @returns the number of items waiting to be loaded
  34697. */
  34698. getWaitingItemsCount(): number;
  34699. /**
  34700. * Returns a boolean indicating if the scene is still loading data
  34701. */
  34702. readonly isLoading: boolean;
  34703. /**
  34704. * Registers a function to be executed when the scene is ready
  34705. * @param {Function} func - the function to be executed
  34706. */
  34707. executeWhenReady(func: () => void): void;
  34708. /**
  34709. * Returns a promise that resolves when the scene is ready
  34710. * @returns A promise that resolves when the scene is ready
  34711. */
  34712. whenReadyAsync(): Promise<void>;
  34713. /** @hidden */
  34714. _checkIsReady(): void;
  34715. /**
  34716. * Gets all animatable attached to the scene
  34717. */
  34718. readonly animatables: Animatable[];
  34719. /**
  34720. * Resets the last animation time frame.
  34721. * Useful to override when animations start running when loading a scene for the first time.
  34722. */
  34723. resetLastAnimationTimeFrame(): void;
  34724. /**
  34725. * Gets the current view matrix
  34726. * @returns a Matrix
  34727. */
  34728. getViewMatrix(): Matrix;
  34729. /**
  34730. * Gets the current projection matrix
  34731. * @returns a Matrix
  34732. */
  34733. getProjectionMatrix(): Matrix;
  34734. /**
  34735. * Gets the current transform matrix
  34736. * @returns a Matrix made of View * Projection
  34737. */
  34738. getTransformMatrix(): Matrix;
  34739. /**
  34740. * Sets the current transform matrix
  34741. * @param viewL defines the View matrix to use
  34742. * @param projectionL defines the Projection matrix to use
  34743. * @param viewR defines the right View matrix to use (if provided)
  34744. * @param projectionR defines the right Projection matrix to use (if provided)
  34745. */
  34746. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34747. /**
  34748. * Gets the uniform buffer used to store scene data
  34749. * @returns a UniformBuffer
  34750. */
  34751. getSceneUniformBuffer(): UniformBuffer;
  34752. /**
  34753. * Gets an unique (relatively to the current scene) Id
  34754. * @returns an unique number for the scene
  34755. */
  34756. getUniqueId(): number;
  34757. /**
  34758. * Add a mesh to the list of scene's meshes
  34759. * @param newMesh defines the mesh to add
  34760. * @param recursive if all child meshes should also be added to the scene
  34761. */
  34762. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34763. /**
  34764. * Remove a mesh for the list of scene's meshes
  34765. * @param toRemove defines the mesh to remove
  34766. * @param recursive if all child meshes should also be removed from the scene
  34767. * @returns the index where the mesh was in the mesh list
  34768. */
  34769. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34770. /**
  34771. * Add a transform node to the list of scene's transform nodes
  34772. * @param newTransformNode defines the transform node to add
  34773. */
  34774. addTransformNode(newTransformNode: TransformNode): void;
  34775. /**
  34776. * Remove a transform node for the list of scene's transform nodes
  34777. * @param toRemove defines the transform node to remove
  34778. * @returns the index where the transform node was in the transform node list
  34779. */
  34780. removeTransformNode(toRemove: TransformNode): number;
  34781. /**
  34782. * Remove a skeleton for the list of scene's skeletons
  34783. * @param toRemove defines the skeleton to remove
  34784. * @returns the index where the skeleton was in the skeleton list
  34785. */
  34786. removeSkeleton(toRemove: Skeleton): number;
  34787. /**
  34788. * Remove a morph target for the list of scene's morph targets
  34789. * @param toRemove defines the morph target to remove
  34790. * @returns the index where the morph target was in the morph target list
  34791. */
  34792. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34793. /**
  34794. * Remove a light for the list of scene's lights
  34795. * @param toRemove defines the light to remove
  34796. * @returns the index where the light was in the light list
  34797. */
  34798. removeLight(toRemove: Light): number;
  34799. /**
  34800. * Remove a camera for the list of scene's cameras
  34801. * @param toRemove defines the camera to remove
  34802. * @returns the index where the camera was in the camera list
  34803. */
  34804. removeCamera(toRemove: Camera): number;
  34805. /**
  34806. * Remove a particle system for the list of scene's particle systems
  34807. * @param toRemove defines the particle system to remove
  34808. * @returns the index where the particle system was in the particle system list
  34809. */
  34810. removeParticleSystem(toRemove: IParticleSystem): number;
  34811. /**
  34812. * Remove a animation for the list of scene's animations
  34813. * @param toRemove defines the animation to remove
  34814. * @returns the index where the animation was in the animation list
  34815. */
  34816. removeAnimation(toRemove: Animation): number;
  34817. /**
  34818. * Will stop the animation of the given target
  34819. * @param target - the target
  34820. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34821. * @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)
  34822. */
  34823. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34824. /**
  34825. * Removes the given animation group from this scene.
  34826. * @param toRemove The animation group to remove
  34827. * @returns The index of the removed animation group
  34828. */
  34829. removeAnimationGroup(toRemove: AnimationGroup): number;
  34830. /**
  34831. * Removes the given multi-material from this scene.
  34832. * @param toRemove The multi-material to remove
  34833. * @returns The index of the removed multi-material
  34834. */
  34835. removeMultiMaterial(toRemove: MultiMaterial): number;
  34836. /**
  34837. * Removes the given material from this scene.
  34838. * @param toRemove The material to remove
  34839. * @returns The index of the removed material
  34840. */
  34841. removeMaterial(toRemove: Material): number;
  34842. /**
  34843. * Removes the given action manager from this scene.
  34844. * @param toRemove The action manager to remove
  34845. * @returns The index of the removed action manager
  34846. */
  34847. removeActionManager(toRemove: AbstractActionManager): number;
  34848. /**
  34849. * Removes the given texture from this scene.
  34850. * @param toRemove The texture to remove
  34851. * @returns The index of the removed texture
  34852. */
  34853. removeTexture(toRemove: BaseTexture): number;
  34854. /**
  34855. * Adds the given light to this scene
  34856. * @param newLight The light to add
  34857. */
  34858. addLight(newLight: Light): void;
  34859. /**
  34860. * Sorts the list list based on light priorities
  34861. */
  34862. sortLightsByPriority(): void;
  34863. /**
  34864. * Adds the given camera to this scene
  34865. * @param newCamera The camera to add
  34866. */
  34867. addCamera(newCamera: Camera): void;
  34868. /**
  34869. * Adds the given skeleton to this scene
  34870. * @param newSkeleton The skeleton to add
  34871. */
  34872. addSkeleton(newSkeleton: Skeleton): void;
  34873. /**
  34874. * Adds the given particle system to this scene
  34875. * @param newParticleSystem The particle system to add
  34876. */
  34877. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34878. /**
  34879. * Adds the given animation to this scene
  34880. * @param newAnimation The animation to add
  34881. */
  34882. addAnimation(newAnimation: Animation): void;
  34883. /**
  34884. * Adds the given animation group to this scene.
  34885. * @param newAnimationGroup The animation group to add
  34886. */
  34887. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34888. /**
  34889. * Adds the given multi-material to this scene
  34890. * @param newMultiMaterial The multi-material to add
  34891. */
  34892. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34893. /**
  34894. * Adds the given material to this scene
  34895. * @param newMaterial The material to add
  34896. */
  34897. addMaterial(newMaterial: Material): void;
  34898. /**
  34899. * Adds the given morph target to this scene
  34900. * @param newMorphTargetManager The morph target to add
  34901. */
  34902. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34903. /**
  34904. * Adds the given geometry to this scene
  34905. * @param newGeometry The geometry to add
  34906. */
  34907. addGeometry(newGeometry: Geometry): void;
  34908. /**
  34909. * Adds the given action manager to this scene
  34910. * @param newActionManager The action manager to add
  34911. */
  34912. addActionManager(newActionManager: AbstractActionManager): void;
  34913. /**
  34914. * Adds the given texture to this scene.
  34915. * @param newTexture The texture to add
  34916. */
  34917. addTexture(newTexture: BaseTexture): void;
  34918. /**
  34919. * Switch active camera
  34920. * @param newCamera defines the new active camera
  34921. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34922. */
  34923. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34924. /**
  34925. * sets the active camera of the scene using its ID
  34926. * @param id defines the camera's ID
  34927. * @return the new active camera or null if none found.
  34928. */
  34929. setActiveCameraByID(id: string): Nullable<Camera>;
  34930. /**
  34931. * sets the active camera of the scene using its name
  34932. * @param name defines the camera's name
  34933. * @returns the new active camera or null if none found.
  34934. */
  34935. setActiveCameraByName(name: string): Nullable<Camera>;
  34936. /**
  34937. * get an animation group using its name
  34938. * @param name defines the material's name
  34939. * @return the animation group or null if none found.
  34940. */
  34941. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34942. /**
  34943. * Get a material using its unique id
  34944. * @param uniqueId defines the material's unique id
  34945. * @return the material or null if none found.
  34946. */
  34947. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34948. /**
  34949. * get a material using its id
  34950. * @param id defines the material's ID
  34951. * @return the material or null if none found.
  34952. */
  34953. getMaterialByID(id: string): Nullable<Material>;
  34954. /**
  34955. * Gets a the last added material using a given id
  34956. * @param id defines the material's ID
  34957. * @return the last material with the given id or null if none found.
  34958. */
  34959. getLastMaterialByID(id: string): Nullable<Material>;
  34960. /**
  34961. * Gets a material using its name
  34962. * @param name defines the material's name
  34963. * @return the material or null if none found.
  34964. */
  34965. getMaterialByName(name: string): Nullable<Material>;
  34966. /**
  34967. * Get a texture using its unique id
  34968. * @param uniqueId defines the texture's unique id
  34969. * @return the texture or null if none found.
  34970. */
  34971. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34972. /**
  34973. * Gets a camera using its id
  34974. * @param id defines the id to look for
  34975. * @returns the camera or null if not found
  34976. */
  34977. getCameraByID(id: string): Nullable<Camera>;
  34978. /**
  34979. * Gets a camera using its unique id
  34980. * @param uniqueId defines the unique id to look for
  34981. * @returns the camera or null if not found
  34982. */
  34983. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34984. /**
  34985. * Gets a camera using its name
  34986. * @param name defines the camera's name
  34987. * @return the camera or null if none found.
  34988. */
  34989. getCameraByName(name: string): Nullable<Camera>;
  34990. /**
  34991. * Gets a bone using its id
  34992. * @param id defines the bone's id
  34993. * @return the bone or null if not found
  34994. */
  34995. getBoneByID(id: string): Nullable<Bone>;
  34996. /**
  34997. * Gets a bone using its id
  34998. * @param name defines the bone's name
  34999. * @return the bone or null if not found
  35000. */
  35001. getBoneByName(name: string): Nullable<Bone>;
  35002. /**
  35003. * Gets a light node using its name
  35004. * @param name defines the the light's name
  35005. * @return the light or null if none found.
  35006. */
  35007. getLightByName(name: string): Nullable<Light>;
  35008. /**
  35009. * Gets a light node using its id
  35010. * @param id defines the light's id
  35011. * @return the light or null if none found.
  35012. */
  35013. getLightByID(id: string): Nullable<Light>;
  35014. /**
  35015. * Gets a light node using its scene-generated unique ID
  35016. * @param uniqueId defines the light's unique id
  35017. * @return the light or null if none found.
  35018. */
  35019. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35020. /**
  35021. * Gets a particle system by id
  35022. * @param id defines the particle system id
  35023. * @return the corresponding system or null if none found
  35024. */
  35025. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35026. /**
  35027. * Gets a geometry using its ID
  35028. * @param id defines the geometry's id
  35029. * @return the geometry or null if none found.
  35030. */
  35031. getGeometryByID(id: string): Nullable<Geometry>;
  35032. private _getGeometryByUniqueID;
  35033. /**
  35034. * Add a new geometry to this scene
  35035. * @param geometry defines the geometry to be added to the scene.
  35036. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35037. * @return a boolean defining if the geometry was added or not
  35038. */
  35039. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35040. /**
  35041. * Removes an existing geometry
  35042. * @param geometry defines the geometry to be removed from the scene
  35043. * @return a boolean defining if the geometry was removed or not
  35044. */
  35045. removeGeometry(geometry: Geometry): boolean;
  35046. /**
  35047. * Gets the list of geometries attached to the scene
  35048. * @returns an array of Geometry
  35049. */
  35050. getGeometries(): Geometry[];
  35051. /**
  35052. * Gets the first added mesh found of a given ID
  35053. * @param id defines the id to search for
  35054. * @return the mesh found or null if not found at all
  35055. */
  35056. getMeshByID(id: string): Nullable<AbstractMesh>;
  35057. /**
  35058. * Gets a list of meshes using their id
  35059. * @param id defines the id to search for
  35060. * @returns a list of meshes
  35061. */
  35062. getMeshesByID(id: string): Array<AbstractMesh>;
  35063. /**
  35064. * Gets the first added transform node found of a given ID
  35065. * @param id defines the id to search for
  35066. * @return the found transform node or null if not found at all.
  35067. */
  35068. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35069. /**
  35070. * Gets a transform node with its auto-generated unique id
  35071. * @param uniqueId efines the unique id to search for
  35072. * @return the found transform node or null if not found at all.
  35073. */
  35074. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35075. /**
  35076. * Gets a list of transform nodes using their id
  35077. * @param id defines the id to search for
  35078. * @returns a list of transform nodes
  35079. */
  35080. getTransformNodesByID(id: string): Array<TransformNode>;
  35081. /**
  35082. * Gets a mesh with its auto-generated unique id
  35083. * @param uniqueId defines the unique id to search for
  35084. * @return the found mesh or null if not found at all.
  35085. */
  35086. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35087. /**
  35088. * Gets a the last added mesh using a given id
  35089. * @param id defines the id to search for
  35090. * @return the found mesh or null if not found at all.
  35091. */
  35092. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35093. /**
  35094. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35095. * @param id defines the id to search for
  35096. * @return the found node or null if not found at all
  35097. */
  35098. getLastEntryByID(id: string): Nullable<Node>;
  35099. /**
  35100. * Gets a node (Mesh, Camera, Light) using a given id
  35101. * @param id defines the id to search for
  35102. * @return the found node or null if not found at all
  35103. */
  35104. getNodeByID(id: string): Nullable<Node>;
  35105. /**
  35106. * Gets a node (Mesh, Camera, Light) using a given name
  35107. * @param name defines the name to search for
  35108. * @return the found node or null if not found at all.
  35109. */
  35110. getNodeByName(name: string): Nullable<Node>;
  35111. /**
  35112. * Gets a mesh using a given name
  35113. * @param name defines the name to search for
  35114. * @return the found mesh or null if not found at all.
  35115. */
  35116. getMeshByName(name: string): Nullable<AbstractMesh>;
  35117. /**
  35118. * Gets a transform node using a given name
  35119. * @param name defines the name to search for
  35120. * @return the found transform node or null if not found at all.
  35121. */
  35122. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35123. /**
  35124. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35125. * @param id defines the id to search for
  35126. * @return the found skeleton or null if not found at all.
  35127. */
  35128. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35129. /**
  35130. * Gets a skeleton using a given auto generated unique id
  35131. * @param uniqueId defines the unique id to search for
  35132. * @return the found skeleton or null if not found at all.
  35133. */
  35134. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35135. /**
  35136. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35137. * @param id defines the id to search for
  35138. * @return the found skeleton or null if not found at all.
  35139. */
  35140. getSkeletonById(id: string): Nullable<Skeleton>;
  35141. /**
  35142. * Gets a skeleton using a given name
  35143. * @param name defines the name to search for
  35144. * @return the found skeleton or null if not found at all.
  35145. */
  35146. getSkeletonByName(name: string): Nullable<Skeleton>;
  35147. /**
  35148. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35149. * @param id defines the id to search for
  35150. * @return the found morph target manager or null if not found at all.
  35151. */
  35152. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35153. /**
  35154. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35155. * @param id defines the id to search for
  35156. * @return the found morph target or null if not found at all.
  35157. */
  35158. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35159. /**
  35160. * Gets a boolean indicating if the given mesh is active
  35161. * @param mesh defines the mesh to look for
  35162. * @returns true if the mesh is in the active list
  35163. */
  35164. isActiveMesh(mesh: AbstractMesh): boolean;
  35165. /**
  35166. * Return a unique id as a string which can serve as an identifier for the scene
  35167. */
  35168. readonly uid: string;
  35169. /**
  35170. * Add an externaly attached data from its key.
  35171. * This method call will fail and return false, if such key already exists.
  35172. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35173. * @param key the unique key that identifies the data
  35174. * @param data the data object to associate to the key for this Engine instance
  35175. * @return true if no such key were already present and the data was added successfully, false otherwise
  35176. */
  35177. addExternalData<T>(key: string, data: T): boolean;
  35178. /**
  35179. * Get an externaly attached data from its key
  35180. * @param key the unique key that identifies the data
  35181. * @return the associated data, if present (can be null), or undefined if not present
  35182. */
  35183. getExternalData<T>(key: string): Nullable<T>;
  35184. /**
  35185. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35186. * @param key the unique key that identifies the data
  35187. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35188. * @return the associated data, can be null if the factory returned null.
  35189. */
  35190. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35191. /**
  35192. * Remove an externaly attached data from the Engine instance
  35193. * @param key the unique key that identifies the data
  35194. * @return true if the data was successfully removed, false if it doesn't exist
  35195. */
  35196. removeExternalData(key: string): boolean;
  35197. private _evaluateSubMesh;
  35198. /**
  35199. * Clear the processed materials smart array preventing retention point in material dispose.
  35200. */
  35201. freeProcessedMaterials(): void;
  35202. private _preventFreeActiveMeshesAndRenderingGroups;
  35203. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35204. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35205. * when disposing several meshes in a row or a hierarchy of meshes.
  35206. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35207. */
  35208. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35209. /**
  35210. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35211. */
  35212. freeActiveMeshes(): void;
  35213. /**
  35214. * Clear the info related to rendering groups preventing retention points during dispose.
  35215. */
  35216. freeRenderingGroups(): void;
  35217. /** @hidden */
  35218. _isInIntermediateRendering(): boolean;
  35219. /**
  35220. * Lambda returning the list of potentially active meshes.
  35221. */
  35222. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35223. /**
  35224. * Lambda returning the list of potentially active sub meshes.
  35225. */
  35226. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35227. /**
  35228. * Lambda returning the list of potentially intersecting sub meshes.
  35229. */
  35230. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35231. /**
  35232. * Lambda returning the list of potentially colliding sub meshes.
  35233. */
  35234. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35235. private _activeMeshesFrozen;
  35236. /**
  35237. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35238. * @returns the current scene
  35239. */
  35240. freezeActiveMeshes(): Scene;
  35241. /**
  35242. * Use this function to restart evaluating active meshes on every frame
  35243. * @returns the current scene
  35244. */
  35245. unfreezeActiveMeshes(): Scene;
  35246. private _evaluateActiveMeshes;
  35247. private _activeMesh;
  35248. /**
  35249. * Update the transform matrix to update from the current active camera
  35250. * @param force defines a boolean used to force the update even if cache is up to date
  35251. */
  35252. updateTransformMatrix(force?: boolean): void;
  35253. private _bindFrameBuffer;
  35254. /** @hidden */
  35255. _allowPostProcessClearColor: boolean;
  35256. /** @hidden */
  35257. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35258. private _processSubCameras;
  35259. private _checkIntersections;
  35260. /** @hidden */
  35261. _advancePhysicsEngineStep(step: number): void;
  35262. /**
  35263. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35264. */
  35265. getDeterministicFrameTime: () => number;
  35266. /** @hidden */
  35267. _animate(): void;
  35268. /** Execute all animations (for a frame) */
  35269. animate(): void;
  35270. /**
  35271. * Render the scene
  35272. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35273. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35274. */
  35275. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35276. /**
  35277. * Freeze all materials
  35278. * A frozen material will not be updatable but should be faster to render
  35279. */
  35280. freezeMaterials(): void;
  35281. /**
  35282. * Unfreeze all materials
  35283. * A frozen material will not be updatable but should be faster to render
  35284. */
  35285. unfreezeMaterials(): void;
  35286. /**
  35287. * Releases all held ressources
  35288. */
  35289. dispose(): void;
  35290. /**
  35291. * Gets if the scene is already disposed
  35292. */
  35293. readonly isDisposed: boolean;
  35294. /**
  35295. * Call this function to reduce memory footprint of the scene.
  35296. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35297. */
  35298. clearCachedVertexData(): void;
  35299. /**
  35300. * This function will remove the local cached buffer data from texture.
  35301. * It will save memory but will prevent the texture from being rebuilt
  35302. */
  35303. cleanCachedTextureBuffer(): void;
  35304. /**
  35305. * Get the world extend vectors with an optional filter
  35306. *
  35307. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35308. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35309. */
  35310. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35311. min: Vector3;
  35312. max: Vector3;
  35313. };
  35314. /**
  35315. * Creates a ray that can be used to pick in the scene
  35316. * @param x defines the x coordinate of the origin (on-screen)
  35317. * @param y defines the y coordinate of the origin (on-screen)
  35318. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35319. * @param camera defines the camera to use for the picking
  35320. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35321. * @returns a Ray
  35322. */
  35323. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35324. /**
  35325. * Creates a ray that can be used to pick in the scene
  35326. * @param x defines the x coordinate of the origin (on-screen)
  35327. * @param y defines the y coordinate of the origin (on-screen)
  35328. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35329. * @param result defines the ray where to store the picking ray
  35330. * @param camera defines the camera to use for the picking
  35331. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35332. * @returns the current scene
  35333. */
  35334. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35335. /**
  35336. * Creates a ray that can be used to pick in the scene
  35337. * @param x defines the x coordinate of the origin (on-screen)
  35338. * @param y defines the y coordinate of the origin (on-screen)
  35339. * @param camera defines the camera to use for the picking
  35340. * @returns a Ray
  35341. */
  35342. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35343. /**
  35344. * Creates a ray that can be used to pick in the scene
  35345. * @param x defines the x coordinate of the origin (on-screen)
  35346. * @param y defines the y coordinate of the origin (on-screen)
  35347. * @param result defines the ray where to store the picking ray
  35348. * @param camera defines the camera to use for the picking
  35349. * @returns the current scene
  35350. */
  35351. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35352. /** Launch a ray to try to pick a mesh in the scene
  35353. * @param x position on screen
  35354. * @param y position on screen
  35355. * @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
  35356. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35357. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35358. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35359. * @returns a PickingInfo
  35360. */
  35361. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35362. /** Use the given ray to pick a mesh in the scene
  35363. * @param ray The ray to use to pick meshes
  35364. * @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
  35365. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35366. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35367. * @returns a PickingInfo
  35368. */
  35369. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35370. /**
  35371. * Launch a ray to try to pick a mesh in the scene
  35372. * @param x X position on screen
  35373. * @param y Y position on screen
  35374. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  35375. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35376. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35377. * @returns an array of PickingInfo
  35378. */
  35379. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35380. /**
  35381. * Launch a ray to try to pick a mesh in the scene
  35382. * @param ray Ray to use
  35383. * @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
  35384. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35385. * @returns an array of PickingInfo
  35386. */
  35387. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35388. /**
  35389. * Force the value of meshUnderPointer
  35390. * @param mesh defines the mesh to use
  35391. */
  35392. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35393. /**
  35394. * Gets the mesh under the pointer
  35395. * @returns a Mesh or null if no mesh is under the pointer
  35396. */
  35397. getPointerOverMesh(): Nullable<AbstractMesh>;
  35398. /** @hidden */
  35399. _rebuildGeometries(): void;
  35400. /** @hidden */
  35401. _rebuildTextures(): void;
  35402. private _getByTags;
  35403. /**
  35404. * Get a list of meshes by tags
  35405. * @param tagsQuery defines the tags query to use
  35406. * @param forEach defines a predicate used to filter results
  35407. * @returns an array of Mesh
  35408. */
  35409. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35410. /**
  35411. * Get a list of cameras by tags
  35412. * @param tagsQuery defines the tags query to use
  35413. * @param forEach defines a predicate used to filter results
  35414. * @returns an array of Camera
  35415. */
  35416. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35417. /**
  35418. * Get a list of lights by tags
  35419. * @param tagsQuery defines the tags query to use
  35420. * @param forEach defines a predicate used to filter results
  35421. * @returns an array of Light
  35422. */
  35423. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35424. /**
  35425. * Get a list of materials by tags
  35426. * @param tagsQuery defines the tags query to use
  35427. * @param forEach defines a predicate used to filter results
  35428. * @returns an array of Material
  35429. */
  35430. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35431. /**
  35432. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35433. * This allowed control for front to back rendering or reversly depending of the special needs.
  35434. *
  35435. * @param renderingGroupId The rendering group id corresponding to its index
  35436. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35437. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35438. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35439. */
  35440. 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;
  35441. /**
  35442. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35443. *
  35444. * @param renderingGroupId The rendering group id corresponding to its index
  35445. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35446. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35447. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35448. */
  35449. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35450. /**
  35451. * Gets the current auto clear configuration for one rendering group of the rendering
  35452. * manager.
  35453. * @param index the rendering group index to get the information for
  35454. * @returns The auto clear setup for the requested rendering group
  35455. */
  35456. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35457. private _blockMaterialDirtyMechanism;
  35458. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35459. blockMaterialDirtyMechanism: boolean;
  35460. /**
  35461. * Will flag all materials as dirty to trigger new shader compilation
  35462. * @param flag defines the flag used to specify which material part must be marked as dirty
  35463. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35464. */
  35465. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35466. /** @hidden */
  35467. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  35468. /** @hidden */
  35469. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35470. }
  35471. }
  35472. declare module "babylonjs/assetContainer" {
  35473. import { AbstractScene } from "babylonjs/abstractScene";
  35474. import { Scene } from "babylonjs/scene";
  35475. import { Mesh } from "babylonjs/Meshes/mesh";
  35476. /**
  35477. * Set of assets to keep when moving a scene into an asset container.
  35478. */
  35479. export class KeepAssets extends AbstractScene {
  35480. }
  35481. /**
  35482. * Container with a set of assets that can be added or removed from a scene.
  35483. */
  35484. export class AssetContainer extends AbstractScene {
  35485. /**
  35486. * The scene the AssetContainer belongs to.
  35487. */
  35488. scene: Scene;
  35489. /**
  35490. * Instantiates an AssetContainer.
  35491. * @param scene The scene the AssetContainer belongs to.
  35492. */
  35493. constructor(scene: Scene);
  35494. /**
  35495. * Adds all the assets from the container to the scene.
  35496. */
  35497. addAllToScene(): void;
  35498. /**
  35499. * Removes all the assets in the container from the scene
  35500. */
  35501. removeAllFromScene(): void;
  35502. /**
  35503. * Disposes all the assets in the container
  35504. */
  35505. dispose(): void;
  35506. private _moveAssets;
  35507. /**
  35508. * Removes all the assets contained in the scene and adds them to the container.
  35509. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35510. */
  35511. moveAllFromScene(keepAssets?: KeepAssets): void;
  35512. /**
  35513. * 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.
  35514. * @returns the root mesh
  35515. */
  35516. createRootMesh(): Mesh;
  35517. }
  35518. }
  35519. declare module "babylonjs/abstractScene" {
  35520. import { Scene } from "babylonjs/scene";
  35521. import { Nullable } from "babylonjs/types";
  35522. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35523. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35524. import { Geometry } from "babylonjs/Meshes/geometry";
  35525. import { Skeleton } from "babylonjs/Bones/skeleton";
  35526. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35527. import { AssetContainer } from "babylonjs/assetContainer";
  35528. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35529. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35530. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35531. import { Material } from "babylonjs/Materials/material";
  35532. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35533. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35534. import { Camera } from "babylonjs/Cameras/camera";
  35535. import { Light } from "babylonjs/Lights/light";
  35536. import { Node } from "babylonjs/node";
  35537. import { Animation } from "babylonjs/Animations/animation";
  35538. /**
  35539. * Defines how the parser contract is defined.
  35540. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35541. */
  35542. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35543. /**
  35544. * Defines how the individual parser contract is defined.
  35545. * These parser can parse an individual asset
  35546. */
  35547. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35548. /**
  35549. * Base class of the scene acting as a container for the different elements composing a scene.
  35550. * This class is dynamically extended by the different components of the scene increasing
  35551. * flexibility and reducing coupling
  35552. */
  35553. export abstract class AbstractScene {
  35554. /**
  35555. * Stores the list of available parsers in the application.
  35556. */
  35557. private static _BabylonFileParsers;
  35558. /**
  35559. * Stores the list of available individual parsers in the application.
  35560. */
  35561. private static _IndividualBabylonFileParsers;
  35562. /**
  35563. * Adds a parser in the list of available ones
  35564. * @param name Defines the name of the parser
  35565. * @param parser Defines the parser to add
  35566. */
  35567. static AddParser(name: string, parser: BabylonFileParser): void;
  35568. /**
  35569. * Gets a general parser from the list of avaialble ones
  35570. * @param name Defines the name of the parser
  35571. * @returns the requested parser or null
  35572. */
  35573. static GetParser(name: string): Nullable<BabylonFileParser>;
  35574. /**
  35575. * Adds n individual parser in the list of available ones
  35576. * @param name Defines the name of the parser
  35577. * @param parser Defines the parser to add
  35578. */
  35579. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35580. /**
  35581. * Gets an individual parser from the list of avaialble ones
  35582. * @param name Defines the name of the parser
  35583. * @returns the requested parser or null
  35584. */
  35585. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35586. /**
  35587. * Parser json data and populate both a scene and its associated container object
  35588. * @param jsonData Defines the data to parse
  35589. * @param scene Defines the scene to parse the data for
  35590. * @param container Defines the container attached to the parsing sequence
  35591. * @param rootUrl Defines the root url of the data
  35592. */
  35593. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35594. /**
  35595. * Gets the list of root nodes (ie. nodes with no parent)
  35596. */
  35597. rootNodes: Node[];
  35598. /** All of the cameras added to this scene
  35599. * @see http://doc.babylonjs.com/babylon101/cameras
  35600. */
  35601. cameras: Camera[];
  35602. /**
  35603. * All of the lights added to this scene
  35604. * @see http://doc.babylonjs.com/babylon101/lights
  35605. */
  35606. lights: Light[];
  35607. /**
  35608. * All of the (abstract) meshes added to this scene
  35609. */
  35610. meshes: AbstractMesh[];
  35611. /**
  35612. * The list of skeletons added to the scene
  35613. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35614. */
  35615. skeletons: Skeleton[];
  35616. /**
  35617. * All of the particle systems added to this scene
  35618. * @see http://doc.babylonjs.com/babylon101/particles
  35619. */
  35620. particleSystems: IParticleSystem[];
  35621. /**
  35622. * Gets a list of Animations associated with the scene
  35623. */
  35624. animations: Animation[];
  35625. /**
  35626. * All of the animation groups added to this scene
  35627. * @see http://doc.babylonjs.com/how_to/group
  35628. */
  35629. animationGroups: AnimationGroup[];
  35630. /**
  35631. * All of the multi-materials added to this scene
  35632. * @see http://doc.babylonjs.com/how_to/multi_materials
  35633. */
  35634. multiMaterials: MultiMaterial[];
  35635. /**
  35636. * All of the materials added to this scene
  35637. * In the context of a Scene, it is not supposed to be modified manually.
  35638. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35639. * Note also that the order of the Material wihin the array is not significant and might change.
  35640. * @see http://doc.babylonjs.com/babylon101/materials
  35641. */
  35642. materials: Material[];
  35643. /**
  35644. * The list of morph target managers added to the scene
  35645. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35646. */
  35647. morphTargetManagers: MorphTargetManager[];
  35648. /**
  35649. * The list of geometries used in the scene.
  35650. */
  35651. geometries: Geometry[];
  35652. /**
  35653. * All of the tranform nodes added to this scene
  35654. * In the context of a Scene, it is not supposed to be modified manually.
  35655. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35656. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35657. * @see http://doc.babylonjs.com/how_to/transformnode
  35658. */
  35659. transformNodes: TransformNode[];
  35660. /**
  35661. * ActionManagers available on the scene.
  35662. */
  35663. actionManagers: AbstractActionManager[];
  35664. /**
  35665. * Textures to keep.
  35666. */
  35667. textures: BaseTexture[];
  35668. /**
  35669. * Environment texture for the scene
  35670. */
  35671. environmentTexture: Nullable<BaseTexture>;
  35672. }
  35673. }
  35674. declare module "babylonjs/Audio/sound" {
  35675. import { Observable } from "babylonjs/Misc/observable";
  35676. import { Vector3 } from "babylonjs/Maths/math.vector";
  35677. import { Nullable } from "babylonjs/types";
  35678. import { Scene } from "babylonjs/scene";
  35679. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35680. /**
  35681. * Interface used to define options for Sound class
  35682. */
  35683. export interface ISoundOptions {
  35684. /**
  35685. * Does the sound autoplay once loaded.
  35686. */
  35687. autoplay?: boolean;
  35688. /**
  35689. * Does the sound loop after it finishes playing once.
  35690. */
  35691. loop?: boolean;
  35692. /**
  35693. * Sound's volume
  35694. */
  35695. volume?: number;
  35696. /**
  35697. * Is it a spatial sound?
  35698. */
  35699. spatialSound?: boolean;
  35700. /**
  35701. * Maximum distance to hear that sound
  35702. */
  35703. maxDistance?: number;
  35704. /**
  35705. * Uses user defined attenuation function
  35706. */
  35707. useCustomAttenuation?: boolean;
  35708. /**
  35709. * Define the roll off factor of spatial sounds.
  35710. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35711. */
  35712. rolloffFactor?: number;
  35713. /**
  35714. * Define the reference distance the sound should be heard perfectly.
  35715. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35716. */
  35717. refDistance?: number;
  35718. /**
  35719. * Define the distance attenuation model the sound will follow.
  35720. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35721. */
  35722. distanceModel?: string;
  35723. /**
  35724. * Defines the playback speed (1 by default)
  35725. */
  35726. playbackRate?: number;
  35727. /**
  35728. * Defines if the sound is from a streaming source
  35729. */
  35730. streaming?: boolean;
  35731. /**
  35732. * Defines an optional length (in seconds) inside the sound file
  35733. */
  35734. length?: number;
  35735. /**
  35736. * Defines an optional offset (in seconds) inside the sound file
  35737. */
  35738. offset?: number;
  35739. /**
  35740. * If true, URLs will not be required to state the audio file codec to use.
  35741. */
  35742. skipCodecCheck?: boolean;
  35743. }
  35744. /**
  35745. * Defines a sound that can be played in the application.
  35746. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35747. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35748. */
  35749. export class Sound {
  35750. /**
  35751. * The name of the sound in the scene.
  35752. */
  35753. name: string;
  35754. /**
  35755. * Does the sound autoplay once loaded.
  35756. */
  35757. autoplay: boolean;
  35758. /**
  35759. * Does the sound loop after it finishes playing once.
  35760. */
  35761. loop: boolean;
  35762. /**
  35763. * Does the sound use a custom attenuation curve to simulate the falloff
  35764. * happening when the source gets further away from the camera.
  35765. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35766. */
  35767. useCustomAttenuation: boolean;
  35768. /**
  35769. * The sound track id this sound belongs to.
  35770. */
  35771. soundTrackId: number;
  35772. /**
  35773. * Is this sound currently played.
  35774. */
  35775. isPlaying: boolean;
  35776. /**
  35777. * Is this sound currently paused.
  35778. */
  35779. isPaused: boolean;
  35780. /**
  35781. * Does this sound enables spatial sound.
  35782. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35783. */
  35784. spatialSound: boolean;
  35785. /**
  35786. * Define the reference distance the sound should be heard perfectly.
  35787. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35788. */
  35789. refDistance: number;
  35790. /**
  35791. * Define the roll off factor of spatial sounds.
  35792. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35793. */
  35794. rolloffFactor: number;
  35795. /**
  35796. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35797. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35798. */
  35799. maxDistance: number;
  35800. /**
  35801. * Define the distance attenuation model the sound will follow.
  35802. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35803. */
  35804. distanceModel: string;
  35805. /**
  35806. * @hidden
  35807. * Back Compat
  35808. **/
  35809. onended: () => any;
  35810. /**
  35811. * Observable event when the current playing sound finishes.
  35812. */
  35813. onEndedObservable: Observable<Sound>;
  35814. private _panningModel;
  35815. private _playbackRate;
  35816. private _streaming;
  35817. private _startTime;
  35818. private _startOffset;
  35819. private _position;
  35820. /** @hidden */
  35821. _positionInEmitterSpace: boolean;
  35822. private _localDirection;
  35823. private _volume;
  35824. private _isReadyToPlay;
  35825. private _isDirectional;
  35826. private _readyToPlayCallback;
  35827. private _audioBuffer;
  35828. private _soundSource;
  35829. private _streamingSource;
  35830. private _soundPanner;
  35831. private _soundGain;
  35832. private _inputAudioNode;
  35833. private _outputAudioNode;
  35834. private _coneInnerAngle;
  35835. private _coneOuterAngle;
  35836. private _coneOuterGain;
  35837. private _scene;
  35838. private _connectedTransformNode;
  35839. private _customAttenuationFunction;
  35840. private _registerFunc;
  35841. private _isOutputConnected;
  35842. private _htmlAudioElement;
  35843. private _urlType;
  35844. private _length?;
  35845. private _offset?;
  35846. /** @hidden */
  35847. static _SceneComponentInitialization: (scene: Scene) => void;
  35848. /**
  35849. * Create a sound and attach it to a scene
  35850. * @param name Name of your sound
  35851. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35852. * @param scene defines the scene the sound belongs to
  35853. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35854. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35855. */
  35856. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35857. /**
  35858. * Release the sound and its associated resources
  35859. */
  35860. dispose(): void;
  35861. /**
  35862. * Gets if the sounds is ready to be played or not.
  35863. * @returns true if ready, otherwise false
  35864. */
  35865. isReady(): boolean;
  35866. private _soundLoaded;
  35867. /**
  35868. * Sets the data of the sound from an audiobuffer
  35869. * @param audioBuffer The audioBuffer containing the data
  35870. */
  35871. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35872. /**
  35873. * Updates the current sounds options such as maxdistance, loop...
  35874. * @param options A JSON object containing values named as the object properties
  35875. */
  35876. updateOptions(options: ISoundOptions): void;
  35877. private _createSpatialParameters;
  35878. private _updateSpatialParameters;
  35879. /**
  35880. * Switch the panning model to HRTF:
  35881. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35882. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35883. */
  35884. switchPanningModelToHRTF(): void;
  35885. /**
  35886. * Switch the panning model to Equal Power:
  35887. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35889. */
  35890. switchPanningModelToEqualPower(): void;
  35891. private _switchPanningModel;
  35892. /**
  35893. * Connect this sound to a sound track audio node like gain...
  35894. * @param soundTrackAudioNode the sound track audio node to connect to
  35895. */
  35896. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35897. /**
  35898. * Transform this sound into a directional source
  35899. * @param coneInnerAngle Size of the inner cone in degree
  35900. * @param coneOuterAngle Size of the outer cone in degree
  35901. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35902. */
  35903. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35904. /**
  35905. * Gets or sets the inner angle for the directional cone.
  35906. */
  35907. /**
  35908. * Gets or sets the inner angle for the directional cone.
  35909. */
  35910. directionalConeInnerAngle: number;
  35911. /**
  35912. * Gets or sets the outer angle for the directional cone.
  35913. */
  35914. /**
  35915. * Gets or sets the outer angle for the directional cone.
  35916. */
  35917. directionalConeOuterAngle: number;
  35918. /**
  35919. * Sets the position of the emitter if spatial sound is enabled
  35920. * @param newPosition Defines the new posisiton
  35921. */
  35922. setPosition(newPosition: Vector3): void;
  35923. /**
  35924. * Sets the local direction of the emitter if spatial sound is enabled
  35925. * @param newLocalDirection Defines the new local direction
  35926. */
  35927. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35928. private _updateDirection;
  35929. /** @hidden */
  35930. updateDistanceFromListener(): void;
  35931. /**
  35932. * Sets a new custom attenuation function for the sound.
  35933. * @param callback Defines the function used for the attenuation
  35934. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35935. */
  35936. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35937. /**
  35938. * Play the sound
  35939. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35940. * @param offset (optional) Start the sound at a specific time in seconds
  35941. * @param length (optional) Sound duration (in seconds)
  35942. */
  35943. play(time?: number, offset?: number, length?: number): void;
  35944. private _onended;
  35945. /**
  35946. * Stop the sound
  35947. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35948. */
  35949. stop(time?: number): void;
  35950. /**
  35951. * Put the sound in pause
  35952. */
  35953. pause(): void;
  35954. /**
  35955. * Sets a dedicated volume for this sounds
  35956. * @param newVolume Define the new volume of the sound
  35957. * @param time Define time for gradual change to new volume
  35958. */
  35959. setVolume(newVolume: number, time?: number): void;
  35960. /**
  35961. * Set the sound play back rate
  35962. * @param newPlaybackRate Define the playback rate the sound should be played at
  35963. */
  35964. setPlaybackRate(newPlaybackRate: number): void;
  35965. /**
  35966. * Gets the volume of the sound.
  35967. * @returns the volume of the sound
  35968. */
  35969. getVolume(): number;
  35970. /**
  35971. * Attach the sound to a dedicated mesh
  35972. * @param transformNode The transform node to connect the sound with
  35973. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35974. */
  35975. attachToMesh(transformNode: TransformNode): void;
  35976. /**
  35977. * Detach the sound from the previously attached mesh
  35978. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35979. */
  35980. detachFromMesh(): void;
  35981. private _onRegisterAfterWorldMatrixUpdate;
  35982. /**
  35983. * Clone the current sound in the scene.
  35984. * @returns the new sound clone
  35985. */
  35986. clone(): Nullable<Sound>;
  35987. /**
  35988. * Gets the current underlying audio buffer containing the data
  35989. * @returns the audio buffer
  35990. */
  35991. getAudioBuffer(): Nullable<AudioBuffer>;
  35992. /**
  35993. * Serializes the Sound in a JSON representation
  35994. * @returns the JSON representation of the sound
  35995. */
  35996. serialize(): any;
  35997. /**
  35998. * Parse a JSON representation of a sound to innstantiate in a given scene
  35999. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36000. * @param scene Define the scene the new parsed sound should be created in
  36001. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36002. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36003. * @returns the newly parsed sound
  36004. */
  36005. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36006. }
  36007. }
  36008. declare module "babylonjs/Actions/directAudioActions" {
  36009. import { Action } from "babylonjs/Actions/action";
  36010. import { Condition } from "babylonjs/Actions/condition";
  36011. import { Sound } from "babylonjs/Audio/sound";
  36012. /**
  36013. * This defines an action helpful to play a defined sound on a triggered action.
  36014. */
  36015. export class PlaySoundAction extends Action {
  36016. private _sound;
  36017. /**
  36018. * Instantiate the action
  36019. * @param triggerOptions defines the trigger options
  36020. * @param sound defines the sound to play
  36021. * @param condition defines the trigger related conditions
  36022. */
  36023. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36024. /** @hidden */
  36025. _prepare(): void;
  36026. /**
  36027. * Execute the action and play the sound.
  36028. */
  36029. execute(): void;
  36030. /**
  36031. * Serializes the actions and its related information.
  36032. * @param parent defines the object to serialize in
  36033. * @returns the serialized object
  36034. */
  36035. serialize(parent: any): any;
  36036. }
  36037. /**
  36038. * This defines an action helpful to stop a defined sound on a triggered action.
  36039. */
  36040. export class StopSoundAction extends Action {
  36041. private _sound;
  36042. /**
  36043. * Instantiate the action
  36044. * @param triggerOptions defines the trigger options
  36045. * @param sound defines the sound to stop
  36046. * @param condition defines the trigger related conditions
  36047. */
  36048. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36049. /** @hidden */
  36050. _prepare(): void;
  36051. /**
  36052. * Execute the action and stop the sound.
  36053. */
  36054. execute(): void;
  36055. /**
  36056. * Serializes the actions and its related information.
  36057. * @param parent defines the object to serialize in
  36058. * @returns the serialized object
  36059. */
  36060. serialize(parent: any): any;
  36061. }
  36062. }
  36063. declare module "babylonjs/Actions/interpolateValueAction" {
  36064. import { Action } from "babylonjs/Actions/action";
  36065. import { Condition } from "babylonjs/Actions/condition";
  36066. import { Observable } from "babylonjs/Misc/observable";
  36067. /**
  36068. * This defines an action responsible to change the value of a property
  36069. * by interpolating between its current value and the newly set one once triggered.
  36070. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36071. */
  36072. export class InterpolateValueAction extends Action {
  36073. /**
  36074. * Defines the path of the property where the value should be interpolated
  36075. */
  36076. propertyPath: string;
  36077. /**
  36078. * Defines the target value at the end of the interpolation.
  36079. */
  36080. value: any;
  36081. /**
  36082. * Defines the time it will take for the property to interpolate to the value.
  36083. */
  36084. duration: number;
  36085. /**
  36086. * Defines if the other scene animations should be stopped when the action has been triggered
  36087. */
  36088. stopOtherAnimations?: boolean;
  36089. /**
  36090. * Defines a callback raised once the interpolation animation has been done.
  36091. */
  36092. onInterpolationDone?: () => void;
  36093. /**
  36094. * Observable triggered once the interpolation animation has been done.
  36095. */
  36096. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36097. private _target;
  36098. private _effectiveTarget;
  36099. private _property;
  36100. /**
  36101. * Instantiate the action
  36102. * @param triggerOptions defines the trigger options
  36103. * @param target defines the object containing the value to interpolate
  36104. * @param propertyPath defines the path to the property in the target object
  36105. * @param value defines the target value at the end of the interpolation
  36106. * @param duration deines the time it will take for the property to interpolate to the value.
  36107. * @param condition defines the trigger related conditions
  36108. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36109. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36110. */
  36111. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36112. /** @hidden */
  36113. _prepare(): void;
  36114. /**
  36115. * Execute the action starts the value interpolation.
  36116. */
  36117. execute(): void;
  36118. /**
  36119. * Serializes the actions and its related information.
  36120. * @param parent defines the object to serialize in
  36121. * @returns the serialized object
  36122. */
  36123. serialize(parent: any): any;
  36124. }
  36125. }
  36126. declare module "babylonjs/Actions/index" {
  36127. export * from "babylonjs/Actions/abstractActionManager";
  36128. export * from "babylonjs/Actions/action";
  36129. export * from "babylonjs/Actions/actionEvent";
  36130. export * from "babylonjs/Actions/actionManager";
  36131. export * from "babylonjs/Actions/condition";
  36132. export * from "babylonjs/Actions/directActions";
  36133. export * from "babylonjs/Actions/directAudioActions";
  36134. export * from "babylonjs/Actions/interpolateValueAction";
  36135. }
  36136. declare module "babylonjs/Animations/index" {
  36137. export * from "babylonjs/Animations/animatable";
  36138. export * from "babylonjs/Animations/animation";
  36139. export * from "babylonjs/Animations/animationGroup";
  36140. export * from "babylonjs/Animations/animationPropertiesOverride";
  36141. export * from "babylonjs/Animations/easing";
  36142. export * from "babylonjs/Animations/runtimeAnimation";
  36143. export * from "babylonjs/Animations/animationEvent";
  36144. export * from "babylonjs/Animations/animationGroup";
  36145. export * from "babylonjs/Animations/animationKey";
  36146. export * from "babylonjs/Animations/animationRange";
  36147. export * from "babylonjs/Animations/animatable.interface";
  36148. }
  36149. declare module "babylonjs/Audio/soundTrack" {
  36150. import { Sound } from "babylonjs/Audio/sound";
  36151. import { Analyser } from "babylonjs/Audio/analyser";
  36152. import { Scene } from "babylonjs/scene";
  36153. /**
  36154. * Options allowed during the creation of a sound track.
  36155. */
  36156. export interface ISoundTrackOptions {
  36157. /**
  36158. * The volume the sound track should take during creation
  36159. */
  36160. volume?: number;
  36161. /**
  36162. * Define if the sound track is the main sound track of the scene
  36163. */
  36164. mainTrack?: boolean;
  36165. }
  36166. /**
  36167. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36168. * It will be also used in a future release to apply effects on a specific track.
  36169. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36170. */
  36171. export class SoundTrack {
  36172. /**
  36173. * The unique identifier of the sound track in the scene.
  36174. */
  36175. id: number;
  36176. /**
  36177. * The list of sounds included in the sound track.
  36178. */
  36179. soundCollection: Array<Sound>;
  36180. private _outputAudioNode;
  36181. private _scene;
  36182. private _isMainTrack;
  36183. private _connectedAnalyser;
  36184. private _options;
  36185. private _isInitialized;
  36186. /**
  36187. * Creates a new sound track.
  36188. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36189. * @param scene Define the scene the sound track belongs to
  36190. * @param options
  36191. */
  36192. constructor(scene: Scene, options?: ISoundTrackOptions);
  36193. private _initializeSoundTrackAudioGraph;
  36194. /**
  36195. * Release the sound track and its associated resources
  36196. */
  36197. dispose(): void;
  36198. /**
  36199. * Adds a sound to this sound track
  36200. * @param sound define the cound to add
  36201. * @ignoreNaming
  36202. */
  36203. AddSound(sound: Sound): void;
  36204. /**
  36205. * Removes a sound to this sound track
  36206. * @param sound define the cound to remove
  36207. * @ignoreNaming
  36208. */
  36209. RemoveSound(sound: Sound): void;
  36210. /**
  36211. * Set a global volume for the full sound track.
  36212. * @param newVolume Define the new volume of the sound track
  36213. */
  36214. setVolume(newVolume: number): void;
  36215. /**
  36216. * Switch the panning model to HRTF:
  36217. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36218. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36219. */
  36220. switchPanningModelToHRTF(): void;
  36221. /**
  36222. * Switch the panning model to Equal Power:
  36223. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36224. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36225. */
  36226. switchPanningModelToEqualPower(): void;
  36227. /**
  36228. * Connect the sound track to an audio analyser allowing some amazing
  36229. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36230. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36231. * @param analyser The analyser to connect to the engine
  36232. */
  36233. connectToAnalyser(analyser: Analyser): void;
  36234. }
  36235. }
  36236. declare module "babylonjs/Audio/audioSceneComponent" {
  36237. import { Sound } from "babylonjs/Audio/sound";
  36238. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36239. import { Nullable } from "babylonjs/types";
  36240. import { Vector3 } from "babylonjs/Maths/math.vector";
  36241. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36242. import { Scene } from "babylonjs/scene";
  36243. import { AbstractScene } from "babylonjs/abstractScene";
  36244. import "babylonjs/Audio/audioEngine";
  36245. module "babylonjs/abstractScene" {
  36246. interface AbstractScene {
  36247. /**
  36248. * The list of sounds used in the scene.
  36249. */
  36250. sounds: Nullable<Array<Sound>>;
  36251. }
  36252. }
  36253. module "babylonjs/scene" {
  36254. interface Scene {
  36255. /**
  36256. * @hidden
  36257. * Backing field
  36258. */
  36259. _mainSoundTrack: SoundTrack;
  36260. /**
  36261. * The main sound track played by the scene.
  36262. * It cotains your primary collection of sounds.
  36263. */
  36264. mainSoundTrack: SoundTrack;
  36265. /**
  36266. * The list of sound tracks added to the scene
  36267. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36268. */
  36269. soundTracks: Nullable<Array<SoundTrack>>;
  36270. /**
  36271. * Gets a sound using a given name
  36272. * @param name defines the name to search for
  36273. * @return the found sound or null if not found at all.
  36274. */
  36275. getSoundByName(name: string): Nullable<Sound>;
  36276. /**
  36277. * Gets or sets if audio support is enabled
  36278. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36279. */
  36280. audioEnabled: boolean;
  36281. /**
  36282. * Gets or sets if audio will be output to headphones
  36283. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36284. */
  36285. headphone: boolean;
  36286. /**
  36287. * Gets or sets custom audio listener position provider
  36288. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36289. */
  36290. audioListenerPositionProvider: Nullable<() => Vector3>;
  36291. }
  36292. }
  36293. /**
  36294. * Defines the sound scene component responsible to manage any sounds
  36295. * in a given scene.
  36296. */
  36297. export class AudioSceneComponent implements ISceneSerializableComponent {
  36298. /**
  36299. * The component name helpfull to identify the component in the list of scene components.
  36300. */
  36301. readonly name: string;
  36302. /**
  36303. * The scene the component belongs to.
  36304. */
  36305. scene: Scene;
  36306. private _audioEnabled;
  36307. /**
  36308. * Gets whether audio is enabled or not.
  36309. * Please use related enable/disable method to switch state.
  36310. */
  36311. readonly audioEnabled: boolean;
  36312. private _headphone;
  36313. /**
  36314. * Gets whether audio is outputing to headphone or not.
  36315. * Please use the according Switch methods to change output.
  36316. */
  36317. readonly headphone: boolean;
  36318. private _audioListenerPositionProvider;
  36319. /**
  36320. * Gets the current audio listener position provider
  36321. */
  36322. /**
  36323. * Sets a custom listener position for all sounds in the scene
  36324. * By default, this is the position of the first active camera
  36325. */
  36326. audioListenerPositionProvider: Nullable<() => Vector3>;
  36327. /**
  36328. * Creates a new instance of the component for the given scene
  36329. * @param scene Defines the scene to register the component in
  36330. */
  36331. constructor(scene: Scene);
  36332. /**
  36333. * Registers the component in a given scene
  36334. */
  36335. register(): void;
  36336. /**
  36337. * Rebuilds the elements related to this component in case of
  36338. * context lost for instance.
  36339. */
  36340. rebuild(): void;
  36341. /**
  36342. * Serializes the component data to the specified json object
  36343. * @param serializationObject The object to serialize to
  36344. */
  36345. serialize(serializationObject: any): void;
  36346. /**
  36347. * Adds all the elements from the container to the scene
  36348. * @param container the container holding the elements
  36349. */
  36350. addFromContainer(container: AbstractScene): void;
  36351. /**
  36352. * Removes all the elements in the container from the scene
  36353. * @param container contains the elements to remove
  36354. * @param dispose if the removed element should be disposed (default: false)
  36355. */
  36356. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36357. /**
  36358. * Disposes the component and the associated ressources.
  36359. */
  36360. dispose(): void;
  36361. /**
  36362. * Disables audio in the associated scene.
  36363. */
  36364. disableAudio(): void;
  36365. /**
  36366. * Enables audio in the associated scene.
  36367. */
  36368. enableAudio(): void;
  36369. /**
  36370. * Switch audio to headphone output.
  36371. */
  36372. switchAudioModeForHeadphones(): void;
  36373. /**
  36374. * Switch audio to normal speakers.
  36375. */
  36376. switchAudioModeForNormalSpeakers(): void;
  36377. private _afterRender;
  36378. }
  36379. }
  36380. declare module "babylonjs/Audio/weightedsound" {
  36381. import { Sound } from "babylonjs/Audio/sound";
  36382. /**
  36383. * Wraps one or more Sound objects and selects one with random weight for playback.
  36384. */
  36385. export class WeightedSound {
  36386. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36387. loop: boolean;
  36388. private _coneInnerAngle;
  36389. private _coneOuterAngle;
  36390. private _volume;
  36391. /** A Sound is currently playing. */
  36392. isPlaying: boolean;
  36393. /** A Sound is currently paused. */
  36394. isPaused: boolean;
  36395. private _sounds;
  36396. private _weights;
  36397. private _currentIndex?;
  36398. /**
  36399. * Creates a new WeightedSound from the list of sounds given.
  36400. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36401. * @param sounds Array of Sounds that will be selected from.
  36402. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36403. */
  36404. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36405. /**
  36406. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36407. */
  36408. /**
  36409. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36410. */
  36411. directionalConeInnerAngle: number;
  36412. /**
  36413. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36414. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36415. */
  36416. /**
  36417. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36418. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36419. */
  36420. directionalConeOuterAngle: number;
  36421. /**
  36422. * Playback volume.
  36423. */
  36424. /**
  36425. * Playback volume.
  36426. */
  36427. volume: number;
  36428. private _onended;
  36429. /**
  36430. * Suspend playback
  36431. */
  36432. pause(): void;
  36433. /**
  36434. * Stop playback
  36435. */
  36436. stop(): void;
  36437. /**
  36438. * Start playback.
  36439. * @param startOffset Position the clip head at a specific time in seconds.
  36440. */
  36441. play(startOffset?: number): void;
  36442. }
  36443. }
  36444. declare module "babylonjs/Audio/index" {
  36445. export * from "babylonjs/Audio/analyser";
  36446. export * from "babylonjs/Audio/audioEngine";
  36447. export * from "babylonjs/Audio/audioSceneComponent";
  36448. export * from "babylonjs/Audio/sound";
  36449. export * from "babylonjs/Audio/soundTrack";
  36450. export * from "babylonjs/Audio/weightedsound";
  36451. }
  36452. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36453. import { Behavior } from "babylonjs/Behaviors/behavior";
  36454. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36455. import { BackEase } from "babylonjs/Animations/easing";
  36456. /**
  36457. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36458. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36459. */
  36460. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36461. /**
  36462. * Gets the name of the behavior.
  36463. */
  36464. readonly name: string;
  36465. /**
  36466. * The easing function used by animations
  36467. */
  36468. static EasingFunction: BackEase;
  36469. /**
  36470. * The easing mode used by animations
  36471. */
  36472. static EasingMode: number;
  36473. /**
  36474. * The duration of the animation, in milliseconds
  36475. */
  36476. transitionDuration: number;
  36477. /**
  36478. * Length of the distance animated by the transition when lower radius is reached
  36479. */
  36480. lowerRadiusTransitionRange: number;
  36481. /**
  36482. * Length of the distance animated by the transition when upper radius is reached
  36483. */
  36484. upperRadiusTransitionRange: number;
  36485. private _autoTransitionRange;
  36486. /**
  36487. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36488. */
  36489. /**
  36490. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36491. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36492. */
  36493. autoTransitionRange: boolean;
  36494. private _attachedCamera;
  36495. private _onAfterCheckInputsObserver;
  36496. private _onMeshTargetChangedObserver;
  36497. /**
  36498. * Initializes the behavior.
  36499. */
  36500. init(): void;
  36501. /**
  36502. * Attaches the behavior to its arc rotate camera.
  36503. * @param camera Defines the camera to attach the behavior to
  36504. */
  36505. attach(camera: ArcRotateCamera): void;
  36506. /**
  36507. * Detaches the behavior from its current arc rotate camera.
  36508. */
  36509. detach(): void;
  36510. private _radiusIsAnimating;
  36511. private _radiusBounceTransition;
  36512. private _animatables;
  36513. private _cachedWheelPrecision;
  36514. /**
  36515. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36516. * @param radiusLimit The limit to check against.
  36517. * @return Bool to indicate if at limit.
  36518. */
  36519. private _isRadiusAtLimit;
  36520. /**
  36521. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36522. * @param radiusDelta The delta by which to animate to. Can be negative.
  36523. */
  36524. private _applyBoundRadiusAnimation;
  36525. /**
  36526. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36527. */
  36528. protected _clearAnimationLocks(): void;
  36529. /**
  36530. * Stops and removes all animations that have been applied to the camera
  36531. */
  36532. stopAllAnimations(): void;
  36533. }
  36534. }
  36535. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36536. import { Behavior } from "babylonjs/Behaviors/behavior";
  36537. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36538. import { ExponentialEase } from "babylonjs/Animations/easing";
  36539. import { Nullable } from "babylonjs/types";
  36540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36541. import { Vector3 } from "babylonjs/Maths/math.vector";
  36542. /**
  36543. * 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.
  36544. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36545. */
  36546. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36547. /**
  36548. * Gets the name of the behavior.
  36549. */
  36550. readonly name: string;
  36551. private _mode;
  36552. private _radiusScale;
  36553. private _positionScale;
  36554. private _defaultElevation;
  36555. private _elevationReturnTime;
  36556. private _elevationReturnWaitTime;
  36557. private _zoomStopsAnimation;
  36558. private _framingTime;
  36559. /**
  36560. * The easing function used by animations
  36561. */
  36562. static EasingFunction: ExponentialEase;
  36563. /**
  36564. * The easing mode used by animations
  36565. */
  36566. static EasingMode: number;
  36567. /**
  36568. * Sets the current mode used by the behavior
  36569. */
  36570. /**
  36571. * Gets current mode used by the behavior.
  36572. */
  36573. mode: number;
  36574. /**
  36575. * Sets the scale applied to the radius (1 by default)
  36576. */
  36577. /**
  36578. * Gets the scale applied to the radius
  36579. */
  36580. radiusScale: number;
  36581. /**
  36582. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36583. */
  36584. /**
  36585. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36586. */
  36587. positionScale: number;
  36588. /**
  36589. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36590. * behaviour is triggered, in radians.
  36591. */
  36592. /**
  36593. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36594. * behaviour is triggered, in radians.
  36595. */
  36596. defaultElevation: number;
  36597. /**
  36598. * Sets the time (in milliseconds) taken to return to the default beta position.
  36599. * Negative value indicates camera should not return to default.
  36600. */
  36601. /**
  36602. * Gets the time (in milliseconds) taken to return to the default beta position.
  36603. * Negative value indicates camera should not return to default.
  36604. */
  36605. elevationReturnTime: number;
  36606. /**
  36607. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36608. */
  36609. /**
  36610. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36611. */
  36612. elevationReturnWaitTime: number;
  36613. /**
  36614. * Sets the flag that indicates if user zooming should stop animation.
  36615. */
  36616. /**
  36617. * Gets the flag that indicates if user zooming should stop animation.
  36618. */
  36619. zoomStopsAnimation: boolean;
  36620. /**
  36621. * Sets the transition time when framing the mesh, in milliseconds
  36622. */
  36623. /**
  36624. * Gets the transition time when framing the mesh, in milliseconds
  36625. */
  36626. framingTime: number;
  36627. /**
  36628. * Define if the behavior should automatically change the configured
  36629. * camera limits and sensibilities.
  36630. */
  36631. autoCorrectCameraLimitsAndSensibility: boolean;
  36632. private _onPrePointerObservableObserver;
  36633. private _onAfterCheckInputsObserver;
  36634. private _onMeshTargetChangedObserver;
  36635. private _attachedCamera;
  36636. private _isPointerDown;
  36637. private _lastInteractionTime;
  36638. /**
  36639. * Initializes the behavior.
  36640. */
  36641. init(): void;
  36642. /**
  36643. * Attaches the behavior to its arc rotate camera.
  36644. * @param camera Defines the camera to attach the behavior to
  36645. */
  36646. attach(camera: ArcRotateCamera): void;
  36647. /**
  36648. * Detaches the behavior from its current arc rotate camera.
  36649. */
  36650. detach(): void;
  36651. private _animatables;
  36652. private _betaIsAnimating;
  36653. private _betaTransition;
  36654. private _radiusTransition;
  36655. private _vectorTransition;
  36656. /**
  36657. * Targets the given mesh and updates zoom level accordingly.
  36658. * @param mesh The mesh to target.
  36659. * @param radius Optional. If a cached radius position already exists, overrides default.
  36660. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36661. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36662. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36663. */
  36664. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36665. /**
  36666. * Targets the given mesh with its children and updates zoom level accordingly.
  36667. * @param mesh The mesh to target.
  36668. * @param radius Optional. If a cached radius position already exists, overrides default.
  36669. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36670. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36671. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36672. */
  36673. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36674. /**
  36675. * Targets the given meshes with their children and updates zoom level accordingly.
  36676. * @param meshes The mesh to target.
  36677. * @param radius Optional. If a cached radius position already exists, overrides default.
  36678. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36679. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36680. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36681. */
  36682. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36683. /**
  36684. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36685. * @param minimumWorld Determines the smaller position of the bounding box extend
  36686. * @param maximumWorld Determines the bigger position of the bounding box extend
  36687. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36688. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36689. */
  36690. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36691. /**
  36692. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36693. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36694. * frustum width.
  36695. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36696. * to fully enclose the mesh in the viewing frustum.
  36697. */
  36698. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36699. /**
  36700. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36701. * is automatically returned to its default position (expected to be above ground plane).
  36702. */
  36703. private _maintainCameraAboveGround;
  36704. /**
  36705. * Returns the frustum slope based on the canvas ratio and camera FOV
  36706. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36707. */
  36708. private _getFrustumSlope;
  36709. /**
  36710. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36711. */
  36712. private _clearAnimationLocks;
  36713. /**
  36714. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36715. */
  36716. private _applyUserInteraction;
  36717. /**
  36718. * Stops and removes all animations that have been applied to the camera
  36719. */
  36720. stopAllAnimations(): void;
  36721. /**
  36722. * Gets a value indicating if the user is moving the camera
  36723. */
  36724. readonly isUserIsMoving: boolean;
  36725. /**
  36726. * The camera can move all the way towards the mesh.
  36727. */
  36728. static IgnoreBoundsSizeMode: number;
  36729. /**
  36730. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36731. */
  36732. static FitFrustumSidesMode: number;
  36733. }
  36734. }
  36735. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36736. import { Nullable } from "babylonjs/types";
  36737. import { Camera } from "babylonjs/Cameras/camera";
  36738. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36739. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36740. /**
  36741. * Base class for Camera Pointer Inputs.
  36742. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36743. * for example usage.
  36744. */
  36745. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36746. /**
  36747. * Defines the camera the input is attached to.
  36748. */
  36749. abstract camera: Camera;
  36750. /**
  36751. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36752. */
  36753. protected _altKey: boolean;
  36754. protected _ctrlKey: boolean;
  36755. protected _metaKey: boolean;
  36756. protected _shiftKey: boolean;
  36757. /**
  36758. * Which mouse buttons were pressed at time of last mouse event.
  36759. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36760. */
  36761. protected _buttonsPressed: number;
  36762. /**
  36763. * Defines the buttons associated with the input to handle camera move.
  36764. */
  36765. buttons: number[];
  36766. /**
  36767. * Attach the input controls to a specific dom element to get the input from.
  36768. * @param element Defines the element the controls should be listened from
  36769. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36770. */
  36771. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36772. /**
  36773. * Detach the current controls from the specified dom element.
  36774. * @param element Defines the element to stop listening the inputs from
  36775. */
  36776. detachControl(element: Nullable<HTMLElement>): void;
  36777. /**
  36778. * Gets the class name of the current input.
  36779. * @returns the class name
  36780. */
  36781. getClassName(): string;
  36782. /**
  36783. * Get the friendly name associated with the input class.
  36784. * @returns the input friendly name
  36785. */
  36786. getSimpleName(): string;
  36787. /**
  36788. * Called on pointer POINTERDOUBLETAP event.
  36789. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36790. */
  36791. protected onDoubleTap(type: string): void;
  36792. /**
  36793. * Called on pointer POINTERMOVE event if only a single touch is active.
  36794. * Override this method to provide functionality.
  36795. */
  36796. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36797. /**
  36798. * Called on pointer POINTERMOVE event if multiple touches are active.
  36799. * Override this method to provide functionality.
  36800. */
  36801. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36802. /**
  36803. * Called on JS contextmenu event.
  36804. * Override this method to provide functionality.
  36805. */
  36806. protected onContextMenu(evt: PointerEvent): void;
  36807. /**
  36808. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36809. * press.
  36810. * Override this method to provide functionality.
  36811. */
  36812. protected onButtonDown(evt: PointerEvent): void;
  36813. /**
  36814. * Called each time a new POINTERUP event occurs. Ie, for each button
  36815. * release.
  36816. * Override this method to provide functionality.
  36817. */
  36818. protected onButtonUp(evt: PointerEvent): void;
  36819. /**
  36820. * Called when window becomes inactive.
  36821. * Override this method to provide functionality.
  36822. */
  36823. protected onLostFocus(): void;
  36824. private _pointerInput;
  36825. private _observer;
  36826. private _onLostFocus;
  36827. private pointA;
  36828. private pointB;
  36829. }
  36830. }
  36831. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36832. import { Nullable } from "babylonjs/types";
  36833. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36834. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36835. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36836. /**
  36837. * Manage the pointers inputs to control an arc rotate camera.
  36838. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36839. */
  36840. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36841. /**
  36842. * Defines the camera the input is attached to.
  36843. */
  36844. camera: ArcRotateCamera;
  36845. /**
  36846. * Gets the class name of the current input.
  36847. * @returns the class name
  36848. */
  36849. getClassName(): string;
  36850. /**
  36851. * Defines the buttons associated with the input to handle camera move.
  36852. */
  36853. buttons: number[];
  36854. /**
  36855. * Defines the pointer angular sensibility along the X axis or how fast is
  36856. * the camera rotating.
  36857. */
  36858. angularSensibilityX: number;
  36859. /**
  36860. * Defines the pointer angular sensibility along the Y axis or how fast is
  36861. * the camera rotating.
  36862. */
  36863. angularSensibilityY: number;
  36864. /**
  36865. * Defines the pointer pinch precision or how fast is the camera zooming.
  36866. */
  36867. pinchPrecision: number;
  36868. /**
  36869. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36870. * from 0.
  36871. * It defines the percentage of current camera.radius to use as delta when
  36872. * pinch zoom is used.
  36873. */
  36874. pinchDeltaPercentage: number;
  36875. /**
  36876. * Defines the pointer panning sensibility or how fast is the camera moving.
  36877. */
  36878. panningSensibility: number;
  36879. /**
  36880. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36881. */
  36882. multiTouchPanning: boolean;
  36883. /**
  36884. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36885. * zoom (pinch) through multitouch.
  36886. */
  36887. multiTouchPanAndZoom: boolean;
  36888. /**
  36889. * Revers pinch action direction.
  36890. */
  36891. pinchInwards: boolean;
  36892. private _isPanClick;
  36893. private _twoFingerActivityCount;
  36894. private _isPinching;
  36895. /**
  36896. * Called on pointer POINTERMOVE event if only a single touch is active.
  36897. */
  36898. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36899. /**
  36900. * Called on pointer POINTERDOUBLETAP event.
  36901. */
  36902. protected onDoubleTap(type: string): void;
  36903. /**
  36904. * Called on pointer POINTERMOVE event if multiple touches are active.
  36905. */
  36906. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36907. /**
  36908. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36909. * press.
  36910. */
  36911. protected onButtonDown(evt: PointerEvent): void;
  36912. /**
  36913. * Called each time a new POINTERUP event occurs. Ie, for each button
  36914. * release.
  36915. */
  36916. protected onButtonUp(evt: PointerEvent): void;
  36917. /**
  36918. * Called when window becomes inactive.
  36919. */
  36920. protected onLostFocus(): void;
  36921. }
  36922. }
  36923. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36924. import { Nullable } from "babylonjs/types";
  36925. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36926. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36927. /**
  36928. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36929. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36930. */
  36931. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36932. /**
  36933. * Defines the camera the input is attached to.
  36934. */
  36935. camera: ArcRotateCamera;
  36936. /**
  36937. * Defines the list of key codes associated with the up action (increase alpha)
  36938. */
  36939. keysUp: number[];
  36940. /**
  36941. * Defines the list of key codes associated with the down action (decrease alpha)
  36942. */
  36943. keysDown: number[];
  36944. /**
  36945. * Defines the list of key codes associated with the left action (increase beta)
  36946. */
  36947. keysLeft: number[];
  36948. /**
  36949. * Defines the list of key codes associated with the right action (decrease beta)
  36950. */
  36951. keysRight: number[];
  36952. /**
  36953. * Defines the list of key codes associated with the reset action.
  36954. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36955. */
  36956. keysReset: number[];
  36957. /**
  36958. * Defines the panning sensibility of the inputs.
  36959. * (How fast is the camera paning)
  36960. */
  36961. panningSensibility: number;
  36962. /**
  36963. * Defines the zooming sensibility of the inputs.
  36964. * (How fast is the camera zooming)
  36965. */
  36966. zoomingSensibility: number;
  36967. /**
  36968. * Defines wether maintaining the alt key down switch the movement mode from
  36969. * orientation to zoom.
  36970. */
  36971. useAltToZoom: boolean;
  36972. /**
  36973. * Rotation speed of the camera
  36974. */
  36975. angularSpeed: number;
  36976. private _keys;
  36977. private _ctrlPressed;
  36978. private _altPressed;
  36979. private _onCanvasBlurObserver;
  36980. private _onKeyboardObserver;
  36981. private _engine;
  36982. private _scene;
  36983. /**
  36984. * Attach the input controls to a specific dom element to get the input from.
  36985. * @param element Defines the element the controls should be listened from
  36986. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36987. */
  36988. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36989. /**
  36990. * Detach the current controls from the specified dom element.
  36991. * @param element Defines the element to stop listening the inputs from
  36992. */
  36993. detachControl(element: Nullable<HTMLElement>): void;
  36994. /**
  36995. * Update the current camera state depending on the inputs that have been used this frame.
  36996. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36997. */
  36998. checkInputs(): void;
  36999. /**
  37000. * Gets the class name of the current intput.
  37001. * @returns the class name
  37002. */
  37003. getClassName(): string;
  37004. /**
  37005. * Get the friendly name associated with the input class.
  37006. * @returns the input friendly name
  37007. */
  37008. getSimpleName(): string;
  37009. }
  37010. }
  37011. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37012. import { Nullable } from "babylonjs/types";
  37013. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37014. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37015. /**
  37016. * Manage the mouse wheel inputs to control an arc rotate camera.
  37017. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37018. */
  37019. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37020. /**
  37021. * Defines the camera the input is attached to.
  37022. */
  37023. camera: ArcRotateCamera;
  37024. /**
  37025. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37026. */
  37027. wheelPrecision: number;
  37028. /**
  37029. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37030. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37031. */
  37032. wheelDeltaPercentage: number;
  37033. private _wheel;
  37034. private _observer;
  37035. private computeDeltaFromMouseWheelLegacyEvent;
  37036. /**
  37037. * Attach the input controls to a specific dom element to get the input from.
  37038. * @param element Defines the element the controls should be listened from
  37039. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37040. */
  37041. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37042. /**
  37043. * Detach the current controls from the specified dom element.
  37044. * @param element Defines the element to stop listening the inputs from
  37045. */
  37046. detachControl(element: Nullable<HTMLElement>): void;
  37047. /**
  37048. * Gets the class name of the current intput.
  37049. * @returns the class name
  37050. */
  37051. getClassName(): string;
  37052. /**
  37053. * Get the friendly name associated with the input class.
  37054. * @returns the input friendly name
  37055. */
  37056. getSimpleName(): string;
  37057. }
  37058. }
  37059. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37060. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37061. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37062. /**
  37063. * Default Inputs manager for the ArcRotateCamera.
  37064. * It groups all the default supported inputs for ease of use.
  37065. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37066. */
  37067. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37068. /**
  37069. * Instantiates a new ArcRotateCameraInputsManager.
  37070. * @param camera Defines the camera the inputs belong to
  37071. */
  37072. constructor(camera: ArcRotateCamera);
  37073. /**
  37074. * Add mouse wheel input support to the input manager.
  37075. * @returns the current input manager
  37076. */
  37077. addMouseWheel(): ArcRotateCameraInputsManager;
  37078. /**
  37079. * Add pointers input support to the input manager.
  37080. * @returns the current input manager
  37081. */
  37082. addPointers(): ArcRotateCameraInputsManager;
  37083. /**
  37084. * Add keyboard input support to the input manager.
  37085. * @returns the current input manager
  37086. */
  37087. addKeyboard(): ArcRotateCameraInputsManager;
  37088. }
  37089. }
  37090. declare module "babylonjs/Cameras/arcRotateCamera" {
  37091. import { Observable } from "babylonjs/Misc/observable";
  37092. import { Nullable } from "babylonjs/types";
  37093. import { Scene } from "babylonjs/scene";
  37094. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37095. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37096. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37097. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37098. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37099. import { Camera } from "babylonjs/Cameras/camera";
  37100. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37101. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37102. import { Collider } from "babylonjs/Collisions/collider";
  37103. /**
  37104. * This represents an orbital type of camera.
  37105. *
  37106. * 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.
  37107. * 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.
  37108. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37109. */
  37110. export class ArcRotateCamera extends TargetCamera {
  37111. /**
  37112. * Defines the rotation angle of the camera along the longitudinal axis.
  37113. */
  37114. alpha: number;
  37115. /**
  37116. * Defines the rotation angle of the camera along the latitudinal axis.
  37117. */
  37118. beta: number;
  37119. /**
  37120. * Defines the radius of the camera from it s target point.
  37121. */
  37122. radius: number;
  37123. protected _target: Vector3;
  37124. protected _targetHost: Nullable<AbstractMesh>;
  37125. /**
  37126. * Defines the target point of the camera.
  37127. * The camera looks towards it form the radius distance.
  37128. */
  37129. target: Vector3;
  37130. /**
  37131. * Define the current local position of the camera in the scene
  37132. */
  37133. position: Vector3;
  37134. protected _upVector: Vector3;
  37135. protected _upToYMatrix: Matrix;
  37136. protected _YToUpMatrix: Matrix;
  37137. /**
  37138. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37139. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37140. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37141. */
  37142. upVector: Vector3;
  37143. /**
  37144. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37145. */
  37146. setMatUp(): void;
  37147. /**
  37148. * Current inertia value on the longitudinal axis.
  37149. * The bigger this number the longer it will take for the camera to stop.
  37150. */
  37151. inertialAlphaOffset: number;
  37152. /**
  37153. * Current inertia value on the latitudinal axis.
  37154. * The bigger this number the longer it will take for the camera to stop.
  37155. */
  37156. inertialBetaOffset: number;
  37157. /**
  37158. * Current inertia value on the radius axis.
  37159. * The bigger this number the longer it will take for the camera to stop.
  37160. */
  37161. inertialRadiusOffset: number;
  37162. /**
  37163. * Minimum allowed angle on the longitudinal axis.
  37164. * This can help limiting how the Camera is able to move in the scene.
  37165. */
  37166. lowerAlphaLimit: Nullable<number>;
  37167. /**
  37168. * Maximum allowed angle on the longitudinal axis.
  37169. * This can help limiting how the Camera is able to move in the scene.
  37170. */
  37171. upperAlphaLimit: Nullable<number>;
  37172. /**
  37173. * Minimum allowed angle on the latitudinal axis.
  37174. * This can help limiting how the Camera is able to move in the scene.
  37175. */
  37176. lowerBetaLimit: number;
  37177. /**
  37178. * Maximum allowed angle on the latitudinal axis.
  37179. * This can help limiting how the Camera is able to move in the scene.
  37180. */
  37181. upperBetaLimit: number;
  37182. /**
  37183. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37184. * This can help limiting how the Camera is able to move in the scene.
  37185. */
  37186. lowerRadiusLimit: Nullable<number>;
  37187. /**
  37188. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37189. * This can help limiting how the Camera is able to move in the scene.
  37190. */
  37191. upperRadiusLimit: Nullable<number>;
  37192. /**
  37193. * Defines the current inertia value used during panning of the camera along the X axis.
  37194. */
  37195. inertialPanningX: number;
  37196. /**
  37197. * Defines the current inertia value used during panning of the camera along the Y axis.
  37198. */
  37199. inertialPanningY: number;
  37200. /**
  37201. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37202. * Basically if your fingers moves away from more than this distance you will be considered
  37203. * in pinch mode.
  37204. */
  37205. pinchToPanMaxDistance: number;
  37206. /**
  37207. * Defines the maximum distance the camera can pan.
  37208. * This could help keeping the cammera always in your scene.
  37209. */
  37210. panningDistanceLimit: Nullable<number>;
  37211. /**
  37212. * Defines the target of the camera before paning.
  37213. */
  37214. panningOriginTarget: Vector3;
  37215. /**
  37216. * Defines the value of the inertia used during panning.
  37217. * 0 would mean stop inertia and one would mean no decelleration at all.
  37218. */
  37219. panningInertia: number;
  37220. /**
  37221. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37222. */
  37223. angularSensibilityX: number;
  37224. /**
  37225. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37226. */
  37227. angularSensibilityY: number;
  37228. /**
  37229. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37230. */
  37231. pinchPrecision: number;
  37232. /**
  37233. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37234. * It will be used instead of pinchDeltaPrecision if different from 0.
  37235. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37236. */
  37237. pinchDeltaPercentage: number;
  37238. /**
  37239. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37240. */
  37241. panningSensibility: number;
  37242. /**
  37243. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37244. */
  37245. keysUp: number[];
  37246. /**
  37247. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37248. */
  37249. keysDown: number[];
  37250. /**
  37251. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37252. */
  37253. keysLeft: number[];
  37254. /**
  37255. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37256. */
  37257. keysRight: number[];
  37258. /**
  37259. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37260. */
  37261. wheelPrecision: number;
  37262. /**
  37263. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37264. * It will be used instead of pinchDeltaPrecision if different from 0.
  37265. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37266. */
  37267. wheelDeltaPercentage: number;
  37268. /**
  37269. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37270. */
  37271. zoomOnFactor: number;
  37272. /**
  37273. * Defines a screen offset for the camera position.
  37274. */
  37275. targetScreenOffset: Vector2;
  37276. /**
  37277. * Allows the camera to be completely reversed.
  37278. * If false the camera can not arrive upside down.
  37279. */
  37280. allowUpsideDown: boolean;
  37281. /**
  37282. * Define if double tap/click is used to restore the previously saved state of the camera.
  37283. */
  37284. useInputToRestoreState: boolean;
  37285. /** @hidden */
  37286. _viewMatrix: Matrix;
  37287. /** @hidden */
  37288. _useCtrlForPanning: boolean;
  37289. /** @hidden */
  37290. _panningMouseButton: number;
  37291. /**
  37292. * Defines the input associated to the camera.
  37293. */
  37294. inputs: ArcRotateCameraInputsManager;
  37295. /** @hidden */
  37296. _reset: () => void;
  37297. /**
  37298. * Defines the allowed panning axis.
  37299. */
  37300. panningAxis: Vector3;
  37301. protected _localDirection: Vector3;
  37302. protected _transformedDirection: Vector3;
  37303. private _bouncingBehavior;
  37304. /**
  37305. * Gets the bouncing behavior of the camera if it has been enabled.
  37306. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37307. */
  37308. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37309. /**
  37310. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37311. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37312. */
  37313. useBouncingBehavior: boolean;
  37314. private _framingBehavior;
  37315. /**
  37316. * Gets the framing behavior of the camera if it has been enabled.
  37317. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37318. */
  37319. readonly framingBehavior: Nullable<FramingBehavior>;
  37320. /**
  37321. * Defines if the framing behavior of the camera is enabled on the camera.
  37322. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37323. */
  37324. useFramingBehavior: boolean;
  37325. private _autoRotationBehavior;
  37326. /**
  37327. * Gets the auto rotation behavior of the camera if it has been enabled.
  37328. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37329. */
  37330. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37331. /**
  37332. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37333. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37334. */
  37335. useAutoRotationBehavior: boolean;
  37336. /**
  37337. * Observable triggered when the mesh target has been changed on the camera.
  37338. */
  37339. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37340. /**
  37341. * Event raised when the camera is colliding with a mesh.
  37342. */
  37343. onCollide: (collidedMesh: AbstractMesh) => void;
  37344. /**
  37345. * Defines whether the camera should check collision with the objects oh the scene.
  37346. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37347. */
  37348. checkCollisions: boolean;
  37349. /**
  37350. * Defines the collision radius of the camera.
  37351. * This simulates a sphere around the camera.
  37352. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37353. */
  37354. collisionRadius: Vector3;
  37355. protected _collider: Collider;
  37356. protected _previousPosition: Vector3;
  37357. protected _collisionVelocity: Vector3;
  37358. protected _newPosition: Vector3;
  37359. protected _previousAlpha: number;
  37360. protected _previousBeta: number;
  37361. protected _previousRadius: number;
  37362. protected _collisionTriggered: boolean;
  37363. protected _targetBoundingCenter: Nullable<Vector3>;
  37364. private _computationVector;
  37365. /**
  37366. * Instantiates a new ArcRotateCamera in a given scene
  37367. * @param name Defines the name of the camera
  37368. * @param alpha Defines the camera rotation along the logitudinal axis
  37369. * @param beta Defines the camera rotation along the latitudinal axis
  37370. * @param radius Defines the camera distance from its target
  37371. * @param target Defines the camera target
  37372. * @param scene Defines the scene the camera belongs to
  37373. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37374. */
  37375. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37376. /** @hidden */
  37377. _initCache(): void;
  37378. /** @hidden */
  37379. _updateCache(ignoreParentClass?: boolean): void;
  37380. protected _getTargetPosition(): Vector3;
  37381. private _storedAlpha;
  37382. private _storedBeta;
  37383. private _storedRadius;
  37384. private _storedTarget;
  37385. private _storedTargetScreenOffset;
  37386. /**
  37387. * Stores the current state of the camera (alpha, beta, radius and target)
  37388. * @returns the camera itself
  37389. */
  37390. storeState(): Camera;
  37391. /**
  37392. * @hidden
  37393. * Restored camera state. You must call storeState() first
  37394. */
  37395. _restoreStateValues(): boolean;
  37396. /** @hidden */
  37397. _isSynchronizedViewMatrix(): boolean;
  37398. /**
  37399. * Attached controls to the current camera.
  37400. * @param element Defines the element the controls should be listened from
  37401. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37402. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37403. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37404. */
  37405. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37406. /**
  37407. * Detach the current controls from the camera.
  37408. * The camera will stop reacting to inputs.
  37409. * @param element Defines the element to stop listening the inputs from
  37410. */
  37411. detachControl(element: HTMLElement): void;
  37412. /** @hidden */
  37413. _checkInputs(): void;
  37414. protected _checkLimits(): void;
  37415. /**
  37416. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37417. */
  37418. rebuildAnglesAndRadius(): void;
  37419. /**
  37420. * Use a position to define the current camera related information like aplha, beta and radius
  37421. * @param position Defines the position to set the camera at
  37422. */
  37423. setPosition(position: Vector3): void;
  37424. /**
  37425. * Defines the target the camera should look at.
  37426. * This will automatically adapt alpha beta and radius to fit within the new target.
  37427. * @param target Defines the new target as a Vector or a mesh
  37428. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37429. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37430. */
  37431. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37432. /** @hidden */
  37433. _getViewMatrix(): Matrix;
  37434. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37435. /**
  37436. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37437. * @param meshes Defines the mesh to zoom on
  37438. * @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)
  37439. */
  37440. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37441. /**
  37442. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37443. * The target will be changed but the radius
  37444. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37445. * @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)
  37446. */
  37447. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37448. min: Vector3;
  37449. max: Vector3;
  37450. distance: number;
  37451. }, doNotUpdateMaxZ?: boolean): void;
  37452. /**
  37453. * @override
  37454. * Override Camera.createRigCamera
  37455. */
  37456. createRigCamera(name: string, cameraIndex: number): Camera;
  37457. /**
  37458. * @hidden
  37459. * @override
  37460. * Override Camera._updateRigCameras
  37461. */
  37462. _updateRigCameras(): void;
  37463. /**
  37464. * Destroy the camera and release the current resources hold by it.
  37465. */
  37466. dispose(): void;
  37467. /**
  37468. * Gets the current object class name.
  37469. * @return the class name
  37470. */
  37471. getClassName(): string;
  37472. }
  37473. }
  37474. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37475. import { Behavior } from "babylonjs/Behaviors/behavior";
  37476. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37477. /**
  37478. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37479. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37480. */
  37481. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37482. /**
  37483. * Gets the name of the behavior.
  37484. */
  37485. readonly name: string;
  37486. private _zoomStopsAnimation;
  37487. private _idleRotationSpeed;
  37488. private _idleRotationWaitTime;
  37489. private _idleRotationSpinupTime;
  37490. /**
  37491. * Sets the flag that indicates if user zooming should stop animation.
  37492. */
  37493. /**
  37494. * Gets the flag that indicates if user zooming should stop animation.
  37495. */
  37496. zoomStopsAnimation: boolean;
  37497. /**
  37498. * Sets the default speed at which the camera rotates around the model.
  37499. */
  37500. /**
  37501. * Gets the default speed at which the camera rotates around the model.
  37502. */
  37503. idleRotationSpeed: number;
  37504. /**
  37505. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37506. */
  37507. /**
  37508. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37509. */
  37510. idleRotationWaitTime: number;
  37511. /**
  37512. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37513. */
  37514. /**
  37515. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37516. */
  37517. idleRotationSpinupTime: number;
  37518. /**
  37519. * Gets a value indicating if the camera is currently rotating because of this behavior
  37520. */
  37521. readonly rotationInProgress: boolean;
  37522. private _onPrePointerObservableObserver;
  37523. private _onAfterCheckInputsObserver;
  37524. private _attachedCamera;
  37525. private _isPointerDown;
  37526. private _lastFrameTime;
  37527. private _lastInteractionTime;
  37528. private _cameraRotationSpeed;
  37529. /**
  37530. * Initializes the behavior.
  37531. */
  37532. init(): void;
  37533. /**
  37534. * Attaches the behavior to its arc rotate camera.
  37535. * @param camera Defines the camera to attach the behavior to
  37536. */
  37537. attach(camera: ArcRotateCamera): void;
  37538. /**
  37539. * Detaches the behavior from its current arc rotate camera.
  37540. */
  37541. detach(): void;
  37542. /**
  37543. * Returns true if user is scrolling.
  37544. * @return true if user is scrolling.
  37545. */
  37546. private _userIsZooming;
  37547. private _lastFrameRadius;
  37548. private _shouldAnimationStopForInteraction;
  37549. /**
  37550. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37551. */
  37552. private _applyUserInteraction;
  37553. private _userIsMoving;
  37554. }
  37555. }
  37556. declare module "babylonjs/Behaviors/Cameras/index" {
  37557. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37558. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37559. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37560. }
  37561. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37562. import { Mesh } from "babylonjs/Meshes/mesh";
  37563. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37564. import { Behavior } from "babylonjs/Behaviors/behavior";
  37565. /**
  37566. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37567. */
  37568. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37569. private ui;
  37570. /**
  37571. * The name of the behavior
  37572. */
  37573. name: string;
  37574. /**
  37575. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37576. */
  37577. distanceAwayFromFace: number;
  37578. /**
  37579. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37580. */
  37581. distanceAwayFromBottomOfFace: number;
  37582. private _faceVectors;
  37583. private _target;
  37584. private _scene;
  37585. private _onRenderObserver;
  37586. private _tmpMatrix;
  37587. private _tmpVector;
  37588. /**
  37589. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37590. * @param ui The transform node that should be attched to the mesh
  37591. */
  37592. constructor(ui: TransformNode);
  37593. /**
  37594. * Initializes the behavior
  37595. */
  37596. init(): void;
  37597. private _closestFace;
  37598. private _zeroVector;
  37599. private _lookAtTmpMatrix;
  37600. private _lookAtToRef;
  37601. /**
  37602. * Attaches the AttachToBoxBehavior to the passed in mesh
  37603. * @param target The mesh that the specified node will be attached to
  37604. */
  37605. attach(target: Mesh): void;
  37606. /**
  37607. * Detaches the behavior from the mesh
  37608. */
  37609. detach(): void;
  37610. }
  37611. }
  37612. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37613. import { Behavior } from "babylonjs/Behaviors/behavior";
  37614. import { Mesh } from "babylonjs/Meshes/mesh";
  37615. /**
  37616. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37617. */
  37618. export class FadeInOutBehavior implements Behavior<Mesh> {
  37619. /**
  37620. * Time in milliseconds to delay before fading in (Default: 0)
  37621. */
  37622. delay: number;
  37623. /**
  37624. * Time in milliseconds for the mesh to fade in (Default: 300)
  37625. */
  37626. fadeInTime: number;
  37627. private _millisecondsPerFrame;
  37628. private _hovered;
  37629. private _hoverValue;
  37630. private _ownerNode;
  37631. /**
  37632. * Instatiates the FadeInOutBehavior
  37633. */
  37634. constructor();
  37635. /**
  37636. * The name of the behavior
  37637. */
  37638. readonly name: string;
  37639. /**
  37640. * Initializes the behavior
  37641. */
  37642. init(): void;
  37643. /**
  37644. * Attaches the fade behavior on the passed in mesh
  37645. * @param ownerNode The mesh that will be faded in/out once attached
  37646. */
  37647. attach(ownerNode: Mesh): void;
  37648. /**
  37649. * Detaches the behavior from the mesh
  37650. */
  37651. detach(): void;
  37652. /**
  37653. * Triggers the mesh to begin fading in or out
  37654. * @param value if the object should fade in or out (true to fade in)
  37655. */
  37656. fadeIn(value: boolean): void;
  37657. private _update;
  37658. private _setAllVisibility;
  37659. }
  37660. }
  37661. declare module "babylonjs/Misc/pivotTools" {
  37662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37663. /**
  37664. * Class containing a set of static utilities functions for managing Pivots
  37665. * @hidden
  37666. */
  37667. export class PivotTools {
  37668. private static _PivotCached;
  37669. private static _OldPivotPoint;
  37670. private static _PivotTranslation;
  37671. private static _PivotTmpVector;
  37672. /** @hidden */
  37673. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37674. /** @hidden */
  37675. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37676. }
  37677. }
  37678. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37679. import { Scene } from "babylonjs/scene";
  37680. import { Vector4 } from "babylonjs/Maths/math.vector";
  37681. import { Mesh } from "babylonjs/Meshes/mesh";
  37682. import { Nullable } from "babylonjs/types";
  37683. import { Plane } from "babylonjs/Maths/math.plane";
  37684. /**
  37685. * Class containing static functions to help procedurally build meshes
  37686. */
  37687. export class PlaneBuilder {
  37688. /**
  37689. * Creates a plane mesh
  37690. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37691. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37692. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37693. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37694. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37696. * @param name defines the name of the mesh
  37697. * @param options defines the options used to create the mesh
  37698. * @param scene defines the hosting scene
  37699. * @returns the plane mesh
  37700. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37701. */
  37702. static CreatePlane(name: string, options: {
  37703. size?: number;
  37704. width?: number;
  37705. height?: number;
  37706. sideOrientation?: number;
  37707. frontUVs?: Vector4;
  37708. backUVs?: Vector4;
  37709. updatable?: boolean;
  37710. sourcePlane?: Plane;
  37711. }, scene?: Nullable<Scene>): Mesh;
  37712. }
  37713. }
  37714. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37715. import { Behavior } from "babylonjs/Behaviors/behavior";
  37716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37717. import { Observable } from "babylonjs/Misc/observable";
  37718. import { Vector3 } from "babylonjs/Maths/math.vector";
  37719. import { Ray } from "babylonjs/Culling/ray";
  37720. import "babylonjs/Meshes/Builders/planeBuilder";
  37721. /**
  37722. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37723. */
  37724. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37725. private static _AnyMouseID;
  37726. /**
  37727. * Abstract mesh the behavior is set on
  37728. */
  37729. attachedNode: AbstractMesh;
  37730. private _dragPlane;
  37731. private _scene;
  37732. private _pointerObserver;
  37733. private _beforeRenderObserver;
  37734. private static _planeScene;
  37735. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37736. /**
  37737. * 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)
  37738. */
  37739. maxDragAngle: number;
  37740. /**
  37741. * @hidden
  37742. */
  37743. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37744. /**
  37745. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37746. */
  37747. currentDraggingPointerID: number;
  37748. /**
  37749. * The last position where the pointer hit the drag plane in world space
  37750. */
  37751. lastDragPosition: Vector3;
  37752. /**
  37753. * If the behavior is currently in a dragging state
  37754. */
  37755. dragging: boolean;
  37756. /**
  37757. * 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)
  37758. */
  37759. dragDeltaRatio: number;
  37760. /**
  37761. * If the drag plane orientation should be updated during the dragging (Default: true)
  37762. */
  37763. updateDragPlane: boolean;
  37764. private _debugMode;
  37765. private _moving;
  37766. /**
  37767. * Fires each time the attached mesh is dragged with the pointer
  37768. * * delta between last drag position and current drag position in world space
  37769. * * dragDistance along the drag axis
  37770. * * dragPlaneNormal normal of the current drag plane used during the drag
  37771. * * dragPlanePoint in world space where the drag intersects the drag plane
  37772. */
  37773. onDragObservable: Observable<{
  37774. delta: Vector3;
  37775. dragPlanePoint: Vector3;
  37776. dragPlaneNormal: Vector3;
  37777. dragDistance: number;
  37778. pointerId: number;
  37779. }>;
  37780. /**
  37781. * Fires each time a drag begins (eg. mouse down on mesh)
  37782. */
  37783. onDragStartObservable: Observable<{
  37784. dragPlanePoint: Vector3;
  37785. pointerId: number;
  37786. }>;
  37787. /**
  37788. * Fires each time a drag ends (eg. mouse release after drag)
  37789. */
  37790. onDragEndObservable: Observable<{
  37791. dragPlanePoint: Vector3;
  37792. pointerId: number;
  37793. }>;
  37794. /**
  37795. * If the attached mesh should be moved when dragged
  37796. */
  37797. moveAttached: boolean;
  37798. /**
  37799. * If the drag behavior will react to drag events (Default: true)
  37800. */
  37801. enabled: boolean;
  37802. /**
  37803. * If pointer events should start and release the drag (Default: true)
  37804. */
  37805. startAndReleaseDragOnPointerEvents: boolean;
  37806. /**
  37807. * If camera controls should be detached during the drag
  37808. */
  37809. detachCameraControls: boolean;
  37810. /**
  37811. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37812. */
  37813. useObjectOrienationForDragging: boolean;
  37814. private _options;
  37815. /**
  37816. * Creates a pointer drag behavior that can be attached to a mesh
  37817. * @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)
  37818. */
  37819. constructor(options?: {
  37820. dragAxis?: Vector3;
  37821. dragPlaneNormal?: Vector3;
  37822. });
  37823. /**
  37824. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37825. */
  37826. validateDrag: (targetPosition: Vector3) => boolean;
  37827. /**
  37828. * The name of the behavior
  37829. */
  37830. readonly name: string;
  37831. /**
  37832. * Initializes the behavior
  37833. */
  37834. init(): void;
  37835. private _tmpVector;
  37836. private _alternatePickedPoint;
  37837. private _worldDragAxis;
  37838. private _targetPosition;
  37839. private _attachedElement;
  37840. /**
  37841. * Attaches the drag behavior the passed in mesh
  37842. * @param ownerNode The mesh that will be dragged around once attached
  37843. * @param predicate Predicate to use for pick filtering
  37844. */
  37845. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  37846. /**
  37847. * Force relase the drag action by code.
  37848. */
  37849. releaseDrag(): void;
  37850. private _startDragRay;
  37851. private _lastPointerRay;
  37852. /**
  37853. * Simulates the start of a pointer drag event on the behavior
  37854. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37855. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37856. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37857. */
  37858. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37859. private _startDrag;
  37860. private _dragDelta;
  37861. private _moveDrag;
  37862. private _pickWithRayOnDragPlane;
  37863. private _pointA;
  37864. private _pointB;
  37865. private _pointC;
  37866. private _lineA;
  37867. private _lineB;
  37868. private _localAxis;
  37869. private _lookAt;
  37870. private _updateDragPlanePosition;
  37871. /**
  37872. * Detaches the behavior from the mesh
  37873. */
  37874. detach(): void;
  37875. }
  37876. }
  37877. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37878. import { Mesh } from "babylonjs/Meshes/mesh";
  37879. import { Behavior } from "babylonjs/Behaviors/behavior";
  37880. /**
  37881. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37882. */
  37883. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37884. private _dragBehaviorA;
  37885. private _dragBehaviorB;
  37886. private _startDistance;
  37887. private _initialScale;
  37888. private _targetScale;
  37889. private _ownerNode;
  37890. private _sceneRenderObserver;
  37891. /**
  37892. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37893. */
  37894. constructor();
  37895. /**
  37896. * The name of the behavior
  37897. */
  37898. readonly name: string;
  37899. /**
  37900. * Initializes the behavior
  37901. */
  37902. init(): void;
  37903. private _getCurrentDistance;
  37904. /**
  37905. * Attaches the scale behavior the passed in mesh
  37906. * @param ownerNode The mesh that will be scaled around once attached
  37907. */
  37908. attach(ownerNode: Mesh): void;
  37909. /**
  37910. * Detaches the behavior from the mesh
  37911. */
  37912. detach(): void;
  37913. }
  37914. }
  37915. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37916. import { Behavior } from "babylonjs/Behaviors/behavior";
  37917. import { Mesh } from "babylonjs/Meshes/mesh";
  37918. import { Observable } from "babylonjs/Misc/observable";
  37919. /**
  37920. * 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
  37921. */
  37922. export class SixDofDragBehavior implements Behavior<Mesh> {
  37923. private static _virtualScene;
  37924. private _ownerNode;
  37925. private _sceneRenderObserver;
  37926. private _scene;
  37927. private _targetPosition;
  37928. private _virtualOriginMesh;
  37929. private _virtualDragMesh;
  37930. private _pointerObserver;
  37931. private _moving;
  37932. private _startingOrientation;
  37933. /**
  37934. * 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)
  37935. */
  37936. private zDragFactor;
  37937. /**
  37938. * If the object should rotate to face the drag origin
  37939. */
  37940. rotateDraggedObject: boolean;
  37941. /**
  37942. * If the behavior is currently in a dragging state
  37943. */
  37944. dragging: boolean;
  37945. /**
  37946. * 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)
  37947. */
  37948. dragDeltaRatio: number;
  37949. /**
  37950. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37951. */
  37952. currentDraggingPointerID: number;
  37953. /**
  37954. * If camera controls should be detached during the drag
  37955. */
  37956. detachCameraControls: boolean;
  37957. /**
  37958. * Fires each time a drag starts
  37959. */
  37960. onDragStartObservable: Observable<{}>;
  37961. /**
  37962. * Fires each time a drag ends (eg. mouse release after drag)
  37963. */
  37964. onDragEndObservable: Observable<{}>;
  37965. /**
  37966. * 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
  37967. */
  37968. constructor();
  37969. /**
  37970. * The name of the behavior
  37971. */
  37972. readonly name: string;
  37973. /**
  37974. * Initializes the behavior
  37975. */
  37976. init(): void;
  37977. /**
  37978. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37979. */
  37980. private readonly _pointerCamera;
  37981. /**
  37982. * Attaches the scale behavior the passed in mesh
  37983. * @param ownerNode The mesh that will be scaled around once attached
  37984. */
  37985. attach(ownerNode: Mesh): void;
  37986. /**
  37987. * Detaches the behavior from the mesh
  37988. */
  37989. detach(): void;
  37990. }
  37991. }
  37992. declare module "babylonjs/Behaviors/Meshes/index" {
  37993. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37994. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37995. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37996. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37997. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37998. }
  37999. declare module "babylonjs/Behaviors/index" {
  38000. export * from "babylonjs/Behaviors/behavior";
  38001. export * from "babylonjs/Behaviors/Cameras/index";
  38002. export * from "babylonjs/Behaviors/Meshes/index";
  38003. }
  38004. declare module "babylonjs/Bones/boneIKController" {
  38005. import { Bone } from "babylonjs/Bones/bone";
  38006. import { Vector3 } from "babylonjs/Maths/math.vector";
  38007. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38008. import { Nullable } from "babylonjs/types";
  38009. /**
  38010. * Class used to apply inverse kinematics to bones
  38011. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38012. */
  38013. export class BoneIKController {
  38014. private static _tmpVecs;
  38015. private static _tmpQuat;
  38016. private static _tmpMats;
  38017. /**
  38018. * Gets or sets the target mesh
  38019. */
  38020. targetMesh: AbstractMesh;
  38021. /** Gets or sets the mesh used as pole */
  38022. poleTargetMesh: AbstractMesh;
  38023. /**
  38024. * Gets or sets the bone used as pole
  38025. */
  38026. poleTargetBone: Nullable<Bone>;
  38027. /**
  38028. * Gets or sets the target position
  38029. */
  38030. targetPosition: Vector3;
  38031. /**
  38032. * Gets or sets the pole target position
  38033. */
  38034. poleTargetPosition: Vector3;
  38035. /**
  38036. * Gets or sets the pole target local offset
  38037. */
  38038. poleTargetLocalOffset: Vector3;
  38039. /**
  38040. * Gets or sets the pole angle
  38041. */
  38042. poleAngle: number;
  38043. /**
  38044. * Gets or sets the mesh associated with the controller
  38045. */
  38046. mesh: AbstractMesh;
  38047. /**
  38048. * 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)
  38049. */
  38050. slerpAmount: number;
  38051. private _bone1Quat;
  38052. private _bone1Mat;
  38053. private _bone2Ang;
  38054. private _bone1;
  38055. private _bone2;
  38056. private _bone1Length;
  38057. private _bone2Length;
  38058. private _maxAngle;
  38059. private _maxReach;
  38060. private _rightHandedSystem;
  38061. private _bendAxis;
  38062. private _slerping;
  38063. private _adjustRoll;
  38064. /**
  38065. * Gets or sets maximum allowed angle
  38066. */
  38067. maxAngle: number;
  38068. /**
  38069. * Creates a new BoneIKController
  38070. * @param mesh defines the mesh to control
  38071. * @param bone defines the bone to control
  38072. * @param options defines options to set up the controller
  38073. */
  38074. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38075. targetMesh?: AbstractMesh;
  38076. poleTargetMesh?: AbstractMesh;
  38077. poleTargetBone?: Bone;
  38078. poleTargetLocalOffset?: Vector3;
  38079. poleAngle?: number;
  38080. bendAxis?: Vector3;
  38081. maxAngle?: number;
  38082. slerpAmount?: number;
  38083. });
  38084. private _setMaxAngle;
  38085. /**
  38086. * Force the controller to update the bones
  38087. */
  38088. update(): void;
  38089. }
  38090. }
  38091. declare module "babylonjs/Bones/boneLookController" {
  38092. import { Vector3 } from "babylonjs/Maths/math.vector";
  38093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38094. import { Bone } from "babylonjs/Bones/bone";
  38095. import { Space } from "babylonjs/Maths/math.axis";
  38096. /**
  38097. * Class used to make a bone look toward a point in space
  38098. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38099. */
  38100. export class BoneLookController {
  38101. private static _tmpVecs;
  38102. private static _tmpQuat;
  38103. private static _tmpMats;
  38104. /**
  38105. * The target Vector3 that the bone will look at
  38106. */
  38107. target: Vector3;
  38108. /**
  38109. * The mesh that the bone is attached to
  38110. */
  38111. mesh: AbstractMesh;
  38112. /**
  38113. * The bone that will be looking to the target
  38114. */
  38115. bone: Bone;
  38116. /**
  38117. * The up axis of the coordinate system that is used when the bone is rotated
  38118. */
  38119. upAxis: Vector3;
  38120. /**
  38121. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38122. */
  38123. upAxisSpace: Space;
  38124. /**
  38125. * Used to make an adjustment to the yaw of the bone
  38126. */
  38127. adjustYaw: number;
  38128. /**
  38129. * Used to make an adjustment to the pitch of the bone
  38130. */
  38131. adjustPitch: number;
  38132. /**
  38133. * Used to make an adjustment to the roll of the bone
  38134. */
  38135. adjustRoll: number;
  38136. /**
  38137. * 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)
  38138. */
  38139. slerpAmount: number;
  38140. private _minYaw;
  38141. private _maxYaw;
  38142. private _minPitch;
  38143. private _maxPitch;
  38144. private _minYawSin;
  38145. private _minYawCos;
  38146. private _maxYawSin;
  38147. private _maxYawCos;
  38148. private _midYawConstraint;
  38149. private _minPitchTan;
  38150. private _maxPitchTan;
  38151. private _boneQuat;
  38152. private _slerping;
  38153. private _transformYawPitch;
  38154. private _transformYawPitchInv;
  38155. private _firstFrameSkipped;
  38156. private _yawRange;
  38157. private _fowardAxis;
  38158. /**
  38159. * Gets or sets the minimum yaw angle that the bone can look to
  38160. */
  38161. minYaw: number;
  38162. /**
  38163. * Gets or sets the maximum yaw angle that the bone can look to
  38164. */
  38165. maxYaw: number;
  38166. /**
  38167. * Gets or sets the minimum pitch angle that the bone can look to
  38168. */
  38169. minPitch: number;
  38170. /**
  38171. * Gets or sets the maximum pitch angle that the bone can look to
  38172. */
  38173. maxPitch: number;
  38174. /**
  38175. * Create a BoneLookController
  38176. * @param mesh the mesh that the bone belongs to
  38177. * @param bone the bone that will be looking to the target
  38178. * @param target the target Vector3 to look at
  38179. * @param options optional settings:
  38180. * * maxYaw: the maximum angle the bone will yaw to
  38181. * * minYaw: the minimum angle the bone will yaw to
  38182. * * maxPitch: the maximum angle the bone will pitch to
  38183. * * minPitch: the minimum angle the bone will yaw to
  38184. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38185. * * upAxis: the up axis of the coordinate system
  38186. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38187. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38188. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38189. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38190. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38191. * * adjustRoll: used to make an adjustment to the roll of the bone
  38192. **/
  38193. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38194. maxYaw?: number;
  38195. minYaw?: number;
  38196. maxPitch?: number;
  38197. minPitch?: number;
  38198. slerpAmount?: number;
  38199. upAxis?: Vector3;
  38200. upAxisSpace?: Space;
  38201. yawAxis?: Vector3;
  38202. pitchAxis?: Vector3;
  38203. adjustYaw?: number;
  38204. adjustPitch?: number;
  38205. adjustRoll?: number;
  38206. });
  38207. /**
  38208. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38209. */
  38210. update(): void;
  38211. private _getAngleDiff;
  38212. private _getAngleBetween;
  38213. private _isAngleBetween;
  38214. }
  38215. }
  38216. declare module "babylonjs/Bones/index" {
  38217. export * from "babylonjs/Bones/bone";
  38218. export * from "babylonjs/Bones/boneIKController";
  38219. export * from "babylonjs/Bones/boneLookController";
  38220. export * from "babylonjs/Bones/skeleton";
  38221. }
  38222. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38223. import { Nullable } from "babylonjs/types";
  38224. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38225. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38226. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38227. /**
  38228. * Manage the gamepad inputs to control an arc rotate camera.
  38229. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38230. */
  38231. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38232. /**
  38233. * Defines the camera the input is attached to.
  38234. */
  38235. camera: ArcRotateCamera;
  38236. /**
  38237. * Defines the gamepad the input is gathering event from.
  38238. */
  38239. gamepad: Nullable<Gamepad>;
  38240. /**
  38241. * Defines the gamepad rotation sensiblity.
  38242. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38243. */
  38244. gamepadRotationSensibility: number;
  38245. /**
  38246. * Defines the gamepad move sensiblity.
  38247. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38248. */
  38249. gamepadMoveSensibility: number;
  38250. private _onGamepadConnectedObserver;
  38251. private _onGamepadDisconnectedObserver;
  38252. /**
  38253. * Attach the input controls to a specific dom element to get the input from.
  38254. * @param element Defines the element the controls should be listened from
  38255. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38256. */
  38257. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38258. /**
  38259. * Detach the current controls from the specified dom element.
  38260. * @param element Defines the element to stop listening the inputs from
  38261. */
  38262. detachControl(element: Nullable<HTMLElement>): void;
  38263. /**
  38264. * Update the current camera state depending on the inputs that have been used this frame.
  38265. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38266. */
  38267. checkInputs(): void;
  38268. /**
  38269. * Gets the class name of the current intput.
  38270. * @returns the class name
  38271. */
  38272. getClassName(): string;
  38273. /**
  38274. * Get the friendly name associated with the input class.
  38275. * @returns the input friendly name
  38276. */
  38277. getSimpleName(): string;
  38278. }
  38279. }
  38280. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38281. import { Nullable } from "babylonjs/types";
  38282. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38283. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38284. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38285. interface ArcRotateCameraInputsManager {
  38286. /**
  38287. * Add orientation input support to the input manager.
  38288. * @returns the current input manager
  38289. */
  38290. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38291. }
  38292. }
  38293. /**
  38294. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38295. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38296. */
  38297. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38298. /**
  38299. * Defines the camera the input is attached to.
  38300. */
  38301. camera: ArcRotateCamera;
  38302. /**
  38303. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38304. */
  38305. alphaCorrection: number;
  38306. /**
  38307. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38308. */
  38309. gammaCorrection: number;
  38310. private _alpha;
  38311. private _gamma;
  38312. private _dirty;
  38313. private _deviceOrientationHandler;
  38314. /**
  38315. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38316. */
  38317. constructor();
  38318. /**
  38319. * Attach the input controls to a specific dom element to get the input from.
  38320. * @param element Defines the element the controls should be listened from
  38321. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38322. */
  38323. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38324. /** @hidden */
  38325. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38326. /**
  38327. * Update the current camera state depending on the inputs that have been used this frame.
  38328. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38329. */
  38330. checkInputs(): void;
  38331. /**
  38332. * Detach the current controls from the specified dom element.
  38333. * @param element Defines the element to stop listening the inputs from
  38334. */
  38335. detachControl(element: Nullable<HTMLElement>): void;
  38336. /**
  38337. * Gets the class name of the current intput.
  38338. * @returns the class name
  38339. */
  38340. getClassName(): string;
  38341. /**
  38342. * Get the friendly name associated with the input class.
  38343. * @returns the input friendly name
  38344. */
  38345. getSimpleName(): string;
  38346. }
  38347. }
  38348. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38349. import { Nullable } from "babylonjs/types";
  38350. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38351. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38352. /**
  38353. * Listen to mouse events to control the camera.
  38354. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38355. */
  38356. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38357. /**
  38358. * Defines the camera the input is attached to.
  38359. */
  38360. camera: FlyCamera;
  38361. /**
  38362. * Defines if touch is enabled. (Default is true.)
  38363. */
  38364. touchEnabled: boolean;
  38365. /**
  38366. * Defines the buttons associated with the input to handle camera rotation.
  38367. */
  38368. buttons: number[];
  38369. /**
  38370. * Assign buttons for Yaw control.
  38371. */
  38372. buttonsYaw: number[];
  38373. /**
  38374. * Assign buttons for Pitch control.
  38375. */
  38376. buttonsPitch: number[];
  38377. /**
  38378. * Assign buttons for Roll control.
  38379. */
  38380. buttonsRoll: number[];
  38381. /**
  38382. * Detect if any button is being pressed while mouse is moved.
  38383. * -1 = Mouse locked.
  38384. * 0 = Left button.
  38385. * 1 = Middle Button.
  38386. * 2 = Right Button.
  38387. */
  38388. activeButton: number;
  38389. /**
  38390. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38391. * Higher values reduce its sensitivity.
  38392. */
  38393. angularSensibility: number;
  38394. private _mousemoveCallback;
  38395. private _observer;
  38396. private _rollObserver;
  38397. private previousPosition;
  38398. private noPreventDefault;
  38399. private element;
  38400. /**
  38401. * Listen to mouse events to control the camera.
  38402. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38403. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38404. */
  38405. constructor(touchEnabled?: boolean);
  38406. /**
  38407. * Attach the mouse control to the HTML DOM element.
  38408. * @param element Defines the element that listens to the input events.
  38409. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38410. */
  38411. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38412. /**
  38413. * Detach the current controls from the specified dom element.
  38414. * @param element Defines the element to stop listening the inputs from
  38415. */
  38416. detachControl(element: Nullable<HTMLElement>): void;
  38417. /**
  38418. * Gets the class name of the current input.
  38419. * @returns the class name.
  38420. */
  38421. getClassName(): string;
  38422. /**
  38423. * Get the friendly name associated with the input class.
  38424. * @returns the input's friendly name.
  38425. */
  38426. getSimpleName(): string;
  38427. private _pointerInput;
  38428. private _onMouseMove;
  38429. /**
  38430. * Rotate camera by mouse offset.
  38431. */
  38432. private rotateCamera;
  38433. }
  38434. }
  38435. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38436. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38437. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38438. /**
  38439. * Default Inputs manager for the FlyCamera.
  38440. * It groups all the default supported inputs for ease of use.
  38441. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38442. */
  38443. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38444. /**
  38445. * Instantiates a new FlyCameraInputsManager.
  38446. * @param camera Defines the camera the inputs belong to.
  38447. */
  38448. constructor(camera: FlyCamera);
  38449. /**
  38450. * Add keyboard input support to the input manager.
  38451. * @returns the new FlyCameraKeyboardMoveInput().
  38452. */
  38453. addKeyboard(): FlyCameraInputsManager;
  38454. /**
  38455. * Add mouse input support to the input manager.
  38456. * @param touchEnabled Enable touch screen support.
  38457. * @returns the new FlyCameraMouseInput().
  38458. */
  38459. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38460. }
  38461. }
  38462. declare module "babylonjs/Cameras/flyCamera" {
  38463. import { Scene } from "babylonjs/scene";
  38464. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38466. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38467. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38468. /**
  38469. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38470. * such as in a 3D Space Shooter or a Flight Simulator.
  38471. */
  38472. export class FlyCamera extends TargetCamera {
  38473. /**
  38474. * Define the collision ellipsoid of the camera.
  38475. * This is helpful for simulating a camera body, like a player's body.
  38476. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38477. */
  38478. ellipsoid: Vector3;
  38479. /**
  38480. * Define an offset for the position of the ellipsoid around the camera.
  38481. * This can be helpful if the camera is attached away from the player's body center,
  38482. * such as at its head.
  38483. */
  38484. ellipsoidOffset: Vector3;
  38485. /**
  38486. * Enable or disable collisions of the camera with the rest of the scene objects.
  38487. */
  38488. checkCollisions: boolean;
  38489. /**
  38490. * Enable or disable gravity on the camera.
  38491. */
  38492. applyGravity: boolean;
  38493. /**
  38494. * Define the current direction the camera is moving to.
  38495. */
  38496. cameraDirection: Vector3;
  38497. /**
  38498. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38499. * This overrides and empties cameraRotation.
  38500. */
  38501. rotationQuaternion: Quaternion;
  38502. /**
  38503. * Track Roll to maintain the wanted Rolling when looking around.
  38504. */
  38505. _trackRoll: number;
  38506. /**
  38507. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38508. */
  38509. rollCorrect: number;
  38510. /**
  38511. * Mimic a banked turn, Rolling the camera when Yawing.
  38512. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38513. */
  38514. bankedTurn: boolean;
  38515. /**
  38516. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38517. */
  38518. bankedTurnLimit: number;
  38519. /**
  38520. * Value of 0 disables the banked Roll.
  38521. * Value of 1 is equal to the Yaw angle in radians.
  38522. */
  38523. bankedTurnMultiplier: number;
  38524. /**
  38525. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38526. */
  38527. inputs: FlyCameraInputsManager;
  38528. /**
  38529. * Gets the input sensibility for mouse input.
  38530. * Higher values reduce sensitivity.
  38531. */
  38532. /**
  38533. * Sets the input sensibility for a mouse input.
  38534. * Higher values reduce sensitivity.
  38535. */
  38536. angularSensibility: number;
  38537. /**
  38538. * Get the keys for camera movement forward.
  38539. */
  38540. /**
  38541. * Set the keys for camera movement forward.
  38542. */
  38543. keysForward: number[];
  38544. /**
  38545. * Get the keys for camera movement backward.
  38546. */
  38547. keysBackward: number[];
  38548. /**
  38549. * Get the keys for camera movement up.
  38550. */
  38551. /**
  38552. * Set the keys for camera movement up.
  38553. */
  38554. keysUp: number[];
  38555. /**
  38556. * Get the keys for camera movement down.
  38557. */
  38558. /**
  38559. * Set the keys for camera movement down.
  38560. */
  38561. keysDown: number[];
  38562. /**
  38563. * Get the keys for camera movement left.
  38564. */
  38565. /**
  38566. * Set the keys for camera movement left.
  38567. */
  38568. keysLeft: number[];
  38569. /**
  38570. * Set the keys for camera movement right.
  38571. */
  38572. /**
  38573. * Set the keys for camera movement right.
  38574. */
  38575. keysRight: number[];
  38576. /**
  38577. * Event raised when the camera collides with a mesh in the scene.
  38578. */
  38579. onCollide: (collidedMesh: AbstractMesh) => void;
  38580. private _collider;
  38581. private _needMoveForGravity;
  38582. private _oldPosition;
  38583. private _diffPosition;
  38584. private _newPosition;
  38585. /** @hidden */
  38586. _localDirection: Vector3;
  38587. /** @hidden */
  38588. _transformedDirection: Vector3;
  38589. /**
  38590. * Instantiates a FlyCamera.
  38591. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38592. * such as in a 3D Space Shooter or a Flight Simulator.
  38593. * @param name Define the name of the camera in the scene.
  38594. * @param position Define the starting position of the camera in the scene.
  38595. * @param scene Define the scene the camera belongs to.
  38596. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38597. */
  38598. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38599. /**
  38600. * Attach a control to the HTML DOM element.
  38601. * @param element Defines the element that listens to the input events.
  38602. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38603. */
  38604. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38605. /**
  38606. * Detach a control from the HTML DOM element.
  38607. * The camera will stop reacting to that input.
  38608. * @param element Defines the element that listens to the input events.
  38609. */
  38610. detachControl(element: HTMLElement): void;
  38611. private _collisionMask;
  38612. /**
  38613. * Get the mask that the camera ignores in collision events.
  38614. */
  38615. /**
  38616. * Set the mask that the camera ignores in collision events.
  38617. */
  38618. collisionMask: number;
  38619. /** @hidden */
  38620. _collideWithWorld(displacement: Vector3): void;
  38621. /** @hidden */
  38622. private _onCollisionPositionChange;
  38623. /** @hidden */
  38624. _checkInputs(): void;
  38625. /** @hidden */
  38626. _decideIfNeedsToMove(): boolean;
  38627. /** @hidden */
  38628. _updatePosition(): void;
  38629. /**
  38630. * Restore the Roll to its target value at the rate specified.
  38631. * @param rate - Higher means slower restoring.
  38632. * @hidden
  38633. */
  38634. restoreRoll(rate: number): void;
  38635. /**
  38636. * Destroy the camera and release the current resources held by it.
  38637. */
  38638. dispose(): void;
  38639. /**
  38640. * Get the current object class name.
  38641. * @returns the class name.
  38642. */
  38643. getClassName(): string;
  38644. }
  38645. }
  38646. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38647. import { Nullable } from "babylonjs/types";
  38648. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38649. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38650. /**
  38651. * Listen to keyboard events to control the camera.
  38652. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38653. */
  38654. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38655. /**
  38656. * Defines the camera the input is attached to.
  38657. */
  38658. camera: FlyCamera;
  38659. /**
  38660. * The list of keyboard keys used to control the forward move of the camera.
  38661. */
  38662. keysForward: number[];
  38663. /**
  38664. * The list of keyboard keys used to control the backward move of the camera.
  38665. */
  38666. keysBackward: number[];
  38667. /**
  38668. * The list of keyboard keys used to control the forward move of the camera.
  38669. */
  38670. keysUp: number[];
  38671. /**
  38672. * The list of keyboard keys used to control the backward move of the camera.
  38673. */
  38674. keysDown: number[];
  38675. /**
  38676. * The list of keyboard keys used to control the right strafe move of the camera.
  38677. */
  38678. keysRight: number[];
  38679. /**
  38680. * The list of keyboard keys used to control the left strafe move of the camera.
  38681. */
  38682. keysLeft: number[];
  38683. private _keys;
  38684. private _onCanvasBlurObserver;
  38685. private _onKeyboardObserver;
  38686. private _engine;
  38687. private _scene;
  38688. /**
  38689. * Attach the input controls to a specific dom element to get the input from.
  38690. * @param element Defines the element the controls should be listened from
  38691. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38692. */
  38693. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38694. /**
  38695. * Detach the current controls from the specified dom element.
  38696. * @param element Defines the element to stop listening the inputs from
  38697. */
  38698. detachControl(element: Nullable<HTMLElement>): void;
  38699. /**
  38700. * Gets the class name of the current intput.
  38701. * @returns the class name
  38702. */
  38703. getClassName(): string;
  38704. /** @hidden */
  38705. _onLostFocus(e: FocusEvent): void;
  38706. /**
  38707. * Get the friendly name associated with the input class.
  38708. * @returns the input friendly name
  38709. */
  38710. getSimpleName(): string;
  38711. /**
  38712. * Update the current camera state depending on the inputs that have been used this frame.
  38713. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38714. */
  38715. checkInputs(): void;
  38716. }
  38717. }
  38718. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38719. import { Nullable } from "babylonjs/types";
  38720. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38721. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38722. /**
  38723. * Manage the mouse wheel inputs to control a follow camera.
  38724. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38725. */
  38726. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38727. /**
  38728. * Defines the camera the input is attached to.
  38729. */
  38730. camera: FollowCamera;
  38731. /**
  38732. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38733. */
  38734. axisControlRadius: boolean;
  38735. /**
  38736. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38737. */
  38738. axisControlHeight: boolean;
  38739. /**
  38740. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38741. */
  38742. axisControlRotation: boolean;
  38743. /**
  38744. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38745. * relation to mouseWheel events.
  38746. */
  38747. wheelPrecision: number;
  38748. /**
  38749. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38750. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38751. */
  38752. wheelDeltaPercentage: number;
  38753. private _wheel;
  38754. private _observer;
  38755. /**
  38756. * Attach the input controls to a specific dom element to get the input from.
  38757. * @param element Defines the element the controls should be listened from
  38758. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38759. */
  38760. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38761. /**
  38762. * Detach the current controls from the specified dom element.
  38763. * @param element Defines the element to stop listening the inputs from
  38764. */
  38765. detachControl(element: Nullable<HTMLElement>): void;
  38766. /**
  38767. * Gets the class name of the current intput.
  38768. * @returns the class name
  38769. */
  38770. getClassName(): string;
  38771. /**
  38772. * Get the friendly name associated with the input class.
  38773. * @returns the input friendly name
  38774. */
  38775. getSimpleName(): string;
  38776. }
  38777. }
  38778. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38779. import { Nullable } from "babylonjs/types";
  38780. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38781. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38782. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38783. /**
  38784. * Manage the pointers inputs to control an follow camera.
  38785. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38786. */
  38787. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38788. /**
  38789. * Defines the camera the input is attached to.
  38790. */
  38791. camera: FollowCamera;
  38792. /**
  38793. * Gets the class name of the current input.
  38794. * @returns the class name
  38795. */
  38796. getClassName(): string;
  38797. /**
  38798. * Defines the pointer angular sensibility along the X axis or how fast is
  38799. * the camera rotating.
  38800. * A negative number will reverse the axis direction.
  38801. */
  38802. angularSensibilityX: number;
  38803. /**
  38804. * Defines the pointer angular sensibility along the Y axis or how fast is
  38805. * the camera rotating.
  38806. * A negative number will reverse the axis direction.
  38807. */
  38808. angularSensibilityY: number;
  38809. /**
  38810. * Defines the pointer pinch precision or how fast is the camera zooming.
  38811. * A negative number will reverse the axis direction.
  38812. */
  38813. pinchPrecision: number;
  38814. /**
  38815. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38816. * from 0.
  38817. * It defines the percentage of current camera.radius to use as delta when
  38818. * pinch zoom is used.
  38819. */
  38820. pinchDeltaPercentage: number;
  38821. /**
  38822. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38823. */
  38824. axisXControlRadius: boolean;
  38825. /**
  38826. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38827. */
  38828. axisXControlHeight: boolean;
  38829. /**
  38830. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38831. */
  38832. axisXControlRotation: boolean;
  38833. /**
  38834. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38835. */
  38836. axisYControlRadius: boolean;
  38837. /**
  38838. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38839. */
  38840. axisYControlHeight: boolean;
  38841. /**
  38842. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38843. */
  38844. axisYControlRotation: boolean;
  38845. /**
  38846. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38847. */
  38848. axisPinchControlRadius: boolean;
  38849. /**
  38850. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38851. */
  38852. axisPinchControlHeight: boolean;
  38853. /**
  38854. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38855. */
  38856. axisPinchControlRotation: boolean;
  38857. /**
  38858. * Log error messages if basic misconfiguration has occurred.
  38859. */
  38860. warningEnable: boolean;
  38861. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38862. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38863. private _warningCounter;
  38864. private _warning;
  38865. }
  38866. }
  38867. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38868. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38869. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38870. /**
  38871. * Default Inputs manager for the FollowCamera.
  38872. * It groups all the default supported inputs for ease of use.
  38873. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38874. */
  38875. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38876. /**
  38877. * Instantiates a new FollowCameraInputsManager.
  38878. * @param camera Defines the camera the inputs belong to
  38879. */
  38880. constructor(camera: FollowCamera);
  38881. /**
  38882. * Add keyboard input support to the input manager.
  38883. * @returns the current input manager
  38884. */
  38885. addKeyboard(): FollowCameraInputsManager;
  38886. /**
  38887. * Add mouse wheel input support to the input manager.
  38888. * @returns the current input manager
  38889. */
  38890. addMouseWheel(): FollowCameraInputsManager;
  38891. /**
  38892. * Add pointers input support to the input manager.
  38893. * @returns the current input manager
  38894. */
  38895. addPointers(): FollowCameraInputsManager;
  38896. /**
  38897. * Add orientation input support to the input manager.
  38898. * @returns the current input manager
  38899. */
  38900. addVRDeviceOrientation(): FollowCameraInputsManager;
  38901. }
  38902. }
  38903. declare module "babylonjs/Cameras/followCamera" {
  38904. import { Nullable } from "babylonjs/types";
  38905. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38906. import { Scene } from "babylonjs/scene";
  38907. import { Vector3 } from "babylonjs/Maths/math.vector";
  38908. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38909. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38910. /**
  38911. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38912. * an arc rotate version arcFollowCamera are available.
  38913. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38914. */
  38915. export class FollowCamera extends TargetCamera {
  38916. /**
  38917. * Distance the follow camera should follow an object at
  38918. */
  38919. radius: number;
  38920. /**
  38921. * Minimum allowed distance of the camera to the axis of rotation
  38922. * (The camera can not get closer).
  38923. * This can help limiting how the Camera is able to move in the scene.
  38924. */
  38925. lowerRadiusLimit: Nullable<number>;
  38926. /**
  38927. * Maximum allowed distance of the camera to the axis of rotation
  38928. * (The camera can not get further).
  38929. * This can help limiting how the Camera is able to move in the scene.
  38930. */
  38931. upperRadiusLimit: Nullable<number>;
  38932. /**
  38933. * Define a rotation offset between the camera and the object it follows
  38934. */
  38935. rotationOffset: number;
  38936. /**
  38937. * Minimum allowed angle to camera position relative to target object.
  38938. * This can help limiting how the Camera is able to move in the scene.
  38939. */
  38940. lowerRotationOffsetLimit: Nullable<number>;
  38941. /**
  38942. * Maximum allowed angle to camera position relative to target object.
  38943. * This can help limiting how the Camera is able to move in the scene.
  38944. */
  38945. upperRotationOffsetLimit: Nullable<number>;
  38946. /**
  38947. * Define a height offset between the camera and the object it follows.
  38948. * It can help following an object from the top (like a car chaing a plane)
  38949. */
  38950. heightOffset: number;
  38951. /**
  38952. * Minimum allowed height of camera position relative to target object.
  38953. * This can help limiting how the Camera is able to move in the scene.
  38954. */
  38955. lowerHeightOffsetLimit: Nullable<number>;
  38956. /**
  38957. * Maximum allowed height of camera position relative to target object.
  38958. * This can help limiting how the Camera is able to move in the scene.
  38959. */
  38960. upperHeightOffsetLimit: Nullable<number>;
  38961. /**
  38962. * Define how fast the camera can accelerate to follow it s target.
  38963. */
  38964. cameraAcceleration: number;
  38965. /**
  38966. * Define the speed limit of the camera following an object.
  38967. */
  38968. maxCameraSpeed: number;
  38969. /**
  38970. * Define the target of the camera.
  38971. */
  38972. lockedTarget: Nullable<AbstractMesh>;
  38973. /**
  38974. * Defines the input associated with the camera.
  38975. */
  38976. inputs: FollowCameraInputsManager;
  38977. /**
  38978. * Instantiates the follow camera.
  38979. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38980. * @param name Define the name of the camera in the scene
  38981. * @param position Define the position of the camera
  38982. * @param scene Define the scene the camera belong to
  38983. * @param lockedTarget Define the target of the camera
  38984. */
  38985. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38986. private _follow;
  38987. /**
  38988. * Attached controls to the current camera.
  38989. * @param element Defines the element the controls should be listened from
  38990. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38991. */
  38992. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38993. /**
  38994. * Detach the current controls from the camera.
  38995. * The camera will stop reacting to inputs.
  38996. * @param element Defines the element to stop listening the inputs from
  38997. */
  38998. detachControl(element: HTMLElement): void;
  38999. /** @hidden */
  39000. _checkInputs(): void;
  39001. private _checkLimits;
  39002. /**
  39003. * Gets the camera class name.
  39004. * @returns the class name
  39005. */
  39006. getClassName(): string;
  39007. }
  39008. /**
  39009. * Arc Rotate version of the follow camera.
  39010. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39011. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39012. */
  39013. export class ArcFollowCamera extends TargetCamera {
  39014. /** The longitudinal angle of the camera */
  39015. alpha: number;
  39016. /** The latitudinal angle of the camera */
  39017. beta: number;
  39018. /** The radius of the camera from its target */
  39019. radius: number;
  39020. /** Define the camera target (the messh it should follow) */
  39021. target: Nullable<AbstractMesh>;
  39022. private _cartesianCoordinates;
  39023. /**
  39024. * Instantiates a new ArcFollowCamera
  39025. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39026. * @param name Define the name of the camera
  39027. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39028. * @param beta Define the rotation angle of the camera around the elevation axis
  39029. * @param radius Define the radius of the camera from its target point
  39030. * @param target Define the target of the camera
  39031. * @param scene Define the scene the camera belongs to
  39032. */
  39033. constructor(name: string,
  39034. /** The longitudinal angle of the camera */
  39035. alpha: number,
  39036. /** The latitudinal angle of the camera */
  39037. beta: number,
  39038. /** The radius of the camera from its target */
  39039. radius: number,
  39040. /** Define the camera target (the messh it should follow) */
  39041. target: Nullable<AbstractMesh>, scene: Scene);
  39042. private _follow;
  39043. /** @hidden */
  39044. _checkInputs(): void;
  39045. /**
  39046. * Returns the class name of the object.
  39047. * It is mostly used internally for serialization purposes.
  39048. */
  39049. getClassName(): string;
  39050. }
  39051. }
  39052. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39053. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39054. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39055. import { Nullable } from "babylonjs/types";
  39056. /**
  39057. * Manage the keyboard inputs to control the movement of a follow camera.
  39058. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39059. */
  39060. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39061. /**
  39062. * Defines the camera the input is attached to.
  39063. */
  39064. camera: FollowCamera;
  39065. /**
  39066. * Defines the list of key codes associated with the up action (increase heightOffset)
  39067. */
  39068. keysHeightOffsetIncr: number[];
  39069. /**
  39070. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39071. */
  39072. keysHeightOffsetDecr: number[];
  39073. /**
  39074. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39075. */
  39076. keysHeightOffsetModifierAlt: boolean;
  39077. /**
  39078. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39079. */
  39080. keysHeightOffsetModifierCtrl: boolean;
  39081. /**
  39082. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39083. */
  39084. keysHeightOffsetModifierShift: boolean;
  39085. /**
  39086. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39087. */
  39088. keysRotationOffsetIncr: number[];
  39089. /**
  39090. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39091. */
  39092. keysRotationOffsetDecr: number[];
  39093. /**
  39094. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39095. */
  39096. keysRotationOffsetModifierAlt: boolean;
  39097. /**
  39098. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39099. */
  39100. keysRotationOffsetModifierCtrl: boolean;
  39101. /**
  39102. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39103. */
  39104. keysRotationOffsetModifierShift: boolean;
  39105. /**
  39106. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39107. */
  39108. keysRadiusIncr: number[];
  39109. /**
  39110. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39111. */
  39112. keysRadiusDecr: number[];
  39113. /**
  39114. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39115. */
  39116. keysRadiusModifierAlt: boolean;
  39117. /**
  39118. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39119. */
  39120. keysRadiusModifierCtrl: boolean;
  39121. /**
  39122. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39123. */
  39124. keysRadiusModifierShift: boolean;
  39125. /**
  39126. * Defines the rate of change of heightOffset.
  39127. */
  39128. heightSensibility: number;
  39129. /**
  39130. * Defines the rate of change of rotationOffset.
  39131. */
  39132. rotationSensibility: number;
  39133. /**
  39134. * Defines the rate of change of radius.
  39135. */
  39136. radiusSensibility: number;
  39137. private _keys;
  39138. private _ctrlPressed;
  39139. private _altPressed;
  39140. private _shiftPressed;
  39141. private _onCanvasBlurObserver;
  39142. private _onKeyboardObserver;
  39143. private _engine;
  39144. private _scene;
  39145. /**
  39146. * Attach the input controls to a specific dom element to get the input from.
  39147. * @param element Defines the element the controls should be listened from
  39148. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39149. */
  39150. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39151. /**
  39152. * Detach the current controls from the specified dom element.
  39153. * @param element Defines the element to stop listening the inputs from
  39154. */
  39155. detachControl(element: Nullable<HTMLElement>): void;
  39156. /**
  39157. * Update the current camera state depending on the inputs that have been used this frame.
  39158. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39159. */
  39160. checkInputs(): void;
  39161. /**
  39162. * Gets the class name of the current input.
  39163. * @returns the class name
  39164. */
  39165. getClassName(): string;
  39166. /**
  39167. * Get the friendly name associated with the input class.
  39168. * @returns the input friendly name
  39169. */
  39170. getSimpleName(): string;
  39171. /**
  39172. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39173. * allow modification of the heightOffset value.
  39174. */
  39175. private _modifierHeightOffset;
  39176. /**
  39177. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39178. * allow modification of the rotationOffset value.
  39179. */
  39180. private _modifierRotationOffset;
  39181. /**
  39182. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39183. * allow modification of the radius value.
  39184. */
  39185. private _modifierRadius;
  39186. }
  39187. }
  39188. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39189. import { Nullable } from "babylonjs/types";
  39190. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39191. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39192. import { Observable } from "babylonjs/Misc/observable";
  39193. module "babylonjs/Cameras/freeCameraInputsManager" {
  39194. interface FreeCameraInputsManager {
  39195. /**
  39196. * @hidden
  39197. */
  39198. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39199. /**
  39200. * Add orientation input support to the input manager.
  39201. * @returns the current input manager
  39202. */
  39203. addDeviceOrientation(): FreeCameraInputsManager;
  39204. }
  39205. }
  39206. /**
  39207. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39208. * Screen rotation is taken into account.
  39209. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39210. */
  39211. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39212. private _camera;
  39213. private _screenOrientationAngle;
  39214. private _constantTranform;
  39215. private _screenQuaternion;
  39216. private _alpha;
  39217. private _beta;
  39218. private _gamma;
  39219. /**
  39220. * Can be used to detect if a device orientation sensor is availible on a device
  39221. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39222. * @returns a promise that will resolve on orientation change
  39223. */
  39224. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39225. /**
  39226. * @hidden
  39227. */
  39228. _onDeviceOrientationChangedObservable: Observable<void>;
  39229. /**
  39230. * Instantiates a new input
  39231. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39232. */
  39233. constructor();
  39234. /**
  39235. * Define the camera controlled by the input.
  39236. */
  39237. camera: FreeCamera;
  39238. /**
  39239. * Attach the input controls to a specific dom element to get the input from.
  39240. * @param element Defines the element the controls should be listened from
  39241. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39242. */
  39243. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39244. private _orientationChanged;
  39245. private _deviceOrientation;
  39246. /**
  39247. * Detach the current controls from the specified dom element.
  39248. * @param element Defines the element to stop listening the inputs from
  39249. */
  39250. detachControl(element: Nullable<HTMLElement>): void;
  39251. /**
  39252. * Update the current camera state depending on the inputs that have been used this frame.
  39253. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39254. */
  39255. checkInputs(): void;
  39256. /**
  39257. * Gets the class name of the current intput.
  39258. * @returns the class name
  39259. */
  39260. getClassName(): string;
  39261. /**
  39262. * Get the friendly name associated with the input class.
  39263. * @returns the input friendly name
  39264. */
  39265. getSimpleName(): string;
  39266. }
  39267. }
  39268. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39269. import { Nullable } from "babylonjs/types";
  39270. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39271. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39272. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39273. /**
  39274. * Manage the gamepad inputs to control a free camera.
  39275. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39276. */
  39277. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39278. /**
  39279. * Define the camera the input is attached to.
  39280. */
  39281. camera: FreeCamera;
  39282. /**
  39283. * Define the Gamepad controlling the input
  39284. */
  39285. gamepad: Nullable<Gamepad>;
  39286. /**
  39287. * Defines the gamepad rotation sensiblity.
  39288. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39289. */
  39290. gamepadAngularSensibility: number;
  39291. /**
  39292. * Defines the gamepad move sensiblity.
  39293. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39294. */
  39295. gamepadMoveSensibility: number;
  39296. private _onGamepadConnectedObserver;
  39297. private _onGamepadDisconnectedObserver;
  39298. private _cameraTransform;
  39299. private _deltaTransform;
  39300. private _vector3;
  39301. private _vector2;
  39302. /**
  39303. * Attach the input controls to a specific dom element to get the input from.
  39304. * @param element Defines the element the controls should be listened from
  39305. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39306. */
  39307. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39308. /**
  39309. * Detach the current controls from the specified dom element.
  39310. * @param element Defines the element to stop listening the inputs from
  39311. */
  39312. detachControl(element: Nullable<HTMLElement>): void;
  39313. /**
  39314. * Update the current camera state depending on the inputs that have been used this frame.
  39315. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39316. */
  39317. checkInputs(): void;
  39318. /**
  39319. * Gets the class name of the current intput.
  39320. * @returns the class name
  39321. */
  39322. getClassName(): string;
  39323. /**
  39324. * Get the friendly name associated with the input class.
  39325. * @returns the input friendly name
  39326. */
  39327. getSimpleName(): string;
  39328. }
  39329. }
  39330. declare module "babylonjs/Misc/virtualJoystick" {
  39331. import { Nullable } from "babylonjs/types";
  39332. import { Vector3 } from "babylonjs/Maths/math.vector";
  39333. /**
  39334. * Defines the potential axis of a Joystick
  39335. */
  39336. export enum JoystickAxis {
  39337. /** X axis */
  39338. X = 0,
  39339. /** Y axis */
  39340. Y = 1,
  39341. /** Z axis */
  39342. Z = 2
  39343. }
  39344. /**
  39345. * Class used to define virtual joystick (used in touch mode)
  39346. */
  39347. export class VirtualJoystick {
  39348. /**
  39349. * Gets or sets a boolean indicating that left and right values must be inverted
  39350. */
  39351. reverseLeftRight: boolean;
  39352. /**
  39353. * Gets or sets a boolean indicating that up and down values must be inverted
  39354. */
  39355. reverseUpDown: boolean;
  39356. /**
  39357. * Gets the offset value for the position (ie. the change of the position value)
  39358. */
  39359. deltaPosition: Vector3;
  39360. /**
  39361. * Gets a boolean indicating if the virtual joystick was pressed
  39362. */
  39363. pressed: boolean;
  39364. /**
  39365. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39366. */
  39367. static Canvas: Nullable<HTMLCanvasElement>;
  39368. private static _globalJoystickIndex;
  39369. private static vjCanvasContext;
  39370. private static vjCanvasWidth;
  39371. private static vjCanvasHeight;
  39372. private static halfWidth;
  39373. private _action;
  39374. private _axisTargetedByLeftAndRight;
  39375. private _axisTargetedByUpAndDown;
  39376. private _joystickSensibility;
  39377. private _inversedSensibility;
  39378. private _joystickPointerID;
  39379. private _joystickColor;
  39380. private _joystickPointerPos;
  39381. private _joystickPreviousPointerPos;
  39382. private _joystickPointerStartPos;
  39383. private _deltaJoystickVector;
  39384. private _leftJoystick;
  39385. private _touches;
  39386. private _onPointerDownHandlerRef;
  39387. private _onPointerMoveHandlerRef;
  39388. private _onPointerUpHandlerRef;
  39389. private _onResize;
  39390. /**
  39391. * Creates a new virtual joystick
  39392. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39393. */
  39394. constructor(leftJoystick?: boolean);
  39395. /**
  39396. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39397. * @param newJoystickSensibility defines the new sensibility
  39398. */
  39399. setJoystickSensibility(newJoystickSensibility: number): void;
  39400. private _onPointerDown;
  39401. private _onPointerMove;
  39402. private _onPointerUp;
  39403. /**
  39404. * Change the color of the virtual joystick
  39405. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39406. */
  39407. setJoystickColor(newColor: string): void;
  39408. /**
  39409. * Defines a callback to call when the joystick is touched
  39410. * @param action defines the callback
  39411. */
  39412. setActionOnTouch(action: () => any): void;
  39413. /**
  39414. * Defines which axis you'd like to control for left & right
  39415. * @param axis defines the axis to use
  39416. */
  39417. setAxisForLeftRight(axis: JoystickAxis): void;
  39418. /**
  39419. * Defines which axis you'd like to control for up & down
  39420. * @param axis defines the axis to use
  39421. */
  39422. setAxisForUpDown(axis: JoystickAxis): void;
  39423. private _drawVirtualJoystick;
  39424. /**
  39425. * Release internal HTML canvas
  39426. */
  39427. releaseCanvas(): void;
  39428. }
  39429. }
  39430. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39431. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39432. import { Nullable } from "babylonjs/types";
  39433. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39434. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39435. module "babylonjs/Cameras/freeCameraInputsManager" {
  39436. interface FreeCameraInputsManager {
  39437. /**
  39438. * Add virtual joystick input support to the input manager.
  39439. * @returns the current input manager
  39440. */
  39441. addVirtualJoystick(): FreeCameraInputsManager;
  39442. }
  39443. }
  39444. /**
  39445. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39446. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39447. */
  39448. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39449. /**
  39450. * Defines the camera the input is attached to.
  39451. */
  39452. camera: FreeCamera;
  39453. private _leftjoystick;
  39454. private _rightjoystick;
  39455. /**
  39456. * Gets the left stick of the virtual joystick.
  39457. * @returns The virtual Joystick
  39458. */
  39459. getLeftJoystick(): VirtualJoystick;
  39460. /**
  39461. * Gets the right stick of the virtual joystick.
  39462. * @returns The virtual Joystick
  39463. */
  39464. getRightJoystick(): VirtualJoystick;
  39465. /**
  39466. * Update the current camera state depending on the inputs that have been used this frame.
  39467. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39468. */
  39469. checkInputs(): void;
  39470. /**
  39471. * Attach the input controls to a specific dom element to get the input from.
  39472. * @param element Defines the element the controls should be listened from
  39473. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39474. */
  39475. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39476. /**
  39477. * Detach the current controls from the specified dom element.
  39478. * @param element Defines the element to stop listening the inputs from
  39479. */
  39480. detachControl(element: Nullable<HTMLElement>): void;
  39481. /**
  39482. * Gets the class name of the current intput.
  39483. * @returns the class name
  39484. */
  39485. getClassName(): string;
  39486. /**
  39487. * Get the friendly name associated with the input class.
  39488. * @returns the input friendly name
  39489. */
  39490. getSimpleName(): string;
  39491. }
  39492. }
  39493. declare module "babylonjs/Cameras/Inputs/index" {
  39494. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39495. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39496. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39497. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39498. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39499. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39500. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39501. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39502. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39503. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39504. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39505. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39506. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39507. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39508. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39509. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39510. }
  39511. declare module "babylonjs/Cameras/touchCamera" {
  39512. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39513. import { Scene } from "babylonjs/scene";
  39514. import { Vector3 } from "babylonjs/Maths/math.vector";
  39515. /**
  39516. * This represents a FPS type of camera controlled by touch.
  39517. * This is like a universal camera minus the Gamepad controls.
  39518. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39519. */
  39520. export class TouchCamera extends FreeCamera {
  39521. /**
  39522. * Defines the touch sensibility for rotation.
  39523. * The higher the faster.
  39524. */
  39525. touchAngularSensibility: number;
  39526. /**
  39527. * Defines the touch sensibility for move.
  39528. * The higher the faster.
  39529. */
  39530. touchMoveSensibility: number;
  39531. /**
  39532. * Instantiates a new touch camera.
  39533. * This represents a FPS type of camera controlled by touch.
  39534. * This is like a universal camera minus the Gamepad controls.
  39535. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39536. * @param name Define the name of the camera in the scene
  39537. * @param position Define the start position of the camera in the scene
  39538. * @param scene Define the scene the camera belongs to
  39539. */
  39540. constructor(name: string, position: Vector3, scene: Scene);
  39541. /**
  39542. * Gets the current object class name.
  39543. * @return the class name
  39544. */
  39545. getClassName(): string;
  39546. /** @hidden */
  39547. _setupInputs(): void;
  39548. }
  39549. }
  39550. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39551. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39552. import { Scene } from "babylonjs/scene";
  39553. import { Vector3 } from "babylonjs/Maths/math.vector";
  39554. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39555. import { Axis } from "babylonjs/Maths/math.axis";
  39556. /**
  39557. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39558. * being tilted forward or back and left or right.
  39559. */
  39560. export class DeviceOrientationCamera extends FreeCamera {
  39561. private _initialQuaternion;
  39562. private _quaternionCache;
  39563. private _tmpDragQuaternion;
  39564. private _disablePointerInputWhenUsingDeviceOrientation;
  39565. /**
  39566. * Creates a new device orientation camera
  39567. * @param name The name of the camera
  39568. * @param position The start position camera
  39569. * @param scene The scene the camera belongs to
  39570. */
  39571. constructor(name: string, position: Vector3, scene: Scene);
  39572. /**
  39573. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39574. */
  39575. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39576. private _dragFactor;
  39577. /**
  39578. * Enabled turning on the y axis when the orientation sensor is active
  39579. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39580. */
  39581. enableHorizontalDragging(dragFactor?: number): void;
  39582. /**
  39583. * Gets the current instance class name ("DeviceOrientationCamera").
  39584. * This helps avoiding instanceof at run time.
  39585. * @returns the class name
  39586. */
  39587. getClassName(): string;
  39588. /**
  39589. * @hidden
  39590. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39591. */
  39592. _checkInputs(): void;
  39593. /**
  39594. * Reset the camera to its default orientation on the specified axis only.
  39595. * @param axis The axis to reset
  39596. */
  39597. resetToCurrentRotation(axis?: Axis): void;
  39598. }
  39599. }
  39600. declare module "babylonjs/Gamepads/xboxGamepad" {
  39601. import { Observable } from "babylonjs/Misc/observable";
  39602. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39603. /**
  39604. * Defines supported buttons for XBox360 compatible gamepads
  39605. */
  39606. export enum Xbox360Button {
  39607. /** A */
  39608. A = 0,
  39609. /** B */
  39610. B = 1,
  39611. /** X */
  39612. X = 2,
  39613. /** Y */
  39614. Y = 3,
  39615. /** Start */
  39616. Start = 4,
  39617. /** Back */
  39618. Back = 5,
  39619. /** Left button */
  39620. LB = 6,
  39621. /** Right button */
  39622. RB = 7,
  39623. /** Left stick */
  39624. LeftStick = 8,
  39625. /** Right stick */
  39626. RightStick = 9
  39627. }
  39628. /** Defines values for XBox360 DPad */
  39629. export enum Xbox360Dpad {
  39630. /** Up */
  39631. Up = 0,
  39632. /** Down */
  39633. Down = 1,
  39634. /** Left */
  39635. Left = 2,
  39636. /** Right */
  39637. Right = 3
  39638. }
  39639. /**
  39640. * Defines a XBox360 gamepad
  39641. */
  39642. export class Xbox360Pad extends Gamepad {
  39643. private _leftTrigger;
  39644. private _rightTrigger;
  39645. private _onlefttriggerchanged;
  39646. private _onrighttriggerchanged;
  39647. private _onbuttondown;
  39648. private _onbuttonup;
  39649. private _ondpaddown;
  39650. private _ondpadup;
  39651. /** Observable raised when a button is pressed */
  39652. onButtonDownObservable: Observable<Xbox360Button>;
  39653. /** Observable raised when a button is released */
  39654. onButtonUpObservable: Observable<Xbox360Button>;
  39655. /** Observable raised when a pad is pressed */
  39656. onPadDownObservable: Observable<Xbox360Dpad>;
  39657. /** Observable raised when a pad is released */
  39658. onPadUpObservable: Observable<Xbox360Dpad>;
  39659. private _buttonA;
  39660. private _buttonB;
  39661. private _buttonX;
  39662. private _buttonY;
  39663. private _buttonBack;
  39664. private _buttonStart;
  39665. private _buttonLB;
  39666. private _buttonRB;
  39667. private _buttonLeftStick;
  39668. private _buttonRightStick;
  39669. private _dPadUp;
  39670. private _dPadDown;
  39671. private _dPadLeft;
  39672. private _dPadRight;
  39673. private _isXboxOnePad;
  39674. /**
  39675. * Creates a new XBox360 gamepad object
  39676. * @param id defines the id of this gamepad
  39677. * @param index defines its index
  39678. * @param gamepad defines the internal HTML gamepad object
  39679. * @param xboxOne defines if it is a XBox One gamepad
  39680. */
  39681. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39682. /**
  39683. * Defines the callback to call when left trigger is pressed
  39684. * @param callback defines the callback to use
  39685. */
  39686. onlefttriggerchanged(callback: (value: number) => void): void;
  39687. /**
  39688. * Defines the callback to call when right trigger is pressed
  39689. * @param callback defines the callback to use
  39690. */
  39691. onrighttriggerchanged(callback: (value: number) => void): void;
  39692. /**
  39693. * Gets the left trigger value
  39694. */
  39695. /**
  39696. * Sets the left trigger value
  39697. */
  39698. leftTrigger: number;
  39699. /**
  39700. * Gets the right trigger value
  39701. */
  39702. /**
  39703. * Sets the right trigger value
  39704. */
  39705. rightTrigger: number;
  39706. /**
  39707. * Defines the callback to call when a button is pressed
  39708. * @param callback defines the callback to use
  39709. */
  39710. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39711. /**
  39712. * Defines the callback to call when a button is released
  39713. * @param callback defines the callback to use
  39714. */
  39715. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39716. /**
  39717. * Defines the callback to call when a pad is pressed
  39718. * @param callback defines the callback to use
  39719. */
  39720. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39721. /**
  39722. * Defines the callback to call when a pad is released
  39723. * @param callback defines the callback to use
  39724. */
  39725. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39726. private _setButtonValue;
  39727. private _setDPadValue;
  39728. /**
  39729. * Gets the value of the `A` button
  39730. */
  39731. /**
  39732. * Sets the value of the `A` button
  39733. */
  39734. buttonA: number;
  39735. /**
  39736. * Gets the value of the `B` button
  39737. */
  39738. /**
  39739. * Sets the value of the `B` button
  39740. */
  39741. buttonB: number;
  39742. /**
  39743. * Gets the value of the `X` button
  39744. */
  39745. /**
  39746. * Sets the value of the `X` button
  39747. */
  39748. buttonX: number;
  39749. /**
  39750. * Gets the value of the `Y` button
  39751. */
  39752. /**
  39753. * Sets the value of the `Y` button
  39754. */
  39755. buttonY: number;
  39756. /**
  39757. * Gets the value of the `Start` button
  39758. */
  39759. /**
  39760. * Sets the value of the `Start` button
  39761. */
  39762. buttonStart: number;
  39763. /**
  39764. * Gets the value of the `Back` button
  39765. */
  39766. /**
  39767. * Sets the value of the `Back` button
  39768. */
  39769. buttonBack: number;
  39770. /**
  39771. * Gets the value of the `Left` button
  39772. */
  39773. /**
  39774. * Sets the value of the `Left` button
  39775. */
  39776. buttonLB: number;
  39777. /**
  39778. * Gets the value of the `Right` button
  39779. */
  39780. /**
  39781. * Sets the value of the `Right` button
  39782. */
  39783. buttonRB: number;
  39784. /**
  39785. * Gets the value of the Left joystick
  39786. */
  39787. /**
  39788. * Sets the value of the Left joystick
  39789. */
  39790. buttonLeftStick: number;
  39791. /**
  39792. * Gets the value of the Right joystick
  39793. */
  39794. /**
  39795. * Sets the value of the Right joystick
  39796. */
  39797. buttonRightStick: number;
  39798. /**
  39799. * Gets the value of D-pad up
  39800. */
  39801. /**
  39802. * Sets the value of D-pad up
  39803. */
  39804. dPadUp: number;
  39805. /**
  39806. * Gets the value of D-pad down
  39807. */
  39808. /**
  39809. * Sets the value of D-pad down
  39810. */
  39811. dPadDown: number;
  39812. /**
  39813. * Gets the value of D-pad left
  39814. */
  39815. /**
  39816. * Sets the value of D-pad left
  39817. */
  39818. dPadLeft: number;
  39819. /**
  39820. * Gets the value of D-pad right
  39821. */
  39822. /**
  39823. * Sets the value of D-pad right
  39824. */
  39825. dPadRight: number;
  39826. /**
  39827. * Force the gamepad to synchronize with device values
  39828. */
  39829. update(): void;
  39830. /**
  39831. * Disposes the gamepad
  39832. */
  39833. dispose(): void;
  39834. }
  39835. }
  39836. declare module "babylonjs/Gamepads/dualShockGamepad" {
  39837. import { Observable } from "babylonjs/Misc/observable";
  39838. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39839. /**
  39840. * Defines supported buttons for DualShock compatible gamepads
  39841. */
  39842. export enum DualShockButton {
  39843. /** Cross */
  39844. Cross = 0,
  39845. /** Circle */
  39846. Circle = 1,
  39847. /** Square */
  39848. Square = 2,
  39849. /** Triangle */
  39850. Triangle = 3,
  39851. /** Options */
  39852. Options = 4,
  39853. /** Share */
  39854. Share = 5,
  39855. /** L1 */
  39856. L1 = 6,
  39857. /** R1 */
  39858. R1 = 7,
  39859. /** Left stick */
  39860. LeftStick = 8,
  39861. /** Right stick */
  39862. RightStick = 9
  39863. }
  39864. /** Defines values for DualShock DPad */
  39865. export enum DualShockDpad {
  39866. /** Up */
  39867. Up = 0,
  39868. /** Down */
  39869. Down = 1,
  39870. /** Left */
  39871. Left = 2,
  39872. /** Right */
  39873. Right = 3
  39874. }
  39875. /**
  39876. * Defines a DualShock gamepad
  39877. */
  39878. export class DualShockPad extends Gamepad {
  39879. private _leftTrigger;
  39880. private _rightTrigger;
  39881. private _onlefttriggerchanged;
  39882. private _onrighttriggerchanged;
  39883. private _onbuttondown;
  39884. private _onbuttonup;
  39885. private _ondpaddown;
  39886. private _ondpadup;
  39887. /** Observable raised when a button is pressed */
  39888. onButtonDownObservable: Observable<DualShockButton>;
  39889. /** Observable raised when a button is released */
  39890. onButtonUpObservable: Observable<DualShockButton>;
  39891. /** Observable raised when a pad is pressed */
  39892. onPadDownObservable: Observable<DualShockDpad>;
  39893. /** Observable raised when a pad is released */
  39894. onPadUpObservable: Observable<DualShockDpad>;
  39895. private _buttonCross;
  39896. private _buttonCircle;
  39897. private _buttonSquare;
  39898. private _buttonTriangle;
  39899. private _buttonShare;
  39900. private _buttonOptions;
  39901. private _buttonL1;
  39902. private _buttonR1;
  39903. private _buttonLeftStick;
  39904. private _buttonRightStick;
  39905. private _dPadUp;
  39906. private _dPadDown;
  39907. private _dPadLeft;
  39908. private _dPadRight;
  39909. /**
  39910. * Creates a new DualShock gamepad object
  39911. * @param id defines the id of this gamepad
  39912. * @param index defines its index
  39913. * @param gamepad defines the internal HTML gamepad object
  39914. */
  39915. constructor(id: string, index: number, gamepad: any);
  39916. /**
  39917. * Defines the callback to call when left trigger is pressed
  39918. * @param callback defines the callback to use
  39919. */
  39920. onlefttriggerchanged(callback: (value: number) => void): void;
  39921. /**
  39922. * Defines the callback to call when right trigger is pressed
  39923. * @param callback defines the callback to use
  39924. */
  39925. onrighttriggerchanged(callback: (value: number) => void): void;
  39926. /**
  39927. * Gets the left trigger value
  39928. */
  39929. /**
  39930. * Sets the left trigger value
  39931. */
  39932. leftTrigger: number;
  39933. /**
  39934. * Gets the right trigger value
  39935. */
  39936. /**
  39937. * Sets the right trigger value
  39938. */
  39939. rightTrigger: number;
  39940. /**
  39941. * Defines the callback to call when a button is pressed
  39942. * @param callback defines the callback to use
  39943. */
  39944. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  39945. /**
  39946. * Defines the callback to call when a button is released
  39947. * @param callback defines the callback to use
  39948. */
  39949. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  39950. /**
  39951. * Defines the callback to call when a pad is pressed
  39952. * @param callback defines the callback to use
  39953. */
  39954. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  39955. /**
  39956. * Defines the callback to call when a pad is released
  39957. * @param callback defines the callback to use
  39958. */
  39959. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  39960. private _setButtonValue;
  39961. private _setDPadValue;
  39962. /**
  39963. * Gets the value of the `Cross` button
  39964. */
  39965. /**
  39966. * Sets the value of the `Cross` button
  39967. */
  39968. buttonCross: number;
  39969. /**
  39970. * Gets the value of the `Circle` button
  39971. */
  39972. /**
  39973. * Sets the value of the `Circle` button
  39974. */
  39975. buttonCircle: number;
  39976. /**
  39977. * Gets the value of the `Square` button
  39978. */
  39979. /**
  39980. * Sets the value of the `Square` button
  39981. */
  39982. buttonSquare: number;
  39983. /**
  39984. * Gets the value of the `Triangle` button
  39985. */
  39986. /**
  39987. * Sets the value of the `Triangle` button
  39988. */
  39989. buttonTriangle: number;
  39990. /**
  39991. * Gets the value of the `Options` button
  39992. */
  39993. /**
  39994. * Sets the value of the `Options` button
  39995. */
  39996. buttonOptions: number;
  39997. /**
  39998. * Gets the value of the `Share` button
  39999. */
  40000. /**
  40001. * Sets the value of the `Share` button
  40002. */
  40003. buttonShare: number;
  40004. /**
  40005. * Gets the value of the `L1` button
  40006. */
  40007. /**
  40008. * Sets the value of the `L1` button
  40009. */
  40010. buttonL1: number;
  40011. /**
  40012. * Gets the value of the `R1` button
  40013. */
  40014. /**
  40015. * Sets the value of the `R1` button
  40016. */
  40017. buttonR1: number;
  40018. /**
  40019. * Gets the value of the Left joystick
  40020. */
  40021. /**
  40022. * Sets the value of the Left joystick
  40023. */
  40024. buttonLeftStick: number;
  40025. /**
  40026. * Gets the value of the Right joystick
  40027. */
  40028. /**
  40029. * Sets the value of the Right joystick
  40030. */
  40031. buttonRightStick: number;
  40032. /**
  40033. * Gets the value of D-pad up
  40034. */
  40035. /**
  40036. * Sets the value of D-pad up
  40037. */
  40038. dPadUp: number;
  40039. /**
  40040. * Gets the value of D-pad down
  40041. */
  40042. /**
  40043. * Sets the value of D-pad down
  40044. */
  40045. dPadDown: number;
  40046. /**
  40047. * Gets the value of D-pad left
  40048. */
  40049. /**
  40050. * Sets the value of D-pad left
  40051. */
  40052. dPadLeft: number;
  40053. /**
  40054. * Gets the value of D-pad right
  40055. */
  40056. /**
  40057. * Sets the value of D-pad right
  40058. */
  40059. dPadRight: number;
  40060. /**
  40061. * Force the gamepad to synchronize with device values
  40062. */
  40063. update(): void;
  40064. /**
  40065. * Disposes the gamepad
  40066. */
  40067. dispose(): void;
  40068. }
  40069. }
  40070. declare module "babylonjs/Gamepads/gamepadManager" {
  40071. import { Observable } from "babylonjs/Misc/observable";
  40072. import { Nullable } from "babylonjs/types";
  40073. import { Scene } from "babylonjs/scene";
  40074. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40075. /**
  40076. * Manager for handling gamepads
  40077. */
  40078. export class GamepadManager {
  40079. private _scene?;
  40080. private _babylonGamepads;
  40081. private _oneGamepadConnected;
  40082. /** @hidden */
  40083. _isMonitoring: boolean;
  40084. private _gamepadEventSupported;
  40085. private _gamepadSupport;
  40086. /**
  40087. * observable to be triggered when the gamepad controller has been connected
  40088. */
  40089. onGamepadConnectedObservable: Observable<Gamepad>;
  40090. /**
  40091. * observable to be triggered when the gamepad controller has been disconnected
  40092. */
  40093. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40094. private _onGamepadConnectedEvent;
  40095. private _onGamepadDisconnectedEvent;
  40096. /**
  40097. * Initializes the gamepad manager
  40098. * @param _scene BabylonJS scene
  40099. */
  40100. constructor(_scene?: Scene | undefined);
  40101. /**
  40102. * The gamepads in the game pad manager
  40103. */
  40104. readonly gamepads: Gamepad[];
  40105. /**
  40106. * Get the gamepad controllers based on type
  40107. * @param type The type of gamepad controller
  40108. * @returns Nullable gamepad
  40109. */
  40110. getGamepadByType(type?: number): Nullable<Gamepad>;
  40111. /**
  40112. * Disposes the gamepad manager
  40113. */
  40114. dispose(): void;
  40115. private _addNewGamepad;
  40116. private _startMonitoringGamepads;
  40117. private _stopMonitoringGamepads;
  40118. /** @hidden */
  40119. _checkGamepadsStatus(): void;
  40120. private _updateGamepadObjects;
  40121. }
  40122. }
  40123. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40124. import { Nullable } from "babylonjs/types";
  40125. import { Scene } from "babylonjs/scene";
  40126. import { ISceneComponent } from "babylonjs/sceneComponent";
  40127. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40128. module "babylonjs/scene" {
  40129. interface Scene {
  40130. /** @hidden */
  40131. _gamepadManager: Nullable<GamepadManager>;
  40132. /**
  40133. * Gets the gamepad manager associated with the scene
  40134. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40135. */
  40136. gamepadManager: GamepadManager;
  40137. }
  40138. }
  40139. module "babylonjs/Cameras/freeCameraInputsManager" {
  40140. /**
  40141. * Interface representing a free camera inputs manager
  40142. */
  40143. interface FreeCameraInputsManager {
  40144. /**
  40145. * Adds gamepad input support to the FreeCameraInputsManager.
  40146. * @returns the FreeCameraInputsManager
  40147. */
  40148. addGamepad(): FreeCameraInputsManager;
  40149. }
  40150. }
  40151. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40152. /**
  40153. * Interface representing an arc rotate camera inputs manager
  40154. */
  40155. interface ArcRotateCameraInputsManager {
  40156. /**
  40157. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40158. * @returns the camera inputs manager
  40159. */
  40160. addGamepad(): ArcRotateCameraInputsManager;
  40161. }
  40162. }
  40163. /**
  40164. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40165. */
  40166. export class GamepadSystemSceneComponent implements ISceneComponent {
  40167. /**
  40168. * The component name helpfull to identify the component in the list of scene components.
  40169. */
  40170. readonly name: string;
  40171. /**
  40172. * The scene the component belongs to.
  40173. */
  40174. scene: Scene;
  40175. /**
  40176. * Creates a new instance of the component for the given scene
  40177. * @param scene Defines the scene to register the component in
  40178. */
  40179. constructor(scene: Scene);
  40180. /**
  40181. * Registers the component in a given scene
  40182. */
  40183. register(): void;
  40184. /**
  40185. * Rebuilds the elements related to this component in case of
  40186. * context lost for instance.
  40187. */
  40188. rebuild(): void;
  40189. /**
  40190. * Disposes the component and the associated ressources
  40191. */
  40192. dispose(): void;
  40193. private _beforeCameraUpdate;
  40194. }
  40195. }
  40196. declare module "babylonjs/Cameras/universalCamera" {
  40197. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40198. import { Scene } from "babylonjs/scene";
  40199. import { Vector3 } from "babylonjs/Maths/math.vector";
  40200. import "babylonjs/Gamepads/gamepadSceneComponent";
  40201. /**
  40202. * 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,
  40203. * which still works and will still be found in many Playgrounds.
  40204. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40205. */
  40206. export class UniversalCamera extends TouchCamera {
  40207. /**
  40208. * Defines the gamepad rotation sensiblity.
  40209. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40210. */
  40211. gamepadAngularSensibility: number;
  40212. /**
  40213. * Defines the gamepad move sensiblity.
  40214. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40215. */
  40216. gamepadMoveSensibility: number;
  40217. /**
  40218. * 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,
  40219. * which still works and will still be found in many Playgrounds.
  40220. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40221. * @param name Define the name of the camera in the scene
  40222. * @param position Define the start position of the camera in the scene
  40223. * @param scene Define the scene the camera belongs to
  40224. */
  40225. constructor(name: string, position: Vector3, scene: Scene);
  40226. /**
  40227. * Gets the current object class name.
  40228. * @return the class name
  40229. */
  40230. getClassName(): string;
  40231. }
  40232. }
  40233. declare module "babylonjs/Cameras/gamepadCamera" {
  40234. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40235. import { Scene } from "babylonjs/scene";
  40236. import { Vector3 } from "babylonjs/Maths/math.vector";
  40237. /**
  40238. * This represents a FPS type of camera. This is only here for back compat purpose.
  40239. * Please use the UniversalCamera instead as both are identical.
  40240. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40241. */
  40242. export class GamepadCamera extends UniversalCamera {
  40243. /**
  40244. * Instantiates a new Gamepad Camera
  40245. * This represents a FPS type of camera. This is only here for back compat purpose.
  40246. * Please use the UniversalCamera instead as both are identical.
  40247. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40248. * @param name Define the name of the camera in the scene
  40249. * @param position Define the start position of the camera in the scene
  40250. * @param scene Define the scene the camera belongs to
  40251. */
  40252. constructor(name: string, position: Vector3, scene: Scene);
  40253. /**
  40254. * Gets the current object class name.
  40255. * @return the class name
  40256. */
  40257. getClassName(): string;
  40258. }
  40259. }
  40260. declare module "babylonjs/Shaders/pass.fragment" {
  40261. /** @hidden */
  40262. export var passPixelShader: {
  40263. name: string;
  40264. shader: string;
  40265. };
  40266. }
  40267. declare module "babylonjs/Shaders/passCube.fragment" {
  40268. /** @hidden */
  40269. export var passCubePixelShader: {
  40270. name: string;
  40271. shader: string;
  40272. };
  40273. }
  40274. declare module "babylonjs/PostProcesses/passPostProcess" {
  40275. import { Nullable } from "babylonjs/types";
  40276. import { Camera } from "babylonjs/Cameras/camera";
  40277. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40278. import { Engine } from "babylonjs/Engines/engine";
  40279. import "babylonjs/Shaders/pass.fragment";
  40280. import "babylonjs/Shaders/passCube.fragment";
  40281. /**
  40282. * PassPostProcess which produces an output the same as it's input
  40283. */
  40284. export class PassPostProcess extends PostProcess {
  40285. /**
  40286. * Creates the PassPostProcess
  40287. * @param name The name of the effect.
  40288. * @param options The required width/height ratio to downsize to before computing the render pass.
  40289. * @param camera The camera to apply the render pass to.
  40290. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40291. * @param engine The engine which the post process will be applied. (default: current engine)
  40292. * @param reusable If the post process can be reused on the same frame. (default: false)
  40293. * @param textureType The type of texture to be used when performing the post processing.
  40294. * @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)
  40295. */
  40296. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40297. }
  40298. /**
  40299. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40300. */
  40301. export class PassCubePostProcess extends PostProcess {
  40302. private _face;
  40303. /**
  40304. * Gets or sets the cube face to display.
  40305. * * 0 is +X
  40306. * * 1 is -X
  40307. * * 2 is +Y
  40308. * * 3 is -Y
  40309. * * 4 is +Z
  40310. * * 5 is -Z
  40311. */
  40312. face: number;
  40313. /**
  40314. * Creates the PassCubePostProcess
  40315. * @param name The name of the effect.
  40316. * @param options The required width/height ratio to downsize to before computing the render pass.
  40317. * @param camera The camera to apply the render pass to.
  40318. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40319. * @param engine The engine which the post process will be applied. (default: current engine)
  40320. * @param reusable If the post process can be reused on the same frame. (default: false)
  40321. * @param textureType The type of texture to be used when performing the post processing.
  40322. * @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)
  40323. */
  40324. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40325. }
  40326. }
  40327. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40328. /** @hidden */
  40329. export var anaglyphPixelShader: {
  40330. name: string;
  40331. shader: string;
  40332. };
  40333. }
  40334. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40335. import { Engine } from "babylonjs/Engines/engine";
  40336. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40337. import { Camera } from "babylonjs/Cameras/camera";
  40338. import "babylonjs/Shaders/anaglyph.fragment";
  40339. /**
  40340. * Postprocess used to generate anaglyphic rendering
  40341. */
  40342. export class AnaglyphPostProcess extends PostProcess {
  40343. private _passedProcess;
  40344. /**
  40345. * Creates a new AnaglyphPostProcess
  40346. * @param name defines postprocess name
  40347. * @param options defines creation options or target ratio scale
  40348. * @param rigCameras defines cameras using this postprocess
  40349. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40350. * @param engine defines hosting engine
  40351. * @param reusable defines if the postprocess will be reused multiple times per frame
  40352. */
  40353. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40354. }
  40355. }
  40356. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40357. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40358. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40359. import { Scene } from "babylonjs/scene";
  40360. import { Vector3 } from "babylonjs/Maths/math.vector";
  40361. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40362. /**
  40363. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40364. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40365. */
  40366. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40367. /**
  40368. * Creates a new AnaglyphArcRotateCamera
  40369. * @param name defines camera name
  40370. * @param alpha defines alpha angle (in radians)
  40371. * @param beta defines beta angle (in radians)
  40372. * @param radius defines radius
  40373. * @param target defines camera target
  40374. * @param interaxialDistance defines distance between each color axis
  40375. * @param scene defines the hosting scene
  40376. */
  40377. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40378. /**
  40379. * Gets camera class name
  40380. * @returns AnaglyphArcRotateCamera
  40381. */
  40382. getClassName(): string;
  40383. }
  40384. }
  40385. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40386. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40387. import { Scene } from "babylonjs/scene";
  40388. import { Vector3 } from "babylonjs/Maths/math.vector";
  40389. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40390. /**
  40391. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40392. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40393. */
  40394. export class AnaglyphFreeCamera extends FreeCamera {
  40395. /**
  40396. * Creates a new AnaglyphFreeCamera
  40397. * @param name defines camera name
  40398. * @param position defines initial position
  40399. * @param interaxialDistance defines distance between each color axis
  40400. * @param scene defines the hosting scene
  40401. */
  40402. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40403. /**
  40404. * Gets camera class name
  40405. * @returns AnaglyphFreeCamera
  40406. */
  40407. getClassName(): string;
  40408. }
  40409. }
  40410. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40411. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40412. import { Scene } from "babylonjs/scene";
  40413. import { Vector3 } from "babylonjs/Maths/math.vector";
  40414. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40415. /**
  40416. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40417. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40418. */
  40419. export class AnaglyphGamepadCamera extends GamepadCamera {
  40420. /**
  40421. * Creates a new AnaglyphGamepadCamera
  40422. * @param name defines camera name
  40423. * @param position defines initial position
  40424. * @param interaxialDistance defines distance between each color axis
  40425. * @param scene defines the hosting scene
  40426. */
  40427. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40428. /**
  40429. * Gets camera class name
  40430. * @returns AnaglyphGamepadCamera
  40431. */
  40432. getClassName(): string;
  40433. }
  40434. }
  40435. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40436. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40437. import { Scene } from "babylonjs/scene";
  40438. import { Vector3 } from "babylonjs/Maths/math.vector";
  40439. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40440. /**
  40441. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40442. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40443. */
  40444. export class AnaglyphUniversalCamera extends UniversalCamera {
  40445. /**
  40446. * Creates a new AnaglyphUniversalCamera
  40447. * @param name defines camera name
  40448. * @param position defines initial position
  40449. * @param interaxialDistance defines distance between each color axis
  40450. * @param scene defines the hosting scene
  40451. */
  40452. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40453. /**
  40454. * Gets camera class name
  40455. * @returns AnaglyphUniversalCamera
  40456. */
  40457. getClassName(): string;
  40458. }
  40459. }
  40460. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40461. /** @hidden */
  40462. export var stereoscopicInterlacePixelShader: {
  40463. name: string;
  40464. shader: string;
  40465. };
  40466. }
  40467. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40468. import { Camera } from "babylonjs/Cameras/camera";
  40469. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40470. import { Engine } from "babylonjs/Engines/engine";
  40471. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40472. /**
  40473. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40474. */
  40475. export class StereoscopicInterlacePostProcess extends PostProcess {
  40476. private _stepSize;
  40477. private _passedProcess;
  40478. /**
  40479. * Initializes a StereoscopicInterlacePostProcess
  40480. * @param name The name of the effect.
  40481. * @param rigCameras The rig cameras to be appled to the post process
  40482. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40483. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40484. * @param engine The engine which the post process will be applied. (default: current engine)
  40485. * @param reusable If the post process can be reused on the same frame. (default: false)
  40486. */
  40487. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40488. }
  40489. }
  40490. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40491. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40492. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40493. import { Scene } from "babylonjs/scene";
  40494. import { Vector3 } from "babylonjs/Maths/math.vector";
  40495. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40496. /**
  40497. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40498. * @see http://doc.babylonjs.com/features/cameras
  40499. */
  40500. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40501. /**
  40502. * Creates a new StereoscopicArcRotateCamera
  40503. * @param name defines camera name
  40504. * @param alpha defines alpha angle (in radians)
  40505. * @param beta defines beta angle (in radians)
  40506. * @param radius defines radius
  40507. * @param target defines camera target
  40508. * @param interaxialDistance defines distance between each color axis
  40509. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40510. * @param scene defines the hosting scene
  40511. */
  40512. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40513. /**
  40514. * Gets camera class name
  40515. * @returns StereoscopicArcRotateCamera
  40516. */
  40517. getClassName(): string;
  40518. }
  40519. }
  40520. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40521. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40522. import { Scene } from "babylonjs/scene";
  40523. import { Vector3 } from "babylonjs/Maths/math.vector";
  40524. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40525. /**
  40526. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40527. * @see http://doc.babylonjs.com/features/cameras
  40528. */
  40529. export class StereoscopicFreeCamera extends FreeCamera {
  40530. /**
  40531. * Creates a new StereoscopicFreeCamera
  40532. * @param name defines camera name
  40533. * @param position defines initial position
  40534. * @param interaxialDistance defines distance between each color axis
  40535. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40536. * @param scene defines the hosting scene
  40537. */
  40538. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40539. /**
  40540. * Gets camera class name
  40541. * @returns StereoscopicFreeCamera
  40542. */
  40543. getClassName(): string;
  40544. }
  40545. }
  40546. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40547. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40548. import { Scene } from "babylonjs/scene";
  40549. import { Vector3 } from "babylonjs/Maths/math.vector";
  40550. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40551. /**
  40552. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40553. * @see http://doc.babylonjs.com/features/cameras
  40554. */
  40555. export class StereoscopicGamepadCamera extends GamepadCamera {
  40556. /**
  40557. * Creates a new StereoscopicGamepadCamera
  40558. * @param name defines camera name
  40559. * @param position defines initial position
  40560. * @param interaxialDistance defines distance between each color axis
  40561. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40562. * @param scene defines the hosting scene
  40563. */
  40564. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40565. /**
  40566. * Gets camera class name
  40567. * @returns StereoscopicGamepadCamera
  40568. */
  40569. getClassName(): string;
  40570. }
  40571. }
  40572. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40573. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40574. import { Scene } from "babylonjs/scene";
  40575. import { Vector3 } from "babylonjs/Maths/math.vector";
  40576. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40577. /**
  40578. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40579. * @see http://doc.babylonjs.com/features/cameras
  40580. */
  40581. export class StereoscopicUniversalCamera extends UniversalCamera {
  40582. /**
  40583. * Creates a new StereoscopicUniversalCamera
  40584. * @param name defines camera name
  40585. * @param position defines initial position
  40586. * @param interaxialDistance defines distance between each color axis
  40587. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40588. * @param scene defines the hosting scene
  40589. */
  40590. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40591. /**
  40592. * Gets camera class name
  40593. * @returns StereoscopicUniversalCamera
  40594. */
  40595. getClassName(): string;
  40596. }
  40597. }
  40598. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40599. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40600. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40601. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40602. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40603. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40604. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40605. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40606. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40607. }
  40608. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40609. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40610. import { Scene } from "babylonjs/scene";
  40611. import { Vector3 } from "babylonjs/Maths/math.vector";
  40612. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40613. /**
  40614. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40615. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40616. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40617. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40618. */
  40619. export class VirtualJoysticksCamera extends FreeCamera {
  40620. /**
  40621. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40622. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40623. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40624. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40625. * @param name Define the name of the camera in the scene
  40626. * @param position Define the start position of the camera in the scene
  40627. * @param scene Define the scene the camera belongs to
  40628. */
  40629. constructor(name: string, position: Vector3, scene: Scene);
  40630. /**
  40631. * Gets the current object class name.
  40632. * @return the class name
  40633. */
  40634. getClassName(): string;
  40635. }
  40636. }
  40637. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40638. import { Matrix } from "babylonjs/Maths/math.vector";
  40639. /**
  40640. * This represents all the required metrics to create a VR camera.
  40641. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40642. */
  40643. export class VRCameraMetrics {
  40644. /**
  40645. * Define the horizontal resolution off the screen.
  40646. */
  40647. hResolution: number;
  40648. /**
  40649. * Define the vertical resolution off the screen.
  40650. */
  40651. vResolution: number;
  40652. /**
  40653. * Define the horizontal screen size.
  40654. */
  40655. hScreenSize: number;
  40656. /**
  40657. * Define the vertical screen size.
  40658. */
  40659. vScreenSize: number;
  40660. /**
  40661. * Define the vertical screen center position.
  40662. */
  40663. vScreenCenter: number;
  40664. /**
  40665. * Define the distance of the eyes to the screen.
  40666. */
  40667. eyeToScreenDistance: number;
  40668. /**
  40669. * Define the distance between both lenses
  40670. */
  40671. lensSeparationDistance: number;
  40672. /**
  40673. * Define the distance between both viewer's eyes.
  40674. */
  40675. interpupillaryDistance: number;
  40676. /**
  40677. * Define the distortion factor of the VR postprocess.
  40678. * Please, touch with care.
  40679. */
  40680. distortionK: number[];
  40681. /**
  40682. * Define the chromatic aberration correction factors for the VR post process.
  40683. */
  40684. chromaAbCorrection: number[];
  40685. /**
  40686. * Define the scale factor of the post process.
  40687. * The smaller the better but the slower.
  40688. */
  40689. postProcessScaleFactor: number;
  40690. /**
  40691. * Define an offset for the lens center.
  40692. */
  40693. lensCenterOffset: number;
  40694. /**
  40695. * Define if the current vr camera should compensate the distortion of the lense or not.
  40696. */
  40697. compensateDistortion: boolean;
  40698. /**
  40699. * Defines if multiview should be enabled when rendering (Default: false)
  40700. */
  40701. multiviewEnabled: boolean;
  40702. /**
  40703. * Gets the rendering aspect ratio based on the provided resolutions.
  40704. */
  40705. readonly aspectRatio: number;
  40706. /**
  40707. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40708. */
  40709. readonly aspectRatioFov: number;
  40710. /**
  40711. * @hidden
  40712. */
  40713. readonly leftHMatrix: Matrix;
  40714. /**
  40715. * @hidden
  40716. */
  40717. readonly rightHMatrix: Matrix;
  40718. /**
  40719. * @hidden
  40720. */
  40721. readonly leftPreViewMatrix: Matrix;
  40722. /**
  40723. * @hidden
  40724. */
  40725. readonly rightPreViewMatrix: Matrix;
  40726. /**
  40727. * Get the default VRMetrics based on the most generic setup.
  40728. * @returns the default vr metrics
  40729. */
  40730. static GetDefault(): VRCameraMetrics;
  40731. }
  40732. }
  40733. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40734. /** @hidden */
  40735. export var vrDistortionCorrectionPixelShader: {
  40736. name: string;
  40737. shader: string;
  40738. };
  40739. }
  40740. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  40741. import { Camera } from "babylonjs/Cameras/camera";
  40742. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40743. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40744. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  40745. /**
  40746. * VRDistortionCorrectionPostProcess used for mobile VR
  40747. */
  40748. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40749. private _isRightEye;
  40750. private _distortionFactors;
  40751. private _postProcessScaleFactor;
  40752. private _lensCenterOffset;
  40753. private _scaleIn;
  40754. private _scaleFactor;
  40755. private _lensCenter;
  40756. /**
  40757. * Initializes the VRDistortionCorrectionPostProcess
  40758. * @param name The name of the effect.
  40759. * @param camera The camera to apply the render pass to.
  40760. * @param isRightEye If this is for the right eye distortion
  40761. * @param vrMetrics All the required metrics for the VR camera
  40762. */
  40763. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40764. }
  40765. }
  40766. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40767. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40768. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40769. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40770. import { Scene } from "babylonjs/scene";
  40771. import { Vector3 } from "babylonjs/Maths/math.vector";
  40772. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40773. import "babylonjs/Cameras/RigModes/vrRigMode";
  40774. /**
  40775. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40776. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40777. */
  40778. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40779. /**
  40780. * Creates a new VRDeviceOrientationArcRotateCamera
  40781. * @param name defines camera name
  40782. * @param alpha defines the camera rotation along the logitudinal axis
  40783. * @param beta defines the camera rotation along the latitudinal axis
  40784. * @param radius defines the camera distance from its target
  40785. * @param target defines the camera target
  40786. * @param scene defines the scene the camera belongs to
  40787. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40788. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40789. */
  40790. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40791. /**
  40792. * Gets camera class name
  40793. * @returns VRDeviceOrientationArcRotateCamera
  40794. */
  40795. getClassName(): string;
  40796. }
  40797. }
  40798. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40799. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40800. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40801. import { Scene } from "babylonjs/scene";
  40802. import { Vector3 } from "babylonjs/Maths/math.vector";
  40803. import "babylonjs/Cameras/RigModes/vrRigMode";
  40804. /**
  40805. * Camera used to simulate VR rendering (based on FreeCamera)
  40806. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40807. */
  40808. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40809. /**
  40810. * Creates a new VRDeviceOrientationFreeCamera
  40811. * @param name defines camera name
  40812. * @param position defines the start position of the camera
  40813. * @param scene defines the scene the camera belongs to
  40814. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40815. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40816. */
  40817. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40818. /**
  40819. * Gets camera class name
  40820. * @returns VRDeviceOrientationFreeCamera
  40821. */
  40822. getClassName(): string;
  40823. }
  40824. }
  40825. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40826. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40827. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40828. import { Scene } from "babylonjs/scene";
  40829. import { Vector3 } from "babylonjs/Maths/math.vector";
  40830. import "babylonjs/Gamepads/gamepadSceneComponent";
  40831. /**
  40832. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40833. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40834. */
  40835. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40836. /**
  40837. * Creates a new VRDeviceOrientationGamepadCamera
  40838. * @param name defines camera name
  40839. * @param position defines the start position of the camera
  40840. * @param scene defines the scene the camera belongs to
  40841. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40842. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40843. */
  40844. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40845. /**
  40846. * Gets camera class name
  40847. * @returns VRDeviceOrientationGamepadCamera
  40848. */
  40849. getClassName(): string;
  40850. }
  40851. }
  40852. declare module "babylonjs/Materials/pushMaterial" {
  40853. import { Nullable } from "babylonjs/types";
  40854. import { Scene } from "babylonjs/scene";
  40855. import { Matrix } from "babylonjs/Maths/math.vector";
  40856. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40857. import { Mesh } from "babylonjs/Meshes/mesh";
  40858. import { Material } from "babylonjs/Materials/material";
  40859. import { Effect } from "babylonjs/Materials/effect";
  40860. /**
  40861. * Base class of materials working in push mode in babylon JS
  40862. * @hidden
  40863. */
  40864. export class PushMaterial extends Material {
  40865. protected _activeEffect: Effect;
  40866. protected _normalMatrix: Matrix;
  40867. /**
  40868. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40869. * This means that the material can keep using a previous shader while a new one is being compiled.
  40870. * This is mostly used when shader parallel compilation is supported (true by default)
  40871. */
  40872. allowShaderHotSwapping: boolean;
  40873. constructor(name: string, scene: Scene);
  40874. getEffect(): Effect;
  40875. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40876. /**
  40877. * Binds the given world matrix to the active effect
  40878. *
  40879. * @param world the matrix to bind
  40880. */
  40881. bindOnlyWorldMatrix(world: Matrix): void;
  40882. /**
  40883. * Binds the given normal matrix to the active effect
  40884. *
  40885. * @param normalMatrix the matrix to bind
  40886. */
  40887. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40888. bind(world: Matrix, mesh?: Mesh): void;
  40889. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40890. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40891. }
  40892. }
  40893. declare module "babylonjs/Materials/materialFlags" {
  40894. /**
  40895. * This groups all the flags used to control the materials channel.
  40896. */
  40897. export class MaterialFlags {
  40898. private static _DiffuseTextureEnabled;
  40899. /**
  40900. * Are diffuse textures enabled in the application.
  40901. */
  40902. static DiffuseTextureEnabled: boolean;
  40903. private static _AmbientTextureEnabled;
  40904. /**
  40905. * Are ambient textures enabled in the application.
  40906. */
  40907. static AmbientTextureEnabled: boolean;
  40908. private static _OpacityTextureEnabled;
  40909. /**
  40910. * Are opacity textures enabled in the application.
  40911. */
  40912. static OpacityTextureEnabled: boolean;
  40913. private static _ReflectionTextureEnabled;
  40914. /**
  40915. * Are reflection textures enabled in the application.
  40916. */
  40917. static ReflectionTextureEnabled: boolean;
  40918. private static _EmissiveTextureEnabled;
  40919. /**
  40920. * Are emissive textures enabled in the application.
  40921. */
  40922. static EmissiveTextureEnabled: boolean;
  40923. private static _SpecularTextureEnabled;
  40924. /**
  40925. * Are specular textures enabled in the application.
  40926. */
  40927. static SpecularTextureEnabled: boolean;
  40928. private static _BumpTextureEnabled;
  40929. /**
  40930. * Are bump textures enabled in the application.
  40931. */
  40932. static BumpTextureEnabled: boolean;
  40933. private static _LightmapTextureEnabled;
  40934. /**
  40935. * Are lightmap textures enabled in the application.
  40936. */
  40937. static LightmapTextureEnabled: boolean;
  40938. private static _RefractionTextureEnabled;
  40939. /**
  40940. * Are refraction textures enabled in the application.
  40941. */
  40942. static RefractionTextureEnabled: boolean;
  40943. private static _ColorGradingTextureEnabled;
  40944. /**
  40945. * Are color grading textures enabled in the application.
  40946. */
  40947. static ColorGradingTextureEnabled: boolean;
  40948. private static _FresnelEnabled;
  40949. /**
  40950. * Are fresnels enabled in the application.
  40951. */
  40952. static FresnelEnabled: boolean;
  40953. private static _ClearCoatTextureEnabled;
  40954. /**
  40955. * Are clear coat textures enabled in the application.
  40956. */
  40957. static ClearCoatTextureEnabled: boolean;
  40958. private static _ClearCoatBumpTextureEnabled;
  40959. /**
  40960. * Are clear coat bump textures enabled in the application.
  40961. */
  40962. static ClearCoatBumpTextureEnabled: boolean;
  40963. private static _ClearCoatTintTextureEnabled;
  40964. /**
  40965. * Are clear coat tint textures enabled in the application.
  40966. */
  40967. static ClearCoatTintTextureEnabled: boolean;
  40968. private static _SheenTextureEnabled;
  40969. /**
  40970. * Are sheen textures enabled in the application.
  40971. */
  40972. static SheenTextureEnabled: boolean;
  40973. private static _AnisotropicTextureEnabled;
  40974. /**
  40975. * Are anisotropic textures enabled in the application.
  40976. */
  40977. static AnisotropicTextureEnabled: boolean;
  40978. private static _ThicknessTextureEnabled;
  40979. /**
  40980. * Are thickness textures enabled in the application.
  40981. */
  40982. static ThicknessTextureEnabled: boolean;
  40983. }
  40984. }
  40985. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40986. /** @hidden */
  40987. export var defaultFragmentDeclaration: {
  40988. name: string;
  40989. shader: string;
  40990. };
  40991. }
  40992. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40993. /** @hidden */
  40994. export var defaultUboDeclaration: {
  40995. name: string;
  40996. shader: string;
  40997. };
  40998. }
  40999. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41000. /** @hidden */
  41001. export var lightFragmentDeclaration: {
  41002. name: string;
  41003. shader: string;
  41004. };
  41005. }
  41006. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41007. /** @hidden */
  41008. export var lightUboDeclaration: {
  41009. name: string;
  41010. shader: string;
  41011. };
  41012. }
  41013. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41014. /** @hidden */
  41015. export var lightsFragmentFunctions: {
  41016. name: string;
  41017. shader: string;
  41018. };
  41019. }
  41020. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41021. /** @hidden */
  41022. export var shadowsFragmentFunctions: {
  41023. name: string;
  41024. shader: string;
  41025. };
  41026. }
  41027. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41028. /** @hidden */
  41029. export var fresnelFunction: {
  41030. name: string;
  41031. shader: string;
  41032. };
  41033. }
  41034. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41035. /** @hidden */
  41036. export var reflectionFunction: {
  41037. name: string;
  41038. shader: string;
  41039. };
  41040. }
  41041. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41042. /** @hidden */
  41043. export var bumpFragmentFunctions: {
  41044. name: string;
  41045. shader: string;
  41046. };
  41047. }
  41048. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41049. /** @hidden */
  41050. export var logDepthDeclaration: {
  41051. name: string;
  41052. shader: string;
  41053. };
  41054. }
  41055. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41056. /** @hidden */
  41057. export var bumpFragment: {
  41058. name: string;
  41059. shader: string;
  41060. };
  41061. }
  41062. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41063. /** @hidden */
  41064. export var depthPrePass: {
  41065. name: string;
  41066. shader: string;
  41067. };
  41068. }
  41069. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41070. /** @hidden */
  41071. export var lightFragment: {
  41072. name: string;
  41073. shader: string;
  41074. };
  41075. }
  41076. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41077. /** @hidden */
  41078. export var logDepthFragment: {
  41079. name: string;
  41080. shader: string;
  41081. };
  41082. }
  41083. declare module "babylonjs/Shaders/default.fragment" {
  41084. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41085. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41086. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41087. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41088. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41089. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41090. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41091. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41092. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41093. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41094. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41095. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41096. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41097. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41098. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41099. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41100. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41101. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41102. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41103. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41104. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41105. /** @hidden */
  41106. export var defaultPixelShader: {
  41107. name: string;
  41108. shader: string;
  41109. };
  41110. }
  41111. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41112. /** @hidden */
  41113. export var defaultVertexDeclaration: {
  41114. name: string;
  41115. shader: string;
  41116. };
  41117. }
  41118. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41119. /** @hidden */
  41120. export var bumpVertexDeclaration: {
  41121. name: string;
  41122. shader: string;
  41123. };
  41124. }
  41125. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41126. /** @hidden */
  41127. export var bumpVertex: {
  41128. name: string;
  41129. shader: string;
  41130. };
  41131. }
  41132. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41133. /** @hidden */
  41134. export var fogVertex: {
  41135. name: string;
  41136. shader: string;
  41137. };
  41138. }
  41139. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41140. /** @hidden */
  41141. export var shadowsVertex: {
  41142. name: string;
  41143. shader: string;
  41144. };
  41145. }
  41146. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41147. /** @hidden */
  41148. export var pointCloudVertex: {
  41149. name: string;
  41150. shader: string;
  41151. };
  41152. }
  41153. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41154. /** @hidden */
  41155. export var logDepthVertex: {
  41156. name: string;
  41157. shader: string;
  41158. };
  41159. }
  41160. declare module "babylonjs/Shaders/default.vertex" {
  41161. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41162. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41163. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41164. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41165. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41166. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41167. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41168. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41169. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41170. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41171. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41172. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41173. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41174. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41175. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41176. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41177. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41178. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41179. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41180. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41181. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41182. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41183. /** @hidden */
  41184. export var defaultVertexShader: {
  41185. name: string;
  41186. shader: string;
  41187. };
  41188. }
  41189. declare module "babylonjs/Materials/standardMaterial" {
  41190. import { SmartArray } from "babylonjs/Misc/smartArray";
  41191. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41192. import { Nullable } from "babylonjs/types";
  41193. import { Scene } from "babylonjs/scene";
  41194. import { Matrix } from "babylonjs/Maths/math.vector";
  41195. import { Color3 } from "babylonjs/Maths/math.color";
  41196. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41198. import { Mesh } from "babylonjs/Meshes/mesh";
  41199. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41200. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41201. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41202. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41203. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41204. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41205. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41206. import "babylonjs/Shaders/default.fragment";
  41207. import "babylonjs/Shaders/default.vertex";
  41208. /** @hidden */
  41209. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41210. MAINUV1: boolean;
  41211. MAINUV2: boolean;
  41212. DIFFUSE: boolean;
  41213. DIFFUSEDIRECTUV: number;
  41214. AMBIENT: boolean;
  41215. AMBIENTDIRECTUV: number;
  41216. OPACITY: boolean;
  41217. OPACITYDIRECTUV: number;
  41218. OPACITYRGB: boolean;
  41219. REFLECTION: boolean;
  41220. EMISSIVE: boolean;
  41221. EMISSIVEDIRECTUV: number;
  41222. SPECULAR: boolean;
  41223. SPECULARDIRECTUV: number;
  41224. BUMP: boolean;
  41225. BUMPDIRECTUV: number;
  41226. PARALLAX: boolean;
  41227. PARALLAXOCCLUSION: boolean;
  41228. SPECULAROVERALPHA: boolean;
  41229. CLIPPLANE: boolean;
  41230. CLIPPLANE2: boolean;
  41231. CLIPPLANE3: boolean;
  41232. CLIPPLANE4: boolean;
  41233. ALPHATEST: boolean;
  41234. DEPTHPREPASS: boolean;
  41235. ALPHAFROMDIFFUSE: boolean;
  41236. POINTSIZE: boolean;
  41237. FOG: boolean;
  41238. SPECULARTERM: boolean;
  41239. DIFFUSEFRESNEL: boolean;
  41240. OPACITYFRESNEL: boolean;
  41241. REFLECTIONFRESNEL: boolean;
  41242. REFRACTIONFRESNEL: boolean;
  41243. EMISSIVEFRESNEL: boolean;
  41244. FRESNEL: boolean;
  41245. NORMAL: boolean;
  41246. UV1: boolean;
  41247. UV2: boolean;
  41248. VERTEXCOLOR: boolean;
  41249. VERTEXALPHA: boolean;
  41250. NUM_BONE_INFLUENCERS: number;
  41251. BonesPerMesh: number;
  41252. BONETEXTURE: boolean;
  41253. INSTANCES: boolean;
  41254. GLOSSINESS: boolean;
  41255. ROUGHNESS: boolean;
  41256. EMISSIVEASILLUMINATION: boolean;
  41257. LINKEMISSIVEWITHDIFFUSE: boolean;
  41258. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41259. LIGHTMAP: boolean;
  41260. LIGHTMAPDIRECTUV: number;
  41261. OBJECTSPACE_NORMALMAP: boolean;
  41262. USELIGHTMAPASSHADOWMAP: boolean;
  41263. REFLECTIONMAP_3D: boolean;
  41264. REFLECTIONMAP_SPHERICAL: boolean;
  41265. REFLECTIONMAP_PLANAR: boolean;
  41266. REFLECTIONMAP_CUBIC: boolean;
  41267. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41268. REFLECTIONMAP_PROJECTION: boolean;
  41269. REFLECTIONMAP_SKYBOX: boolean;
  41270. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41271. REFLECTIONMAP_EXPLICIT: boolean;
  41272. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41273. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41274. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41275. INVERTCUBICMAP: boolean;
  41276. LOGARITHMICDEPTH: boolean;
  41277. REFRACTION: boolean;
  41278. REFRACTIONMAP_3D: boolean;
  41279. REFLECTIONOVERALPHA: boolean;
  41280. TWOSIDEDLIGHTING: boolean;
  41281. SHADOWFLOAT: boolean;
  41282. MORPHTARGETS: boolean;
  41283. MORPHTARGETS_NORMAL: boolean;
  41284. MORPHTARGETS_TANGENT: boolean;
  41285. MORPHTARGETS_UV: boolean;
  41286. NUM_MORPH_INFLUENCERS: number;
  41287. NONUNIFORMSCALING: boolean;
  41288. PREMULTIPLYALPHA: boolean;
  41289. IMAGEPROCESSING: boolean;
  41290. VIGNETTE: boolean;
  41291. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41292. VIGNETTEBLENDMODEOPAQUE: boolean;
  41293. TONEMAPPING: boolean;
  41294. TONEMAPPING_ACES: boolean;
  41295. CONTRAST: boolean;
  41296. COLORCURVES: boolean;
  41297. COLORGRADING: boolean;
  41298. COLORGRADING3D: boolean;
  41299. SAMPLER3DGREENDEPTH: boolean;
  41300. SAMPLER3DBGRMAP: boolean;
  41301. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41302. MULTIVIEW: boolean;
  41303. /**
  41304. * If the reflection texture on this material is in linear color space
  41305. * @hidden
  41306. */
  41307. IS_REFLECTION_LINEAR: boolean;
  41308. /**
  41309. * If the refraction texture on this material is in linear color space
  41310. * @hidden
  41311. */
  41312. IS_REFRACTION_LINEAR: boolean;
  41313. EXPOSURE: boolean;
  41314. constructor();
  41315. setReflectionMode(modeToEnable: string): void;
  41316. }
  41317. /**
  41318. * This is the default material used in Babylon. It is the best trade off between quality
  41319. * and performances.
  41320. * @see http://doc.babylonjs.com/babylon101/materials
  41321. */
  41322. export class StandardMaterial extends PushMaterial {
  41323. private _diffuseTexture;
  41324. /**
  41325. * The basic texture of the material as viewed under a light.
  41326. */
  41327. diffuseTexture: Nullable<BaseTexture>;
  41328. private _ambientTexture;
  41329. /**
  41330. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41331. */
  41332. ambientTexture: Nullable<BaseTexture>;
  41333. private _opacityTexture;
  41334. /**
  41335. * Define the transparency of the material from a texture.
  41336. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41337. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41338. */
  41339. opacityTexture: Nullable<BaseTexture>;
  41340. private _reflectionTexture;
  41341. /**
  41342. * Define the texture used to display the reflection.
  41343. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41344. */
  41345. reflectionTexture: Nullable<BaseTexture>;
  41346. private _emissiveTexture;
  41347. /**
  41348. * Define texture of the material as if self lit.
  41349. * This will be mixed in the final result even in the absence of light.
  41350. */
  41351. emissiveTexture: Nullable<BaseTexture>;
  41352. private _specularTexture;
  41353. /**
  41354. * Define how the color and intensity of the highlight given by the light in the material.
  41355. */
  41356. specularTexture: Nullable<BaseTexture>;
  41357. private _bumpTexture;
  41358. /**
  41359. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41360. * 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.
  41361. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41362. */
  41363. bumpTexture: Nullable<BaseTexture>;
  41364. private _lightmapTexture;
  41365. /**
  41366. * Complex lighting can be computationally expensive to compute at runtime.
  41367. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41368. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41369. */
  41370. lightmapTexture: Nullable<BaseTexture>;
  41371. private _refractionTexture;
  41372. /**
  41373. * Define the texture used to display the refraction.
  41374. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41375. */
  41376. refractionTexture: Nullable<BaseTexture>;
  41377. /**
  41378. * The color of the material lit by the environmental background lighting.
  41379. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41380. */
  41381. ambientColor: Color3;
  41382. /**
  41383. * The basic color of the material as viewed under a light.
  41384. */
  41385. diffuseColor: Color3;
  41386. /**
  41387. * Define how the color and intensity of the highlight given by the light in the material.
  41388. */
  41389. specularColor: Color3;
  41390. /**
  41391. * Define the color of the material as if self lit.
  41392. * This will be mixed in the final result even in the absence of light.
  41393. */
  41394. emissiveColor: Color3;
  41395. /**
  41396. * Defines how sharp are the highlights in the material.
  41397. * The bigger the value the sharper giving a more glossy feeling to the result.
  41398. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41399. */
  41400. specularPower: number;
  41401. private _useAlphaFromDiffuseTexture;
  41402. /**
  41403. * Does the transparency come from the diffuse texture alpha channel.
  41404. */
  41405. useAlphaFromDiffuseTexture: boolean;
  41406. private _useEmissiveAsIllumination;
  41407. /**
  41408. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41409. */
  41410. useEmissiveAsIllumination: boolean;
  41411. private _linkEmissiveWithDiffuse;
  41412. /**
  41413. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41414. * the emissive level when the final color is close to one.
  41415. */
  41416. linkEmissiveWithDiffuse: boolean;
  41417. private _useSpecularOverAlpha;
  41418. /**
  41419. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41420. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41421. */
  41422. useSpecularOverAlpha: boolean;
  41423. private _useReflectionOverAlpha;
  41424. /**
  41425. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41426. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41427. */
  41428. useReflectionOverAlpha: boolean;
  41429. private _disableLighting;
  41430. /**
  41431. * Does lights from the scene impacts this material.
  41432. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41433. */
  41434. disableLighting: boolean;
  41435. private _useObjectSpaceNormalMap;
  41436. /**
  41437. * Allows using an object space normal map (instead of tangent space).
  41438. */
  41439. useObjectSpaceNormalMap: boolean;
  41440. private _useParallax;
  41441. /**
  41442. * Is parallax enabled or not.
  41443. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41444. */
  41445. useParallax: boolean;
  41446. private _useParallaxOcclusion;
  41447. /**
  41448. * Is parallax occlusion enabled or not.
  41449. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41450. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41451. */
  41452. useParallaxOcclusion: boolean;
  41453. /**
  41454. * 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.
  41455. */
  41456. parallaxScaleBias: number;
  41457. private _roughness;
  41458. /**
  41459. * Helps to define how blurry the reflections should appears in the material.
  41460. */
  41461. roughness: number;
  41462. /**
  41463. * In case of refraction, define the value of the index of refraction.
  41464. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41465. */
  41466. indexOfRefraction: number;
  41467. /**
  41468. * Invert the refraction texture alongside the y axis.
  41469. * It can be useful with procedural textures or probe for instance.
  41470. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41471. */
  41472. invertRefractionY: boolean;
  41473. /**
  41474. * Defines the alpha limits in alpha test mode.
  41475. */
  41476. alphaCutOff: number;
  41477. private _useLightmapAsShadowmap;
  41478. /**
  41479. * In case of light mapping, define whether the map contains light or shadow informations.
  41480. */
  41481. useLightmapAsShadowmap: boolean;
  41482. private _diffuseFresnelParameters;
  41483. /**
  41484. * Define the diffuse fresnel parameters of the material.
  41485. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41486. */
  41487. diffuseFresnelParameters: FresnelParameters;
  41488. private _opacityFresnelParameters;
  41489. /**
  41490. * Define the opacity fresnel parameters of the material.
  41491. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41492. */
  41493. opacityFresnelParameters: FresnelParameters;
  41494. private _reflectionFresnelParameters;
  41495. /**
  41496. * Define the reflection fresnel parameters of the material.
  41497. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41498. */
  41499. reflectionFresnelParameters: FresnelParameters;
  41500. private _refractionFresnelParameters;
  41501. /**
  41502. * Define the refraction fresnel parameters of the material.
  41503. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41504. */
  41505. refractionFresnelParameters: FresnelParameters;
  41506. private _emissiveFresnelParameters;
  41507. /**
  41508. * Define the emissive fresnel parameters of the material.
  41509. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41510. */
  41511. emissiveFresnelParameters: FresnelParameters;
  41512. private _useReflectionFresnelFromSpecular;
  41513. /**
  41514. * If true automatically deducts the fresnels values from the material specularity.
  41515. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41516. */
  41517. useReflectionFresnelFromSpecular: boolean;
  41518. private _useGlossinessFromSpecularMapAlpha;
  41519. /**
  41520. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41521. */
  41522. useGlossinessFromSpecularMapAlpha: boolean;
  41523. private _maxSimultaneousLights;
  41524. /**
  41525. * Defines the maximum number of lights that can be used in the material
  41526. */
  41527. maxSimultaneousLights: number;
  41528. private _invertNormalMapX;
  41529. /**
  41530. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41531. */
  41532. invertNormalMapX: boolean;
  41533. private _invertNormalMapY;
  41534. /**
  41535. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41536. */
  41537. invertNormalMapY: boolean;
  41538. private _twoSidedLighting;
  41539. /**
  41540. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41541. */
  41542. twoSidedLighting: boolean;
  41543. /**
  41544. * Default configuration related to image processing available in the standard Material.
  41545. */
  41546. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41547. /**
  41548. * Gets the image processing configuration used either in this material.
  41549. */
  41550. /**
  41551. * Sets the Default image processing configuration used either in the this material.
  41552. *
  41553. * If sets to null, the scene one is in use.
  41554. */
  41555. imageProcessingConfiguration: ImageProcessingConfiguration;
  41556. /**
  41557. * Keep track of the image processing observer to allow dispose and replace.
  41558. */
  41559. private _imageProcessingObserver;
  41560. /**
  41561. * Attaches a new image processing configuration to the Standard Material.
  41562. * @param configuration
  41563. */
  41564. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41565. /**
  41566. * Gets wether the color curves effect is enabled.
  41567. */
  41568. /**
  41569. * Sets wether the color curves effect is enabled.
  41570. */
  41571. cameraColorCurvesEnabled: boolean;
  41572. /**
  41573. * Gets wether the color grading effect is enabled.
  41574. */
  41575. /**
  41576. * Gets wether the color grading effect is enabled.
  41577. */
  41578. cameraColorGradingEnabled: boolean;
  41579. /**
  41580. * Gets wether tonemapping is enabled or not.
  41581. */
  41582. /**
  41583. * Sets wether tonemapping is enabled or not
  41584. */
  41585. cameraToneMappingEnabled: boolean;
  41586. /**
  41587. * The camera exposure used on this material.
  41588. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41589. * This corresponds to a photographic exposure.
  41590. */
  41591. /**
  41592. * The camera exposure used on this material.
  41593. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41594. * This corresponds to a photographic exposure.
  41595. */
  41596. cameraExposure: number;
  41597. /**
  41598. * Gets The camera contrast used on this material.
  41599. */
  41600. /**
  41601. * Sets The camera contrast used on this material.
  41602. */
  41603. cameraContrast: number;
  41604. /**
  41605. * Gets the Color Grading 2D Lookup Texture.
  41606. */
  41607. /**
  41608. * Sets the Color Grading 2D Lookup Texture.
  41609. */
  41610. cameraColorGradingTexture: Nullable<BaseTexture>;
  41611. /**
  41612. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41613. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41614. * 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;
  41615. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41616. */
  41617. /**
  41618. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41619. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41620. * 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;
  41621. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41622. */
  41623. cameraColorCurves: Nullable<ColorCurves>;
  41624. /**
  41625. * Custom callback helping to override the default shader used in the material.
  41626. */
  41627. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41628. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41629. protected _worldViewProjectionMatrix: Matrix;
  41630. protected _globalAmbientColor: Color3;
  41631. protected _useLogarithmicDepth: boolean;
  41632. protected _rebuildInParallel: boolean;
  41633. /**
  41634. * Instantiates a new standard material.
  41635. * This is the default material used in Babylon. It is the best trade off between quality
  41636. * and performances.
  41637. * @see http://doc.babylonjs.com/babylon101/materials
  41638. * @param name Define the name of the material in the scene
  41639. * @param scene Define the scene the material belong to
  41640. */
  41641. constructor(name: string, scene: Scene);
  41642. /**
  41643. * Gets a boolean indicating that current material needs to register RTT
  41644. */
  41645. readonly hasRenderTargetTextures: boolean;
  41646. /**
  41647. * Gets the current class name of the material e.g. "StandardMaterial"
  41648. * Mainly use in serialization.
  41649. * @returns the class name
  41650. */
  41651. getClassName(): string;
  41652. /**
  41653. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41654. * You can try switching to logarithmic depth.
  41655. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41656. */
  41657. useLogarithmicDepth: boolean;
  41658. /**
  41659. * Specifies if the material will require alpha blending
  41660. * @returns a boolean specifying if alpha blending is needed
  41661. */
  41662. needAlphaBlending(): boolean;
  41663. /**
  41664. * Specifies if this material should be rendered in alpha test mode
  41665. * @returns a boolean specifying if an alpha test is needed.
  41666. */
  41667. needAlphaTesting(): boolean;
  41668. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41669. /**
  41670. * Get the texture used for alpha test purpose.
  41671. * @returns the diffuse texture in case of the standard material.
  41672. */
  41673. getAlphaTestTexture(): Nullable<BaseTexture>;
  41674. /**
  41675. * Get if the submesh is ready to be used and all its information available.
  41676. * Child classes can use it to update shaders
  41677. * @param mesh defines the mesh to check
  41678. * @param subMesh defines which submesh to check
  41679. * @param useInstances specifies that instances should be used
  41680. * @returns a boolean indicating that the submesh is ready or not
  41681. */
  41682. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41683. /**
  41684. * Builds the material UBO layouts.
  41685. * Used internally during the effect preparation.
  41686. */
  41687. buildUniformLayout(): void;
  41688. /**
  41689. * Unbinds the material from the mesh
  41690. */
  41691. unbind(): void;
  41692. /**
  41693. * Binds the submesh to this material by preparing the effect and shader to draw
  41694. * @param world defines the world transformation matrix
  41695. * @param mesh defines the mesh containing the submesh
  41696. * @param subMesh defines the submesh to bind the material to
  41697. */
  41698. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41699. /**
  41700. * Get the list of animatables in the material.
  41701. * @returns the list of animatables object used in the material
  41702. */
  41703. getAnimatables(): IAnimatable[];
  41704. /**
  41705. * Gets the active textures from the material
  41706. * @returns an array of textures
  41707. */
  41708. getActiveTextures(): BaseTexture[];
  41709. /**
  41710. * Specifies if the material uses a texture
  41711. * @param texture defines the texture to check against the material
  41712. * @returns a boolean specifying if the material uses the texture
  41713. */
  41714. hasTexture(texture: BaseTexture): boolean;
  41715. /**
  41716. * Disposes the material
  41717. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41718. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41719. */
  41720. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41721. /**
  41722. * Makes a duplicate of the material, and gives it a new name
  41723. * @param name defines the new name for the duplicated material
  41724. * @returns the cloned material
  41725. */
  41726. clone(name: string): StandardMaterial;
  41727. /**
  41728. * Serializes this material in a JSON representation
  41729. * @returns the serialized material object
  41730. */
  41731. serialize(): any;
  41732. /**
  41733. * Creates a standard material from parsed material data
  41734. * @param source defines the JSON representation of the material
  41735. * @param scene defines the hosting scene
  41736. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41737. * @returns a new standard material
  41738. */
  41739. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41740. /**
  41741. * Are diffuse textures enabled in the application.
  41742. */
  41743. static DiffuseTextureEnabled: boolean;
  41744. /**
  41745. * Are ambient textures enabled in the application.
  41746. */
  41747. static AmbientTextureEnabled: boolean;
  41748. /**
  41749. * Are opacity textures enabled in the application.
  41750. */
  41751. static OpacityTextureEnabled: boolean;
  41752. /**
  41753. * Are reflection textures enabled in the application.
  41754. */
  41755. static ReflectionTextureEnabled: boolean;
  41756. /**
  41757. * Are emissive textures enabled in the application.
  41758. */
  41759. static EmissiveTextureEnabled: boolean;
  41760. /**
  41761. * Are specular textures enabled in the application.
  41762. */
  41763. static SpecularTextureEnabled: boolean;
  41764. /**
  41765. * Are bump textures enabled in the application.
  41766. */
  41767. static BumpTextureEnabled: boolean;
  41768. /**
  41769. * Are lightmap textures enabled in the application.
  41770. */
  41771. static LightmapTextureEnabled: boolean;
  41772. /**
  41773. * Are refraction textures enabled in the application.
  41774. */
  41775. static RefractionTextureEnabled: boolean;
  41776. /**
  41777. * Are color grading textures enabled in the application.
  41778. */
  41779. static ColorGradingTextureEnabled: boolean;
  41780. /**
  41781. * Are fresnels enabled in the application.
  41782. */
  41783. static FresnelEnabled: boolean;
  41784. }
  41785. }
  41786. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  41787. import { Scene } from "babylonjs/scene";
  41788. import { Texture } from "babylonjs/Materials/Textures/texture";
  41789. /**
  41790. * A class extending Texture allowing drawing on a texture
  41791. * @see http://doc.babylonjs.com/how_to/dynamictexture
  41792. */
  41793. export class DynamicTexture extends Texture {
  41794. private _generateMipMaps;
  41795. private _canvas;
  41796. private _context;
  41797. private _engine;
  41798. /**
  41799. * Creates a DynamicTexture
  41800. * @param name defines the name of the texture
  41801. * @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
  41802. * @param scene defines the scene where you want the texture
  41803. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  41804. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  41805. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  41806. */
  41807. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  41808. /**
  41809. * Get the current class name of the texture useful for serialization or dynamic coding.
  41810. * @returns "DynamicTexture"
  41811. */
  41812. getClassName(): string;
  41813. /**
  41814. * Gets the current state of canRescale
  41815. */
  41816. readonly canRescale: boolean;
  41817. private _recreate;
  41818. /**
  41819. * Scales the texture
  41820. * @param ratio the scale factor to apply to both width and height
  41821. */
  41822. scale(ratio: number): void;
  41823. /**
  41824. * Resizes the texture
  41825. * @param width the new width
  41826. * @param height the new height
  41827. */
  41828. scaleTo(width: number, height: number): void;
  41829. /**
  41830. * Gets the context of the canvas used by the texture
  41831. * @returns the canvas context of the dynamic texture
  41832. */
  41833. getContext(): CanvasRenderingContext2D;
  41834. /**
  41835. * Clears the texture
  41836. */
  41837. clear(): void;
  41838. /**
  41839. * Updates the texture
  41840. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41841. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41842. */
  41843. update(invertY?: boolean, premulAlpha?: boolean): void;
  41844. /**
  41845. * Draws text onto the texture
  41846. * @param text defines the text to be drawn
  41847. * @param x defines the placement of the text from the left
  41848. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41849. * @param font defines the font to be used with font-style, font-size, font-name
  41850. * @param color defines the color used for the text
  41851. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41852. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41853. * @param update defines whether texture is immediately update (default is true)
  41854. */
  41855. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41856. /**
  41857. * Clones the texture
  41858. * @returns the clone of the texture.
  41859. */
  41860. clone(): DynamicTexture;
  41861. /**
  41862. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41863. * @returns a serialized dynamic texture object
  41864. */
  41865. serialize(): any;
  41866. /** @hidden */
  41867. _rebuild(): void;
  41868. }
  41869. }
  41870. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41871. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41872. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41873. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41874. /** @hidden */
  41875. export var imageProcessingPixelShader: {
  41876. name: string;
  41877. shader: string;
  41878. };
  41879. }
  41880. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41881. import { Nullable } from "babylonjs/types";
  41882. import { Color4 } from "babylonjs/Maths/math.color";
  41883. import { Camera } from "babylonjs/Cameras/camera";
  41884. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41885. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41886. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41887. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41888. import { Engine } from "babylonjs/Engines/engine";
  41889. import "babylonjs/Shaders/imageProcessing.fragment";
  41890. import "babylonjs/Shaders/postprocess.vertex";
  41891. /**
  41892. * ImageProcessingPostProcess
  41893. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41894. */
  41895. export class ImageProcessingPostProcess extends PostProcess {
  41896. /**
  41897. * Default configuration related to image processing available in the PBR Material.
  41898. */
  41899. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41900. /**
  41901. * Gets the image processing configuration used either in this material.
  41902. */
  41903. /**
  41904. * Sets the Default image processing configuration used either in the this material.
  41905. *
  41906. * If sets to null, the scene one is in use.
  41907. */
  41908. imageProcessingConfiguration: ImageProcessingConfiguration;
  41909. /**
  41910. * Keep track of the image processing observer to allow dispose and replace.
  41911. */
  41912. private _imageProcessingObserver;
  41913. /**
  41914. * Attaches a new image processing configuration to the PBR Material.
  41915. * @param configuration
  41916. */
  41917. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41918. /**
  41919. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41920. */
  41921. /**
  41922. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41923. */
  41924. colorCurves: Nullable<ColorCurves>;
  41925. /**
  41926. * Gets wether the color curves effect is enabled.
  41927. */
  41928. /**
  41929. * Sets wether the color curves effect is enabled.
  41930. */
  41931. colorCurvesEnabled: boolean;
  41932. /**
  41933. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41934. */
  41935. /**
  41936. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41937. */
  41938. colorGradingTexture: Nullable<BaseTexture>;
  41939. /**
  41940. * Gets wether the color grading effect is enabled.
  41941. */
  41942. /**
  41943. * Gets wether the color grading effect is enabled.
  41944. */
  41945. colorGradingEnabled: boolean;
  41946. /**
  41947. * Gets exposure used in the effect.
  41948. */
  41949. /**
  41950. * Sets exposure used in the effect.
  41951. */
  41952. exposure: number;
  41953. /**
  41954. * Gets wether tonemapping is enabled or not.
  41955. */
  41956. /**
  41957. * Sets wether tonemapping is enabled or not
  41958. */
  41959. toneMappingEnabled: boolean;
  41960. /**
  41961. * Gets the type of tone mapping effect.
  41962. */
  41963. /**
  41964. * Sets the type of tone mapping effect.
  41965. */
  41966. toneMappingType: number;
  41967. /**
  41968. * Gets contrast used in the effect.
  41969. */
  41970. /**
  41971. * Sets contrast used in the effect.
  41972. */
  41973. contrast: number;
  41974. /**
  41975. * Gets Vignette stretch size.
  41976. */
  41977. /**
  41978. * Sets Vignette stretch size.
  41979. */
  41980. vignetteStretch: number;
  41981. /**
  41982. * Gets Vignette centre X Offset.
  41983. */
  41984. /**
  41985. * Sets Vignette centre X Offset.
  41986. */
  41987. vignetteCentreX: number;
  41988. /**
  41989. * Gets Vignette centre Y Offset.
  41990. */
  41991. /**
  41992. * Sets Vignette centre Y Offset.
  41993. */
  41994. vignetteCentreY: number;
  41995. /**
  41996. * Gets Vignette weight or intensity of the vignette effect.
  41997. */
  41998. /**
  41999. * Sets Vignette weight or intensity of the vignette effect.
  42000. */
  42001. vignetteWeight: number;
  42002. /**
  42003. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42004. * if vignetteEnabled is set to true.
  42005. */
  42006. /**
  42007. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42008. * if vignetteEnabled is set to true.
  42009. */
  42010. vignetteColor: Color4;
  42011. /**
  42012. * Gets Camera field of view used by the Vignette effect.
  42013. */
  42014. /**
  42015. * Sets Camera field of view used by the Vignette effect.
  42016. */
  42017. vignetteCameraFov: number;
  42018. /**
  42019. * Gets the vignette blend mode allowing different kind of effect.
  42020. */
  42021. /**
  42022. * Sets the vignette blend mode allowing different kind of effect.
  42023. */
  42024. vignetteBlendMode: number;
  42025. /**
  42026. * Gets wether the vignette effect is enabled.
  42027. */
  42028. /**
  42029. * Sets wether the vignette effect is enabled.
  42030. */
  42031. vignetteEnabled: boolean;
  42032. private _fromLinearSpace;
  42033. /**
  42034. * Gets wether the input of the processing is in Gamma or Linear Space.
  42035. */
  42036. /**
  42037. * Sets wether the input of the processing is in Gamma or Linear Space.
  42038. */
  42039. fromLinearSpace: boolean;
  42040. /**
  42041. * Defines cache preventing GC.
  42042. */
  42043. private _defines;
  42044. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42045. /**
  42046. * "ImageProcessingPostProcess"
  42047. * @returns "ImageProcessingPostProcess"
  42048. */
  42049. getClassName(): string;
  42050. protected _updateParameters(): void;
  42051. dispose(camera?: Camera): void;
  42052. }
  42053. }
  42054. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42055. import { Scene } from "babylonjs/scene";
  42056. import { Color3 } from "babylonjs/Maths/math.color";
  42057. import { Mesh } from "babylonjs/Meshes/mesh";
  42058. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42059. import { Nullable } from "babylonjs/types";
  42060. /**
  42061. * Class containing static functions to help procedurally build meshes
  42062. */
  42063. export class GroundBuilder {
  42064. /**
  42065. * Creates a ground mesh
  42066. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42067. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42069. * @param name defines the name of the mesh
  42070. * @param options defines the options used to create the mesh
  42071. * @param scene defines the hosting scene
  42072. * @returns the ground mesh
  42073. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42074. */
  42075. static CreateGround(name: string, options: {
  42076. width?: number;
  42077. height?: number;
  42078. subdivisions?: number;
  42079. subdivisionsX?: number;
  42080. subdivisionsY?: number;
  42081. updatable?: boolean;
  42082. }, scene: any): Mesh;
  42083. /**
  42084. * Creates a tiled ground mesh
  42085. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42086. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42087. * * 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
  42088. * * 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
  42089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42090. * @param name defines the name of the mesh
  42091. * @param options defines the options used to create the mesh
  42092. * @param scene defines the hosting scene
  42093. * @returns the tiled ground mesh
  42094. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42095. */
  42096. static CreateTiledGround(name: string, options: {
  42097. xmin: number;
  42098. zmin: number;
  42099. xmax: number;
  42100. zmax: number;
  42101. subdivisions?: {
  42102. w: number;
  42103. h: number;
  42104. };
  42105. precision?: {
  42106. w: number;
  42107. h: number;
  42108. };
  42109. updatable?: boolean;
  42110. }, scene?: Nullable<Scene>): Mesh;
  42111. /**
  42112. * Creates a ground mesh from a height map
  42113. * * The parameter `url` sets the URL of the height map image resource.
  42114. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42115. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42116. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42117. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42118. * * 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.
  42119. * * 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).
  42120. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42122. * @param name defines the name of the mesh
  42123. * @param url defines the url to the height map
  42124. * @param options defines the options used to create the mesh
  42125. * @param scene defines the hosting scene
  42126. * @returns the ground mesh
  42127. * @see https://doc.babylonjs.com/babylon101/height_map
  42128. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42129. */
  42130. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42131. width?: number;
  42132. height?: number;
  42133. subdivisions?: number;
  42134. minHeight?: number;
  42135. maxHeight?: number;
  42136. colorFilter?: Color3;
  42137. alphaFilter?: number;
  42138. updatable?: boolean;
  42139. onReady?: (mesh: GroundMesh) => void;
  42140. }, scene?: Nullable<Scene>): GroundMesh;
  42141. }
  42142. }
  42143. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42144. import { Vector4 } from "babylonjs/Maths/math.vector";
  42145. import { Mesh } from "babylonjs/Meshes/mesh";
  42146. /**
  42147. * Class containing static functions to help procedurally build meshes
  42148. */
  42149. export class TorusBuilder {
  42150. /**
  42151. * Creates a torus mesh
  42152. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42153. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42154. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42155. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42156. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42158. * @param name defines the name of the mesh
  42159. * @param options defines the options used to create the mesh
  42160. * @param scene defines the hosting scene
  42161. * @returns the torus mesh
  42162. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42163. */
  42164. static CreateTorus(name: string, options: {
  42165. diameter?: number;
  42166. thickness?: number;
  42167. tessellation?: number;
  42168. updatable?: boolean;
  42169. sideOrientation?: number;
  42170. frontUVs?: Vector4;
  42171. backUVs?: Vector4;
  42172. }, scene: any): Mesh;
  42173. }
  42174. }
  42175. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42176. import { Vector4 } from "babylonjs/Maths/math.vector";
  42177. import { Color4 } from "babylonjs/Maths/math.color";
  42178. import { Mesh } from "babylonjs/Meshes/mesh";
  42179. /**
  42180. * Class containing static functions to help procedurally build meshes
  42181. */
  42182. export class CylinderBuilder {
  42183. /**
  42184. * Creates a cylinder or a cone mesh
  42185. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42186. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42187. * * 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.
  42188. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42189. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42190. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42191. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42192. * * 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).
  42193. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42194. * * 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).
  42195. * * 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
  42196. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42197. * * 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
  42198. * * 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.
  42199. * * If `enclose` is false, a ring surface is one element.
  42200. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42201. * * 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
  42202. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42203. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42205. * @param name defines the name of the mesh
  42206. * @param options defines the options used to create the mesh
  42207. * @param scene defines the hosting scene
  42208. * @returns the cylinder mesh
  42209. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42210. */
  42211. static CreateCylinder(name: string, options: {
  42212. height?: number;
  42213. diameterTop?: number;
  42214. diameterBottom?: number;
  42215. diameter?: number;
  42216. tessellation?: number;
  42217. subdivisions?: number;
  42218. arc?: number;
  42219. faceColors?: Color4[];
  42220. faceUV?: Vector4[];
  42221. updatable?: boolean;
  42222. hasRings?: boolean;
  42223. enclose?: boolean;
  42224. cap?: number;
  42225. sideOrientation?: number;
  42226. frontUVs?: Vector4;
  42227. backUVs?: Vector4;
  42228. }, scene: any): Mesh;
  42229. }
  42230. }
  42231. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42232. import { Observable } from "babylonjs/Misc/observable";
  42233. import { Nullable } from "babylonjs/types";
  42234. import { Camera } from "babylonjs/Cameras/camera";
  42235. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42236. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42237. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42238. import { Scene } from "babylonjs/scene";
  42239. import { Vector3 } from "babylonjs/Maths/math.vector";
  42240. import { Color3 } from "babylonjs/Maths/math.color";
  42241. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42243. import { Mesh } from "babylonjs/Meshes/mesh";
  42244. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42245. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42246. import "babylonjs/Meshes/Builders/groundBuilder";
  42247. import "babylonjs/Meshes/Builders/torusBuilder";
  42248. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42249. import "babylonjs/Gamepads/gamepadSceneComponent";
  42250. import "babylonjs/Animations/animatable";
  42251. /**
  42252. * Options to modify the vr teleportation behavior.
  42253. */
  42254. export interface VRTeleportationOptions {
  42255. /**
  42256. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42257. */
  42258. floorMeshName?: string;
  42259. /**
  42260. * A list of meshes to be used as the teleportation floor. (default: empty)
  42261. */
  42262. floorMeshes?: Mesh[];
  42263. }
  42264. /**
  42265. * Options to modify the vr experience helper's behavior.
  42266. */
  42267. export interface VRExperienceHelperOptions extends WebVROptions {
  42268. /**
  42269. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42270. */
  42271. createDeviceOrientationCamera?: boolean;
  42272. /**
  42273. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42274. */
  42275. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42276. /**
  42277. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42278. */
  42279. laserToggle?: boolean;
  42280. /**
  42281. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42282. */
  42283. floorMeshes?: Mesh[];
  42284. /**
  42285. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42286. */
  42287. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42288. }
  42289. /**
  42290. * Event containing information after VR has been entered
  42291. */
  42292. export class OnAfterEnteringVRObservableEvent {
  42293. /**
  42294. * If entering vr was successful
  42295. */
  42296. success: boolean;
  42297. }
  42298. /**
  42299. * Helps to quickly add VR support to an existing scene.
  42300. * See http://doc.babylonjs.com/how_to/webvr_helper
  42301. */
  42302. export class VRExperienceHelper {
  42303. /** Options to modify the vr experience helper's behavior. */
  42304. webVROptions: VRExperienceHelperOptions;
  42305. private _scene;
  42306. private _position;
  42307. private _btnVR;
  42308. private _btnVRDisplayed;
  42309. private _webVRsupported;
  42310. private _webVRready;
  42311. private _webVRrequesting;
  42312. private _webVRpresenting;
  42313. private _hasEnteredVR;
  42314. private _fullscreenVRpresenting;
  42315. private _canvas;
  42316. private _webVRCamera;
  42317. private _vrDeviceOrientationCamera;
  42318. private _deviceOrientationCamera;
  42319. private _existingCamera;
  42320. private _onKeyDown;
  42321. private _onVrDisplayPresentChange;
  42322. private _onVRDisplayChanged;
  42323. private _onVRRequestPresentStart;
  42324. private _onVRRequestPresentComplete;
  42325. /**
  42326. * 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)
  42327. */
  42328. enableGazeEvenWhenNoPointerLock: boolean;
  42329. /**
  42330. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42331. */
  42332. exitVROnDoubleTap: boolean;
  42333. /**
  42334. * Observable raised right before entering VR.
  42335. */
  42336. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42337. /**
  42338. * Observable raised when entering VR has completed.
  42339. */
  42340. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42341. /**
  42342. * Observable raised when exiting VR.
  42343. */
  42344. onExitingVRObservable: Observable<VRExperienceHelper>;
  42345. /**
  42346. * Observable raised when controller mesh is loaded.
  42347. */
  42348. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42349. /** Return this.onEnteringVRObservable
  42350. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42351. */
  42352. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42353. /** Return this.onExitingVRObservable
  42354. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42355. */
  42356. readonly onExitingVR: Observable<VRExperienceHelper>;
  42357. /** Return this.onControllerMeshLoadedObservable
  42358. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42359. */
  42360. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42361. private _rayLength;
  42362. private _useCustomVRButton;
  42363. private _teleportationRequested;
  42364. private _teleportActive;
  42365. private _floorMeshName;
  42366. private _floorMeshesCollection;
  42367. private _rotationAllowed;
  42368. private _teleportBackwardsVector;
  42369. private _teleportationTarget;
  42370. private _isDefaultTeleportationTarget;
  42371. private _postProcessMove;
  42372. private _teleportationFillColor;
  42373. private _teleportationBorderColor;
  42374. private _rotationAngle;
  42375. private _haloCenter;
  42376. private _cameraGazer;
  42377. private _padSensibilityUp;
  42378. private _padSensibilityDown;
  42379. private _leftController;
  42380. private _rightController;
  42381. /**
  42382. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42383. */
  42384. onNewMeshSelected: Observable<AbstractMesh>;
  42385. /**
  42386. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42387. * This observable will provide the mesh and the controller used to select the mesh
  42388. */
  42389. onMeshSelectedWithController: Observable<{
  42390. mesh: AbstractMesh;
  42391. controller: WebVRController;
  42392. }>;
  42393. /**
  42394. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42395. */
  42396. onNewMeshPicked: Observable<PickingInfo>;
  42397. private _circleEase;
  42398. /**
  42399. * Observable raised before camera teleportation
  42400. */
  42401. onBeforeCameraTeleport: Observable<Vector3>;
  42402. /**
  42403. * Observable raised after camera teleportation
  42404. */
  42405. onAfterCameraTeleport: Observable<Vector3>;
  42406. /**
  42407. * Observable raised when current selected mesh gets unselected
  42408. */
  42409. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42410. private _raySelectionPredicate;
  42411. /**
  42412. * To be optionaly changed by user to define custom ray selection
  42413. */
  42414. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42415. /**
  42416. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42417. */
  42418. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42419. /**
  42420. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42421. */
  42422. teleportationEnabled: boolean;
  42423. private _defaultHeight;
  42424. private _teleportationInitialized;
  42425. private _interactionsEnabled;
  42426. private _interactionsRequested;
  42427. private _displayGaze;
  42428. private _displayLaserPointer;
  42429. /**
  42430. * The mesh used to display where the user is going to teleport.
  42431. */
  42432. /**
  42433. * Sets the mesh to be used to display where the user is going to teleport.
  42434. */
  42435. teleportationTarget: Mesh;
  42436. /**
  42437. * 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
  42438. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42439. * See http://doc.babylonjs.com/resources/baking_transformations
  42440. */
  42441. gazeTrackerMesh: Mesh;
  42442. /**
  42443. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42444. */
  42445. updateGazeTrackerScale: boolean;
  42446. /**
  42447. * If the gaze trackers color should be updated when selecting meshes
  42448. */
  42449. updateGazeTrackerColor: boolean;
  42450. /**
  42451. * If the controller laser color should be updated when selecting meshes
  42452. */
  42453. updateControllerLaserColor: boolean;
  42454. /**
  42455. * The gaze tracking mesh corresponding to the left controller
  42456. */
  42457. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42458. /**
  42459. * The gaze tracking mesh corresponding to the right controller
  42460. */
  42461. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42462. /**
  42463. * If the ray of the gaze should be displayed.
  42464. */
  42465. /**
  42466. * Sets if the ray of the gaze should be displayed.
  42467. */
  42468. displayGaze: boolean;
  42469. /**
  42470. * If the ray of the LaserPointer should be displayed.
  42471. */
  42472. /**
  42473. * Sets if the ray of the LaserPointer should be displayed.
  42474. */
  42475. displayLaserPointer: boolean;
  42476. /**
  42477. * The deviceOrientationCamera used as the camera when not in VR.
  42478. */
  42479. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42480. /**
  42481. * Based on the current WebVR support, returns the current VR camera used.
  42482. */
  42483. readonly currentVRCamera: Nullable<Camera>;
  42484. /**
  42485. * The webVRCamera which is used when in VR.
  42486. */
  42487. readonly webVRCamera: WebVRFreeCamera;
  42488. /**
  42489. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42490. */
  42491. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42492. /**
  42493. * The html button that is used to trigger entering into VR.
  42494. */
  42495. readonly vrButton: Nullable<HTMLButtonElement>;
  42496. private readonly _teleportationRequestInitiated;
  42497. /**
  42498. * Defines wether or not Pointer lock should be requested when switching to
  42499. * full screen.
  42500. */
  42501. requestPointerLockOnFullScreen: boolean;
  42502. /**
  42503. * Instantiates a VRExperienceHelper.
  42504. * Helps to quickly add VR support to an existing scene.
  42505. * @param scene The scene the VRExperienceHelper belongs to.
  42506. * @param webVROptions Options to modify the vr experience helper's behavior.
  42507. */
  42508. constructor(scene: Scene,
  42509. /** Options to modify the vr experience helper's behavior. */
  42510. webVROptions?: VRExperienceHelperOptions);
  42511. private _onDefaultMeshLoaded;
  42512. private _onResize;
  42513. private _onFullscreenChange;
  42514. /**
  42515. * Gets a value indicating if we are currently in VR mode.
  42516. */
  42517. readonly isInVRMode: boolean;
  42518. private onVrDisplayPresentChange;
  42519. private onVRDisplayChanged;
  42520. private moveButtonToBottomRight;
  42521. private displayVRButton;
  42522. private updateButtonVisibility;
  42523. private _cachedAngularSensibility;
  42524. /**
  42525. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42526. * Otherwise, will use the fullscreen API.
  42527. */
  42528. enterVR(): void;
  42529. /**
  42530. * Attempt to exit VR, or fullscreen.
  42531. */
  42532. exitVR(): void;
  42533. /**
  42534. * The position of the vr experience helper.
  42535. */
  42536. /**
  42537. * Sets the position of the vr experience helper.
  42538. */
  42539. position: Vector3;
  42540. /**
  42541. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42542. */
  42543. enableInteractions(): void;
  42544. private readonly _noControllerIsActive;
  42545. private beforeRender;
  42546. private _isTeleportationFloor;
  42547. /**
  42548. * Adds a floor mesh to be used for teleportation.
  42549. * @param floorMesh the mesh to be used for teleportation.
  42550. */
  42551. addFloorMesh(floorMesh: Mesh): void;
  42552. /**
  42553. * Removes a floor mesh from being used for teleportation.
  42554. * @param floorMesh the mesh to be removed.
  42555. */
  42556. removeFloorMesh(floorMesh: Mesh): void;
  42557. /**
  42558. * Enables interactions and teleportation using the VR controllers and gaze.
  42559. * @param vrTeleportationOptions options to modify teleportation behavior.
  42560. */
  42561. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42562. private _onNewGamepadConnected;
  42563. private _tryEnableInteractionOnController;
  42564. private _onNewGamepadDisconnected;
  42565. private _enableInteractionOnController;
  42566. private _checkTeleportWithRay;
  42567. private _checkRotate;
  42568. private _checkTeleportBackwards;
  42569. private _enableTeleportationOnController;
  42570. private _createTeleportationCircles;
  42571. private _displayTeleportationTarget;
  42572. private _hideTeleportationTarget;
  42573. private _rotateCamera;
  42574. private _moveTeleportationSelectorTo;
  42575. private _workingVector;
  42576. private _workingQuaternion;
  42577. private _workingMatrix;
  42578. /**
  42579. * Teleports the users feet to the desired location
  42580. * @param location The location where the user's feet should be placed
  42581. */
  42582. teleportCamera(location: Vector3): void;
  42583. private _convertNormalToDirectionOfRay;
  42584. private _castRayAndSelectObject;
  42585. private _notifySelectedMeshUnselected;
  42586. /**
  42587. * Sets the color of the laser ray from the vr controllers.
  42588. * @param color new color for the ray.
  42589. */
  42590. changeLaserColor(color: Color3): void;
  42591. /**
  42592. * Sets the color of the ray from the vr headsets gaze.
  42593. * @param color new color for the ray.
  42594. */
  42595. changeGazeColor(color: Color3): void;
  42596. /**
  42597. * Exits VR and disposes of the vr experience helper
  42598. */
  42599. dispose(): void;
  42600. /**
  42601. * Gets the name of the VRExperienceHelper class
  42602. * @returns "VRExperienceHelper"
  42603. */
  42604. getClassName(): string;
  42605. }
  42606. }
  42607. declare module "babylonjs/Cameras/VR/index" {
  42608. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42609. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42610. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42611. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42612. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42613. export * from "babylonjs/Cameras/VR/webVRCamera";
  42614. }
  42615. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42616. import { Observable } from "babylonjs/Misc/observable";
  42617. import { Nullable } from "babylonjs/types";
  42618. import { IDisposable, Scene } from "babylonjs/scene";
  42619. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42620. /**
  42621. * Manages an XRSession to work with Babylon's engine
  42622. * @see https://doc.babylonjs.com/how_to/webxr
  42623. */
  42624. export class WebXRSessionManager implements IDisposable {
  42625. private scene;
  42626. /**
  42627. * Fires every time a new xrFrame arrives which can be used to update the camera
  42628. */
  42629. onXRFrameObservable: Observable<any>;
  42630. /**
  42631. * Fires when the xr session is ended either by the device or manually done
  42632. */
  42633. onXRSessionEnded: Observable<any>;
  42634. /**
  42635. * Underlying xr session
  42636. */
  42637. session: XRSession;
  42638. /**
  42639. * Type of reference space used when creating the session
  42640. */
  42641. referenceSpace: XRReferenceSpace;
  42642. /** @hidden */
  42643. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42644. /**
  42645. * Current XR frame
  42646. */
  42647. currentFrame: Nullable<XRFrame>;
  42648. private _xrNavigator;
  42649. private baseLayer;
  42650. /**
  42651. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42652. * @param scene The scene which the session should be created for
  42653. */
  42654. constructor(scene: Scene);
  42655. /**
  42656. * Initializes the manager
  42657. * After initialization enterXR can be called to start an XR session
  42658. * @returns Promise which resolves after it is initialized
  42659. */
  42660. initializeAsync(): Promise<void>;
  42661. /**
  42662. * Initializes an xr session
  42663. * @param xrSessionMode mode to initialize
  42664. * @returns a promise which will resolve once the session has been initialized
  42665. */
  42666. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42667. /**
  42668. * Sets the reference space on the xr session
  42669. * @param referenceSpace space to set
  42670. * @returns a promise that will resolve once the reference space has been set
  42671. */
  42672. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42673. /**
  42674. * Updates the render state of the session
  42675. * @param state state to set
  42676. * @returns a promise that resolves once the render state has been updated
  42677. */
  42678. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42679. /**
  42680. * Starts rendering to the xr layer
  42681. * @returns a promise that will resolve once rendering has started
  42682. */
  42683. startRenderingToXRAsync(): Promise<void>;
  42684. /**
  42685. * Stops the xrSession and restores the renderloop
  42686. * @returns Promise which resolves after it exits XR
  42687. */
  42688. exitXRAsync(): Promise<unknown>;
  42689. /**
  42690. * Checks if a session would be supported for the creation options specified
  42691. * @param sessionMode session mode to check if supported eg. immersive-vr
  42692. * @returns true if supported
  42693. */
  42694. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42695. /**
  42696. * @hidden
  42697. * Converts the render layer of xrSession to a render target
  42698. * @param session session to create render target for
  42699. * @param scene scene the new render target should be created for
  42700. */
  42701. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42702. /**
  42703. * Disposes of the session manager
  42704. */
  42705. dispose(): void;
  42706. }
  42707. }
  42708. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42709. import { Scene } from "babylonjs/scene";
  42710. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42711. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42712. /**
  42713. * WebXR Camera which holds the views for the xrSession
  42714. * @see https://doc.babylonjs.com/how_to/webxr
  42715. */
  42716. export class WebXRCamera extends FreeCamera {
  42717. private static _TmpMatrix;
  42718. /**
  42719. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42720. * @param name the name of the camera
  42721. * @param scene the scene to add the camera to
  42722. */
  42723. constructor(name: string, scene: Scene);
  42724. private _updateNumberOfRigCameras;
  42725. /** @hidden */
  42726. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42727. /**
  42728. * Updates the cameras position from the current pose information of the XR session
  42729. * @param xrSessionManager the session containing pose information
  42730. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42731. */
  42732. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42733. }
  42734. }
  42735. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42736. import { Nullable } from "babylonjs/types";
  42737. import { IDisposable } from "babylonjs/scene";
  42738. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42739. /**
  42740. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42741. */
  42742. export class WebXRManagedOutputCanvas implements IDisposable {
  42743. private helper;
  42744. private _canvas;
  42745. /**
  42746. * xrpresent context of the canvas which can be used to display/mirror xr content
  42747. */
  42748. canvasContext: WebGLRenderingContext;
  42749. /**
  42750. * xr layer for the canvas
  42751. */
  42752. xrLayer: Nullable<XRWebGLLayer>;
  42753. /**
  42754. * Initializes the xr layer for the session
  42755. * @param xrSession xr session
  42756. * @returns a promise that will resolve once the XR Layer has been created
  42757. */
  42758. initializeXRLayerAsync(xrSession: any): any;
  42759. /**
  42760. * Initializes the canvas to be added/removed upon entering/exiting xr
  42761. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42762. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42763. */
  42764. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42765. /**
  42766. * Disposes of the object
  42767. */
  42768. dispose(): void;
  42769. private _setManagedOutputCanvas;
  42770. private _addCanvas;
  42771. private _removeCanvas;
  42772. }
  42773. }
  42774. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42775. import { Observable } from "babylonjs/Misc/observable";
  42776. import { IDisposable, Scene } from "babylonjs/scene";
  42777. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42778. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42779. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42780. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42781. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42782. /**
  42783. * States of the webXR experience
  42784. */
  42785. export enum WebXRState {
  42786. /**
  42787. * Transitioning to being in XR mode
  42788. */
  42789. ENTERING_XR = 0,
  42790. /**
  42791. * Transitioning to non XR mode
  42792. */
  42793. EXITING_XR = 1,
  42794. /**
  42795. * In XR mode and presenting
  42796. */
  42797. IN_XR = 2,
  42798. /**
  42799. * Not entered XR mode
  42800. */
  42801. NOT_IN_XR = 3
  42802. }
  42803. /**
  42804. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42805. * @see https://doc.babylonjs.com/how_to/webxr
  42806. */
  42807. export class WebXRExperienceHelper implements IDisposable {
  42808. private scene;
  42809. /**
  42810. * 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
  42811. */
  42812. container: AbstractMesh;
  42813. /**
  42814. * Camera used to render xr content
  42815. */
  42816. camera: WebXRCamera;
  42817. /**
  42818. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42819. */
  42820. state: WebXRState;
  42821. private _setState;
  42822. private static _TmpVector;
  42823. /**
  42824. * Fires when the state of the experience helper has changed
  42825. */
  42826. onStateChangedObservable: Observable<WebXRState>;
  42827. /** Session manager used to keep track of xr session */
  42828. sessionManager: WebXRSessionManager;
  42829. private _nonVRCamera;
  42830. private _originalSceneAutoClear;
  42831. private _supported;
  42832. /**
  42833. * Creates the experience helper
  42834. * @param scene the scene to attach the experience helper to
  42835. * @returns a promise for the experience helper
  42836. */
  42837. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42838. /**
  42839. * Creates a WebXRExperienceHelper
  42840. * @param scene The scene the helper should be created in
  42841. */
  42842. private constructor();
  42843. /**
  42844. * Exits XR mode and returns the scene to its original state
  42845. * @returns promise that resolves after xr mode has exited
  42846. */
  42847. exitXRAsync(): Promise<unknown>;
  42848. /**
  42849. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42850. * @param sessionCreationOptions options for the XR session
  42851. * @param referenceSpaceType frame of reference of the XR session
  42852. * @param outputCanvas the output canvas that will be used to enter XR mode
  42853. * @returns promise that resolves after xr mode has entered
  42854. */
  42855. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42856. /**
  42857. * Updates the global position of the camera by moving the camera's container
  42858. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42859. * @param position The desired global position of the camera
  42860. */
  42861. setPositionOfCameraUsingContainer(position: Vector3): void;
  42862. /**
  42863. * Rotates the xr camera by rotating the camera's container around the camera's position
  42864. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42865. * @param rotation the desired quaternion rotation to apply to the camera
  42866. */
  42867. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42868. /**
  42869. * Disposes of the experience helper
  42870. */
  42871. dispose(): void;
  42872. }
  42873. }
  42874. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42875. import { Nullable } from "babylonjs/types";
  42876. import { Observable } from "babylonjs/Misc/observable";
  42877. import { IDisposable, Scene } from "babylonjs/scene";
  42878. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42879. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42880. /**
  42881. * Button which can be used to enter a different mode of XR
  42882. */
  42883. export class WebXREnterExitUIButton {
  42884. /** button element */
  42885. element: HTMLElement;
  42886. /** XR initialization options for the button */
  42887. sessionMode: XRSessionMode;
  42888. /** Reference space type */
  42889. referenceSpaceType: XRReferenceSpaceType;
  42890. /**
  42891. * Creates a WebXREnterExitUIButton
  42892. * @param element button element
  42893. * @param sessionMode XR initialization session mode
  42894. * @param referenceSpaceType the type of reference space to be used
  42895. */
  42896. constructor(
  42897. /** button element */
  42898. element: HTMLElement,
  42899. /** XR initialization options for the button */
  42900. sessionMode: XRSessionMode,
  42901. /** Reference space type */
  42902. referenceSpaceType: XRReferenceSpaceType);
  42903. /**
  42904. * Overwritable function which can be used to update the button's visuals when the state changes
  42905. * @param activeButton the current active button in the UI
  42906. */
  42907. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42908. }
  42909. /**
  42910. * Options to create the webXR UI
  42911. */
  42912. export class WebXREnterExitUIOptions {
  42913. /**
  42914. * Context to enter xr with
  42915. */
  42916. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42917. /**
  42918. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42919. */
  42920. customButtons?: Array<WebXREnterExitUIButton>;
  42921. }
  42922. /**
  42923. * UI to allow the user to enter/exit XR mode
  42924. */
  42925. export class WebXREnterExitUI implements IDisposable {
  42926. private scene;
  42927. private _overlay;
  42928. private _buttons;
  42929. private _activeButton;
  42930. /**
  42931. * Fired every time the active button is changed.
  42932. *
  42933. * When xr is entered via a button that launches xr that button will be the callback parameter
  42934. *
  42935. * When exiting xr the callback parameter will be null)
  42936. */
  42937. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42938. /**
  42939. * Creates UI to allow the user to enter/exit XR mode
  42940. * @param scene the scene to add the ui to
  42941. * @param helper the xr experience helper to enter/exit xr with
  42942. * @param options options to configure the UI
  42943. * @returns the created ui
  42944. */
  42945. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42946. private constructor();
  42947. private _updateButtons;
  42948. /**
  42949. * Disposes of the object
  42950. */
  42951. dispose(): void;
  42952. }
  42953. }
  42954. declare module "babylonjs/Cameras/XR/webXRController" {
  42955. import { Nullable } from "babylonjs/types";
  42956. import { Observable } from "babylonjs/Misc/observable";
  42957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42958. import { Ray } from "babylonjs/Culling/ray";
  42959. import { Scene } from "babylonjs/scene";
  42960. /**
  42961. * Represents an XR input
  42962. */
  42963. export class WebXRController {
  42964. private scene;
  42965. /** The underlying input source for the controller */
  42966. inputSource: XRInputSource;
  42967. private parentContainer;
  42968. /**
  42969. * 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
  42970. */
  42971. grip?: AbstractMesh;
  42972. /**
  42973. * Pointer which can be used to select objects or attach a visible laser to
  42974. */
  42975. pointer: AbstractMesh;
  42976. /**
  42977. * Event that fires when the controller is removed/disposed
  42978. */
  42979. onDisposeObservable: Observable<{}>;
  42980. private _tmpMatrix;
  42981. private _tmpQuaternion;
  42982. private _tmpVector;
  42983. /**
  42984. * Creates the controller
  42985. * @see https://doc.babylonjs.com/how_to/webxr
  42986. * @param scene the scene which the controller should be associated to
  42987. * @param inputSource the underlying input source for the controller
  42988. * @param parentContainer parent that the controller meshes should be children of
  42989. */
  42990. constructor(scene: Scene,
  42991. /** The underlying input source for the controller */
  42992. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42993. /**
  42994. * Updates the controller pose based on the given XRFrame
  42995. * @param xrFrame xr frame to update the pose with
  42996. * @param referenceSpace reference space to use
  42997. */
  42998. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42999. /**
  43000. * Gets a world space ray coming from the controller
  43001. * @param result the resulting ray
  43002. */
  43003. getWorldPointerRayToRef(result: Ray): void;
  43004. /**
  43005. * Disposes of the object
  43006. */
  43007. dispose(): void;
  43008. }
  43009. }
  43010. declare module "babylonjs/Cameras/XR/webXRInput" {
  43011. import { Observable } from "babylonjs/Misc/observable";
  43012. import { IDisposable } from "babylonjs/scene";
  43013. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43014. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43015. /**
  43016. * XR input used to track XR inputs such as controllers/rays
  43017. */
  43018. export class WebXRInput implements IDisposable {
  43019. /**
  43020. * Base experience the input listens to
  43021. */
  43022. baseExperience: WebXRExperienceHelper;
  43023. /**
  43024. * XR controllers being tracked
  43025. */
  43026. controllers: Array<WebXRController>;
  43027. private _frameObserver;
  43028. private _stateObserver;
  43029. /**
  43030. * Event when a controller has been connected/added
  43031. */
  43032. onControllerAddedObservable: Observable<WebXRController>;
  43033. /**
  43034. * Event when a controller has been removed/disconnected
  43035. */
  43036. onControllerRemovedObservable: Observable<WebXRController>;
  43037. /**
  43038. * Initializes the WebXRInput
  43039. * @param baseExperience experience helper which the input should be created for
  43040. */
  43041. constructor(
  43042. /**
  43043. * Base experience the input listens to
  43044. */
  43045. baseExperience: WebXRExperienceHelper);
  43046. private _onInputSourcesChange;
  43047. private _addAndRemoveControllers;
  43048. /**
  43049. * Disposes of the object
  43050. */
  43051. dispose(): void;
  43052. }
  43053. }
  43054. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43055. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43056. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43057. /**
  43058. * Enables teleportation
  43059. */
  43060. export class WebXRControllerTeleportation {
  43061. private _teleportationFillColor;
  43062. private _teleportationBorderColor;
  43063. private _tmpRay;
  43064. private _tmpVector;
  43065. /**
  43066. * Creates a WebXRControllerTeleportation
  43067. * @param input input manager to add teleportation to
  43068. * @param floorMeshes floormeshes which can be teleported to
  43069. */
  43070. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43071. }
  43072. }
  43073. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43074. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43075. /**
  43076. * Handles pointer input automatically for the pointer of XR controllers
  43077. */
  43078. export class WebXRControllerPointerSelection {
  43079. private static _idCounter;
  43080. private _tmpRay;
  43081. /**
  43082. * Creates a WebXRControllerPointerSelection
  43083. * @param input input manager to setup pointer selection
  43084. */
  43085. constructor(input: WebXRInput);
  43086. private _convertNormalToDirectionOfRay;
  43087. private _updatePointerDistance;
  43088. }
  43089. }
  43090. declare module "babylonjs/Loading/sceneLoader" {
  43091. import { Observable } from "babylonjs/Misc/observable";
  43092. import { Nullable } from "babylonjs/types";
  43093. import { Scene } from "babylonjs/scene";
  43094. import { Engine } from "babylonjs/Engines/engine";
  43095. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43096. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43097. import { AssetContainer } from "babylonjs/assetContainer";
  43098. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43099. import { Skeleton } from "babylonjs/Bones/skeleton";
  43100. /**
  43101. * Class used to represent data loading progression
  43102. */
  43103. export class SceneLoaderProgressEvent {
  43104. /** defines if data length to load can be evaluated */
  43105. readonly lengthComputable: boolean;
  43106. /** defines the loaded data length */
  43107. readonly loaded: number;
  43108. /** defines the data length to load */
  43109. readonly total: number;
  43110. /**
  43111. * Create a new progress event
  43112. * @param lengthComputable defines if data length to load can be evaluated
  43113. * @param loaded defines the loaded data length
  43114. * @param total defines the data length to load
  43115. */
  43116. constructor(
  43117. /** defines if data length to load can be evaluated */
  43118. lengthComputable: boolean,
  43119. /** defines the loaded data length */
  43120. loaded: number,
  43121. /** defines the data length to load */
  43122. total: number);
  43123. /**
  43124. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43125. * @param event defines the source event
  43126. * @returns a new SceneLoaderProgressEvent
  43127. */
  43128. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43129. }
  43130. /**
  43131. * Interface used by SceneLoader plugins to define supported file extensions
  43132. */
  43133. export interface ISceneLoaderPluginExtensions {
  43134. /**
  43135. * Defines the list of supported extensions
  43136. */
  43137. [extension: string]: {
  43138. isBinary: boolean;
  43139. };
  43140. }
  43141. /**
  43142. * Interface used by SceneLoader plugin factory
  43143. */
  43144. export interface ISceneLoaderPluginFactory {
  43145. /**
  43146. * Defines the name of the factory
  43147. */
  43148. name: string;
  43149. /**
  43150. * Function called to create a new plugin
  43151. * @return the new plugin
  43152. */
  43153. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43154. /**
  43155. * Boolean indicating if the plugin can direct load specific data
  43156. */
  43157. canDirectLoad?: (data: string) => boolean;
  43158. }
  43159. /**
  43160. * Interface used to define a SceneLoader plugin
  43161. */
  43162. export interface ISceneLoaderPlugin {
  43163. /**
  43164. * The friendly name of this plugin.
  43165. */
  43166. name: string;
  43167. /**
  43168. * The file extensions supported by this plugin.
  43169. */
  43170. extensions: string | ISceneLoaderPluginExtensions;
  43171. /**
  43172. * Import meshes into a scene.
  43173. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43174. * @param scene The scene to import into
  43175. * @param data The data to import
  43176. * @param rootUrl The root url for scene and resources
  43177. * @param meshes The meshes array to import into
  43178. * @param particleSystems The particle systems array to import into
  43179. * @param skeletons The skeletons array to import into
  43180. * @param onError The callback when import fails
  43181. * @returns True if successful or false otherwise
  43182. */
  43183. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43184. /**
  43185. * Load into a scene.
  43186. * @param scene The scene to load into
  43187. * @param data The data to import
  43188. * @param rootUrl The root url for scene and resources
  43189. * @param onError The callback when import fails
  43190. * @returns true if successful or false otherwise
  43191. */
  43192. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43193. /**
  43194. * The callback that returns true if the data can be directly loaded.
  43195. */
  43196. canDirectLoad?: (data: string) => boolean;
  43197. /**
  43198. * The callback that allows custom handling of the root url based on the response url.
  43199. */
  43200. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43201. /**
  43202. * Load into an asset container.
  43203. * @param scene The scene to load into
  43204. * @param data The data to import
  43205. * @param rootUrl The root url for scene and resources
  43206. * @param onError The callback when import fails
  43207. * @returns The loaded asset container
  43208. */
  43209. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43210. }
  43211. /**
  43212. * Interface used to define an async SceneLoader plugin
  43213. */
  43214. export interface ISceneLoaderPluginAsync {
  43215. /**
  43216. * The friendly name of this plugin.
  43217. */
  43218. name: string;
  43219. /**
  43220. * The file extensions supported by this plugin.
  43221. */
  43222. extensions: string | ISceneLoaderPluginExtensions;
  43223. /**
  43224. * Import meshes into a scene.
  43225. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43226. * @param scene The scene to import into
  43227. * @param data The data to import
  43228. * @param rootUrl The root url for scene and resources
  43229. * @param onProgress The callback when the load progresses
  43230. * @param fileName Defines the name of the file to load
  43231. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43232. */
  43233. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43234. meshes: AbstractMesh[];
  43235. particleSystems: IParticleSystem[];
  43236. skeletons: Skeleton[];
  43237. animationGroups: AnimationGroup[];
  43238. }>;
  43239. /**
  43240. * Load into a scene.
  43241. * @param scene The scene to load into
  43242. * @param data The data to import
  43243. * @param rootUrl The root url for scene and resources
  43244. * @param onProgress The callback when the load progresses
  43245. * @param fileName Defines the name of the file to load
  43246. * @returns Nothing
  43247. */
  43248. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43249. /**
  43250. * The callback that returns true if the data can be directly loaded.
  43251. */
  43252. canDirectLoad?: (data: string) => boolean;
  43253. /**
  43254. * The callback that allows custom handling of the root url based on the response url.
  43255. */
  43256. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43257. /**
  43258. * Load into an asset container.
  43259. * @param scene The scene to load into
  43260. * @param data The data to import
  43261. * @param rootUrl The root url for scene and resources
  43262. * @param onProgress The callback when the load progresses
  43263. * @param fileName Defines the name of the file to load
  43264. * @returns The loaded asset container
  43265. */
  43266. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43267. }
  43268. /**
  43269. * Class used to load scene from various file formats using registered plugins
  43270. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43271. */
  43272. export class SceneLoader {
  43273. /**
  43274. * No logging while loading
  43275. */
  43276. static readonly NO_LOGGING: number;
  43277. /**
  43278. * Minimal logging while loading
  43279. */
  43280. static readonly MINIMAL_LOGGING: number;
  43281. /**
  43282. * Summary logging while loading
  43283. */
  43284. static readonly SUMMARY_LOGGING: number;
  43285. /**
  43286. * Detailled logging while loading
  43287. */
  43288. static readonly DETAILED_LOGGING: number;
  43289. /**
  43290. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43291. */
  43292. static ForceFullSceneLoadingForIncremental: boolean;
  43293. /**
  43294. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43295. */
  43296. static ShowLoadingScreen: boolean;
  43297. /**
  43298. * Defines the current logging level (while loading the scene)
  43299. * @ignorenaming
  43300. */
  43301. static loggingLevel: number;
  43302. /**
  43303. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43304. */
  43305. static CleanBoneMatrixWeights: boolean;
  43306. /**
  43307. * Event raised when a plugin is used to load a scene
  43308. */
  43309. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43310. private static _registeredPlugins;
  43311. private static _getDefaultPlugin;
  43312. private static _getPluginForExtension;
  43313. private static _getPluginForDirectLoad;
  43314. private static _getPluginForFilename;
  43315. private static _getDirectLoad;
  43316. private static _loadData;
  43317. private static _getFileInfo;
  43318. /**
  43319. * Gets a plugin that can load the given extension
  43320. * @param extension defines the extension to load
  43321. * @returns a plugin or null if none works
  43322. */
  43323. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43324. /**
  43325. * Gets a boolean indicating that the given extension can be loaded
  43326. * @param extension defines the extension to load
  43327. * @returns true if the extension is supported
  43328. */
  43329. static IsPluginForExtensionAvailable(extension: string): boolean;
  43330. /**
  43331. * Adds a new plugin to the list of registered plugins
  43332. * @param plugin defines the plugin to add
  43333. */
  43334. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43335. /**
  43336. * Import meshes into a scene
  43337. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43338. * @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)
  43339. * @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)
  43340. * @param scene the instance of BABYLON.Scene to append to
  43341. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43342. * @param onProgress a callback with a progress event for each file being loaded
  43343. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43344. * @param pluginExtension the extension used to determine the plugin
  43345. * @returns The loaded plugin
  43346. */
  43347. 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>;
  43348. /**
  43349. * Import meshes into a scene
  43350. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43351. * @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)
  43352. * @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)
  43353. * @param scene the instance of BABYLON.Scene to append to
  43354. * @param onProgress a callback with a progress event for each file being loaded
  43355. * @param pluginExtension the extension used to determine the plugin
  43356. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43357. */
  43358. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43359. meshes: AbstractMesh[];
  43360. particleSystems: IParticleSystem[];
  43361. skeletons: Skeleton[];
  43362. animationGroups: AnimationGroup[];
  43363. }>;
  43364. /**
  43365. * Load a scene
  43366. * @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)
  43367. * @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)
  43368. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43369. * @param onSuccess a callback with the scene when import succeeds
  43370. * @param onProgress a callback with a progress event for each file being loaded
  43371. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43372. * @param pluginExtension the extension used to determine the plugin
  43373. * @returns The loaded plugin
  43374. */
  43375. 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>;
  43376. /**
  43377. * Load a scene
  43378. * @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)
  43379. * @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)
  43380. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43381. * @param onProgress a callback with a progress event for each file being loaded
  43382. * @param pluginExtension the extension used to determine the plugin
  43383. * @returns The loaded scene
  43384. */
  43385. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43386. /**
  43387. * Append a scene
  43388. * @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)
  43389. * @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)
  43390. * @param scene is the instance of BABYLON.Scene to append to
  43391. * @param onSuccess a callback with the scene when import succeeds
  43392. * @param onProgress a callback with a progress event for each file being loaded
  43393. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43394. * @param pluginExtension the extension used to determine the plugin
  43395. * @returns The loaded plugin
  43396. */
  43397. 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>;
  43398. /**
  43399. * Append a scene
  43400. * @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)
  43401. * @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)
  43402. * @param scene is the instance of BABYLON.Scene to append to
  43403. * @param onProgress a callback with a progress event for each file being loaded
  43404. * @param pluginExtension the extension used to determine the plugin
  43405. * @returns The given scene
  43406. */
  43407. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43408. /**
  43409. * Load a scene into an asset container
  43410. * @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)
  43411. * @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)
  43412. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43413. * @param onSuccess a callback with the scene when import succeeds
  43414. * @param onProgress a callback with a progress event for each file being loaded
  43415. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43416. * @param pluginExtension the extension used to determine the plugin
  43417. * @returns The loaded plugin
  43418. */
  43419. 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>;
  43420. /**
  43421. * Load a scene into an asset container
  43422. * @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)
  43423. * @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)
  43424. * @param scene is the instance of Scene to append to
  43425. * @param onProgress a callback with a progress event for each file being loaded
  43426. * @param pluginExtension the extension used to determine the plugin
  43427. * @returns The loaded asset container
  43428. */
  43429. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43430. }
  43431. }
  43432. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43433. import { Scene } from "babylonjs/scene";
  43434. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43435. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43436. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43437. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43438. /**
  43439. * Generic Controller
  43440. */
  43441. export class GenericController extends WebVRController {
  43442. /**
  43443. * Base Url for the controller model.
  43444. */
  43445. static readonly MODEL_BASE_URL: string;
  43446. /**
  43447. * File name for the controller model.
  43448. */
  43449. static readonly MODEL_FILENAME: string;
  43450. /**
  43451. * Creates a new GenericController from a gamepad
  43452. * @param vrGamepad the gamepad that the controller should be created from
  43453. */
  43454. constructor(vrGamepad: any);
  43455. /**
  43456. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43457. * @param scene scene in which to add meshes
  43458. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43459. */
  43460. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43461. /**
  43462. * Called once for each button that changed state since the last frame
  43463. * @param buttonIdx Which button index changed
  43464. * @param state New state of the button
  43465. * @param changes Which properties on the state changed since last frame
  43466. */
  43467. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43468. }
  43469. }
  43470. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43471. import { Observable } from "babylonjs/Misc/observable";
  43472. import { Scene } from "babylonjs/scene";
  43473. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43474. import { Ray } from "babylonjs/Culling/ray";
  43475. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43476. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43477. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43478. /**
  43479. * Defines the WindowsMotionController object that the state of the windows motion controller
  43480. */
  43481. export class WindowsMotionController extends WebVRController {
  43482. /**
  43483. * The base url used to load the left and right controller models
  43484. */
  43485. static MODEL_BASE_URL: string;
  43486. /**
  43487. * The name of the left controller model file
  43488. */
  43489. static MODEL_LEFT_FILENAME: string;
  43490. /**
  43491. * The name of the right controller model file
  43492. */
  43493. static MODEL_RIGHT_FILENAME: string;
  43494. /**
  43495. * The controller name prefix for this controller type
  43496. */
  43497. static readonly GAMEPAD_ID_PREFIX: string;
  43498. /**
  43499. * The controller id pattern for this controller type
  43500. */
  43501. private static readonly GAMEPAD_ID_PATTERN;
  43502. private _loadedMeshInfo;
  43503. private readonly _mapping;
  43504. /**
  43505. * Fired when the trackpad on this controller is clicked
  43506. */
  43507. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43508. /**
  43509. * Fired when the trackpad on this controller is modified
  43510. */
  43511. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43512. /**
  43513. * The current x and y values of this controller's trackpad
  43514. */
  43515. trackpad: StickValues;
  43516. /**
  43517. * Creates a new WindowsMotionController from a gamepad
  43518. * @param vrGamepad the gamepad that the controller should be created from
  43519. */
  43520. constructor(vrGamepad: any);
  43521. /**
  43522. * Fired when the trigger on this controller is modified
  43523. */
  43524. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43525. /**
  43526. * Fired when the menu button on this controller is modified
  43527. */
  43528. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43529. /**
  43530. * Fired when the grip button on this controller is modified
  43531. */
  43532. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43533. /**
  43534. * Fired when the thumbstick button on this controller is modified
  43535. */
  43536. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43537. /**
  43538. * Fired when the touchpad button on this controller is modified
  43539. */
  43540. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43541. /**
  43542. * Fired when the touchpad values on this controller are modified
  43543. */
  43544. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43545. private _updateTrackpad;
  43546. /**
  43547. * Called once per frame by the engine.
  43548. */
  43549. update(): void;
  43550. /**
  43551. * Called once for each button that changed state since the last frame
  43552. * @param buttonIdx Which button index changed
  43553. * @param state New state of the button
  43554. * @param changes Which properties on the state changed since last frame
  43555. */
  43556. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43557. /**
  43558. * Moves the buttons on the controller mesh based on their current state
  43559. * @param buttonName the name of the button to move
  43560. * @param buttonValue the value of the button which determines the buttons new position
  43561. */
  43562. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43563. /**
  43564. * Moves the axis on the controller mesh based on its current state
  43565. * @param axis the index of the axis
  43566. * @param axisValue the value of the axis which determines the meshes new position
  43567. * @hidden
  43568. */
  43569. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43570. /**
  43571. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43572. * @param scene scene in which to add meshes
  43573. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43574. */
  43575. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43576. /**
  43577. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43578. * can be transformed by button presses and axes values, based on this._mapping.
  43579. *
  43580. * @param scene scene in which the meshes exist
  43581. * @param meshes list of meshes that make up the controller model to process
  43582. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43583. */
  43584. private processModel;
  43585. private createMeshInfo;
  43586. /**
  43587. * Gets the ray of the controller in the direction the controller is pointing
  43588. * @param length the length the resulting ray should be
  43589. * @returns a ray in the direction the controller is pointing
  43590. */
  43591. getForwardRay(length?: number): Ray;
  43592. /**
  43593. * Disposes of the controller
  43594. */
  43595. dispose(): void;
  43596. }
  43597. }
  43598. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43599. import { Observable } from "babylonjs/Misc/observable";
  43600. import { Scene } from "babylonjs/scene";
  43601. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43602. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43603. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43604. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43605. /**
  43606. * Oculus Touch Controller
  43607. */
  43608. export class OculusTouchController extends WebVRController {
  43609. /**
  43610. * Base Url for the controller model.
  43611. */
  43612. static MODEL_BASE_URL: string;
  43613. /**
  43614. * File name for the left controller model.
  43615. */
  43616. static MODEL_LEFT_FILENAME: string;
  43617. /**
  43618. * File name for the right controller model.
  43619. */
  43620. static MODEL_RIGHT_FILENAME: string;
  43621. /**
  43622. * Base Url for the Quest controller model.
  43623. */
  43624. static QUEST_MODEL_BASE_URL: string;
  43625. /**
  43626. * @hidden
  43627. * If the controllers are running on a device that needs the updated Quest controller models
  43628. */
  43629. static _IsQuest: boolean;
  43630. /**
  43631. * Fired when the secondary trigger on this controller is modified
  43632. */
  43633. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43634. /**
  43635. * Fired when the thumb rest on this controller is modified
  43636. */
  43637. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43638. /**
  43639. * Creates a new OculusTouchController from a gamepad
  43640. * @param vrGamepad the gamepad that the controller should be created from
  43641. */
  43642. constructor(vrGamepad: any);
  43643. /**
  43644. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43645. * @param scene scene in which to add meshes
  43646. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43647. */
  43648. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43649. /**
  43650. * Fired when the A button on this controller is modified
  43651. */
  43652. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43653. /**
  43654. * Fired when the B button on this controller is modified
  43655. */
  43656. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43657. /**
  43658. * Fired when the X button on this controller is modified
  43659. */
  43660. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43661. /**
  43662. * Fired when the Y button on this controller is modified
  43663. */
  43664. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43665. /**
  43666. * Called once for each button that changed state since the last frame
  43667. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43668. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43669. * 2) secondary trigger (same)
  43670. * 3) A (right) X (left), touch, pressed = value
  43671. * 4) B / Y
  43672. * 5) thumb rest
  43673. * @param buttonIdx Which button index changed
  43674. * @param state New state of the button
  43675. * @param changes Which properties on the state changed since last frame
  43676. */
  43677. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43678. }
  43679. }
  43680. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43681. import { Scene } from "babylonjs/scene";
  43682. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43683. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43684. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43685. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43686. import { Observable } from "babylonjs/Misc/observable";
  43687. /**
  43688. * Vive Controller
  43689. */
  43690. export class ViveController extends WebVRController {
  43691. /**
  43692. * Base Url for the controller model.
  43693. */
  43694. static MODEL_BASE_URL: string;
  43695. /**
  43696. * File name for the controller model.
  43697. */
  43698. static MODEL_FILENAME: string;
  43699. /**
  43700. * Creates a new ViveController from a gamepad
  43701. * @param vrGamepad the gamepad that the controller should be created from
  43702. */
  43703. constructor(vrGamepad: any);
  43704. /**
  43705. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43706. * @param scene scene in which to add meshes
  43707. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43708. */
  43709. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43710. /**
  43711. * Fired when the left button on this controller is modified
  43712. */
  43713. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43714. /**
  43715. * Fired when the right button on this controller is modified
  43716. */
  43717. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43718. /**
  43719. * Fired when the menu button on this controller is modified
  43720. */
  43721. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43722. /**
  43723. * Called once for each button that changed state since the last frame
  43724. * Vive mapping:
  43725. * 0: touchpad
  43726. * 1: trigger
  43727. * 2: left AND right buttons
  43728. * 3: menu button
  43729. * @param buttonIdx Which button index changed
  43730. * @param state New state of the button
  43731. * @param changes Which properties on the state changed since last frame
  43732. */
  43733. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43734. }
  43735. }
  43736. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43737. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43738. /**
  43739. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43740. */
  43741. export class WebXRControllerModelLoader {
  43742. /**
  43743. * Creates the WebXRControllerModelLoader
  43744. * @param input xr input that creates the controllers
  43745. */
  43746. constructor(input: WebXRInput);
  43747. }
  43748. }
  43749. declare module "babylonjs/Cameras/XR/index" {
  43750. export * from "babylonjs/Cameras/XR/webXRCamera";
  43751. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43752. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43753. export * from "babylonjs/Cameras/XR/webXRInput";
  43754. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43755. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43756. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43757. export * from "babylonjs/Cameras/XR/webXRController";
  43758. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43759. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43760. }
  43761. declare module "babylonjs/Cameras/RigModes/index" {
  43762. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43763. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43764. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43765. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43766. }
  43767. declare module "babylonjs/Cameras/index" {
  43768. export * from "babylonjs/Cameras/Inputs/index";
  43769. export * from "babylonjs/Cameras/cameraInputsManager";
  43770. export * from "babylonjs/Cameras/camera";
  43771. export * from "babylonjs/Cameras/targetCamera";
  43772. export * from "babylonjs/Cameras/freeCamera";
  43773. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43774. export * from "babylonjs/Cameras/touchCamera";
  43775. export * from "babylonjs/Cameras/arcRotateCamera";
  43776. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43777. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43778. export * from "babylonjs/Cameras/flyCamera";
  43779. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43780. export * from "babylonjs/Cameras/followCamera";
  43781. export * from "babylonjs/Cameras/followCameraInputsManager";
  43782. export * from "babylonjs/Cameras/gamepadCamera";
  43783. export * from "babylonjs/Cameras/Stereoscopic/index";
  43784. export * from "babylonjs/Cameras/universalCamera";
  43785. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43786. export * from "babylonjs/Cameras/VR/index";
  43787. export * from "babylonjs/Cameras/XR/index";
  43788. export * from "babylonjs/Cameras/RigModes/index";
  43789. }
  43790. declare module "babylonjs/Collisions/index" {
  43791. export * from "babylonjs/Collisions/collider";
  43792. export * from "babylonjs/Collisions/collisionCoordinator";
  43793. export * from "babylonjs/Collisions/pickingInfo";
  43794. export * from "babylonjs/Collisions/intersectionInfo";
  43795. export * from "babylonjs/Collisions/meshCollisionData";
  43796. }
  43797. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43798. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43799. import { Vector3 } from "babylonjs/Maths/math.vector";
  43800. import { Ray } from "babylonjs/Culling/ray";
  43801. import { Plane } from "babylonjs/Maths/math.plane";
  43802. /**
  43803. * Contains an array of blocks representing the octree
  43804. */
  43805. export interface IOctreeContainer<T> {
  43806. /**
  43807. * Blocks within the octree
  43808. */
  43809. blocks: Array<OctreeBlock<T>>;
  43810. }
  43811. /**
  43812. * Class used to store a cell in an octree
  43813. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43814. */
  43815. export class OctreeBlock<T> {
  43816. /**
  43817. * Gets the content of the current block
  43818. */
  43819. entries: T[];
  43820. /**
  43821. * Gets the list of block children
  43822. */
  43823. blocks: Array<OctreeBlock<T>>;
  43824. private _depth;
  43825. private _maxDepth;
  43826. private _capacity;
  43827. private _minPoint;
  43828. private _maxPoint;
  43829. private _boundingVectors;
  43830. private _creationFunc;
  43831. /**
  43832. * Creates a new block
  43833. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43834. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43835. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43836. * @param depth defines the current depth of this block in the octree
  43837. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43838. * @param creationFunc defines a callback to call when an element is added to the block
  43839. */
  43840. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43841. /**
  43842. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43843. */
  43844. readonly capacity: number;
  43845. /**
  43846. * Gets the minimum vector (in world space) of the block's bounding box
  43847. */
  43848. readonly minPoint: Vector3;
  43849. /**
  43850. * Gets the maximum vector (in world space) of the block's bounding box
  43851. */
  43852. readonly maxPoint: Vector3;
  43853. /**
  43854. * Add a new element to this block
  43855. * @param entry defines the element to add
  43856. */
  43857. addEntry(entry: T): void;
  43858. /**
  43859. * Remove an element from this block
  43860. * @param entry defines the element to remove
  43861. */
  43862. removeEntry(entry: T): void;
  43863. /**
  43864. * Add an array of elements to this block
  43865. * @param entries defines the array of elements to add
  43866. */
  43867. addEntries(entries: T[]): void;
  43868. /**
  43869. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43870. * @param frustumPlanes defines the frustum planes to test
  43871. * @param selection defines the array to store current content if selection is positive
  43872. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43873. */
  43874. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43875. /**
  43876. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43877. * @param sphereCenter defines the bounding sphere center
  43878. * @param sphereRadius defines the bounding sphere radius
  43879. * @param selection defines the array to store current content if selection is positive
  43880. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43881. */
  43882. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43883. /**
  43884. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43885. * @param ray defines the ray to test with
  43886. * @param selection defines the array to store current content if selection is positive
  43887. */
  43888. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43889. /**
  43890. * Subdivide the content into child blocks (this block will then be empty)
  43891. */
  43892. createInnerBlocks(): void;
  43893. /**
  43894. * @hidden
  43895. */
  43896. 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;
  43897. }
  43898. }
  43899. declare module "babylonjs/Culling/Octrees/octree" {
  43900. import { SmartArray } from "babylonjs/Misc/smartArray";
  43901. import { Vector3 } from "babylonjs/Maths/math.vector";
  43902. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43903. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43904. import { Ray } from "babylonjs/Culling/ray";
  43905. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  43906. import { Plane } from "babylonjs/Maths/math.plane";
  43907. /**
  43908. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43909. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43910. */
  43911. export class Octree<T> {
  43912. /** 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.) */
  43913. maxDepth: number;
  43914. /**
  43915. * Blocks within the octree containing objects
  43916. */
  43917. blocks: Array<OctreeBlock<T>>;
  43918. /**
  43919. * Content stored in the octree
  43920. */
  43921. dynamicContent: T[];
  43922. private _maxBlockCapacity;
  43923. private _selectionContent;
  43924. private _creationFunc;
  43925. /**
  43926. * Creates a octree
  43927. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43928. * @param creationFunc function to be used to instatiate the octree
  43929. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43930. * @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.)
  43931. */
  43932. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43933. /** 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.) */
  43934. maxDepth?: number);
  43935. /**
  43936. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43937. * @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);
  43938. * @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);
  43939. * @param entries meshes to be added to the octree blocks
  43940. */
  43941. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43942. /**
  43943. * Adds a mesh to the octree
  43944. * @param entry Mesh to add to the octree
  43945. */
  43946. addMesh(entry: T): void;
  43947. /**
  43948. * Remove an element from the octree
  43949. * @param entry defines the element to remove
  43950. */
  43951. removeMesh(entry: T): void;
  43952. /**
  43953. * Selects an array of meshes within the frustum
  43954. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43955. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43956. * @returns array of meshes within the frustum
  43957. */
  43958. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43959. /**
  43960. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43961. * @param sphereCenter defines the bounding sphere center
  43962. * @param sphereRadius defines the bounding sphere radius
  43963. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43964. * @returns an array of objects that intersect the sphere
  43965. */
  43966. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43967. /**
  43968. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43969. * @param ray defines the ray to test with
  43970. * @returns array of intersected objects
  43971. */
  43972. intersectsRay(ray: Ray): SmartArray<T>;
  43973. /**
  43974. * Adds a mesh into the octree block if it intersects the block
  43975. */
  43976. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43977. /**
  43978. * Adds a submesh into the octree block if it intersects the block
  43979. */
  43980. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43981. }
  43982. }
  43983. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  43984. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43985. import { Scene } from "babylonjs/scene";
  43986. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43987. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43988. import { Ray } from "babylonjs/Culling/ray";
  43989. import { Octree } from "babylonjs/Culling/Octrees/octree";
  43990. import { Collider } from "babylonjs/Collisions/collider";
  43991. module "babylonjs/scene" {
  43992. interface Scene {
  43993. /**
  43994. * @hidden
  43995. * Backing Filed
  43996. */
  43997. _selectionOctree: Octree<AbstractMesh>;
  43998. /**
  43999. * Gets the octree used to boost mesh selection (picking)
  44000. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44001. */
  44002. selectionOctree: Octree<AbstractMesh>;
  44003. /**
  44004. * Creates or updates the octree used to boost selection (picking)
  44005. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44006. * @param maxCapacity defines the maximum capacity per leaf
  44007. * @param maxDepth defines the maximum depth of the octree
  44008. * @returns an octree of AbstractMesh
  44009. */
  44010. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44011. }
  44012. }
  44013. module "babylonjs/Meshes/abstractMesh" {
  44014. interface AbstractMesh {
  44015. /**
  44016. * @hidden
  44017. * Backing Field
  44018. */
  44019. _submeshesOctree: Octree<SubMesh>;
  44020. /**
  44021. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44022. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44023. * @param maxCapacity defines the maximum size of each block (64 by default)
  44024. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44025. * @returns the new octree
  44026. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44027. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44028. */
  44029. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44030. }
  44031. }
  44032. /**
  44033. * Defines the octree scene component responsible to manage any octrees
  44034. * in a given scene.
  44035. */
  44036. export class OctreeSceneComponent {
  44037. /**
  44038. * The component name help to identify the component in the list of scene components.
  44039. */
  44040. readonly name: string;
  44041. /**
  44042. * The scene the component belongs to.
  44043. */
  44044. scene: Scene;
  44045. /**
  44046. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44047. */
  44048. readonly checksIsEnabled: boolean;
  44049. /**
  44050. * Creates a new instance of the component for the given scene
  44051. * @param scene Defines the scene to register the component in
  44052. */
  44053. constructor(scene: Scene);
  44054. /**
  44055. * Registers the component in a given scene
  44056. */
  44057. register(): void;
  44058. /**
  44059. * Return the list of active meshes
  44060. * @returns the list of active meshes
  44061. */
  44062. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44063. /**
  44064. * Return the list of active sub meshes
  44065. * @param mesh The mesh to get the candidates sub meshes from
  44066. * @returns the list of active sub meshes
  44067. */
  44068. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44069. private _tempRay;
  44070. /**
  44071. * Return the list of sub meshes intersecting with a given local ray
  44072. * @param mesh defines the mesh to find the submesh for
  44073. * @param localRay defines the ray in local space
  44074. * @returns the list of intersecting sub meshes
  44075. */
  44076. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44077. /**
  44078. * Return the list of sub meshes colliding with a collider
  44079. * @param mesh defines the mesh to find the submesh for
  44080. * @param collider defines the collider to evaluate the collision against
  44081. * @returns the list of colliding sub meshes
  44082. */
  44083. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44084. /**
  44085. * Rebuilds the elements related to this component in case of
  44086. * context lost for instance.
  44087. */
  44088. rebuild(): void;
  44089. /**
  44090. * Disposes the component and the associated ressources.
  44091. */
  44092. dispose(): void;
  44093. }
  44094. }
  44095. declare module "babylonjs/Culling/Octrees/index" {
  44096. export * from "babylonjs/Culling/Octrees/octree";
  44097. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44098. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44099. }
  44100. declare module "babylonjs/Culling/index" {
  44101. export * from "babylonjs/Culling/boundingBox";
  44102. export * from "babylonjs/Culling/boundingInfo";
  44103. export * from "babylonjs/Culling/boundingSphere";
  44104. export * from "babylonjs/Culling/Octrees/index";
  44105. export * from "babylonjs/Culling/ray";
  44106. }
  44107. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44108. import { IDisposable, Scene } from "babylonjs/scene";
  44109. import { Nullable } from "babylonjs/types";
  44110. import { Observable } from "babylonjs/Misc/observable";
  44111. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44112. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44113. import { Camera } from "babylonjs/Cameras/camera";
  44114. /**
  44115. * Renders a layer on top of an existing scene
  44116. */
  44117. export class UtilityLayerRenderer implements IDisposable {
  44118. /** the original scene that will be rendered on top of */
  44119. originalScene: Scene;
  44120. private _pointerCaptures;
  44121. private _lastPointerEvents;
  44122. private static _DefaultUtilityLayer;
  44123. private static _DefaultKeepDepthUtilityLayer;
  44124. private _sharedGizmoLight;
  44125. private _renderCamera;
  44126. /**
  44127. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44128. * @returns the camera that is used when rendering the utility layer
  44129. */
  44130. getRenderCamera(): Nullable<Camera>;
  44131. /**
  44132. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44133. * @param cam the camera that should be used when rendering the utility layer
  44134. */
  44135. setRenderCamera(cam: Nullable<Camera>): void;
  44136. /**
  44137. * @hidden
  44138. * Light which used by gizmos to get light shading
  44139. */
  44140. _getSharedGizmoLight(): HemisphericLight;
  44141. /**
  44142. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44143. */
  44144. pickUtilitySceneFirst: boolean;
  44145. /**
  44146. * 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)
  44147. */
  44148. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44149. /**
  44150. * 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)
  44151. */
  44152. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44153. /**
  44154. * The scene that is rendered on top of the original scene
  44155. */
  44156. utilityLayerScene: Scene;
  44157. /**
  44158. * If the utility layer should automatically be rendered on top of existing scene
  44159. */
  44160. shouldRender: boolean;
  44161. /**
  44162. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44163. */
  44164. onlyCheckPointerDownEvents: boolean;
  44165. /**
  44166. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44167. */
  44168. processAllEvents: boolean;
  44169. /**
  44170. * Observable raised when the pointer move from the utility layer scene to the main scene
  44171. */
  44172. onPointerOutObservable: Observable<number>;
  44173. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44174. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44175. private _afterRenderObserver;
  44176. private _sceneDisposeObserver;
  44177. private _originalPointerObserver;
  44178. /**
  44179. * Instantiates a UtilityLayerRenderer
  44180. * @param originalScene the original scene that will be rendered on top of
  44181. * @param handleEvents boolean indicating if the utility layer should handle events
  44182. */
  44183. constructor(
  44184. /** the original scene that will be rendered on top of */
  44185. originalScene: Scene, handleEvents?: boolean);
  44186. private _notifyObservers;
  44187. /**
  44188. * Renders the utility layers scene on top of the original scene
  44189. */
  44190. render(): void;
  44191. /**
  44192. * Disposes of the renderer
  44193. */
  44194. dispose(): void;
  44195. private _updateCamera;
  44196. }
  44197. }
  44198. declare module "babylonjs/Gizmos/gizmo" {
  44199. import { Nullable } from "babylonjs/types";
  44200. import { IDisposable } from "babylonjs/scene";
  44201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44202. import { Mesh } from "babylonjs/Meshes/mesh";
  44203. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44204. /**
  44205. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44206. */
  44207. export class Gizmo implements IDisposable {
  44208. /** The utility layer the gizmo will be added to */
  44209. gizmoLayer: UtilityLayerRenderer;
  44210. /**
  44211. * The root mesh of the gizmo
  44212. */
  44213. _rootMesh: Mesh;
  44214. private _attachedMesh;
  44215. /**
  44216. * Ratio for the scale of the gizmo (Default: 1)
  44217. */
  44218. scaleRatio: number;
  44219. /**
  44220. * If a custom mesh has been set (Default: false)
  44221. */
  44222. protected _customMeshSet: boolean;
  44223. /**
  44224. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44225. * * When set, interactions will be enabled
  44226. */
  44227. attachedMesh: Nullable<AbstractMesh>;
  44228. /**
  44229. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44230. * @param mesh The mesh to replace the default mesh of the gizmo
  44231. */
  44232. setCustomMesh(mesh: Mesh): void;
  44233. /**
  44234. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44235. */
  44236. updateGizmoRotationToMatchAttachedMesh: boolean;
  44237. /**
  44238. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44239. */
  44240. updateGizmoPositionToMatchAttachedMesh: boolean;
  44241. /**
  44242. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44243. */
  44244. updateScale: boolean;
  44245. protected _interactionsEnabled: boolean;
  44246. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44247. private _beforeRenderObserver;
  44248. private _tempVector;
  44249. /**
  44250. * Creates a gizmo
  44251. * @param gizmoLayer The utility layer the gizmo will be added to
  44252. */
  44253. constructor(
  44254. /** The utility layer the gizmo will be added to */
  44255. gizmoLayer?: UtilityLayerRenderer);
  44256. /**
  44257. * Updates the gizmo to match the attached mesh's position/rotation
  44258. */
  44259. protected _update(): void;
  44260. /**
  44261. * Disposes of the gizmo
  44262. */
  44263. dispose(): void;
  44264. }
  44265. }
  44266. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44267. import { Observable } from "babylonjs/Misc/observable";
  44268. import { Nullable } from "babylonjs/types";
  44269. import { Vector3 } from "babylonjs/Maths/math.vector";
  44270. import { Color3 } from "babylonjs/Maths/math.color";
  44271. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44273. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44274. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44275. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44276. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44277. import { Scene } from "babylonjs/scene";
  44278. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44279. /**
  44280. * Single plane drag gizmo
  44281. */
  44282. export class PlaneDragGizmo extends Gizmo {
  44283. /**
  44284. * Drag behavior responsible for the gizmos dragging interactions
  44285. */
  44286. dragBehavior: PointerDragBehavior;
  44287. private _pointerObserver;
  44288. /**
  44289. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44290. */
  44291. snapDistance: number;
  44292. /**
  44293. * Event that fires each time the gizmo snaps to a new location.
  44294. * * snapDistance is the the change in distance
  44295. */
  44296. onSnapObservable: Observable<{
  44297. snapDistance: number;
  44298. }>;
  44299. private _plane;
  44300. private _coloredMaterial;
  44301. private _hoverMaterial;
  44302. private _isEnabled;
  44303. private _parent;
  44304. /** @hidden */
  44305. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44306. /** @hidden */
  44307. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44308. /**
  44309. * Creates a PlaneDragGizmo
  44310. * @param gizmoLayer The utility layer the gizmo will be added to
  44311. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44312. * @param color The color of the gizmo
  44313. */
  44314. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44315. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44316. /**
  44317. * If the gizmo is enabled
  44318. */
  44319. isEnabled: boolean;
  44320. /**
  44321. * Disposes of the gizmo
  44322. */
  44323. dispose(): void;
  44324. }
  44325. }
  44326. declare module "babylonjs/Gizmos/positionGizmo" {
  44327. import { Observable } from "babylonjs/Misc/observable";
  44328. import { Nullable } from "babylonjs/types";
  44329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44330. import { Mesh } from "babylonjs/Meshes/mesh";
  44331. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44332. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44333. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44334. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44335. /**
  44336. * Gizmo that enables dragging a mesh along 3 axis
  44337. */
  44338. export class PositionGizmo extends Gizmo {
  44339. /**
  44340. * Internal gizmo used for interactions on the x axis
  44341. */
  44342. xGizmo: AxisDragGizmo;
  44343. /**
  44344. * Internal gizmo used for interactions on the y axis
  44345. */
  44346. yGizmo: AxisDragGizmo;
  44347. /**
  44348. * Internal gizmo used for interactions on the z axis
  44349. */
  44350. zGizmo: AxisDragGizmo;
  44351. /**
  44352. * Internal gizmo used for interactions on the yz plane
  44353. */
  44354. xPlaneGizmo: PlaneDragGizmo;
  44355. /**
  44356. * Internal gizmo used for interactions on the xz plane
  44357. */
  44358. yPlaneGizmo: PlaneDragGizmo;
  44359. /**
  44360. * Internal gizmo used for interactions on the xy plane
  44361. */
  44362. zPlaneGizmo: PlaneDragGizmo;
  44363. /**
  44364. * private variables
  44365. */
  44366. private _meshAttached;
  44367. private _updateGizmoRotationToMatchAttachedMesh;
  44368. private _snapDistance;
  44369. private _scaleRatio;
  44370. /** Fires an event when any of it's sub gizmos are dragged */
  44371. onDragStartObservable: Observable<unknown>;
  44372. /** Fires an event when any of it's sub gizmos are released from dragging */
  44373. onDragEndObservable: Observable<unknown>;
  44374. /**
  44375. * If set to true, planar drag is enabled
  44376. */
  44377. private _planarGizmoEnabled;
  44378. attachedMesh: Nullable<AbstractMesh>;
  44379. /**
  44380. * Creates a PositionGizmo
  44381. * @param gizmoLayer The utility layer the gizmo will be added to
  44382. */
  44383. constructor(gizmoLayer?: UtilityLayerRenderer);
  44384. /**
  44385. * If the planar drag gizmo is enabled
  44386. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44387. */
  44388. planarGizmoEnabled: boolean;
  44389. updateGizmoRotationToMatchAttachedMesh: boolean;
  44390. /**
  44391. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44392. */
  44393. snapDistance: number;
  44394. /**
  44395. * Ratio for the scale of the gizmo (Default: 1)
  44396. */
  44397. scaleRatio: number;
  44398. /**
  44399. * Disposes of the gizmo
  44400. */
  44401. dispose(): void;
  44402. /**
  44403. * CustomMeshes are not supported by this gizmo
  44404. * @param mesh The mesh to replace the default mesh of the gizmo
  44405. */
  44406. setCustomMesh(mesh: Mesh): void;
  44407. }
  44408. }
  44409. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44410. import { Observable } from "babylonjs/Misc/observable";
  44411. import { Nullable } from "babylonjs/types";
  44412. import { Vector3 } from "babylonjs/Maths/math.vector";
  44413. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44414. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44415. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44416. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44417. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44418. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44419. import { Scene } from "babylonjs/scene";
  44420. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44421. import { Color3 } from "babylonjs/Maths/math.color";
  44422. /**
  44423. * Single axis drag gizmo
  44424. */
  44425. export class AxisDragGizmo extends Gizmo {
  44426. /**
  44427. * Drag behavior responsible for the gizmos dragging interactions
  44428. */
  44429. dragBehavior: PointerDragBehavior;
  44430. private _pointerObserver;
  44431. /**
  44432. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44433. */
  44434. snapDistance: number;
  44435. /**
  44436. * Event that fires each time the gizmo snaps to a new location.
  44437. * * snapDistance is the the change in distance
  44438. */
  44439. onSnapObservable: Observable<{
  44440. snapDistance: number;
  44441. }>;
  44442. private _isEnabled;
  44443. private _parent;
  44444. private _arrow;
  44445. private _coloredMaterial;
  44446. private _hoverMaterial;
  44447. /** @hidden */
  44448. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44449. /** @hidden */
  44450. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44451. /**
  44452. * Creates an AxisDragGizmo
  44453. * @param gizmoLayer The utility layer the gizmo will be added to
  44454. * @param dragAxis The axis which the gizmo will be able to drag on
  44455. * @param color The color of the gizmo
  44456. */
  44457. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44458. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44459. /**
  44460. * If the gizmo is enabled
  44461. */
  44462. isEnabled: boolean;
  44463. /**
  44464. * Disposes of the gizmo
  44465. */
  44466. dispose(): void;
  44467. }
  44468. }
  44469. declare module "babylonjs/Debug/axesViewer" {
  44470. import { Vector3 } from "babylonjs/Maths/math.vector";
  44471. import { Nullable } from "babylonjs/types";
  44472. import { Scene } from "babylonjs/scene";
  44473. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44474. /**
  44475. * The Axes viewer will show 3 axes in a specific point in space
  44476. */
  44477. export class AxesViewer {
  44478. private _xAxis;
  44479. private _yAxis;
  44480. private _zAxis;
  44481. private _scaleLinesFactor;
  44482. private _instanced;
  44483. /**
  44484. * Gets the hosting scene
  44485. */
  44486. scene: Scene;
  44487. /**
  44488. * Gets or sets a number used to scale line length
  44489. */
  44490. scaleLines: number;
  44491. /** Gets the node hierarchy used to render x-axis */
  44492. readonly xAxis: TransformNode;
  44493. /** Gets the node hierarchy used to render y-axis */
  44494. readonly yAxis: TransformNode;
  44495. /** Gets the node hierarchy used to render z-axis */
  44496. readonly zAxis: TransformNode;
  44497. /**
  44498. * Creates a new AxesViewer
  44499. * @param scene defines the hosting scene
  44500. * @param scaleLines defines a number used to scale line length (1 by default)
  44501. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44502. * @param xAxis defines the node hierarchy used to render the x-axis
  44503. * @param yAxis defines the node hierarchy used to render the y-axis
  44504. * @param zAxis defines the node hierarchy used to render the z-axis
  44505. */
  44506. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44507. /**
  44508. * Force the viewer to update
  44509. * @param position defines the position of the viewer
  44510. * @param xaxis defines the x axis of the viewer
  44511. * @param yaxis defines the y axis of the viewer
  44512. * @param zaxis defines the z axis of the viewer
  44513. */
  44514. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44515. /**
  44516. * Creates an instance of this axes viewer.
  44517. * @returns a new axes viewer with instanced meshes
  44518. */
  44519. createInstance(): AxesViewer;
  44520. /** Releases resources */
  44521. dispose(): void;
  44522. private static _SetRenderingGroupId;
  44523. }
  44524. }
  44525. declare module "babylonjs/Debug/boneAxesViewer" {
  44526. import { Nullable } from "babylonjs/types";
  44527. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44528. import { Vector3 } from "babylonjs/Maths/math.vector";
  44529. import { Mesh } from "babylonjs/Meshes/mesh";
  44530. import { Bone } from "babylonjs/Bones/bone";
  44531. import { Scene } from "babylonjs/scene";
  44532. /**
  44533. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44534. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44535. */
  44536. export class BoneAxesViewer extends AxesViewer {
  44537. /**
  44538. * Gets or sets the target mesh where to display the axes viewer
  44539. */
  44540. mesh: Nullable<Mesh>;
  44541. /**
  44542. * Gets or sets the target bone where to display the axes viewer
  44543. */
  44544. bone: Nullable<Bone>;
  44545. /** Gets current position */
  44546. pos: Vector3;
  44547. /** Gets direction of X axis */
  44548. xaxis: Vector3;
  44549. /** Gets direction of Y axis */
  44550. yaxis: Vector3;
  44551. /** Gets direction of Z axis */
  44552. zaxis: Vector3;
  44553. /**
  44554. * Creates a new BoneAxesViewer
  44555. * @param scene defines the hosting scene
  44556. * @param bone defines the target bone
  44557. * @param mesh defines the target mesh
  44558. * @param scaleLines defines a scaling factor for line length (1 by default)
  44559. */
  44560. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44561. /**
  44562. * Force the viewer to update
  44563. */
  44564. update(): void;
  44565. /** Releases resources */
  44566. dispose(): void;
  44567. }
  44568. }
  44569. declare module "babylonjs/Debug/debugLayer" {
  44570. import { Scene } from "babylonjs/scene";
  44571. /**
  44572. * Interface used to define scene explorer extensibility option
  44573. */
  44574. export interface IExplorerExtensibilityOption {
  44575. /**
  44576. * Define the option label
  44577. */
  44578. label: string;
  44579. /**
  44580. * Defines the action to execute on click
  44581. */
  44582. action: (entity: any) => void;
  44583. }
  44584. /**
  44585. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44586. */
  44587. export interface IExplorerExtensibilityGroup {
  44588. /**
  44589. * Defines a predicate to test if a given type mut be extended
  44590. */
  44591. predicate: (entity: any) => boolean;
  44592. /**
  44593. * Gets the list of options added to a type
  44594. */
  44595. entries: IExplorerExtensibilityOption[];
  44596. }
  44597. /**
  44598. * Interface used to define the options to use to create the Inspector
  44599. */
  44600. export interface IInspectorOptions {
  44601. /**
  44602. * Display in overlay mode (default: false)
  44603. */
  44604. overlay?: boolean;
  44605. /**
  44606. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44607. */
  44608. globalRoot?: HTMLElement;
  44609. /**
  44610. * Display the Scene explorer
  44611. */
  44612. showExplorer?: boolean;
  44613. /**
  44614. * Display the property inspector
  44615. */
  44616. showInspector?: boolean;
  44617. /**
  44618. * Display in embed mode (both panes on the right)
  44619. */
  44620. embedMode?: boolean;
  44621. /**
  44622. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44623. */
  44624. handleResize?: boolean;
  44625. /**
  44626. * Allow the panes to popup (default: true)
  44627. */
  44628. enablePopup?: boolean;
  44629. /**
  44630. * Allow the panes to be closed by users (default: true)
  44631. */
  44632. enableClose?: boolean;
  44633. /**
  44634. * Optional list of extensibility entries
  44635. */
  44636. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44637. /**
  44638. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44639. */
  44640. inspectorURL?: string;
  44641. }
  44642. module "babylonjs/scene" {
  44643. interface Scene {
  44644. /**
  44645. * @hidden
  44646. * Backing field
  44647. */
  44648. _debugLayer: DebugLayer;
  44649. /**
  44650. * Gets the debug layer (aka Inspector) associated with the scene
  44651. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44652. */
  44653. debugLayer: DebugLayer;
  44654. }
  44655. }
  44656. /**
  44657. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44658. * what is happening in your scene
  44659. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44660. */
  44661. export class DebugLayer {
  44662. /**
  44663. * Define the url to get the inspector script from.
  44664. * By default it uses the babylonjs CDN.
  44665. * @ignoreNaming
  44666. */
  44667. static InspectorURL: string;
  44668. private _scene;
  44669. private BJSINSPECTOR;
  44670. private _onPropertyChangedObservable?;
  44671. /**
  44672. * Observable triggered when a property is changed through the inspector.
  44673. */
  44674. readonly onPropertyChangedObservable: any;
  44675. /**
  44676. * Instantiates a new debug layer.
  44677. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44678. * what is happening in your scene
  44679. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44680. * @param scene Defines the scene to inspect
  44681. */
  44682. constructor(scene: Scene);
  44683. /** Creates the inspector window. */
  44684. private _createInspector;
  44685. /**
  44686. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44687. * @param entity defines the entity to select
  44688. * @param lineContainerTitle defines the specific block to highlight
  44689. */
  44690. select(entity: any, lineContainerTitle?: string): void;
  44691. /** Get the inspector from bundle or global */
  44692. private _getGlobalInspector;
  44693. /**
  44694. * Get if the inspector is visible or not.
  44695. * @returns true if visible otherwise, false
  44696. */
  44697. isVisible(): boolean;
  44698. /**
  44699. * Hide the inspector and close its window.
  44700. */
  44701. hide(): void;
  44702. /**
  44703. * Launch the debugLayer.
  44704. * @param config Define the configuration of the inspector
  44705. * @return a promise fulfilled when the debug layer is visible
  44706. */
  44707. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44708. }
  44709. }
  44710. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44711. import { Nullable } from "babylonjs/types";
  44712. import { Scene } from "babylonjs/scene";
  44713. import { Vector4 } from "babylonjs/Maths/math.vector";
  44714. import { Color4 } from "babylonjs/Maths/math.color";
  44715. import { Mesh } from "babylonjs/Meshes/mesh";
  44716. /**
  44717. * Class containing static functions to help procedurally build meshes
  44718. */
  44719. export class BoxBuilder {
  44720. /**
  44721. * Creates a box mesh
  44722. * * The parameter `size` sets the size (float) of each box side (default 1)
  44723. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44724. * * 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)
  44725. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44726. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44727. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44729. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44730. * @param name defines the name of the mesh
  44731. * @param options defines the options used to create the mesh
  44732. * @param scene defines the hosting scene
  44733. * @returns the box mesh
  44734. */
  44735. static CreateBox(name: string, options: {
  44736. size?: number;
  44737. width?: number;
  44738. height?: number;
  44739. depth?: number;
  44740. faceUV?: Vector4[];
  44741. faceColors?: Color4[];
  44742. sideOrientation?: number;
  44743. frontUVs?: Vector4;
  44744. backUVs?: Vector4;
  44745. wrap?: boolean;
  44746. topBaseAt?: number;
  44747. bottomBaseAt?: number;
  44748. updatable?: boolean;
  44749. }, scene?: Nullable<Scene>): Mesh;
  44750. }
  44751. }
  44752. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44753. import { Vector4 } from "babylonjs/Maths/math.vector";
  44754. import { Mesh } from "babylonjs/Meshes/mesh";
  44755. import { Scene } from "babylonjs/scene";
  44756. import { Nullable } from "babylonjs/types";
  44757. /**
  44758. * Class containing static functions to help procedurally build meshes
  44759. */
  44760. export class SphereBuilder {
  44761. /**
  44762. * Creates a sphere mesh
  44763. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44764. * * 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`)
  44765. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44766. * * 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
  44767. * * 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)
  44768. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44769. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44771. * @param name defines the name of the mesh
  44772. * @param options defines the options used to create the mesh
  44773. * @param scene defines the hosting scene
  44774. * @returns the sphere mesh
  44775. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44776. */
  44777. static CreateSphere(name: string, options: {
  44778. segments?: number;
  44779. diameter?: number;
  44780. diameterX?: number;
  44781. diameterY?: number;
  44782. diameterZ?: number;
  44783. arc?: number;
  44784. slice?: number;
  44785. sideOrientation?: number;
  44786. frontUVs?: Vector4;
  44787. backUVs?: Vector4;
  44788. updatable?: boolean;
  44789. }, scene?: Nullable<Scene>): Mesh;
  44790. }
  44791. }
  44792. declare module "babylonjs/Debug/physicsViewer" {
  44793. import { Nullable } from "babylonjs/types";
  44794. import { Scene } from "babylonjs/scene";
  44795. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44796. import { Mesh } from "babylonjs/Meshes/mesh";
  44797. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44798. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44799. /**
  44800. * Used to show the physics impostor around the specific mesh
  44801. */
  44802. export class PhysicsViewer {
  44803. /** @hidden */
  44804. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44805. /** @hidden */
  44806. protected _meshes: Array<Nullable<AbstractMesh>>;
  44807. /** @hidden */
  44808. protected _scene: Nullable<Scene>;
  44809. /** @hidden */
  44810. protected _numMeshes: number;
  44811. /** @hidden */
  44812. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44813. private _renderFunction;
  44814. private _utilityLayer;
  44815. private _debugBoxMesh;
  44816. private _debugSphereMesh;
  44817. private _debugCylinderMesh;
  44818. private _debugMaterial;
  44819. private _debugMeshMeshes;
  44820. /**
  44821. * Creates a new PhysicsViewer
  44822. * @param scene defines the hosting scene
  44823. */
  44824. constructor(scene: Scene);
  44825. /** @hidden */
  44826. protected _updateDebugMeshes(): void;
  44827. /**
  44828. * Renders a specified physic impostor
  44829. * @param impostor defines the impostor to render
  44830. * @param targetMesh defines the mesh represented by the impostor
  44831. * @returns the new debug mesh used to render the impostor
  44832. */
  44833. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44834. /**
  44835. * Hides a specified physic impostor
  44836. * @param impostor defines the impostor to hide
  44837. */
  44838. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44839. private _getDebugMaterial;
  44840. private _getDebugBoxMesh;
  44841. private _getDebugSphereMesh;
  44842. private _getDebugCylinderMesh;
  44843. private _getDebugMeshMesh;
  44844. private _getDebugMesh;
  44845. /** Releases all resources */
  44846. dispose(): void;
  44847. }
  44848. }
  44849. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  44850. import { Vector3 } from "babylonjs/Maths/math.vector";
  44851. import { Color4 } from "babylonjs/Maths/math.color";
  44852. import { Nullable } from "babylonjs/types";
  44853. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44854. import { Scene } from "babylonjs/scene";
  44855. /**
  44856. * Class containing static functions to help procedurally build meshes
  44857. */
  44858. export class LinesBuilder {
  44859. /**
  44860. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44861. * * 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
  44862. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44863. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44864. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44865. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44866. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44867. * * 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
  44868. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44870. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44871. * @param name defines the name of the new line system
  44872. * @param options defines the options used to create the line system
  44873. * @param scene defines the hosting scene
  44874. * @returns a new line system mesh
  44875. */
  44876. static CreateLineSystem(name: string, options: {
  44877. lines: Vector3[][];
  44878. updatable?: boolean;
  44879. instance?: Nullable<LinesMesh>;
  44880. colors?: Nullable<Color4[][]>;
  44881. useVertexAlpha?: boolean;
  44882. }, scene: Nullable<Scene>): LinesMesh;
  44883. /**
  44884. * Creates a line mesh
  44885. * 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
  44886. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44887. * * The parameter `points` is an array successive Vector3
  44888. * * 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
  44889. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44890. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44891. * * When updating an instance, remember that only point positions can change, not the number of points
  44892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44893. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44894. * @param name defines the name of the new line system
  44895. * @param options defines the options used to create the line system
  44896. * @param scene defines the hosting scene
  44897. * @returns a new line mesh
  44898. */
  44899. static CreateLines(name: string, options: {
  44900. points: Vector3[];
  44901. updatable?: boolean;
  44902. instance?: Nullable<LinesMesh>;
  44903. colors?: Color4[];
  44904. useVertexAlpha?: boolean;
  44905. }, scene?: Nullable<Scene>): LinesMesh;
  44906. /**
  44907. * Creates a dashed line mesh
  44908. * * 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
  44909. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44910. * * The parameter `points` is an array successive Vector3
  44911. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44912. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44913. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44914. * * 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
  44915. * * When updating an instance, remember that only point positions can change, not the number of points
  44916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44917. * @param name defines the name of the mesh
  44918. * @param options defines the options used to create the mesh
  44919. * @param scene defines the hosting scene
  44920. * @returns the dashed line mesh
  44921. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44922. */
  44923. static CreateDashedLines(name: string, options: {
  44924. points: Vector3[];
  44925. dashSize?: number;
  44926. gapSize?: number;
  44927. dashNb?: number;
  44928. updatable?: boolean;
  44929. instance?: LinesMesh;
  44930. }, scene?: Nullable<Scene>): LinesMesh;
  44931. }
  44932. }
  44933. declare module "babylonjs/Debug/rayHelper" {
  44934. import { Nullable } from "babylonjs/types";
  44935. import { Ray } from "babylonjs/Culling/ray";
  44936. import { Vector3 } from "babylonjs/Maths/math.vector";
  44937. import { Color3 } from "babylonjs/Maths/math.color";
  44938. import { Scene } from "babylonjs/scene";
  44939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44940. import "babylonjs/Meshes/Builders/linesBuilder";
  44941. /**
  44942. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44943. * in order to better appreciate the issue one might have.
  44944. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44945. */
  44946. export class RayHelper {
  44947. /**
  44948. * Defines the ray we are currently tryin to visualize.
  44949. */
  44950. ray: Nullable<Ray>;
  44951. private _renderPoints;
  44952. private _renderLine;
  44953. private _renderFunction;
  44954. private _scene;
  44955. private _updateToMeshFunction;
  44956. private _attachedToMesh;
  44957. private _meshSpaceDirection;
  44958. private _meshSpaceOrigin;
  44959. /**
  44960. * Helper function to create a colored helper in a scene in one line.
  44961. * @param ray Defines the ray we are currently tryin to visualize
  44962. * @param scene Defines the scene the ray is used in
  44963. * @param color Defines the color we want to see the ray in
  44964. * @returns The newly created ray helper.
  44965. */
  44966. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44967. /**
  44968. * Instantiate a new ray helper.
  44969. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44970. * in order to better appreciate the issue one might have.
  44971. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44972. * @param ray Defines the ray we are currently tryin to visualize
  44973. */
  44974. constructor(ray: Ray);
  44975. /**
  44976. * Shows the ray we are willing to debug.
  44977. * @param scene Defines the scene the ray needs to be rendered in
  44978. * @param color Defines the color the ray needs to be rendered in
  44979. */
  44980. show(scene: Scene, color?: Color3): void;
  44981. /**
  44982. * Hides the ray we are debugging.
  44983. */
  44984. hide(): void;
  44985. private _render;
  44986. /**
  44987. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44988. * @param mesh Defines the mesh we want the helper attached to
  44989. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44990. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44991. * @param length Defines the length of the ray
  44992. */
  44993. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  44994. /**
  44995. * Detach the ray helper from the mesh it has previously been attached to.
  44996. */
  44997. detachFromMesh(): void;
  44998. private _updateToMesh;
  44999. /**
  45000. * Dispose the helper and release its associated resources.
  45001. */
  45002. dispose(): void;
  45003. }
  45004. }
  45005. declare module "babylonjs/Debug/skeletonViewer" {
  45006. import { Color3 } from "babylonjs/Maths/math.color";
  45007. import { Scene } from "babylonjs/scene";
  45008. import { Nullable } from "babylonjs/types";
  45009. import { Skeleton } from "babylonjs/Bones/skeleton";
  45010. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45011. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45012. /**
  45013. * Class used to render a debug view of a given skeleton
  45014. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45015. */
  45016. export class SkeletonViewer {
  45017. /** defines the skeleton to render */
  45018. skeleton: Skeleton;
  45019. /** defines the mesh attached to the skeleton */
  45020. mesh: AbstractMesh;
  45021. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45022. autoUpdateBonesMatrices: boolean;
  45023. /** defines the rendering group id to use with the viewer */
  45024. renderingGroupId: number;
  45025. /** Gets or sets the color used to render the skeleton */
  45026. color: Color3;
  45027. private _scene;
  45028. private _debugLines;
  45029. private _debugMesh;
  45030. private _isEnabled;
  45031. private _renderFunction;
  45032. private _utilityLayer;
  45033. /**
  45034. * Returns the mesh used to render the bones
  45035. */
  45036. readonly debugMesh: Nullable<LinesMesh>;
  45037. /**
  45038. * Creates a new SkeletonViewer
  45039. * @param skeleton defines the skeleton to render
  45040. * @param mesh defines the mesh attached to the skeleton
  45041. * @param scene defines the hosting scene
  45042. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45043. * @param renderingGroupId defines the rendering group id to use with the viewer
  45044. */
  45045. constructor(
  45046. /** defines the skeleton to render */
  45047. skeleton: Skeleton,
  45048. /** defines the mesh attached to the skeleton */
  45049. mesh: AbstractMesh, scene: Scene,
  45050. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45051. autoUpdateBonesMatrices?: boolean,
  45052. /** defines the rendering group id to use with the viewer */
  45053. renderingGroupId?: number);
  45054. /** Gets or sets a boolean indicating if the viewer is enabled */
  45055. isEnabled: boolean;
  45056. private _getBonePosition;
  45057. private _getLinesForBonesWithLength;
  45058. private _getLinesForBonesNoLength;
  45059. /** Update the viewer to sync with current skeleton state */
  45060. update(): void;
  45061. /** Release associated resources */
  45062. dispose(): void;
  45063. }
  45064. }
  45065. declare module "babylonjs/Debug/index" {
  45066. export * from "babylonjs/Debug/axesViewer";
  45067. export * from "babylonjs/Debug/boneAxesViewer";
  45068. export * from "babylonjs/Debug/debugLayer";
  45069. export * from "babylonjs/Debug/physicsViewer";
  45070. export * from "babylonjs/Debug/rayHelper";
  45071. export * from "babylonjs/Debug/skeletonViewer";
  45072. }
  45073. declare module "babylonjs/Engines/nullEngine" {
  45074. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45075. import { Scene } from "babylonjs/scene";
  45076. import { Engine } from "babylonjs/Engines/engine";
  45077. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45078. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45079. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45080. import { Effect } from "babylonjs/Materials/effect";
  45081. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45082. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45083. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45084. /**
  45085. * Options to create the null engine
  45086. */
  45087. export class NullEngineOptions {
  45088. /**
  45089. * Render width (Default: 512)
  45090. */
  45091. renderWidth: number;
  45092. /**
  45093. * Render height (Default: 256)
  45094. */
  45095. renderHeight: number;
  45096. /**
  45097. * Texture size (Default: 512)
  45098. */
  45099. textureSize: number;
  45100. /**
  45101. * If delta time between frames should be constant
  45102. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45103. */
  45104. deterministicLockstep: boolean;
  45105. /**
  45106. * Maximum about of steps between frames (Default: 4)
  45107. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45108. */
  45109. lockstepMaxSteps: number;
  45110. }
  45111. /**
  45112. * The null engine class provides support for headless version of babylon.js.
  45113. * This can be used in server side scenario or for testing purposes
  45114. */
  45115. export class NullEngine extends Engine {
  45116. private _options;
  45117. /**
  45118. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45119. */
  45120. isDeterministicLockStep(): boolean;
  45121. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  45122. getLockstepMaxSteps(): number;
  45123. /**
  45124. * Sets hardware scaling, used to save performance if needed
  45125. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  45126. */
  45127. getHardwareScalingLevel(): number;
  45128. constructor(options?: NullEngineOptions);
  45129. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45130. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45131. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45132. getRenderWidth(useScreen?: boolean): number;
  45133. getRenderHeight(useScreen?: boolean): number;
  45134. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45135. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45136. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45137. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45138. bindSamplers(effect: Effect): void;
  45139. enableEffect(effect: Effect): void;
  45140. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45141. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45142. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45143. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45144. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45145. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45146. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45147. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45148. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45149. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45150. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45151. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45152. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45153. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45154. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45155. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45156. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45157. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45158. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45159. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45160. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45161. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45162. bindBuffers(vertexBuffers: {
  45163. [key: string]: VertexBuffer;
  45164. }, indexBuffer: DataBuffer, effect: Effect): void;
  45165. wipeCaches(bruteForce?: boolean): void;
  45166. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45167. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45168. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45169. /** @hidden */
  45170. _createTexture(): WebGLTexture;
  45171. /** @hidden */
  45172. _releaseTexture(texture: InternalTexture): void;
  45173. 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;
  45174. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45175. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45176. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45177. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45178. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45179. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45180. areAllEffectsReady(): boolean;
  45181. /**
  45182. * @hidden
  45183. * Get the current error code of the webGL context
  45184. * @returns the error code
  45185. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45186. */
  45187. getError(): number;
  45188. /** @hidden */
  45189. _getUnpackAlignement(): number;
  45190. /** @hidden */
  45191. _unpackFlipY(value: boolean): void;
  45192. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45193. /**
  45194. * Updates a dynamic vertex buffer.
  45195. * @param vertexBuffer the vertex buffer to update
  45196. * @param data the data used to update the vertex buffer
  45197. * @param byteOffset the byte offset of the data (optional)
  45198. * @param byteLength the byte length of the data (optional)
  45199. */
  45200. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45201. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45202. /** @hidden */
  45203. _bindTexture(channel: number, texture: InternalTexture): void;
  45204. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45205. releaseEffects(): void;
  45206. displayLoadingUI(): void;
  45207. hideLoadingUI(): void;
  45208. /** @hidden */
  45209. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45210. /** @hidden */
  45211. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45212. /** @hidden */
  45213. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45214. /** @hidden */
  45215. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45216. }
  45217. }
  45218. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45219. import { Nullable, int } from "babylonjs/types";
  45220. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45221. /** @hidden */
  45222. export class _OcclusionDataStorage {
  45223. /** @hidden */
  45224. occlusionInternalRetryCounter: number;
  45225. /** @hidden */
  45226. isOcclusionQueryInProgress: boolean;
  45227. /** @hidden */
  45228. isOccluded: boolean;
  45229. /** @hidden */
  45230. occlusionRetryCount: number;
  45231. /** @hidden */
  45232. occlusionType: number;
  45233. /** @hidden */
  45234. occlusionQueryAlgorithmType: number;
  45235. }
  45236. module "babylonjs/Engines/engine" {
  45237. interface Engine {
  45238. /**
  45239. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45240. * @return the new query
  45241. */
  45242. createQuery(): WebGLQuery;
  45243. /**
  45244. * Delete and release a webGL query
  45245. * @param query defines the query to delete
  45246. * @return the current engine
  45247. */
  45248. deleteQuery(query: WebGLQuery): Engine;
  45249. /**
  45250. * Check if a given query has resolved and got its value
  45251. * @param query defines the query to check
  45252. * @returns true if the query got its value
  45253. */
  45254. isQueryResultAvailable(query: WebGLQuery): boolean;
  45255. /**
  45256. * Gets the value of a given query
  45257. * @param query defines the query to check
  45258. * @returns the value of the query
  45259. */
  45260. getQueryResult(query: WebGLQuery): number;
  45261. /**
  45262. * Initiates an occlusion query
  45263. * @param algorithmType defines the algorithm to use
  45264. * @param query defines the query to use
  45265. * @returns the current engine
  45266. * @see http://doc.babylonjs.com/features/occlusionquery
  45267. */
  45268. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45269. /**
  45270. * Ends an occlusion query
  45271. * @see http://doc.babylonjs.com/features/occlusionquery
  45272. * @param algorithmType defines the algorithm to use
  45273. * @returns the current engine
  45274. */
  45275. endOcclusionQuery(algorithmType: number): Engine;
  45276. /**
  45277. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45278. * Please note that only one query can be issued at a time
  45279. * @returns a time token used to track the time span
  45280. */
  45281. startTimeQuery(): Nullable<_TimeToken>;
  45282. /**
  45283. * Ends a time query
  45284. * @param token defines the token used to measure the time span
  45285. * @returns the time spent (in ns)
  45286. */
  45287. endTimeQuery(token: _TimeToken): int;
  45288. /** @hidden */
  45289. _currentNonTimestampToken: Nullable<_TimeToken>;
  45290. /** @hidden */
  45291. _createTimeQuery(): WebGLQuery;
  45292. /** @hidden */
  45293. _deleteTimeQuery(query: WebGLQuery): void;
  45294. /** @hidden */
  45295. _getGlAlgorithmType(algorithmType: number): number;
  45296. /** @hidden */
  45297. _getTimeQueryResult(query: WebGLQuery): any;
  45298. /** @hidden */
  45299. _getTimeQueryAvailability(query: WebGLQuery): any;
  45300. }
  45301. }
  45302. module "babylonjs/Meshes/abstractMesh" {
  45303. interface AbstractMesh {
  45304. /**
  45305. * Backing filed
  45306. * @hidden
  45307. */
  45308. __occlusionDataStorage: _OcclusionDataStorage;
  45309. /**
  45310. * Access property
  45311. * @hidden
  45312. */
  45313. _occlusionDataStorage: _OcclusionDataStorage;
  45314. /**
  45315. * 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.
  45316. * The default value is -1 which means don't break the query and wait till the result
  45317. * @see http://doc.babylonjs.com/features/occlusionquery
  45318. */
  45319. occlusionRetryCount: number;
  45320. /**
  45321. * 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:
  45322. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45323. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45324. * * 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.
  45325. * @see http://doc.babylonjs.com/features/occlusionquery
  45326. */
  45327. occlusionType: number;
  45328. /**
  45329. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45330. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45331. * * 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.
  45332. * @see http://doc.babylonjs.com/features/occlusionquery
  45333. */
  45334. occlusionQueryAlgorithmType: number;
  45335. /**
  45336. * 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
  45337. * @see http://doc.babylonjs.com/features/occlusionquery
  45338. */
  45339. isOccluded: boolean;
  45340. /**
  45341. * Flag to check the progress status of the query
  45342. * @see http://doc.babylonjs.com/features/occlusionquery
  45343. */
  45344. isOcclusionQueryInProgress: boolean;
  45345. }
  45346. }
  45347. }
  45348. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45349. import { Nullable } from "babylonjs/types";
  45350. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45351. /** @hidden */
  45352. export var _forceTransformFeedbackToBundle: boolean;
  45353. module "babylonjs/Engines/engine" {
  45354. interface Engine {
  45355. /**
  45356. * Creates a webGL transform feedback object
  45357. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45358. * @returns the webGL transform feedback object
  45359. */
  45360. createTransformFeedback(): WebGLTransformFeedback;
  45361. /**
  45362. * Delete a webGL transform feedback object
  45363. * @param value defines the webGL transform feedback object to delete
  45364. */
  45365. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45366. /**
  45367. * Bind a webGL transform feedback object to the webgl context
  45368. * @param value defines the webGL transform feedback object to bind
  45369. */
  45370. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45371. /**
  45372. * Begins a transform feedback operation
  45373. * @param usePoints defines if points or triangles must be used
  45374. */
  45375. beginTransformFeedback(usePoints: boolean): void;
  45376. /**
  45377. * Ends a transform feedback operation
  45378. */
  45379. endTransformFeedback(): void;
  45380. /**
  45381. * Specify the varyings to use with transform feedback
  45382. * @param program defines the associated webGL program
  45383. * @param value defines the list of strings representing the varying names
  45384. */
  45385. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45386. /**
  45387. * Bind a webGL buffer for a transform feedback operation
  45388. * @param value defines the webGL buffer to bind
  45389. */
  45390. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45391. }
  45392. }
  45393. }
  45394. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45395. import { Scene } from "babylonjs/scene";
  45396. import { Engine } from "babylonjs/Engines/engine";
  45397. import { Texture } from "babylonjs/Materials/Textures/texture";
  45398. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45399. import "babylonjs/Engines/Extensions/engine.multiRender";
  45400. /**
  45401. * Creation options of the multi render target texture.
  45402. */
  45403. export interface IMultiRenderTargetOptions {
  45404. /**
  45405. * Define if the texture needs to create mip maps after render.
  45406. */
  45407. generateMipMaps?: boolean;
  45408. /**
  45409. * Define the types of all the draw buffers we want to create
  45410. */
  45411. types?: number[];
  45412. /**
  45413. * Define the sampling modes of all the draw buffers we want to create
  45414. */
  45415. samplingModes?: number[];
  45416. /**
  45417. * Define if a depth buffer is required
  45418. */
  45419. generateDepthBuffer?: boolean;
  45420. /**
  45421. * Define if a stencil buffer is required
  45422. */
  45423. generateStencilBuffer?: boolean;
  45424. /**
  45425. * Define if a depth texture is required instead of a depth buffer
  45426. */
  45427. generateDepthTexture?: boolean;
  45428. /**
  45429. * Define the number of desired draw buffers
  45430. */
  45431. textureCount?: number;
  45432. /**
  45433. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45434. */
  45435. doNotChangeAspectRatio?: boolean;
  45436. /**
  45437. * Define the default type of the buffers we are creating
  45438. */
  45439. defaultType?: number;
  45440. }
  45441. /**
  45442. * A multi render target, like a render target provides the ability to render to a texture.
  45443. * Unlike the render target, it can render to several draw buffers in one draw.
  45444. * This is specially interesting in deferred rendering or for any effects requiring more than
  45445. * just one color from a single pass.
  45446. */
  45447. export class MultiRenderTarget extends RenderTargetTexture {
  45448. private _internalTextures;
  45449. private _textures;
  45450. private _multiRenderTargetOptions;
  45451. /**
  45452. * Get if draw buffers are currently supported by the used hardware and browser.
  45453. */
  45454. readonly isSupported: boolean;
  45455. /**
  45456. * Get the list of textures generated by the multi render target.
  45457. */
  45458. readonly textures: Texture[];
  45459. /**
  45460. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45461. */
  45462. readonly depthTexture: Texture;
  45463. /**
  45464. * Set the wrapping mode on U of all the textures we are rendering to.
  45465. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45466. */
  45467. wrapU: number;
  45468. /**
  45469. * Set the wrapping mode on V of all the textures we are rendering to.
  45470. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45471. */
  45472. wrapV: number;
  45473. /**
  45474. * Instantiate a new multi render target texture.
  45475. * A multi render target, like a render target provides the ability to render to a texture.
  45476. * Unlike the render target, it can render to several draw buffers in one draw.
  45477. * This is specially interesting in deferred rendering or for any effects requiring more than
  45478. * just one color from a single pass.
  45479. * @param name Define the name of the texture
  45480. * @param size Define the size of the buffers to render to
  45481. * @param count Define the number of target we are rendering into
  45482. * @param scene Define the scene the texture belongs to
  45483. * @param options Define the options used to create the multi render target
  45484. */
  45485. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45486. /** @hidden */
  45487. _rebuild(): void;
  45488. private _createInternalTextures;
  45489. private _createTextures;
  45490. /**
  45491. * Define the number of samples used if MSAA is enabled.
  45492. */
  45493. samples: number;
  45494. /**
  45495. * Resize all the textures in the multi render target.
  45496. * Be carrefull as it will recreate all the data in the new texture.
  45497. * @param size Define the new size
  45498. */
  45499. resize(size: any): void;
  45500. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45501. /**
  45502. * Dispose the render targets and their associated resources
  45503. */
  45504. dispose(): void;
  45505. /**
  45506. * Release all the underlying texture used as draw buffers.
  45507. */
  45508. releaseInternalTextures(): void;
  45509. }
  45510. }
  45511. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45512. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45513. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45514. import { Nullable } from "babylonjs/types";
  45515. module "babylonjs/Engines/engine" {
  45516. interface Engine {
  45517. /**
  45518. * Unbind a list of render target textures from the webGL context
  45519. * This is used only when drawBuffer extension or webGL2 are active
  45520. * @param textures defines the render target textures to unbind
  45521. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45522. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45523. */
  45524. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45525. /**
  45526. * Create a multi render target texture
  45527. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45528. * @param size defines the size of the texture
  45529. * @param options defines the creation options
  45530. * @returns the cube texture as an InternalTexture
  45531. */
  45532. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45533. /**
  45534. * Update the sample count for a given multiple render target texture
  45535. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45536. * @param textures defines the textures to update
  45537. * @param samples defines the sample count to set
  45538. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45539. */
  45540. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45541. }
  45542. }
  45543. }
  45544. declare module "babylonjs/Engines/Extensions/index" {
  45545. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  45546. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  45547. export * from "babylonjs/Engines/Extensions/engine.multiview";
  45548. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  45549. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  45550. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  45551. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  45552. export * from "babylonjs/Engines/Extensions/engine.webVR";
  45553. }
  45554. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  45555. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45556. /** @hidden */
  45557. export var rgbdEncodePixelShader: {
  45558. name: string;
  45559. shader: string;
  45560. };
  45561. }
  45562. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45563. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45564. /** @hidden */
  45565. export var rgbdDecodePixelShader: {
  45566. name: string;
  45567. shader: string;
  45568. };
  45569. }
  45570. declare module "babylonjs/Misc/environmentTextureTools" {
  45571. import { Nullable } from "babylonjs/types";
  45572. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  45573. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45574. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  45575. import "babylonjs/Engines/Extensions/engine.renderTarget";
  45576. import "babylonjs/Shaders/rgbdEncode.fragment";
  45577. import "babylonjs/Shaders/rgbdDecode.fragment";
  45578. /**
  45579. * Raw texture data and descriptor sufficient for WebGL texture upload
  45580. */
  45581. export interface EnvironmentTextureInfo {
  45582. /**
  45583. * Version of the environment map
  45584. */
  45585. version: number;
  45586. /**
  45587. * Width of image
  45588. */
  45589. width: number;
  45590. /**
  45591. * Irradiance information stored in the file.
  45592. */
  45593. irradiance: any;
  45594. /**
  45595. * Specular information stored in the file.
  45596. */
  45597. specular: any;
  45598. }
  45599. /**
  45600. * Defines One Image in the file. It requires only the position in the file
  45601. * as well as the length.
  45602. */
  45603. interface BufferImageData {
  45604. /**
  45605. * Length of the image data.
  45606. */
  45607. length: number;
  45608. /**
  45609. * Position of the data from the null terminator delimiting the end of the JSON.
  45610. */
  45611. position: number;
  45612. }
  45613. /**
  45614. * Defines the specular data enclosed in the file.
  45615. * This corresponds to the version 1 of the data.
  45616. */
  45617. export interface EnvironmentTextureSpecularInfoV1 {
  45618. /**
  45619. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  45620. */
  45621. specularDataPosition?: number;
  45622. /**
  45623. * This contains all the images data needed to reconstruct the cubemap.
  45624. */
  45625. mipmaps: Array<BufferImageData>;
  45626. /**
  45627. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  45628. */
  45629. lodGenerationScale: number;
  45630. }
  45631. /**
  45632. * Sets of helpers addressing the serialization and deserialization of environment texture
  45633. * stored in a BabylonJS env file.
  45634. * Those files are usually stored as .env files.
  45635. */
  45636. export class EnvironmentTextureTools {
  45637. /**
  45638. * Magic number identifying the env file.
  45639. */
  45640. private static _MagicBytes;
  45641. /**
  45642. * Gets the environment info from an env file.
  45643. * @param data The array buffer containing the .env bytes.
  45644. * @returns the environment file info (the json header) if successfully parsed.
  45645. */
  45646. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45647. /**
  45648. * Creates an environment texture from a loaded cube texture.
  45649. * @param texture defines the cube texture to convert in env file
  45650. * @return a promise containing the environment data if succesfull.
  45651. */
  45652. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45653. /**
  45654. * Creates a JSON representation of the spherical data.
  45655. * @param texture defines the texture containing the polynomials
  45656. * @return the JSON representation of the spherical info
  45657. */
  45658. private static _CreateEnvTextureIrradiance;
  45659. /**
  45660. * Creates the ArrayBufferViews used for initializing environment texture image data.
  45661. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  45662. * @param info parameters that determine what views will be created for accessing the underlying buffer
  45663. * @return the views described by info providing access to the underlying buffer
  45664. */
  45665. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  45666. /**
  45667. * Uploads the texture info contained in the env file to the GPU.
  45668. * @param texture defines the internal texture to upload to
  45669. * @param arrayBuffer defines the buffer cotaining the data to load
  45670. * @param info defines the texture info retrieved through the GetEnvInfo method
  45671. * @returns a promise
  45672. */
  45673. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45674. /**
  45675. * Uploads the levels of image data to the GPU.
  45676. * @param texture defines the internal texture to upload to
  45677. * @param imageData defines the array buffer views of image data [mipmap][face]
  45678. * @returns a promise
  45679. */
  45680. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45681. /**
  45682. * Uploads spherical polynomials information to the texture.
  45683. * @param texture defines the texture we are trying to upload the information to
  45684. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45685. */
  45686. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45687. /** @hidden */
  45688. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45689. }
  45690. }
  45691. declare module "babylonjs/Maths/math.vertexFormat" {
  45692. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  45693. /**
  45694. * Contains position and normal vectors for a vertex
  45695. */
  45696. export class PositionNormalVertex {
  45697. /** the position of the vertex (defaut: 0,0,0) */
  45698. position: Vector3;
  45699. /** the normal of the vertex (defaut: 0,1,0) */
  45700. normal: Vector3;
  45701. /**
  45702. * Creates a PositionNormalVertex
  45703. * @param position the position of the vertex (defaut: 0,0,0)
  45704. * @param normal the normal of the vertex (defaut: 0,1,0)
  45705. */
  45706. constructor(
  45707. /** the position of the vertex (defaut: 0,0,0) */
  45708. position?: Vector3,
  45709. /** the normal of the vertex (defaut: 0,1,0) */
  45710. normal?: Vector3);
  45711. /**
  45712. * Clones the PositionNormalVertex
  45713. * @returns the cloned PositionNormalVertex
  45714. */
  45715. clone(): PositionNormalVertex;
  45716. }
  45717. /**
  45718. * Contains position, normal and uv vectors for a vertex
  45719. */
  45720. export class PositionNormalTextureVertex {
  45721. /** the position of the vertex (defaut: 0,0,0) */
  45722. position: Vector3;
  45723. /** the normal of the vertex (defaut: 0,1,0) */
  45724. normal: Vector3;
  45725. /** the uv of the vertex (default: 0,0) */
  45726. uv: Vector2;
  45727. /**
  45728. * Creates a PositionNormalTextureVertex
  45729. * @param position the position of the vertex (defaut: 0,0,0)
  45730. * @param normal the normal of the vertex (defaut: 0,1,0)
  45731. * @param uv the uv of the vertex (default: 0,0)
  45732. */
  45733. constructor(
  45734. /** the position of the vertex (defaut: 0,0,0) */
  45735. position?: Vector3,
  45736. /** the normal of the vertex (defaut: 0,1,0) */
  45737. normal?: Vector3,
  45738. /** the uv of the vertex (default: 0,0) */
  45739. uv?: Vector2);
  45740. /**
  45741. * Clones the PositionNormalTextureVertex
  45742. * @returns the cloned PositionNormalTextureVertex
  45743. */
  45744. clone(): PositionNormalTextureVertex;
  45745. }
  45746. }
  45747. declare module "babylonjs/Maths/math" {
  45748. export * from "babylonjs/Maths/math.axis";
  45749. export * from "babylonjs/Maths/math.color";
  45750. export * from "babylonjs/Maths/math.constants";
  45751. export * from "babylonjs/Maths/math.frustum";
  45752. export * from "babylonjs/Maths/math.path";
  45753. export * from "babylonjs/Maths/math.plane";
  45754. export * from "babylonjs/Maths/math.size";
  45755. export * from "babylonjs/Maths/math.vector";
  45756. export * from "babylonjs/Maths/math.vertexFormat";
  45757. export * from "babylonjs/Maths/math.viewport";
  45758. }
  45759. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  45760. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  45761. /** @hidden */
  45762. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  45763. private _genericAttributeLocation;
  45764. private _varyingLocationCount;
  45765. private _varyingLocationMap;
  45766. private _replacements;
  45767. private _textureCount;
  45768. private _uniforms;
  45769. lineProcessor(line: string): string;
  45770. attributeProcessor(attribute: string): string;
  45771. varyingProcessor(varying: string, isFragment: boolean): string;
  45772. uniformProcessor(uniform: string): string;
  45773. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  45774. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  45775. }
  45776. }
  45777. declare module "babylonjs/Engines/nativeEngine" {
  45778. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  45779. import { Engine } from "babylonjs/Engines/engine";
  45780. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45781. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45782. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45783. import { Effect } from "babylonjs/Materials/effect";
  45784. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45785. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  45786. import { Scene } from "babylonjs/scene";
  45787. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45788. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45789. /**
  45790. * Container for accessors for natively-stored mesh data buffers.
  45791. */
  45792. class NativeDataBuffer extends DataBuffer {
  45793. /**
  45794. * Accessor value used to identify/retrieve a natively-stored index buffer.
  45795. */
  45796. nativeIndexBuffer?: any;
  45797. /**
  45798. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  45799. */
  45800. nativeVertexBuffer?: any;
  45801. }
  45802. /** @hidden */
  45803. export class NativeEngine extends Engine {
  45804. private readonly _native;
  45805. getHardwareScalingLevel(): number;
  45806. constructor();
  45807. /**
  45808. * Can be used to override the current requestAnimationFrame requester.
  45809. * @hidden
  45810. */
  45811. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  45812. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45813. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  45814. createVertexBuffer(data: DataArray): NativeDataBuffer;
  45815. recordVertexArrayObject(vertexBuffers: {
  45816. [key: string]: VertexBuffer;
  45817. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  45818. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45819. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45820. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45821. /**
  45822. * Draw a list of indexed primitives
  45823. * @param fillMode defines the primitive to use
  45824. * @param indexStart defines the starting index
  45825. * @param indexCount defines the number of index to draw
  45826. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45827. */
  45828. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45829. /**
  45830. * Draw a list of unindexed primitives
  45831. * @param fillMode defines the primitive to use
  45832. * @param verticesStart defines the index of first vertex to draw
  45833. * @param verticesCount defines the count of vertices to draw
  45834. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45835. */
  45836. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45837. createPipelineContext(): IPipelineContext;
  45838. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  45839. /** @hidden */
  45840. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45841. /** @hidden */
  45842. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45843. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45844. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45845. protected _setProgram(program: WebGLProgram): void;
  45846. _releaseEffect(effect: Effect): void;
  45847. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45848. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  45849. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  45850. bindSamplers(effect: Effect): void;
  45851. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  45852. getRenderWidth(useScreen?: boolean): number;
  45853. getRenderHeight(useScreen?: boolean): number;
  45854. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  45855. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45856. /**
  45857. * Set the z offset to apply to current rendering
  45858. * @param value defines the offset to apply
  45859. */
  45860. setZOffset(value: number): void;
  45861. /**
  45862. * Gets the current value of the zOffset
  45863. * @returns the current zOffset state
  45864. */
  45865. getZOffset(): number;
  45866. /**
  45867. * Enable or disable depth buffering
  45868. * @param enable defines the state to set
  45869. */
  45870. setDepthBuffer(enable: boolean): void;
  45871. /**
  45872. * Gets a boolean indicating if depth writing is enabled
  45873. * @returns the current depth writing state
  45874. */
  45875. getDepthWrite(): boolean;
  45876. /**
  45877. * Enable or disable depth writing
  45878. * @param enable defines the state to set
  45879. */
  45880. setDepthWrite(enable: boolean): void;
  45881. /**
  45882. * Enable or disable color writing
  45883. * @param enable defines the state to set
  45884. */
  45885. setColorWrite(enable: boolean): void;
  45886. /**
  45887. * Gets a boolean indicating if color writing is enabled
  45888. * @returns the current color writing state
  45889. */
  45890. getColorWrite(): boolean;
  45891. /**
  45892. * Sets alpha constants used by some alpha blending modes
  45893. * @param r defines the red component
  45894. * @param g defines the green component
  45895. * @param b defines the blue component
  45896. * @param a defines the alpha component
  45897. */
  45898. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  45899. /**
  45900. * Sets the current alpha mode
  45901. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  45902. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45903. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45904. */
  45905. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45906. /**
  45907. * Gets the current alpha mode
  45908. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45909. * @returns the current alpha mode
  45910. */
  45911. getAlphaMode(): number;
  45912. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45913. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45914. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45915. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45916. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45917. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45918. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45919. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45920. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45921. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45922. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45923. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45924. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45925. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45926. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45927. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45928. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45929. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45930. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45931. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45932. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  45933. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  45934. wipeCaches(bruteForce?: boolean): void;
  45935. _createTexture(): WebGLTexture;
  45936. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  45937. /**
  45938. * Usually called from BABYLON.Texture.ts.
  45939. * Passed information to create a WebGLTexture
  45940. * @param urlArg defines a value which contains one of the following:
  45941. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45942. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45943. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45944. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45945. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  45946. * @param scene needed for loading to the correct scene
  45947. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  45948. * @param onLoad optional callback to be called upon successful completion
  45949. * @param onError optional callback to be called upon failure
  45950. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  45951. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45952. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45953. * @param forcedExtension defines the extension to use to pick the right loader
  45954. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45955. */
  45956. 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;
  45957. /**
  45958. * Creates a cube texture
  45959. * @param rootUrl defines the url where the files to load is located
  45960. * @param scene defines the current scene
  45961. * @param files defines the list of files to load (1 per face)
  45962. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45963. * @param onLoad defines an optional callback raised when the texture is loaded
  45964. * @param onError defines an optional callback raised if there is an issue to load the texture
  45965. * @param format defines the format of the data
  45966. * @param forcedExtension defines the extension to use to pick the right loader
  45967. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45968. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45969. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45970. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  45971. * @returns the cube texture as an InternalTexture
  45972. */
  45973. 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;
  45974. private _getSamplingFilter;
  45975. private static _GetNativeTextureFormat;
  45976. createRenderTargetTexture(size: number | {
  45977. width: number;
  45978. height: number;
  45979. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45980. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45981. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45982. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45983. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  45984. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  45985. /**
  45986. * Updates a dynamic vertex buffer.
  45987. * @param vertexBuffer the vertex buffer to update
  45988. * @param data the data used to update the vertex buffer
  45989. * @param byteOffset the byte offset of the data (optional)
  45990. * @param byteLength the byte length of the data (optional)
  45991. */
  45992. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  45993. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  45994. private _updateAnisotropicLevel;
  45995. private _getAddressMode;
  45996. /** @hidden */
  45997. _bindTexture(channel: number, texture: InternalTexture): void;
  45998. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  45999. releaseEffects(): void;
  46000. /** @hidden */
  46001. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46002. /** @hidden */
  46003. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46004. /** @hidden */
  46005. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46006. /** @hidden */
  46007. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46008. }
  46009. }
  46010. declare module "babylonjs/Engines/index" {
  46011. export * from "babylonjs/Engines/constants";
  46012. export * from "babylonjs/Engines/engine";
  46013. export * from "babylonjs/Engines/engineStore";
  46014. export * from "babylonjs/Engines/nullEngine";
  46015. export * from "babylonjs/Engines/Extensions/index";
  46016. export * from "babylonjs/Engines/IPipelineContext";
  46017. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46018. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46019. export * from "babylonjs/Engines/nativeEngine";
  46020. }
  46021. declare module "babylonjs/Events/clipboardEvents" {
  46022. /**
  46023. * Gather the list of clipboard event types as constants.
  46024. */
  46025. export class ClipboardEventTypes {
  46026. /**
  46027. * The clipboard event is fired when a copy command is active (pressed).
  46028. */
  46029. static readonly COPY: number;
  46030. /**
  46031. * The clipboard event is fired when a cut command is active (pressed).
  46032. */
  46033. static readonly CUT: number;
  46034. /**
  46035. * The clipboard event is fired when a paste command is active (pressed).
  46036. */
  46037. static readonly PASTE: number;
  46038. }
  46039. /**
  46040. * This class is used to store clipboard related info for the onClipboardObservable event.
  46041. */
  46042. export class ClipboardInfo {
  46043. /**
  46044. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46045. */
  46046. type: number;
  46047. /**
  46048. * Defines the related dom event
  46049. */
  46050. event: ClipboardEvent;
  46051. /**
  46052. *Creates an instance of ClipboardInfo.
  46053. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46054. * @param event Defines the related dom event
  46055. */
  46056. constructor(
  46057. /**
  46058. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46059. */
  46060. type: number,
  46061. /**
  46062. * Defines the related dom event
  46063. */
  46064. event: ClipboardEvent);
  46065. /**
  46066. * Get the clipboard event's type from the keycode.
  46067. * @param keyCode Defines the keyCode for the current keyboard event.
  46068. * @return {number}
  46069. */
  46070. static GetTypeFromCharacter(keyCode: number): number;
  46071. }
  46072. }
  46073. declare module "babylonjs/Events/index" {
  46074. export * from "babylonjs/Events/keyboardEvents";
  46075. export * from "babylonjs/Events/pointerEvents";
  46076. export * from "babylonjs/Events/clipboardEvents";
  46077. }
  46078. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46079. import { Scene } from "babylonjs/scene";
  46080. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46081. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46082. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46083. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46084. /**
  46085. * Google Daydream controller
  46086. */
  46087. export class DaydreamController extends WebVRController {
  46088. /**
  46089. * Base Url for the controller model.
  46090. */
  46091. static MODEL_BASE_URL: string;
  46092. /**
  46093. * File name for the controller model.
  46094. */
  46095. static MODEL_FILENAME: string;
  46096. /**
  46097. * Gamepad Id prefix used to identify Daydream Controller.
  46098. */
  46099. static readonly GAMEPAD_ID_PREFIX: string;
  46100. /**
  46101. * Creates a new DaydreamController from a gamepad
  46102. * @param vrGamepad the gamepad that the controller should be created from
  46103. */
  46104. constructor(vrGamepad: any);
  46105. /**
  46106. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46107. * @param scene scene in which to add meshes
  46108. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46109. */
  46110. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46111. /**
  46112. * Called once for each button that changed state since the last frame
  46113. * @param buttonIdx Which button index changed
  46114. * @param state New state of the button
  46115. * @param changes Which properties on the state changed since last frame
  46116. */
  46117. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46118. }
  46119. }
  46120. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46121. import { Scene } from "babylonjs/scene";
  46122. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46123. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46124. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46125. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46126. /**
  46127. * Gear VR Controller
  46128. */
  46129. export class GearVRController extends WebVRController {
  46130. /**
  46131. * Base Url for the controller model.
  46132. */
  46133. static MODEL_BASE_URL: string;
  46134. /**
  46135. * File name for the controller model.
  46136. */
  46137. static MODEL_FILENAME: string;
  46138. /**
  46139. * Gamepad Id prefix used to identify this controller.
  46140. */
  46141. static readonly GAMEPAD_ID_PREFIX: string;
  46142. private readonly _buttonIndexToObservableNameMap;
  46143. /**
  46144. * Creates a new GearVRController from a gamepad
  46145. * @param vrGamepad the gamepad that the controller should be created from
  46146. */
  46147. constructor(vrGamepad: any);
  46148. /**
  46149. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46150. * @param scene scene in which to add meshes
  46151. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46152. */
  46153. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46154. /**
  46155. * Called once for each button that changed state since the last frame
  46156. * @param buttonIdx Which button index changed
  46157. * @param state New state of the button
  46158. * @param changes Which properties on the state changed since last frame
  46159. */
  46160. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46161. }
  46162. }
  46163. declare module "babylonjs/Gamepads/Controllers/index" {
  46164. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46165. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46166. export * from "babylonjs/Gamepads/Controllers/genericController";
  46167. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46168. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46169. export * from "babylonjs/Gamepads/Controllers/viveController";
  46170. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46171. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46172. }
  46173. declare module "babylonjs/Gamepads/index" {
  46174. export * from "babylonjs/Gamepads/Controllers/index";
  46175. export * from "babylonjs/Gamepads/gamepad";
  46176. export * from "babylonjs/Gamepads/gamepadManager";
  46177. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46178. export * from "babylonjs/Gamepads/xboxGamepad";
  46179. export * from "babylonjs/Gamepads/dualShockGamepad";
  46180. }
  46181. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46182. import { Scene } from "babylonjs/scene";
  46183. import { Vector4 } from "babylonjs/Maths/math.vector";
  46184. import { Color4 } from "babylonjs/Maths/math.color";
  46185. import { Mesh } from "babylonjs/Meshes/mesh";
  46186. import { Nullable } from "babylonjs/types";
  46187. /**
  46188. * Class containing static functions to help procedurally build meshes
  46189. */
  46190. export class PolyhedronBuilder {
  46191. /**
  46192. * Creates a polyhedron mesh
  46193. * * 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
  46194. * * The parameter `size` (positive float, default 1) sets the polygon size
  46195. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46196. * * 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`
  46197. * * 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
  46198. * * 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)`)
  46199. * * 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
  46200. * * 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
  46201. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46202. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46204. * @param name defines the name of the mesh
  46205. * @param options defines the options used to create the mesh
  46206. * @param scene defines the hosting scene
  46207. * @returns the polyhedron mesh
  46208. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46209. */
  46210. static CreatePolyhedron(name: string, options: {
  46211. type?: number;
  46212. size?: number;
  46213. sizeX?: number;
  46214. sizeY?: number;
  46215. sizeZ?: number;
  46216. custom?: any;
  46217. faceUV?: Vector4[];
  46218. faceColors?: Color4[];
  46219. flat?: boolean;
  46220. updatable?: boolean;
  46221. sideOrientation?: number;
  46222. frontUVs?: Vector4;
  46223. backUVs?: Vector4;
  46224. }, scene?: Nullable<Scene>): Mesh;
  46225. }
  46226. }
  46227. declare module "babylonjs/Gizmos/scaleGizmo" {
  46228. import { Observable } from "babylonjs/Misc/observable";
  46229. import { Nullable } from "babylonjs/types";
  46230. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46231. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46232. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  46233. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46234. /**
  46235. * Gizmo that enables scaling a mesh along 3 axis
  46236. */
  46237. export class ScaleGizmo extends Gizmo {
  46238. /**
  46239. * Internal gizmo used for interactions on the x axis
  46240. */
  46241. xGizmo: AxisScaleGizmo;
  46242. /**
  46243. * Internal gizmo used for interactions on the y axis
  46244. */
  46245. yGizmo: AxisScaleGizmo;
  46246. /**
  46247. * Internal gizmo used for interactions on the z axis
  46248. */
  46249. zGizmo: AxisScaleGizmo;
  46250. /**
  46251. * Internal gizmo used to scale all axis equally
  46252. */
  46253. uniformScaleGizmo: AxisScaleGizmo;
  46254. private _meshAttached;
  46255. private _updateGizmoRotationToMatchAttachedMesh;
  46256. private _snapDistance;
  46257. private _scaleRatio;
  46258. private _uniformScalingMesh;
  46259. private _octahedron;
  46260. /** Fires an event when any of it's sub gizmos are dragged */
  46261. onDragStartObservable: Observable<unknown>;
  46262. /** Fires an event when any of it's sub gizmos are released from dragging */
  46263. onDragEndObservable: Observable<unknown>;
  46264. attachedMesh: Nullable<AbstractMesh>;
  46265. /**
  46266. * Creates a ScaleGizmo
  46267. * @param gizmoLayer The utility layer the gizmo will be added to
  46268. */
  46269. constructor(gizmoLayer?: UtilityLayerRenderer);
  46270. updateGizmoRotationToMatchAttachedMesh: boolean;
  46271. /**
  46272. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46273. */
  46274. snapDistance: number;
  46275. /**
  46276. * Ratio for the scale of the gizmo (Default: 1)
  46277. */
  46278. scaleRatio: number;
  46279. /**
  46280. * Disposes of the gizmo
  46281. */
  46282. dispose(): void;
  46283. }
  46284. }
  46285. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  46286. import { Observable } from "babylonjs/Misc/observable";
  46287. import { Nullable } from "babylonjs/types";
  46288. import { Vector3 } from "babylonjs/Maths/math.vector";
  46289. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46290. import { Mesh } from "babylonjs/Meshes/mesh";
  46291. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46292. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46293. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46294. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46295. import { Color3 } from "babylonjs/Maths/math.color";
  46296. /**
  46297. * Single axis scale gizmo
  46298. */
  46299. export class AxisScaleGizmo extends Gizmo {
  46300. /**
  46301. * Drag behavior responsible for the gizmos dragging interactions
  46302. */
  46303. dragBehavior: PointerDragBehavior;
  46304. private _pointerObserver;
  46305. /**
  46306. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46307. */
  46308. snapDistance: number;
  46309. /**
  46310. * Event that fires each time the gizmo snaps to a new location.
  46311. * * snapDistance is the the change in distance
  46312. */
  46313. onSnapObservable: Observable<{
  46314. snapDistance: number;
  46315. }>;
  46316. /**
  46317. * If the scaling operation should be done on all axis (default: false)
  46318. */
  46319. uniformScaling: boolean;
  46320. private _isEnabled;
  46321. private _parent;
  46322. private _arrow;
  46323. private _coloredMaterial;
  46324. private _hoverMaterial;
  46325. /**
  46326. * Creates an AxisScaleGizmo
  46327. * @param gizmoLayer The utility layer the gizmo will be added to
  46328. * @param dragAxis The axis which the gizmo will be able to scale on
  46329. * @param color The color of the gizmo
  46330. */
  46331. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46332. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46333. /**
  46334. * If the gizmo is enabled
  46335. */
  46336. isEnabled: boolean;
  46337. /**
  46338. * Disposes of the gizmo
  46339. */
  46340. dispose(): void;
  46341. /**
  46342. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46343. * @param mesh The mesh to replace the default mesh of the gizmo
  46344. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46345. */
  46346. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46347. }
  46348. }
  46349. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  46350. import { Observable } from "babylonjs/Misc/observable";
  46351. import { Nullable } from "babylonjs/types";
  46352. import { Vector3 } from "babylonjs/Maths/math.vector";
  46353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46354. import { Mesh } from "babylonjs/Meshes/mesh";
  46355. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46356. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46357. import { Color3 } from "babylonjs/Maths/math.color";
  46358. import "babylonjs/Meshes/Builders/boxBuilder";
  46359. /**
  46360. * Bounding box gizmo
  46361. */
  46362. export class BoundingBoxGizmo extends Gizmo {
  46363. private _lineBoundingBox;
  46364. private _rotateSpheresParent;
  46365. private _scaleBoxesParent;
  46366. private _boundingDimensions;
  46367. private _renderObserver;
  46368. private _pointerObserver;
  46369. private _scaleDragSpeed;
  46370. private _tmpQuaternion;
  46371. private _tmpVector;
  46372. private _tmpRotationMatrix;
  46373. /**
  46374. * 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)
  46375. */
  46376. ignoreChildren: boolean;
  46377. /**
  46378. * 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)
  46379. */
  46380. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46381. /**
  46382. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46383. */
  46384. rotationSphereSize: number;
  46385. /**
  46386. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46387. */
  46388. scaleBoxSize: number;
  46389. /**
  46390. * 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)
  46391. */
  46392. fixedDragMeshScreenSize: boolean;
  46393. /**
  46394. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46395. */
  46396. fixedDragMeshScreenSizeDistanceFactor: number;
  46397. /**
  46398. * Fired when a rotation sphere or scale box is dragged
  46399. */
  46400. onDragStartObservable: Observable<{}>;
  46401. /**
  46402. * Fired when a scale box is dragged
  46403. */
  46404. onScaleBoxDragObservable: Observable<{}>;
  46405. /**
  46406. * Fired when a scale box drag is ended
  46407. */
  46408. onScaleBoxDragEndObservable: Observable<{}>;
  46409. /**
  46410. * Fired when a rotation sphere is dragged
  46411. */
  46412. onRotationSphereDragObservable: Observable<{}>;
  46413. /**
  46414. * Fired when a rotation sphere drag is ended
  46415. */
  46416. onRotationSphereDragEndObservable: Observable<{}>;
  46417. /**
  46418. * 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)
  46419. */
  46420. scalePivot: Nullable<Vector3>;
  46421. /**
  46422. * Mesh used as a pivot to rotate the attached mesh
  46423. */
  46424. private _anchorMesh;
  46425. private _existingMeshScale;
  46426. private _dragMesh;
  46427. private pointerDragBehavior;
  46428. private coloredMaterial;
  46429. private hoverColoredMaterial;
  46430. /**
  46431. * Sets the color of the bounding box gizmo
  46432. * @param color the color to set
  46433. */
  46434. setColor(color: Color3): void;
  46435. /**
  46436. * Creates an BoundingBoxGizmo
  46437. * @param gizmoLayer The utility layer the gizmo will be added to
  46438. * @param color The color of the gizmo
  46439. */
  46440. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  46441. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46442. private _selectNode;
  46443. /**
  46444. * Updates the bounding box information for the Gizmo
  46445. */
  46446. updateBoundingBox(): void;
  46447. private _updateRotationSpheres;
  46448. private _updateScaleBoxes;
  46449. /**
  46450. * Enables rotation on the specified axis and disables rotation on the others
  46451. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  46452. */
  46453. setEnabledRotationAxis(axis: string): void;
  46454. /**
  46455. * Enables/disables scaling
  46456. * @param enable if scaling should be enabled
  46457. */
  46458. setEnabledScaling(enable: boolean): void;
  46459. private _updateDummy;
  46460. /**
  46461. * Enables a pointer drag behavior on the bounding box of the gizmo
  46462. */
  46463. enableDragBehavior(): void;
  46464. /**
  46465. * Disposes of the gizmo
  46466. */
  46467. dispose(): void;
  46468. /**
  46469. * 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)
  46470. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  46471. * @returns the bounding box mesh with the passed in mesh as a child
  46472. */
  46473. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  46474. /**
  46475. * CustomMeshes are not supported by this gizmo
  46476. * @param mesh The mesh to replace the default mesh of the gizmo
  46477. */
  46478. setCustomMesh(mesh: Mesh): void;
  46479. }
  46480. }
  46481. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  46482. import { Observable } from "babylonjs/Misc/observable";
  46483. import { Nullable } from "babylonjs/types";
  46484. import { Vector3 } from "babylonjs/Maths/math.vector";
  46485. import { Color3 } from "babylonjs/Maths/math.color";
  46486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46487. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46488. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46489. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46490. import "babylonjs/Meshes/Builders/linesBuilder";
  46491. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46492. /**
  46493. * Single plane rotation gizmo
  46494. */
  46495. export class PlaneRotationGizmo extends Gizmo {
  46496. /**
  46497. * Drag behavior responsible for the gizmos dragging interactions
  46498. */
  46499. dragBehavior: PointerDragBehavior;
  46500. private _pointerObserver;
  46501. /**
  46502. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  46503. */
  46504. snapDistance: number;
  46505. /**
  46506. * Event that fires each time the gizmo snaps to a new location.
  46507. * * snapDistance is the the change in distance
  46508. */
  46509. onSnapObservable: Observable<{
  46510. snapDistance: number;
  46511. }>;
  46512. private _isEnabled;
  46513. private _parent;
  46514. /**
  46515. * Creates a PlaneRotationGizmo
  46516. * @param gizmoLayer The utility layer the gizmo will be added to
  46517. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  46518. * @param color The color of the gizmo
  46519. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46520. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46521. */
  46522. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  46523. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46524. /**
  46525. * If the gizmo is enabled
  46526. */
  46527. isEnabled: boolean;
  46528. /**
  46529. * Disposes of the gizmo
  46530. */
  46531. dispose(): void;
  46532. }
  46533. }
  46534. declare module "babylonjs/Gizmos/rotationGizmo" {
  46535. import { Observable } from "babylonjs/Misc/observable";
  46536. import { Nullable } from "babylonjs/types";
  46537. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46538. import { Mesh } from "babylonjs/Meshes/mesh";
  46539. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46540. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  46541. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46542. /**
  46543. * Gizmo that enables rotating a mesh along 3 axis
  46544. */
  46545. export class RotationGizmo extends Gizmo {
  46546. /**
  46547. * Internal gizmo used for interactions on the x axis
  46548. */
  46549. xGizmo: PlaneRotationGizmo;
  46550. /**
  46551. * Internal gizmo used for interactions on the y axis
  46552. */
  46553. yGizmo: PlaneRotationGizmo;
  46554. /**
  46555. * Internal gizmo used for interactions on the z axis
  46556. */
  46557. zGizmo: PlaneRotationGizmo;
  46558. /** Fires an event when any of it's sub gizmos are dragged */
  46559. onDragStartObservable: Observable<unknown>;
  46560. /** Fires an event when any of it's sub gizmos are released from dragging */
  46561. onDragEndObservable: Observable<unknown>;
  46562. private _meshAttached;
  46563. attachedMesh: Nullable<AbstractMesh>;
  46564. /**
  46565. * Creates a RotationGizmo
  46566. * @param gizmoLayer The utility layer the gizmo will be added to
  46567. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46568. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46569. */
  46570. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  46571. updateGizmoRotationToMatchAttachedMesh: boolean;
  46572. /**
  46573. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46574. */
  46575. snapDistance: number;
  46576. /**
  46577. * Ratio for the scale of the gizmo (Default: 1)
  46578. */
  46579. scaleRatio: number;
  46580. /**
  46581. * Disposes of the gizmo
  46582. */
  46583. dispose(): void;
  46584. /**
  46585. * CustomMeshes are not supported by this gizmo
  46586. * @param mesh The mesh to replace the default mesh of the gizmo
  46587. */
  46588. setCustomMesh(mesh: Mesh): void;
  46589. }
  46590. }
  46591. declare module "babylonjs/Gizmos/gizmoManager" {
  46592. import { Observable } from "babylonjs/Misc/observable";
  46593. import { Nullable } from "babylonjs/types";
  46594. import { Scene, IDisposable } from "babylonjs/scene";
  46595. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46596. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46597. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  46598. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46599. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46600. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46601. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  46602. /**
  46603. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  46604. */
  46605. export class GizmoManager implements IDisposable {
  46606. private scene;
  46607. /**
  46608. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  46609. */
  46610. gizmos: {
  46611. positionGizmo: Nullable<PositionGizmo>;
  46612. rotationGizmo: Nullable<RotationGizmo>;
  46613. scaleGizmo: Nullable<ScaleGizmo>;
  46614. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  46615. };
  46616. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  46617. clearGizmoOnEmptyPointerEvent: boolean;
  46618. /** Fires an event when the manager is attached to a mesh */
  46619. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  46620. private _gizmosEnabled;
  46621. private _pointerObserver;
  46622. private _attachedMesh;
  46623. private _boundingBoxColor;
  46624. private _defaultUtilityLayer;
  46625. private _defaultKeepDepthUtilityLayer;
  46626. /**
  46627. * When bounding box gizmo is enabled, this can be used to track drag/end events
  46628. */
  46629. boundingBoxDragBehavior: SixDofDragBehavior;
  46630. /**
  46631. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  46632. */
  46633. attachableMeshes: Nullable<Array<AbstractMesh>>;
  46634. /**
  46635. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  46636. */
  46637. usePointerToAttachGizmos: boolean;
  46638. /**
  46639. * Utility layer that the bounding box gizmo belongs to
  46640. */
  46641. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  46642. /**
  46643. * Utility layer that all gizmos besides bounding box belong to
  46644. */
  46645. readonly utilityLayer: UtilityLayerRenderer;
  46646. /**
  46647. * Instatiates a gizmo manager
  46648. * @param scene the scene to overlay the gizmos on top of
  46649. */
  46650. constructor(scene: Scene);
  46651. /**
  46652. * Attaches a set of gizmos to the specified mesh
  46653. * @param mesh The mesh the gizmo's should be attached to
  46654. */
  46655. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  46656. /**
  46657. * If the position gizmo is enabled
  46658. */
  46659. positionGizmoEnabled: boolean;
  46660. /**
  46661. * If the rotation gizmo is enabled
  46662. */
  46663. rotationGizmoEnabled: boolean;
  46664. /**
  46665. * If the scale gizmo is enabled
  46666. */
  46667. scaleGizmoEnabled: boolean;
  46668. /**
  46669. * If the boundingBox gizmo is enabled
  46670. */
  46671. boundingBoxGizmoEnabled: boolean;
  46672. /**
  46673. * Disposes of the gizmo manager
  46674. */
  46675. dispose(): void;
  46676. }
  46677. }
  46678. declare module "babylonjs/Lights/directionalLight" {
  46679. import { Camera } from "babylonjs/Cameras/camera";
  46680. import { Scene } from "babylonjs/scene";
  46681. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46682. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46683. import { Light } from "babylonjs/Lights/light";
  46684. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46685. import { Effect } from "babylonjs/Materials/effect";
  46686. /**
  46687. * A directional light is defined by a direction (what a surprise!).
  46688. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46689. * 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.
  46690. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46691. */
  46692. export class DirectionalLight extends ShadowLight {
  46693. private _shadowFrustumSize;
  46694. /**
  46695. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46696. */
  46697. /**
  46698. * Specifies a fix frustum size for the shadow generation.
  46699. */
  46700. shadowFrustumSize: number;
  46701. private _shadowOrthoScale;
  46702. /**
  46703. * Gets the shadow projection scale against the optimal computed one.
  46704. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46705. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46706. */
  46707. /**
  46708. * Sets the shadow projection scale against the optimal computed one.
  46709. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46710. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46711. */
  46712. shadowOrthoScale: number;
  46713. /**
  46714. * Automatically compute the projection matrix to best fit (including all the casters)
  46715. * on each frame.
  46716. */
  46717. autoUpdateExtends: boolean;
  46718. private _orthoLeft;
  46719. private _orthoRight;
  46720. private _orthoTop;
  46721. private _orthoBottom;
  46722. /**
  46723. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46724. * The directional light is emitted from everywhere in the given direction.
  46725. * It can cast shadows.
  46726. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46727. * @param name The friendly name of the light
  46728. * @param direction The direction of the light
  46729. * @param scene The scene the light belongs to
  46730. */
  46731. constructor(name: string, direction: Vector3, scene: Scene);
  46732. /**
  46733. * Returns the string "DirectionalLight".
  46734. * @return The class name
  46735. */
  46736. getClassName(): string;
  46737. /**
  46738. * Returns the integer 1.
  46739. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46740. */
  46741. getTypeID(): number;
  46742. /**
  46743. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46744. * Returns the DirectionalLight Shadow projection matrix.
  46745. */
  46746. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46747. /**
  46748. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46749. * Returns the DirectionalLight Shadow projection matrix.
  46750. */
  46751. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46752. /**
  46753. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46754. * Returns the DirectionalLight Shadow projection matrix.
  46755. */
  46756. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46757. protected _buildUniformLayout(): void;
  46758. /**
  46759. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46760. * @param effect The effect to update
  46761. * @param lightIndex The index of the light in the effect to update
  46762. * @returns The directional light
  46763. */
  46764. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46765. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  46766. /**
  46767. * Gets the minZ used for shadow according to both the scene and the light.
  46768. *
  46769. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46770. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46771. * @param activeCamera The camera we are returning the min for
  46772. * @returns the depth min z
  46773. */
  46774. getDepthMinZ(activeCamera: Camera): number;
  46775. /**
  46776. * Gets the maxZ used for shadow according to both the scene and the light.
  46777. *
  46778. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46779. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46780. * @param activeCamera The camera we are returning the max for
  46781. * @returns the depth max z
  46782. */
  46783. getDepthMaxZ(activeCamera: Camera): number;
  46784. /**
  46785. * Prepares the list of defines specific to the light type.
  46786. * @param defines the list of defines
  46787. * @param lightIndex defines the index of the light for the effect
  46788. */
  46789. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46790. }
  46791. }
  46792. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  46793. import { Mesh } from "babylonjs/Meshes/mesh";
  46794. /**
  46795. * Class containing static functions to help procedurally build meshes
  46796. */
  46797. export class HemisphereBuilder {
  46798. /**
  46799. * Creates a hemisphere mesh
  46800. * @param name defines the name of the mesh
  46801. * @param options defines the options used to create the mesh
  46802. * @param scene defines the hosting scene
  46803. * @returns the hemisphere mesh
  46804. */
  46805. static CreateHemisphere(name: string, options: {
  46806. segments?: number;
  46807. diameter?: number;
  46808. sideOrientation?: number;
  46809. }, scene: any): Mesh;
  46810. }
  46811. }
  46812. declare module "babylonjs/Lights/spotLight" {
  46813. import { Nullable } from "babylonjs/types";
  46814. import { Scene } from "babylonjs/scene";
  46815. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46816. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46817. import { Effect } from "babylonjs/Materials/effect";
  46818. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46819. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46820. /**
  46821. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46822. * These values define a cone of light starting from the position, emitting toward the direction.
  46823. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46824. * and the exponent defines the speed of the decay of the light with distance (reach).
  46825. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46826. */
  46827. export class SpotLight extends ShadowLight {
  46828. private _angle;
  46829. private _innerAngle;
  46830. private _cosHalfAngle;
  46831. private _lightAngleScale;
  46832. private _lightAngleOffset;
  46833. /**
  46834. * Gets the cone angle of the spot light in Radians.
  46835. */
  46836. /**
  46837. * Sets the cone angle of the spot light in Radians.
  46838. */
  46839. angle: number;
  46840. /**
  46841. * Only used in gltf falloff mode, this defines the angle where
  46842. * the directional falloff will start before cutting at angle which could be seen
  46843. * as outer angle.
  46844. */
  46845. /**
  46846. * Only used in gltf falloff mode, this defines the angle where
  46847. * the directional falloff will start before cutting at angle which could be seen
  46848. * as outer angle.
  46849. */
  46850. innerAngle: number;
  46851. private _shadowAngleScale;
  46852. /**
  46853. * Allows scaling the angle of the light for shadow generation only.
  46854. */
  46855. /**
  46856. * Allows scaling the angle of the light for shadow generation only.
  46857. */
  46858. shadowAngleScale: number;
  46859. /**
  46860. * The light decay speed with the distance from the emission spot.
  46861. */
  46862. exponent: number;
  46863. private _projectionTextureMatrix;
  46864. /**
  46865. * Allows reading the projecton texture
  46866. */
  46867. readonly projectionTextureMatrix: Matrix;
  46868. protected _projectionTextureLightNear: number;
  46869. /**
  46870. * Gets the near clip of the Spotlight for texture projection.
  46871. */
  46872. /**
  46873. * Sets the near clip of the Spotlight for texture projection.
  46874. */
  46875. projectionTextureLightNear: number;
  46876. protected _projectionTextureLightFar: number;
  46877. /**
  46878. * Gets the far clip of the Spotlight for texture projection.
  46879. */
  46880. /**
  46881. * Sets the far clip of the Spotlight for texture projection.
  46882. */
  46883. projectionTextureLightFar: number;
  46884. protected _projectionTextureUpDirection: Vector3;
  46885. /**
  46886. * Gets the Up vector of the Spotlight for texture projection.
  46887. */
  46888. /**
  46889. * Sets the Up vector of the Spotlight for texture projection.
  46890. */
  46891. projectionTextureUpDirection: Vector3;
  46892. private _projectionTexture;
  46893. /**
  46894. * Gets the projection texture of the light.
  46895. */
  46896. /**
  46897. * Sets the projection texture of the light.
  46898. */
  46899. projectionTexture: Nullable<BaseTexture>;
  46900. private _projectionTextureViewLightDirty;
  46901. private _projectionTextureProjectionLightDirty;
  46902. private _projectionTextureDirty;
  46903. private _projectionTextureViewTargetVector;
  46904. private _projectionTextureViewLightMatrix;
  46905. private _projectionTextureProjectionLightMatrix;
  46906. private _projectionTextureScalingMatrix;
  46907. /**
  46908. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46909. * It can cast shadows.
  46910. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46911. * @param name The light friendly name
  46912. * @param position The position of the spot light in the scene
  46913. * @param direction The direction of the light in the scene
  46914. * @param angle The cone angle of the light in Radians
  46915. * @param exponent The light decay speed with the distance from the emission spot
  46916. * @param scene The scene the lights belongs to
  46917. */
  46918. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46919. /**
  46920. * Returns the string "SpotLight".
  46921. * @returns the class name
  46922. */
  46923. getClassName(): string;
  46924. /**
  46925. * Returns the integer 2.
  46926. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46927. */
  46928. getTypeID(): number;
  46929. /**
  46930. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46931. */
  46932. protected _setDirection(value: Vector3): void;
  46933. /**
  46934. * Overrides the position setter to recompute the projection texture view light Matrix.
  46935. */
  46936. protected _setPosition(value: Vector3): void;
  46937. /**
  46938. * 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.
  46939. * Returns the SpotLight.
  46940. */
  46941. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46942. protected _computeProjectionTextureViewLightMatrix(): void;
  46943. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46944. /**
  46945. * Main function for light texture projection matrix computing.
  46946. */
  46947. protected _computeProjectionTextureMatrix(): void;
  46948. protected _buildUniformLayout(): void;
  46949. private _computeAngleValues;
  46950. /**
  46951. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46952. * @param effect The effect to update
  46953. * @param lightIndex The index of the light in the effect to update
  46954. * @returns The spot light
  46955. */
  46956. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46957. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  46958. /**
  46959. * Disposes the light and the associated resources.
  46960. */
  46961. dispose(): void;
  46962. /**
  46963. * Prepares the list of defines specific to the light type.
  46964. * @param defines the list of defines
  46965. * @param lightIndex defines the index of the light for the effect
  46966. */
  46967. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46968. }
  46969. }
  46970. declare module "babylonjs/Gizmos/lightGizmo" {
  46971. import { Nullable } from "babylonjs/types";
  46972. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46973. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46974. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46975. import { Light } from "babylonjs/Lights/light";
  46976. /**
  46977. * Gizmo that enables viewing a light
  46978. */
  46979. export class LightGizmo extends Gizmo {
  46980. private _lightMesh;
  46981. private _material;
  46982. private cachedPosition;
  46983. private cachedForward;
  46984. /**
  46985. * Creates a LightGizmo
  46986. * @param gizmoLayer The utility layer the gizmo will be added to
  46987. */
  46988. constructor(gizmoLayer?: UtilityLayerRenderer);
  46989. private _light;
  46990. /**
  46991. * The light that the gizmo is attached to
  46992. */
  46993. light: Nullable<Light>;
  46994. /**
  46995. * Gets the material used to render the light gizmo
  46996. */
  46997. readonly material: StandardMaterial;
  46998. /**
  46999. * @hidden
  47000. * Updates the gizmo to match the attached mesh's position/rotation
  47001. */
  47002. protected _update(): void;
  47003. private static _Scale;
  47004. /**
  47005. * Creates the lines for a light mesh
  47006. */
  47007. private static _createLightLines;
  47008. /**
  47009. * Disposes of the light gizmo
  47010. */
  47011. dispose(): void;
  47012. private static _CreateHemisphericLightMesh;
  47013. private static _CreatePointLightMesh;
  47014. private static _CreateSpotLightMesh;
  47015. private static _CreateDirectionalLightMesh;
  47016. }
  47017. }
  47018. declare module "babylonjs/Gizmos/index" {
  47019. export * from "babylonjs/Gizmos/axisDragGizmo";
  47020. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47021. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47022. export * from "babylonjs/Gizmos/gizmo";
  47023. export * from "babylonjs/Gizmos/gizmoManager";
  47024. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47025. export * from "babylonjs/Gizmos/positionGizmo";
  47026. export * from "babylonjs/Gizmos/rotationGizmo";
  47027. export * from "babylonjs/Gizmos/scaleGizmo";
  47028. export * from "babylonjs/Gizmos/lightGizmo";
  47029. export * from "babylonjs/Gizmos/planeDragGizmo";
  47030. }
  47031. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47032. /** @hidden */
  47033. export var backgroundFragmentDeclaration: {
  47034. name: string;
  47035. shader: string;
  47036. };
  47037. }
  47038. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47039. /** @hidden */
  47040. export var backgroundUboDeclaration: {
  47041. name: string;
  47042. shader: string;
  47043. };
  47044. }
  47045. declare module "babylonjs/Shaders/background.fragment" {
  47046. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47047. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47048. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47049. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47050. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47051. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47052. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47053. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47054. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47055. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47056. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47057. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47058. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47059. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47060. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47061. /** @hidden */
  47062. export var backgroundPixelShader: {
  47063. name: string;
  47064. shader: string;
  47065. };
  47066. }
  47067. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47068. /** @hidden */
  47069. export var backgroundVertexDeclaration: {
  47070. name: string;
  47071. shader: string;
  47072. };
  47073. }
  47074. declare module "babylonjs/Shaders/background.vertex" {
  47075. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47076. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47077. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47078. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47079. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47080. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47081. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47082. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47083. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47084. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47085. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47086. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47087. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47088. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47089. /** @hidden */
  47090. export var backgroundVertexShader: {
  47091. name: string;
  47092. shader: string;
  47093. };
  47094. }
  47095. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47096. import { Nullable, int, float } from "babylonjs/types";
  47097. import { Scene } from "babylonjs/scene";
  47098. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47099. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47100. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47101. import { Mesh } from "babylonjs/Meshes/mesh";
  47102. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47103. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47104. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47105. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47106. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47107. import { Color3 } from "babylonjs/Maths/math.color";
  47108. import "babylonjs/Shaders/background.fragment";
  47109. import "babylonjs/Shaders/background.vertex";
  47110. /**
  47111. * Background material used to create an efficient environement around your scene.
  47112. */
  47113. export class BackgroundMaterial extends PushMaterial {
  47114. /**
  47115. * Standard reflectance value at parallel view angle.
  47116. */
  47117. static StandardReflectance0: number;
  47118. /**
  47119. * Standard reflectance value at grazing angle.
  47120. */
  47121. static StandardReflectance90: number;
  47122. protected _primaryColor: Color3;
  47123. /**
  47124. * Key light Color (multiply against the environement texture)
  47125. */
  47126. primaryColor: Color3;
  47127. protected __perceptualColor: Nullable<Color3>;
  47128. /**
  47129. * Experimental Internal Use Only.
  47130. *
  47131. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47132. * This acts as a helper to set the primary color to a more "human friendly" value.
  47133. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47134. * output color as close as possible from the chosen value.
  47135. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47136. * part of lighting setup.)
  47137. */
  47138. _perceptualColor: Nullable<Color3>;
  47139. protected _primaryColorShadowLevel: float;
  47140. /**
  47141. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47142. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47143. */
  47144. primaryColorShadowLevel: float;
  47145. protected _primaryColorHighlightLevel: float;
  47146. /**
  47147. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47148. * The primary color is used at the level chosen to define what the white area would look.
  47149. */
  47150. primaryColorHighlightLevel: float;
  47151. protected _reflectionTexture: Nullable<BaseTexture>;
  47152. /**
  47153. * Reflection Texture used in the material.
  47154. * Should be author in a specific way for the best result (refer to the documentation).
  47155. */
  47156. reflectionTexture: Nullable<BaseTexture>;
  47157. protected _reflectionBlur: float;
  47158. /**
  47159. * Reflection Texture level of blur.
  47160. *
  47161. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47162. * texture twice.
  47163. */
  47164. reflectionBlur: float;
  47165. protected _diffuseTexture: Nullable<BaseTexture>;
  47166. /**
  47167. * Diffuse Texture used in the material.
  47168. * Should be author in a specific way for the best result (refer to the documentation).
  47169. */
  47170. diffuseTexture: Nullable<BaseTexture>;
  47171. protected _shadowLights: Nullable<IShadowLight[]>;
  47172. /**
  47173. * Specify the list of lights casting shadow on the material.
  47174. * All scene shadow lights will be included if null.
  47175. */
  47176. shadowLights: Nullable<IShadowLight[]>;
  47177. protected _shadowLevel: float;
  47178. /**
  47179. * Helps adjusting the shadow to a softer level if required.
  47180. * 0 means black shadows and 1 means no shadows.
  47181. */
  47182. shadowLevel: float;
  47183. protected _sceneCenter: Vector3;
  47184. /**
  47185. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47186. * It is usually zero but might be interesting to modify according to your setup.
  47187. */
  47188. sceneCenter: Vector3;
  47189. protected _opacityFresnel: boolean;
  47190. /**
  47191. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47192. * This helps ensuring a nice transition when the camera goes under the ground.
  47193. */
  47194. opacityFresnel: boolean;
  47195. protected _reflectionFresnel: boolean;
  47196. /**
  47197. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47198. * This helps adding a mirror texture on the ground.
  47199. */
  47200. reflectionFresnel: boolean;
  47201. protected _reflectionFalloffDistance: number;
  47202. /**
  47203. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47204. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47205. */
  47206. reflectionFalloffDistance: number;
  47207. protected _reflectionAmount: number;
  47208. /**
  47209. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47210. */
  47211. reflectionAmount: number;
  47212. protected _reflectionReflectance0: number;
  47213. /**
  47214. * This specifies the weight of the reflection at grazing angle.
  47215. */
  47216. reflectionReflectance0: number;
  47217. protected _reflectionReflectance90: number;
  47218. /**
  47219. * This specifies the weight of the reflection at a perpendicular point of view.
  47220. */
  47221. reflectionReflectance90: number;
  47222. /**
  47223. * Sets the reflection reflectance fresnel values according to the default standard
  47224. * empirically know to work well :-)
  47225. */
  47226. reflectionStandardFresnelWeight: number;
  47227. protected _useRGBColor: boolean;
  47228. /**
  47229. * Helps to directly use the maps channels instead of their level.
  47230. */
  47231. useRGBColor: boolean;
  47232. protected _enableNoise: boolean;
  47233. /**
  47234. * This helps reducing the banding effect that could occur on the background.
  47235. */
  47236. enableNoise: boolean;
  47237. /**
  47238. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47239. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47240. * Recommended to be keep at 1.0 except for special cases.
  47241. */
  47242. fovMultiplier: number;
  47243. private _fovMultiplier;
  47244. /**
  47245. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47246. */
  47247. useEquirectangularFOV: boolean;
  47248. private _maxSimultaneousLights;
  47249. /**
  47250. * Number of Simultaneous lights allowed on the material.
  47251. */
  47252. maxSimultaneousLights: int;
  47253. /**
  47254. * Default configuration related to image processing available in the Background Material.
  47255. */
  47256. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47257. /**
  47258. * Keep track of the image processing observer to allow dispose and replace.
  47259. */
  47260. private _imageProcessingObserver;
  47261. /**
  47262. * Attaches a new image processing configuration to the PBR Material.
  47263. * @param configuration (if null the scene configuration will be use)
  47264. */
  47265. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47266. /**
  47267. * Gets the image processing configuration used either in this material.
  47268. */
  47269. /**
  47270. * Sets the Default image processing configuration used either in the this material.
  47271. *
  47272. * If sets to null, the scene one is in use.
  47273. */
  47274. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47275. /**
  47276. * Gets wether the color curves effect is enabled.
  47277. */
  47278. /**
  47279. * Sets wether the color curves effect is enabled.
  47280. */
  47281. cameraColorCurvesEnabled: boolean;
  47282. /**
  47283. * Gets wether the color grading effect is enabled.
  47284. */
  47285. /**
  47286. * Gets wether the color grading effect is enabled.
  47287. */
  47288. cameraColorGradingEnabled: boolean;
  47289. /**
  47290. * Gets wether tonemapping is enabled or not.
  47291. */
  47292. /**
  47293. * Sets wether tonemapping is enabled or not
  47294. */
  47295. cameraToneMappingEnabled: boolean;
  47296. /**
  47297. * The camera exposure used on this material.
  47298. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47299. * This corresponds to a photographic exposure.
  47300. */
  47301. /**
  47302. * The camera exposure used on this material.
  47303. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47304. * This corresponds to a photographic exposure.
  47305. */
  47306. cameraExposure: float;
  47307. /**
  47308. * Gets The camera contrast used on this material.
  47309. */
  47310. /**
  47311. * Sets The camera contrast used on this material.
  47312. */
  47313. cameraContrast: float;
  47314. /**
  47315. * Gets the Color Grading 2D Lookup Texture.
  47316. */
  47317. /**
  47318. * Sets the Color Grading 2D Lookup Texture.
  47319. */
  47320. cameraColorGradingTexture: Nullable<BaseTexture>;
  47321. /**
  47322. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47323. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47324. * 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;
  47325. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47326. */
  47327. /**
  47328. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47329. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47330. * 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;
  47331. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47332. */
  47333. cameraColorCurves: Nullable<ColorCurves>;
  47334. /**
  47335. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47336. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47337. */
  47338. switchToBGR: boolean;
  47339. private _renderTargets;
  47340. private _reflectionControls;
  47341. private _white;
  47342. private _primaryShadowColor;
  47343. private _primaryHighlightColor;
  47344. /**
  47345. * Instantiates a Background Material in the given scene
  47346. * @param name The friendly name of the material
  47347. * @param scene The scene to add the material to
  47348. */
  47349. constructor(name: string, scene: Scene);
  47350. /**
  47351. * Gets a boolean indicating that current material needs to register RTT
  47352. */
  47353. readonly hasRenderTargetTextures: boolean;
  47354. /**
  47355. * The entire material has been created in order to prevent overdraw.
  47356. * @returns false
  47357. */
  47358. needAlphaTesting(): boolean;
  47359. /**
  47360. * The entire material has been created in order to prevent overdraw.
  47361. * @returns true if blending is enable
  47362. */
  47363. needAlphaBlending(): boolean;
  47364. /**
  47365. * Checks wether the material is ready to be rendered for a given mesh.
  47366. * @param mesh The mesh to render
  47367. * @param subMesh The submesh to check against
  47368. * @param useInstances Specify wether or not the material is used with instances
  47369. * @returns true if all the dependencies are ready (Textures, Effects...)
  47370. */
  47371. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47372. /**
  47373. * Compute the primary color according to the chosen perceptual color.
  47374. */
  47375. private _computePrimaryColorFromPerceptualColor;
  47376. /**
  47377. * Compute the highlights and shadow colors according to their chosen levels.
  47378. */
  47379. private _computePrimaryColors;
  47380. /**
  47381. * Build the uniform buffer used in the material.
  47382. */
  47383. buildUniformLayout(): void;
  47384. /**
  47385. * Unbind the material.
  47386. */
  47387. unbind(): void;
  47388. /**
  47389. * Bind only the world matrix to the material.
  47390. * @param world The world matrix to bind.
  47391. */
  47392. bindOnlyWorldMatrix(world: Matrix): void;
  47393. /**
  47394. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47395. * @param world The world matrix to bind.
  47396. * @param subMesh The submesh to bind for.
  47397. */
  47398. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47399. /**
  47400. * Checks to see if a texture is used in the material.
  47401. * @param texture - Base texture to use.
  47402. * @returns - Boolean specifying if a texture is used in the material.
  47403. */
  47404. hasTexture(texture: BaseTexture): boolean;
  47405. /**
  47406. * Dispose the material.
  47407. * @param forceDisposeEffect Force disposal of the associated effect.
  47408. * @param forceDisposeTextures Force disposal of the associated textures.
  47409. */
  47410. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47411. /**
  47412. * Clones the material.
  47413. * @param name The cloned name.
  47414. * @returns The cloned material.
  47415. */
  47416. clone(name: string): BackgroundMaterial;
  47417. /**
  47418. * Serializes the current material to its JSON representation.
  47419. * @returns The JSON representation.
  47420. */
  47421. serialize(): any;
  47422. /**
  47423. * Gets the class name of the material
  47424. * @returns "BackgroundMaterial"
  47425. */
  47426. getClassName(): string;
  47427. /**
  47428. * Parse a JSON input to create back a background material.
  47429. * @param source The JSON data to parse
  47430. * @param scene The scene to create the parsed material in
  47431. * @param rootUrl The root url of the assets the material depends upon
  47432. * @returns the instantiated BackgroundMaterial.
  47433. */
  47434. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  47435. }
  47436. }
  47437. declare module "babylonjs/Helpers/environmentHelper" {
  47438. import { Observable } from "babylonjs/Misc/observable";
  47439. import { Nullable } from "babylonjs/types";
  47440. import { Scene } from "babylonjs/scene";
  47441. import { Vector3 } from "babylonjs/Maths/math.vector";
  47442. import { Color3 } from "babylonjs/Maths/math.color";
  47443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47444. import { Mesh } from "babylonjs/Meshes/mesh";
  47445. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47446. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  47447. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47448. import "babylonjs/Meshes/Builders/planeBuilder";
  47449. import "babylonjs/Meshes/Builders/boxBuilder";
  47450. /**
  47451. * Represents the different options available during the creation of
  47452. * a Environment helper.
  47453. *
  47454. * This can control the default ground, skybox and image processing setup of your scene.
  47455. */
  47456. export interface IEnvironmentHelperOptions {
  47457. /**
  47458. * Specifies wether or not to create a ground.
  47459. * True by default.
  47460. */
  47461. createGround: boolean;
  47462. /**
  47463. * Specifies the ground size.
  47464. * 15 by default.
  47465. */
  47466. groundSize: number;
  47467. /**
  47468. * The texture used on the ground for the main color.
  47469. * Comes from the BabylonJS CDN by default.
  47470. *
  47471. * Remarks: Can be either a texture or a url.
  47472. */
  47473. groundTexture: string | BaseTexture;
  47474. /**
  47475. * The color mixed in the ground texture by default.
  47476. * BabylonJS clearColor by default.
  47477. */
  47478. groundColor: Color3;
  47479. /**
  47480. * Specifies the ground opacity.
  47481. * 1 by default.
  47482. */
  47483. groundOpacity: number;
  47484. /**
  47485. * Enables the ground to receive shadows.
  47486. * True by default.
  47487. */
  47488. enableGroundShadow: boolean;
  47489. /**
  47490. * Helps preventing the shadow to be fully black on the ground.
  47491. * 0.5 by default.
  47492. */
  47493. groundShadowLevel: number;
  47494. /**
  47495. * Creates a mirror texture attach to the ground.
  47496. * false by default.
  47497. */
  47498. enableGroundMirror: boolean;
  47499. /**
  47500. * Specifies the ground mirror size ratio.
  47501. * 0.3 by default as the default kernel is 64.
  47502. */
  47503. groundMirrorSizeRatio: number;
  47504. /**
  47505. * Specifies the ground mirror blur kernel size.
  47506. * 64 by default.
  47507. */
  47508. groundMirrorBlurKernel: number;
  47509. /**
  47510. * Specifies the ground mirror visibility amount.
  47511. * 1 by default
  47512. */
  47513. groundMirrorAmount: number;
  47514. /**
  47515. * Specifies the ground mirror reflectance weight.
  47516. * This uses the standard weight of the background material to setup the fresnel effect
  47517. * of the mirror.
  47518. * 1 by default.
  47519. */
  47520. groundMirrorFresnelWeight: number;
  47521. /**
  47522. * Specifies the ground mirror Falloff distance.
  47523. * This can helps reducing the size of the reflection.
  47524. * 0 by Default.
  47525. */
  47526. groundMirrorFallOffDistance: number;
  47527. /**
  47528. * Specifies the ground mirror texture type.
  47529. * Unsigned Int by Default.
  47530. */
  47531. groundMirrorTextureType: number;
  47532. /**
  47533. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  47534. * the shown objects.
  47535. */
  47536. groundYBias: number;
  47537. /**
  47538. * Specifies wether or not to create a skybox.
  47539. * True by default.
  47540. */
  47541. createSkybox: boolean;
  47542. /**
  47543. * Specifies the skybox size.
  47544. * 20 by default.
  47545. */
  47546. skyboxSize: number;
  47547. /**
  47548. * The texture used on the skybox for the main color.
  47549. * Comes from the BabylonJS CDN by default.
  47550. *
  47551. * Remarks: Can be either a texture or a url.
  47552. */
  47553. skyboxTexture: string | BaseTexture;
  47554. /**
  47555. * The color mixed in the skybox texture by default.
  47556. * BabylonJS clearColor by default.
  47557. */
  47558. skyboxColor: Color3;
  47559. /**
  47560. * The background rotation around the Y axis of the scene.
  47561. * This helps aligning the key lights of your scene with the background.
  47562. * 0 by default.
  47563. */
  47564. backgroundYRotation: number;
  47565. /**
  47566. * Compute automatically the size of the elements to best fit with the scene.
  47567. */
  47568. sizeAuto: boolean;
  47569. /**
  47570. * Default position of the rootMesh if autoSize is not true.
  47571. */
  47572. rootPosition: Vector3;
  47573. /**
  47574. * Sets up the image processing in the scene.
  47575. * true by default.
  47576. */
  47577. setupImageProcessing: boolean;
  47578. /**
  47579. * The texture used as your environment texture in the scene.
  47580. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  47581. *
  47582. * Remarks: Can be either a texture or a url.
  47583. */
  47584. environmentTexture: string | BaseTexture;
  47585. /**
  47586. * The value of the exposure to apply to the scene.
  47587. * 0.6 by default if setupImageProcessing is true.
  47588. */
  47589. cameraExposure: number;
  47590. /**
  47591. * The value of the contrast to apply to the scene.
  47592. * 1.6 by default if setupImageProcessing is true.
  47593. */
  47594. cameraContrast: number;
  47595. /**
  47596. * Specifies wether or not tonemapping should be enabled in the scene.
  47597. * true by default if setupImageProcessing is true.
  47598. */
  47599. toneMappingEnabled: boolean;
  47600. }
  47601. /**
  47602. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  47603. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  47604. * It also helps with the default setup of your imageProcessing configuration.
  47605. */
  47606. export class EnvironmentHelper {
  47607. /**
  47608. * Default ground texture URL.
  47609. */
  47610. private static _groundTextureCDNUrl;
  47611. /**
  47612. * Default skybox texture URL.
  47613. */
  47614. private static _skyboxTextureCDNUrl;
  47615. /**
  47616. * Default environment texture URL.
  47617. */
  47618. private static _environmentTextureCDNUrl;
  47619. /**
  47620. * Creates the default options for the helper.
  47621. */
  47622. private static _getDefaultOptions;
  47623. private _rootMesh;
  47624. /**
  47625. * Gets the root mesh created by the helper.
  47626. */
  47627. readonly rootMesh: Mesh;
  47628. private _skybox;
  47629. /**
  47630. * Gets the skybox created by the helper.
  47631. */
  47632. readonly skybox: Nullable<Mesh>;
  47633. private _skyboxTexture;
  47634. /**
  47635. * Gets the skybox texture created by the helper.
  47636. */
  47637. readonly skyboxTexture: Nullable<BaseTexture>;
  47638. private _skyboxMaterial;
  47639. /**
  47640. * Gets the skybox material created by the helper.
  47641. */
  47642. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  47643. private _ground;
  47644. /**
  47645. * Gets the ground mesh created by the helper.
  47646. */
  47647. readonly ground: Nullable<Mesh>;
  47648. private _groundTexture;
  47649. /**
  47650. * Gets the ground texture created by the helper.
  47651. */
  47652. readonly groundTexture: Nullable<BaseTexture>;
  47653. private _groundMirror;
  47654. /**
  47655. * Gets the ground mirror created by the helper.
  47656. */
  47657. readonly groundMirror: Nullable<MirrorTexture>;
  47658. /**
  47659. * Gets the ground mirror render list to helps pushing the meshes
  47660. * you wish in the ground reflection.
  47661. */
  47662. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  47663. private _groundMaterial;
  47664. /**
  47665. * Gets the ground material created by the helper.
  47666. */
  47667. readonly groundMaterial: Nullable<BackgroundMaterial>;
  47668. /**
  47669. * Stores the creation options.
  47670. */
  47671. private readonly _scene;
  47672. private _options;
  47673. /**
  47674. * This observable will be notified with any error during the creation of the environment,
  47675. * mainly texture creation errors.
  47676. */
  47677. onErrorObservable: Observable<{
  47678. message?: string;
  47679. exception?: any;
  47680. }>;
  47681. /**
  47682. * constructor
  47683. * @param options Defines the options we want to customize the helper
  47684. * @param scene The scene to add the material to
  47685. */
  47686. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  47687. /**
  47688. * Updates the background according to the new options
  47689. * @param options
  47690. */
  47691. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  47692. /**
  47693. * Sets the primary color of all the available elements.
  47694. * @param color the main color to affect to the ground and the background
  47695. */
  47696. setMainColor(color: Color3): void;
  47697. /**
  47698. * Setup the image processing according to the specified options.
  47699. */
  47700. private _setupImageProcessing;
  47701. /**
  47702. * Setup the environment texture according to the specified options.
  47703. */
  47704. private _setupEnvironmentTexture;
  47705. /**
  47706. * Setup the background according to the specified options.
  47707. */
  47708. private _setupBackground;
  47709. /**
  47710. * Get the scene sizes according to the setup.
  47711. */
  47712. private _getSceneSize;
  47713. /**
  47714. * Setup the ground according to the specified options.
  47715. */
  47716. private _setupGround;
  47717. /**
  47718. * Setup the ground material according to the specified options.
  47719. */
  47720. private _setupGroundMaterial;
  47721. /**
  47722. * Setup the ground diffuse texture according to the specified options.
  47723. */
  47724. private _setupGroundDiffuseTexture;
  47725. /**
  47726. * Setup the ground mirror texture according to the specified options.
  47727. */
  47728. private _setupGroundMirrorTexture;
  47729. /**
  47730. * Setup the ground to receive the mirror texture.
  47731. */
  47732. private _setupMirrorInGroundMaterial;
  47733. /**
  47734. * Setup the skybox according to the specified options.
  47735. */
  47736. private _setupSkybox;
  47737. /**
  47738. * Setup the skybox material according to the specified options.
  47739. */
  47740. private _setupSkyboxMaterial;
  47741. /**
  47742. * Setup the skybox reflection texture according to the specified options.
  47743. */
  47744. private _setupSkyboxReflectionTexture;
  47745. private _errorHandler;
  47746. /**
  47747. * Dispose all the elements created by the Helper.
  47748. */
  47749. dispose(): void;
  47750. }
  47751. }
  47752. declare module "babylonjs/Helpers/photoDome" {
  47753. import { Observable } from "babylonjs/Misc/observable";
  47754. import { Nullable } from "babylonjs/types";
  47755. import { Scene } from "babylonjs/scene";
  47756. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47757. import { Mesh } from "babylonjs/Meshes/mesh";
  47758. import { Texture } from "babylonjs/Materials/Textures/texture";
  47759. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47760. import "babylonjs/Meshes/Builders/sphereBuilder";
  47761. /**
  47762. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  47763. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  47764. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  47765. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47766. */
  47767. export class PhotoDome extends TransformNode {
  47768. /**
  47769. * Define the image as a Monoscopic panoramic 360 image.
  47770. */
  47771. static readonly MODE_MONOSCOPIC: number;
  47772. /**
  47773. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47774. */
  47775. static readonly MODE_TOPBOTTOM: number;
  47776. /**
  47777. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47778. */
  47779. static readonly MODE_SIDEBYSIDE: number;
  47780. private _useDirectMapping;
  47781. /**
  47782. * The texture being displayed on the sphere
  47783. */
  47784. protected _photoTexture: Texture;
  47785. /**
  47786. * Gets or sets the texture being displayed on the sphere
  47787. */
  47788. photoTexture: Texture;
  47789. /**
  47790. * Observable raised when an error occured while loading the 360 image
  47791. */
  47792. onLoadErrorObservable: Observable<string>;
  47793. /**
  47794. * The skybox material
  47795. */
  47796. protected _material: BackgroundMaterial;
  47797. /**
  47798. * The surface used for the skybox
  47799. */
  47800. protected _mesh: Mesh;
  47801. /**
  47802. * Gets the mesh used for the skybox.
  47803. */
  47804. readonly mesh: Mesh;
  47805. /**
  47806. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47807. * Also see the options.resolution property.
  47808. */
  47809. fovMultiplier: number;
  47810. private _imageMode;
  47811. /**
  47812. * Gets or set the current video mode for the video. It can be:
  47813. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  47814. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47815. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47816. */
  47817. imageMode: number;
  47818. /**
  47819. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  47820. * @param name Element's name, child elements will append suffixes for their own names.
  47821. * @param urlsOfPhoto defines the url of the photo to display
  47822. * @param options defines an object containing optional or exposed sub element properties
  47823. * @param onError defines a callback called when an error occured while loading the texture
  47824. */
  47825. constructor(name: string, urlOfPhoto: string, options: {
  47826. resolution?: number;
  47827. size?: number;
  47828. useDirectMapping?: boolean;
  47829. faceForward?: boolean;
  47830. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  47831. private _onBeforeCameraRenderObserver;
  47832. private _changeImageMode;
  47833. /**
  47834. * Releases resources associated with this node.
  47835. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47836. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47837. */
  47838. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47839. }
  47840. }
  47841. declare module "babylonjs/Misc/rgbdTextureTools" {
  47842. import "babylonjs/Shaders/rgbdDecode.fragment";
  47843. import { Texture } from "babylonjs/Materials/Textures/texture";
  47844. /**
  47845. * Class used to host RGBD texture specific utilities
  47846. */
  47847. export class RGBDTextureTools {
  47848. /**
  47849. * Expand the RGBD Texture from RGBD to Half Float if possible.
  47850. * @param texture the texture to expand.
  47851. */
  47852. static ExpandRGBDTexture(texture: Texture): void;
  47853. }
  47854. }
  47855. declare module "babylonjs/Misc/brdfTextureTools" {
  47856. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47857. import { Scene } from "babylonjs/scene";
  47858. /**
  47859. * Class used to host texture specific utilities
  47860. */
  47861. export class BRDFTextureTools {
  47862. /**
  47863. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  47864. * @param scene defines the hosting scene
  47865. * @returns the environment BRDF texture
  47866. */
  47867. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  47868. private static _environmentBRDFBase64Texture;
  47869. }
  47870. }
  47871. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  47872. import { Nullable } from "babylonjs/types";
  47873. import { Color3 } from "babylonjs/Maths/math.color";
  47874. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47875. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47876. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47877. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47878. import { Engine } from "babylonjs/Engines/engine";
  47879. import { Scene } from "babylonjs/scene";
  47880. /**
  47881. * @hidden
  47882. */
  47883. export interface IMaterialClearCoatDefines {
  47884. CLEARCOAT: boolean;
  47885. CLEARCOAT_DEFAULTIOR: boolean;
  47886. CLEARCOAT_TEXTURE: boolean;
  47887. CLEARCOAT_TEXTUREDIRECTUV: number;
  47888. CLEARCOAT_BUMP: boolean;
  47889. CLEARCOAT_BUMPDIRECTUV: number;
  47890. CLEARCOAT_TINT: boolean;
  47891. CLEARCOAT_TINT_TEXTURE: boolean;
  47892. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47893. /** @hidden */
  47894. _areTexturesDirty: boolean;
  47895. }
  47896. /**
  47897. * Define the code related to the clear coat parameters of the pbr material.
  47898. */
  47899. export class PBRClearCoatConfiguration {
  47900. /**
  47901. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47902. * The default fits with a polyurethane material.
  47903. */
  47904. private static readonly _DefaultIndexOfRefraction;
  47905. private _isEnabled;
  47906. /**
  47907. * Defines if the clear coat is enabled in the material.
  47908. */
  47909. isEnabled: boolean;
  47910. /**
  47911. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47912. */
  47913. intensity: number;
  47914. /**
  47915. * Defines the clear coat layer roughness.
  47916. */
  47917. roughness: number;
  47918. private _indexOfRefraction;
  47919. /**
  47920. * Defines the index of refraction of the clear coat.
  47921. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47922. * The default fits with a polyurethane material.
  47923. * Changing the default value is more performance intensive.
  47924. */
  47925. indexOfRefraction: number;
  47926. private _texture;
  47927. /**
  47928. * Stores the clear coat values in a texture.
  47929. */
  47930. texture: Nullable<BaseTexture>;
  47931. private _bumpTexture;
  47932. /**
  47933. * Define the clear coat specific bump texture.
  47934. */
  47935. bumpTexture: Nullable<BaseTexture>;
  47936. private _isTintEnabled;
  47937. /**
  47938. * Defines if the clear coat tint is enabled in the material.
  47939. */
  47940. isTintEnabled: boolean;
  47941. /**
  47942. * Defines the clear coat tint of the material.
  47943. * This is only use if tint is enabled
  47944. */
  47945. tintColor: Color3;
  47946. /**
  47947. * Defines the distance at which the tint color should be found in the
  47948. * clear coat media.
  47949. * This is only use if tint is enabled
  47950. */
  47951. tintColorAtDistance: number;
  47952. /**
  47953. * Defines the clear coat layer thickness.
  47954. * This is only use if tint is enabled
  47955. */
  47956. tintThickness: number;
  47957. private _tintTexture;
  47958. /**
  47959. * Stores the clear tint values in a texture.
  47960. * rgb is tint
  47961. * a is a thickness factor
  47962. */
  47963. tintTexture: Nullable<BaseTexture>;
  47964. /** @hidden */
  47965. private _internalMarkAllSubMeshesAsTexturesDirty;
  47966. /** @hidden */
  47967. _markAllSubMeshesAsTexturesDirty(): void;
  47968. /**
  47969. * Instantiate a new istance of clear coat configuration.
  47970. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47971. */
  47972. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47973. /**
  47974. * Gets wehter the submesh is ready to be used or not.
  47975. * @param defines the list of "defines" to update.
  47976. * @param scene defines the scene the material belongs to.
  47977. * @param engine defines the engine the material belongs to.
  47978. * @param disableBumpMap defines wether the material disables bump or not.
  47979. * @returns - boolean indicating that the submesh is ready or not.
  47980. */
  47981. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  47982. /**
  47983. * Checks to see if a texture is used in the material.
  47984. * @param defines the list of "defines" to update.
  47985. * @param scene defines the scene to the material belongs to.
  47986. */
  47987. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47988. /**
  47989. * Binds the material data.
  47990. * @param uniformBuffer defines the Uniform buffer to fill in.
  47991. * @param scene defines the scene the material belongs to.
  47992. * @param engine defines the engine the material belongs to.
  47993. * @param disableBumpMap defines wether the material disables bump or not.
  47994. * @param isFrozen defines wether the material is frozen or not.
  47995. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47996. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47997. */
  47998. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  47999. /**
  48000. * Checks to see if a texture is used in the material.
  48001. * @param texture - Base texture to use.
  48002. * @returns - Boolean specifying if a texture is used in the material.
  48003. */
  48004. hasTexture(texture: BaseTexture): boolean;
  48005. /**
  48006. * Returns an array of the actively used textures.
  48007. * @param activeTextures Array of BaseTextures
  48008. */
  48009. getActiveTextures(activeTextures: BaseTexture[]): void;
  48010. /**
  48011. * Returns the animatable textures.
  48012. * @param animatables Array of animatable textures.
  48013. */
  48014. getAnimatables(animatables: IAnimatable[]): void;
  48015. /**
  48016. * Disposes the resources of the material.
  48017. * @param forceDisposeTextures - Forces the disposal of all textures.
  48018. */
  48019. dispose(forceDisposeTextures?: boolean): void;
  48020. /**
  48021. * Get the current class name of the texture useful for serialization or dynamic coding.
  48022. * @returns "PBRClearCoatConfiguration"
  48023. */
  48024. getClassName(): string;
  48025. /**
  48026. * Add fallbacks to the effect fallbacks list.
  48027. * @param defines defines the Base texture to use.
  48028. * @param fallbacks defines the current fallback list.
  48029. * @param currentRank defines the current fallback rank.
  48030. * @returns the new fallback rank.
  48031. */
  48032. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48033. /**
  48034. * Add the required uniforms to the current list.
  48035. * @param uniforms defines the current uniform list.
  48036. */
  48037. static AddUniforms(uniforms: string[]): void;
  48038. /**
  48039. * Add the required samplers to the current list.
  48040. * @param samplers defines the current sampler list.
  48041. */
  48042. static AddSamplers(samplers: string[]): void;
  48043. /**
  48044. * Add the required uniforms to the current buffer.
  48045. * @param uniformBuffer defines the current uniform buffer.
  48046. */
  48047. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48048. /**
  48049. * Makes a duplicate of the current configuration into another one.
  48050. * @param clearCoatConfiguration define the config where to copy the info
  48051. */
  48052. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48053. /**
  48054. * Serializes this clear coat configuration.
  48055. * @returns - An object with the serialized config.
  48056. */
  48057. serialize(): any;
  48058. /**
  48059. * Parses a anisotropy Configuration from a serialized object.
  48060. * @param source - Serialized object.
  48061. * @param scene Defines the scene we are parsing for
  48062. * @param rootUrl Defines the rootUrl to load from
  48063. */
  48064. parse(source: any, scene: Scene, rootUrl: string): void;
  48065. }
  48066. }
  48067. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48068. import { EffectFallbacks } from "babylonjs/Materials/effect";
  48069. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48071. import { Vector2 } from "babylonjs/Maths/math.vector";
  48072. import { Scene } from "babylonjs/scene";
  48073. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48074. import { Nullable } from "babylonjs/types";
  48075. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48076. /**
  48077. * @hidden
  48078. */
  48079. export interface IMaterialAnisotropicDefines {
  48080. ANISOTROPIC: boolean;
  48081. ANISOTROPIC_TEXTURE: boolean;
  48082. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48083. MAINUV1: boolean;
  48084. _areTexturesDirty: boolean;
  48085. _needUVs: boolean;
  48086. }
  48087. /**
  48088. * Define the code related to the anisotropic parameters of the pbr material.
  48089. */
  48090. export class PBRAnisotropicConfiguration {
  48091. private _isEnabled;
  48092. /**
  48093. * Defines if the anisotropy is enabled in the material.
  48094. */
  48095. isEnabled: boolean;
  48096. /**
  48097. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48098. */
  48099. intensity: number;
  48100. /**
  48101. * Defines if the effect is along the tangents, bitangents or in between.
  48102. * By default, the effect is "strectching" the highlights along the tangents.
  48103. */
  48104. direction: Vector2;
  48105. private _texture;
  48106. /**
  48107. * Stores the anisotropy values in a texture.
  48108. * rg is direction (like normal from -1 to 1)
  48109. * b is a intensity
  48110. */
  48111. texture: Nullable<BaseTexture>;
  48112. /** @hidden */
  48113. private _internalMarkAllSubMeshesAsTexturesDirty;
  48114. /** @hidden */
  48115. _markAllSubMeshesAsTexturesDirty(): void;
  48116. /**
  48117. * Instantiate a new istance of anisotropy configuration.
  48118. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48119. */
  48120. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48121. /**
  48122. * Specifies that the submesh is ready to be used.
  48123. * @param defines the list of "defines" to update.
  48124. * @param scene defines the scene the material belongs to.
  48125. * @returns - boolean indicating that the submesh is ready or not.
  48126. */
  48127. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48128. /**
  48129. * Checks to see if a texture is used in the material.
  48130. * @param defines the list of "defines" to update.
  48131. * @param mesh the mesh we are preparing the defines for.
  48132. * @param scene defines the scene the material belongs to.
  48133. */
  48134. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48135. /**
  48136. * Binds the material data.
  48137. * @param uniformBuffer defines the Uniform buffer to fill in.
  48138. * @param scene defines the scene the material belongs to.
  48139. * @param isFrozen defines wether the material is frozen or not.
  48140. */
  48141. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48142. /**
  48143. * Checks to see if a texture is used in the material.
  48144. * @param texture - Base texture to use.
  48145. * @returns - Boolean specifying if a texture is used in the material.
  48146. */
  48147. hasTexture(texture: BaseTexture): boolean;
  48148. /**
  48149. * Returns an array of the actively used textures.
  48150. * @param activeTextures Array of BaseTextures
  48151. */
  48152. getActiveTextures(activeTextures: BaseTexture[]): void;
  48153. /**
  48154. * Returns the animatable textures.
  48155. * @param animatables Array of animatable textures.
  48156. */
  48157. getAnimatables(animatables: IAnimatable[]): void;
  48158. /**
  48159. * Disposes the resources of the material.
  48160. * @param forceDisposeTextures - Forces the disposal of all textures.
  48161. */
  48162. dispose(forceDisposeTextures?: boolean): void;
  48163. /**
  48164. * Get the current class name of the texture useful for serialization or dynamic coding.
  48165. * @returns "PBRAnisotropicConfiguration"
  48166. */
  48167. getClassName(): string;
  48168. /**
  48169. * Add fallbacks to the effect fallbacks list.
  48170. * @param defines defines the Base texture to use.
  48171. * @param fallbacks defines the current fallback list.
  48172. * @param currentRank defines the current fallback rank.
  48173. * @returns the new fallback rank.
  48174. */
  48175. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48176. /**
  48177. * Add the required uniforms to the current list.
  48178. * @param uniforms defines the current uniform list.
  48179. */
  48180. static AddUniforms(uniforms: string[]): void;
  48181. /**
  48182. * Add the required uniforms to the current buffer.
  48183. * @param uniformBuffer defines the current uniform buffer.
  48184. */
  48185. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48186. /**
  48187. * Add the required samplers to the current list.
  48188. * @param samplers defines the current sampler list.
  48189. */
  48190. static AddSamplers(samplers: string[]): void;
  48191. /**
  48192. * Makes a duplicate of the current configuration into another one.
  48193. * @param anisotropicConfiguration define the config where to copy the info
  48194. */
  48195. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48196. /**
  48197. * Serializes this anisotropy configuration.
  48198. * @returns - An object with the serialized config.
  48199. */
  48200. serialize(): any;
  48201. /**
  48202. * Parses a anisotropy Configuration from a serialized object.
  48203. * @param source - Serialized object.
  48204. * @param scene Defines the scene we are parsing for
  48205. * @param rootUrl Defines the rootUrl to load from
  48206. */
  48207. parse(source: any, scene: Scene, rootUrl: string): void;
  48208. }
  48209. }
  48210. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48211. import { Scene } from "babylonjs/scene";
  48212. /**
  48213. * @hidden
  48214. */
  48215. export interface IMaterialBRDFDefines {
  48216. BRDF_V_HEIGHT_CORRELATED: boolean;
  48217. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48218. SPHERICAL_HARMONICS: boolean;
  48219. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48220. /** @hidden */
  48221. _areMiscDirty: boolean;
  48222. }
  48223. /**
  48224. * Define the code related to the BRDF parameters of the pbr material.
  48225. */
  48226. export class PBRBRDFConfiguration {
  48227. /**
  48228. * Default value used for the energy conservation.
  48229. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48230. */
  48231. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48232. /**
  48233. * Default value used for the Smith Visibility Height Correlated mode.
  48234. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48235. */
  48236. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48237. /**
  48238. * Default value used for the IBL diffuse part.
  48239. * This can help switching back to the polynomials mode globally which is a tiny bit
  48240. * less GPU intensive at the drawback of a lower quality.
  48241. */
  48242. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48243. /**
  48244. * Default value used for activating energy conservation for the specular workflow.
  48245. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48246. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48247. */
  48248. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48249. private _useEnergyConservation;
  48250. /**
  48251. * Defines if the material uses energy conservation.
  48252. */
  48253. useEnergyConservation: boolean;
  48254. private _useSmithVisibilityHeightCorrelated;
  48255. /**
  48256. * LEGACY Mode set to false
  48257. * Defines if the material uses height smith correlated visibility term.
  48258. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48259. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48260. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48261. * Not relying on height correlated will also disable energy conservation.
  48262. */
  48263. useSmithVisibilityHeightCorrelated: boolean;
  48264. private _useSphericalHarmonics;
  48265. /**
  48266. * LEGACY Mode set to false
  48267. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48268. * diffuse part of the IBL.
  48269. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48270. * to the ground truth.
  48271. */
  48272. useSphericalHarmonics: boolean;
  48273. private _useSpecularGlossinessInputEnergyConservation;
  48274. /**
  48275. * Defines if the material uses energy conservation, when the specular workflow is active.
  48276. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48277. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48278. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48279. */
  48280. useSpecularGlossinessInputEnergyConservation: boolean;
  48281. /** @hidden */
  48282. private _internalMarkAllSubMeshesAsMiscDirty;
  48283. /** @hidden */
  48284. _markAllSubMeshesAsMiscDirty(): void;
  48285. /**
  48286. * Instantiate a new istance of clear coat configuration.
  48287. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48288. */
  48289. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48290. /**
  48291. * Checks to see if a texture is used in the material.
  48292. * @param defines the list of "defines" to update.
  48293. */
  48294. prepareDefines(defines: IMaterialBRDFDefines): void;
  48295. /**
  48296. * Get the current class name of the texture useful for serialization or dynamic coding.
  48297. * @returns "PBRClearCoatConfiguration"
  48298. */
  48299. getClassName(): string;
  48300. /**
  48301. * Makes a duplicate of the current configuration into another one.
  48302. * @param brdfConfiguration define the config where to copy the info
  48303. */
  48304. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48305. /**
  48306. * Serializes this BRDF configuration.
  48307. * @returns - An object with the serialized config.
  48308. */
  48309. serialize(): any;
  48310. /**
  48311. * Parses a anisotropy Configuration from a serialized object.
  48312. * @param source - Serialized object.
  48313. * @param scene Defines the scene we are parsing for
  48314. * @param rootUrl Defines the rootUrl to load from
  48315. */
  48316. parse(source: any, scene: Scene, rootUrl: string): void;
  48317. }
  48318. }
  48319. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  48320. import { EffectFallbacks } from "babylonjs/Materials/effect";
  48321. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48322. import { Color3 } from "babylonjs/Maths/math.color";
  48323. import { Scene } from "babylonjs/scene";
  48324. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48325. import { Nullable } from "babylonjs/types";
  48326. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48327. /**
  48328. * @hidden
  48329. */
  48330. export interface IMaterialSheenDefines {
  48331. SHEEN: boolean;
  48332. SHEEN_TEXTURE: boolean;
  48333. SHEEN_TEXTUREDIRECTUV: number;
  48334. SHEEN_LINKWITHALBEDO: boolean;
  48335. /** @hidden */
  48336. _areTexturesDirty: boolean;
  48337. }
  48338. /**
  48339. * Define the code related to the Sheen parameters of the pbr material.
  48340. */
  48341. export class PBRSheenConfiguration {
  48342. private _isEnabled;
  48343. /**
  48344. * Defines if the material uses sheen.
  48345. */
  48346. isEnabled: boolean;
  48347. private _linkSheenWithAlbedo;
  48348. /**
  48349. * Defines if the sheen is linked to the sheen color.
  48350. */
  48351. linkSheenWithAlbedo: boolean;
  48352. /**
  48353. * Defines the sheen intensity.
  48354. */
  48355. intensity: number;
  48356. /**
  48357. * Defines the sheen color.
  48358. */
  48359. color: Color3;
  48360. private _texture;
  48361. /**
  48362. * Stores the sheen tint values in a texture.
  48363. * rgb is tint
  48364. * a is a intensity
  48365. */
  48366. texture: Nullable<BaseTexture>;
  48367. /** @hidden */
  48368. private _internalMarkAllSubMeshesAsTexturesDirty;
  48369. /** @hidden */
  48370. _markAllSubMeshesAsTexturesDirty(): void;
  48371. /**
  48372. * Instantiate a new istance of clear coat configuration.
  48373. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48374. */
  48375. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48376. /**
  48377. * Specifies that the submesh is ready to be used.
  48378. * @param defines the list of "defines" to update.
  48379. * @param scene defines the scene the material belongs to.
  48380. * @returns - boolean indicating that the submesh is ready or not.
  48381. */
  48382. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48383. /**
  48384. * Checks to see if a texture is used in the material.
  48385. * @param defines the list of "defines" to update.
  48386. * @param scene defines the scene the material belongs to.
  48387. */
  48388. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48389. /**
  48390. * Binds the material data.
  48391. * @param uniformBuffer defines the Uniform buffer to fill in.
  48392. * @param scene defines the scene the material belongs to.
  48393. * @param isFrozen defines wether the material is frozen or not.
  48394. */
  48395. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48396. /**
  48397. * Checks to see if a texture is used in the material.
  48398. * @param texture - Base texture to use.
  48399. * @returns - Boolean specifying if a texture is used in the material.
  48400. */
  48401. hasTexture(texture: BaseTexture): boolean;
  48402. /**
  48403. * Returns an array of the actively used textures.
  48404. * @param activeTextures Array of BaseTextures
  48405. */
  48406. getActiveTextures(activeTextures: BaseTexture[]): void;
  48407. /**
  48408. * Returns the animatable textures.
  48409. * @param animatables Array of animatable textures.
  48410. */
  48411. getAnimatables(animatables: IAnimatable[]): void;
  48412. /**
  48413. * Disposes the resources of the material.
  48414. * @param forceDisposeTextures - Forces the disposal of all textures.
  48415. */
  48416. dispose(forceDisposeTextures?: boolean): void;
  48417. /**
  48418. * Get the current class name of the texture useful for serialization or dynamic coding.
  48419. * @returns "PBRSheenConfiguration"
  48420. */
  48421. getClassName(): string;
  48422. /**
  48423. * Add fallbacks to the effect fallbacks list.
  48424. * @param defines defines the Base texture to use.
  48425. * @param fallbacks defines the current fallback list.
  48426. * @param currentRank defines the current fallback rank.
  48427. * @returns the new fallback rank.
  48428. */
  48429. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48430. /**
  48431. * Add the required uniforms to the current list.
  48432. * @param uniforms defines the current uniform list.
  48433. */
  48434. static AddUniforms(uniforms: string[]): void;
  48435. /**
  48436. * Add the required uniforms to the current buffer.
  48437. * @param uniformBuffer defines the current uniform buffer.
  48438. */
  48439. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48440. /**
  48441. * Add the required samplers to the current list.
  48442. * @param samplers defines the current sampler list.
  48443. */
  48444. static AddSamplers(samplers: string[]): void;
  48445. /**
  48446. * Makes a duplicate of the current configuration into another one.
  48447. * @param sheenConfiguration define the config where to copy the info
  48448. */
  48449. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  48450. /**
  48451. * Serializes this BRDF configuration.
  48452. * @returns - An object with the serialized config.
  48453. */
  48454. serialize(): any;
  48455. /**
  48456. * Parses a anisotropy Configuration from a serialized object.
  48457. * @param source - Serialized object.
  48458. * @param scene Defines the scene we are parsing for
  48459. * @param rootUrl Defines the rootUrl to load from
  48460. */
  48461. parse(source: any, scene: Scene, rootUrl: string): void;
  48462. }
  48463. }
  48464. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  48465. import { Nullable } from "babylonjs/types";
  48466. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48467. import { Color3 } from "babylonjs/Maths/math.color";
  48468. import { SmartArray } from "babylonjs/Misc/smartArray";
  48469. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48470. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48471. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  48472. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48473. import { Engine } from "babylonjs/Engines/engine";
  48474. import { Scene } from "babylonjs/scene";
  48475. /**
  48476. * @hidden
  48477. */
  48478. export interface IMaterialSubSurfaceDefines {
  48479. SUBSURFACE: boolean;
  48480. SS_REFRACTION: boolean;
  48481. SS_TRANSLUCENCY: boolean;
  48482. SS_SCATERRING: boolean;
  48483. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48484. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48485. SS_REFRACTIONMAP_3D: boolean;
  48486. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48487. SS_LODINREFRACTIONALPHA: boolean;
  48488. SS_GAMMAREFRACTION: boolean;
  48489. SS_RGBDREFRACTION: boolean;
  48490. SS_LINEARSPECULARREFRACTION: boolean;
  48491. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48492. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48493. /** @hidden */
  48494. _areTexturesDirty: boolean;
  48495. }
  48496. /**
  48497. * Define the code related to the sub surface parameters of the pbr material.
  48498. */
  48499. export class PBRSubSurfaceConfiguration {
  48500. private _isRefractionEnabled;
  48501. /**
  48502. * Defines if the refraction is enabled in the material.
  48503. */
  48504. isRefractionEnabled: boolean;
  48505. private _isTranslucencyEnabled;
  48506. /**
  48507. * Defines if the translucency is enabled in the material.
  48508. */
  48509. isTranslucencyEnabled: boolean;
  48510. private _isScatteringEnabled;
  48511. /**
  48512. * Defines the refraction intensity of the material.
  48513. * The refraction when enabled replaces the Diffuse part of the material.
  48514. * The intensity helps transitionning between diffuse and refraction.
  48515. */
  48516. refractionIntensity: number;
  48517. /**
  48518. * Defines the translucency intensity of the material.
  48519. * When translucency has been enabled, this defines how much of the "translucency"
  48520. * is addded to the diffuse part of the material.
  48521. */
  48522. translucencyIntensity: number;
  48523. /**
  48524. * Defines the scattering intensity of the material.
  48525. * When scattering has been enabled, this defines how much of the "scattered light"
  48526. * is addded to the diffuse part of the material.
  48527. */
  48528. scatteringIntensity: number;
  48529. private _thicknessTexture;
  48530. /**
  48531. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  48532. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  48533. * 0 would mean minimumThickness
  48534. * 1 would mean maximumThickness
  48535. * The other channels might be use as a mask to vary the different effects intensity.
  48536. */
  48537. thicknessTexture: Nullable<BaseTexture>;
  48538. private _refractionTexture;
  48539. /**
  48540. * Defines the texture to use for refraction.
  48541. */
  48542. refractionTexture: Nullable<BaseTexture>;
  48543. private _indexOfRefraction;
  48544. /**
  48545. * Defines the index of refraction used in the material.
  48546. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  48547. */
  48548. indexOfRefraction: number;
  48549. private _invertRefractionY;
  48550. /**
  48551. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48552. */
  48553. invertRefractionY: boolean;
  48554. private _linkRefractionWithTransparency;
  48555. /**
  48556. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48557. * Materials half opaque for instance using refraction could benefit from this control.
  48558. */
  48559. linkRefractionWithTransparency: boolean;
  48560. /**
  48561. * Defines the minimum thickness stored in the thickness map.
  48562. * If no thickness map is defined, this value will be used to simulate thickness.
  48563. */
  48564. minimumThickness: number;
  48565. /**
  48566. * Defines the maximum thickness stored in the thickness map.
  48567. */
  48568. maximumThickness: number;
  48569. /**
  48570. * Defines the volume tint of the material.
  48571. * This is used for both translucency and scattering.
  48572. */
  48573. tintColor: Color3;
  48574. /**
  48575. * Defines the distance at which the tint color should be found in the media.
  48576. * This is used for refraction only.
  48577. */
  48578. tintColorAtDistance: number;
  48579. /**
  48580. * Defines how far each channel transmit through the media.
  48581. * It is defined as a color to simplify it selection.
  48582. */
  48583. diffusionDistance: Color3;
  48584. private _useMaskFromThicknessTexture;
  48585. /**
  48586. * Stores the intensity of the different subsurface effects in the thickness texture.
  48587. * * the green channel is the translucency intensity.
  48588. * * the blue channel is the scattering intensity.
  48589. * * the alpha channel is the refraction intensity.
  48590. */
  48591. useMaskFromThicknessTexture: boolean;
  48592. /** @hidden */
  48593. private _internalMarkAllSubMeshesAsTexturesDirty;
  48594. /** @hidden */
  48595. _markAllSubMeshesAsTexturesDirty(): void;
  48596. /**
  48597. * Instantiate a new istance of sub surface configuration.
  48598. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48599. */
  48600. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48601. /**
  48602. * Gets wehter the submesh is ready to be used or not.
  48603. * @param defines the list of "defines" to update.
  48604. * @param scene defines the scene the material belongs to.
  48605. * @returns - boolean indicating that the submesh is ready or not.
  48606. */
  48607. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  48608. /**
  48609. * Checks to see if a texture is used in the material.
  48610. * @param defines the list of "defines" to update.
  48611. * @param scene defines the scene to the material belongs to.
  48612. */
  48613. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  48614. /**
  48615. * Binds the material data.
  48616. * @param uniformBuffer defines the Uniform buffer to fill in.
  48617. * @param scene defines the scene the material belongs to.
  48618. * @param engine defines the engine the material belongs to.
  48619. * @param isFrozen defines wether the material is frozen or not.
  48620. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  48621. */
  48622. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  48623. /**
  48624. * Unbinds the material from the mesh.
  48625. * @param activeEffect defines the effect that should be unbound from.
  48626. * @returns true if unbound, otherwise false
  48627. */
  48628. unbind(activeEffect: Effect): boolean;
  48629. /**
  48630. * Returns the texture used for refraction or null if none is used.
  48631. * @param scene defines the scene the material belongs to.
  48632. * @returns - Refraction texture if present. If no refraction texture and refraction
  48633. * is linked with transparency, returns environment texture. Otherwise, returns null.
  48634. */
  48635. private _getRefractionTexture;
  48636. /**
  48637. * Returns true if alpha blending should be disabled.
  48638. */
  48639. readonly disableAlphaBlending: boolean;
  48640. /**
  48641. * Fills the list of render target textures.
  48642. * @param renderTargets the list of render targets to update
  48643. */
  48644. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  48645. /**
  48646. * Checks to see if a texture is used in the material.
  48647. * @param texture - Base texture to use.
  48648. * @returns - Boolean specifying if a texture is used in the material.
  48649. */
  48650. hasTexture(texture: BaseTexture): boolean;
  48651. /**
  48652. * Gets a boolean indicating that current material needs to register RTT
  48653. * @returns true if this uses a render target otherwise false.
  48654. */
  48655. hasRenderTargetTextures(): boolean;
  48656. /**
  48657. * Returns an array of the actively used textures.
  48658. * @param activeTextures Array of BaseTextures
  48659. */
  48660. getActiveTextures(activeTextures: BaseTexture[]): void;
  48661. /**
  48662. * Returns the animatable textures.
  48663. * @param animatables Array of animatable textures.
  48664. */
  48665. getAnimatables(animatables: IAnimatable[]): void;
  48666. /**
  48667. * Disposes the resources of the material.
  48668. * @param forceDisposeTextures - Forces the disposal of all textures.
  48669. */
  48670. dispose(forceDisposeTextures?: boolean): void;
  48671. /**
  48672. * Get the current class name of the texture useful for serialization or dynamic coding.
  48673. * @returns "PBRSubSurfaceConfiguration"
  48674. */
  48675. getClassName(): string;
  48676. /**
  48677. * Add fallbacks to the effect fallbacks list.
  48678. * @param defines defines the Base texture to use.
  48679. * @param fallbacks defines the current fallback list.
  48680. * @param currentRank defines the current fallback rank.
  48681. * @returns the new fallback rank.
  48682. */
  48683. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48684. /**
  48685. * Add the required uniforms to the current list.
  48686. * @param uniforms defines the current uniform list.
  48687. */
  48688. static AddUniforms(uniforms: string[]): void;
  48689. /**
  48690. * Add the required samplers to the current list.
  48691. * @param samplers defines the current sampler list.
  48692. */
  48693. static AddSamplers(samplers: string[]): void;
  48694. /**
  48695. * Add the required uniforms to the current buffer.
  48696. * @param uniformBuffer defines the current uniform buffer.
  48697. */
  48698. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48699. /**
  48700. * Makes a duplicate of the current configuration into another one.
  48701. * @param configuration define the config where to copy the info
  48702. */
  48703. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  48704. /**
  48705. * Serializes this Sub Surface configuration.
  48706. * @returns - An object with the serialized config.
  48707. */
  48708. serialize(): any;
  48709. /**
  48710. * Parses a anisotropy Configuration from a serialized object.
  48711. * @param source - Serialized object.
  48712. * @param scene Defines the scene we are parsing for
  48713. * @param rootUrl Defines the rootUrl to load from
  48714. */
  48715. parse(source: any, scene: Scene, rootUrl: string): void;
  48716. }
  48717. }
  48718. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  48719. /** @hidden */
  48720. export var pbrFragmentDeclaration: {
  48721. name: string;
  48722. shader: string;
  48723. };
  48724. }
  48725. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  48726. /** @hidden */
  48727. export var pbrUboDeclaration: {
  48728. name: string;
  48729. shader: string;
  48730. };
  48731. }
  48732. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  48733. /** @hidden */
  48734. export var pbrFragmentExtraDeclaration: {
  48735. name: string;
  48736. shader: string;
  48737. };
  48738. }
  48739. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  48740. /** @hidden */
  48741. export var pbrFragmentSamplersDeclaration: {
  48742. name: string;
  48743. shader: string;
  48744. };
  48745. }
  48746. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  48747. /** @hidden */
  48748. export var pbrHelperFunctions: {
  48749. name: string;
  48750. shader: string;
  48751. };
  48752. }
  48753. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  48754. /** @hidden */
  48755. export var harmonicsFunctions: {
  48756. name: string;
  48757. shader: string;
  48758. };
  48759. }
  48760. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  48761. /** @hidden */
  48762. export var pbrDirectLightingSetupFunctions: {
  48763. name: string;
  48764. shader: string;
  48765. };
  48766. }
  48767. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  48768. /** @hidden */
  48769. export var pbrDirectLightingFalloffFunctions: {
  48770. name: string;
  48771. shader: string;
  48772. };
  48773. }
  48774. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  48775. /** @hidden */
  48776. export var pbrBRDFFunctions: {
  48777. name: string;
  48778. shader: string;
  48779. };
  48780. }
  48781. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  48782. /** @hidden */
  48783. export var pbrDirectLightingFunctions: {
  48784. name: string;
  48785. shader: string;
  48786. };
  48787. }
  48788. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  48789. /** @hidden */
  48790. export var pbrIBLFunctions: {
  48791. name: string;
  48792. shader: string;
  48793. };
  48794. }
  48795. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  48796. /** @hidden */
  48797. export var pbrDebug: {
  48798. name: string;
  48799. shader: string;
  48800. };
  48801. }
  48802. declare module "babylonjs/Shaders/pbr.fragment" {
  48803. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  48804. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48805. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  48806. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48807. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48808. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  48809. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48810. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48811. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48812. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48813. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48814. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  48815. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48816. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48817. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48818. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  48819. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  48820. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  48821. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  48822. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  48823. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  48824. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48825. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48826. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  48827. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  48828. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48829. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  48830. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48831. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  48832. /** @hidden */
  48833. export var pbrPixelShader: {
  48834. name: string;
  48835. shader: string;
  48836. };
  48837. }
  48838. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  48839. /** @hidden */
  48840. export var pbrVertexDeclaration: {
  48841. name: string;
  48842. shader: string;
  48843. };
  48844. }
  48845. declare module "babylonjs/Shaders/pbr.vertex" {
  48846. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  48847. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48848. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48849. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48850. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48851. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48852. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  48853. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48854. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48855. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48856. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48857. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48858. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48859. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48860. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48861. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48862. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48863. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  48864. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48865. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48866. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48867. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  48868. /** @hidden */
  48869. export var pbrVertexShader: {
  48870. name: string;
  48871. shader: string;
  48872. };
  48873. }
  48874. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  48875. import { Nullable } from "babylonjs/types";
  48876. import { Scene } from "babylonjs/scene";
  48877. import { Matrix } from "babylonjs/Maths/math.vector";
  48878. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48880. import { Mesh } from "babylonjs/Meshes/mesh";
  48881. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  48882. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  48883. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  48884. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  48885. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  48886. import { Color3 } from "babylonjs/Maths/math.color";
  48887. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  48888. import { Material } from "babylonjs/Materials/material";
  48889. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  48890. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48891. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48892. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48893. import "babylonjs/Shaders/pbr.fragment";
  48894. import "babylonjs/Shaders/pbr.vertex";
  48895. /**
  48896. * Manages the defines for the PBR Material.
  48897. * @hidden
  48898. */
  48899. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  48900. PBR: boolean;
  48901. MAINUV1: boolean;
  48902. MAINUV2: boolean;
  48903. UV1: boolean;
  48904. UV2: boolean;
  48905. ALBEDO: boolean;
  48906. ALBEDODIRECTUV: number;
  48907. VERTEXCOLOR: boolean;
  48908. AMBIENT: boolean;
  48909. AMBIENTDIRECTUV: number;
  48910. AMBIENTINGRAYSCALE: boolean;
  48911. OPACITY: boolean;
  48912. VERTEXALPHA: boolean;
  48913. OPACITYDIRECTUV: number;
  48914. OPACITYRGB: boolean;
  48915. ALPHATEST: boolean;
  48916. DEPTHPREPASS: boolean;
  48917. ALPHABLEND: boolean;
  48918. ALPHAFROMALBEDO: boolean;
  48919. ALPHATESTVALUE: string;
  48920. SPECULAROVERALPHA: boolean;
  48921. RADIANCEOVERALPHA: boolean;
  48922. ALPHAFRESNEL: boolean;
  48923. LINEARALPHAFRESNEL: boolean;
  48924. PREMULTIPLYALPHA: boolean;
  48925. EMISSIVE: boolean;
  48926. EMISSIVEDIRECTUV: number;
  48927. REFLECTIVITY: boolean;
  48928. REFLECTIVITYDIRECTUV: number;
  48929. SPECULARTERM: boolean;
  48930. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  48931. MICROSURFACEAUTOMATIC: boolean;
  48932. LODBASEDMICROSFURACE: boolean;
  48933. MICROSURFACEMAP: boolean;
  48934. MICROSURFACEMAPDIRECTUV: number;
  48935. METALLICWORKFLOW: boolean;
  48936. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48937. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48938. METALLNESSSTOREINMETALMAPBLUE: boolean;
  48939. AOSTOREINMETALMAPRED: boolean;
  48940. ENVIRONMENTBRDF: boolean;
  48941. ENVIRONMENTBRDF_RGBD: boolean;
  48942. NORMAL: boolean;
  48943. TANGENT: boolean;
  48944. BUMP: boolean;
  48945. BUMPDIRECTUV: number;
  48946. OBJECTSPACE_NORMALMAP: boolean;
  48947. PARALLAX: boolean;
  48948. PARALLAXOCCLUSION: boolean;
  48949. NORMALXYSCALE: boolean;
  48950. LIGHTMAP: boolean;
  48951. LIGHTMAPDIRECTUV: number;
  48952. USELIGHTMAPASSHADOWMAP: boolean;
  48953. GAMMALIGHTMAP: boolean;
  48954. RGBDLIGHTMAP: boolean;
  48955. REFLECTION: boolean;
  48956. REFLECTIONMAP_3D: boolean;
  48957. REFLECTIONMAP_SPHERICAL: boolean;
  48958. REFLECTIONMAP_PLANAR: boolean;
  48959. REFLECTIONMAP_CUBIC: boolean;
  48960. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  48961. REFLECTIONMAP_PROJECTION: boolean;
  48962. REFLECTIONMAP_SKYBOX: boolean;
  48963. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  48964. REFLECTIONMAP_EXPLICIT: boolean;
  48965. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  48966. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  48967. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  48968. INVERTCUBICMAP: boolean;
  48969. USESPHERICALFROMREFLECTIONMAP: boolean;
  48970. USEIRRADIANCEMAP: boolean;
  48971. SPHERICAL_HARMONICS: boolean;
  48972. USESPHERICALINVERTEX: boolean;
  48973. REFLECTIONMAP_OPPOSITEZ: boolean;
  48974. LODINREFLECTIONALPHA: boolean;
  48975. GAMMAREFLECTION: boolean;
  48976. RGBDREFLECTION: boolean;
  48977. LINEARSPECULARREFLECTION: boolean;
  48978. RADIANCEOCCLUSION: boolean;
  48979. HORIZONOCCLUSION: boolean;
  48980. INSTANCES: boolean;
  48981. NUM_BONE_INFLUENCERS: number;
  48982. BonesPerMesh: number;
  48983. BONETEXTURE: boolean;
  48984. NONUNIFORMSCALING: boolean;
  48985. MORPHTARGETS: boolean;
  48986. MORPHTARGETS_NORMAL: boolean;
  48987. MORPHTARGETS_TANGENT: boolean;
  48988. MORPHTARGETS_UV: boolean;
  48989. NUM_MORPH_INFLUENCERS: number;
  48990. IMAGEPROCESSING: boolean;
  48991. VIGNETTE: boolean;
  48992. VIGNETTEBLENDMODEMULTIPLY: boolean;
  48993. VIGNETTEBLENDMODEOPAQUE: boolean;
  48994. TONEMAPPING: boolean;
  48995. TONEMAPPING_ACES: boolean;
  48996. CONTRAST: boolean;
  48997. COLORCURVES: boolean;
  48998. COLORGRADING: boolean;
  48999. COLORGRADING3D: boolean;
  49000. SAMPLER3DGREENDEPTH: boolean;
  49001. SAMPLER3DBGRMAP: boolean;
  49002. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49003. EXPOSURE: boolean;
  49004. MULTIVIEW: boolean;
  49005. USEPHYSICALLIGHTFALLOFF: boolean;
  49006. USEGLTFLIGHTFALLOFF: boolean;
  49007. TWOSIDEDLIGHTING: boolean;
  49008. SHADOWFLOAT: boolean;
  49009. CLIPPLANE: boolean;
  49010. CLIPPLANE2: boolean;
  49011. CLIPPLANE3: boolean;
  49012. CLIPPLANE4: boolean;
  49013. POINTSIZE: boolean;
  49014. FOG: boolean;
  49015. LOGARITHMICDEPTH: boolean;
  49016. FORCENORMALFORWARD: boolean;
  49017. SPECULARAA: boolean;
  49018. CLEARCOAT: boolean;
  49019. CLEARCOAT_DEFAULTIOR: boolean;
  49020. CLEARCOAT_TEXTURE: boolean;
  49021. CLEARCOAT_TEXTUREDIRECTUV: number;
  49022. CLEARCOAT_BUMP: boolean;
  49023. CLEARCOAT_BUMPDIRECTUV: number;
  49024. CLEARCOAT_TINT: boolean;
  49025. CLEARCOAT_TINT_TEXTURE: boolean;
  49026. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49027. ANISOTROPIC: boolean;
  49028. ANISOTROPIC_TEXTURE: boolean;
  49029. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49030. BRDF_V_HEIGHT_CORRELATED: boolean;
  49031. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49032. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49033. SHEEN: boolean;
  49034. SHEEN_TEXTURE: boolean;
  49035. SHEEN_TEXTUREDIRECTUV: number;
  49036. SHEEN_LINKWITHALBEDO: boolean;
  49037. SUBSURFACE: boolean;
  49038. SS_REFRACTION: boolean;
  49039. SS_TRANSLUCENCY: boolean;
  49040. SS_SCATERRING: boolean;
  49041. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49042. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49043. SS_REFRACTIONMAP_3D: boolean;
  49044. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49045. SS_LODINREFRACTIONALPHA: boolean;
  49046. SS_GAMMAREFRACTION: boolean;
  49047. SS_RGBDREFRACTION: boolean;
  49048. SS_LINEARSPECULARREFRACTION: boolean;
  49049. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49050. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49051. UNLIT: boolean;
  49052. DEBUGMODE: number;
  49053. /**
  49054. * Initializes the PBR Material defines.
  49055. */
  49056. constructor();
  49057. /**
  49058. * Resets the PBR Material defines.
  49059. */
  49060. reset(): void;
  49061. }
  49062. /**
  49063. * The Physically based material base class of BJS.
  49064. *
  49065. * This offers the main features of a standard PBR material.
  49066. * For more information, please refer to the documentation :
  49067. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49068. */
  49069. export abstract class PBRBaseMaterial extends PushMaterial {
  49070. /**
  49071. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49072. */
  49073. static readonly PBRMATERIAL_OPAQUE: number;
  49074. /**
  49075. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49076. */
  49077. static readonly PBRMATERIAL_ALPHATEST: number;
  49078. /**
  49079. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49080. */
  49081. static readonly PBRMATERIAL_ALPHABLEND: number;
  49082. /**
  49083. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49084. * They are also discarded below the alpha cutoff threshold to improve performances.
  49085. */
  49086. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49087. /**
  49088. * Defines the default value of how much AO map is occluding the analytical lights
  49089. * (point spot...).
  49090. */
  49091. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49092. /**
  49093. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49094. */
  49095. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49096. /**
  49097. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49098. * to enhance interoperability with other engines.
  49099. */
  49100. static readonly LIGHTFALLOFF_GLTF: number;
  49101. /**
  49102. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49103. * to enhance interoperability with other materials.
  49104. */
  49105. static readonly LIGHTFALLOFF_STANDARD: number;
  49106. /**
  49107. * Intensity of the direct lights e.g. the four lights available in your scene.
  49108. * This impacts both the direct diffuse and specular highlights.
  49109. */
  49110. protected _directIntensity: number;
  49111. /**
  49112. * Intensity of the emissive part of the material.
  49113. * This helps controlling the emissive effect without modifying the emissive color.
  49114. */
  49115. protected _emissiveIntensity: number;
  49116. /**
  49117. * Intensity of the environment e.g. how much the environment will light the object
  49118. * either through harmonics for rough material or through the refelction for shiny ones.
  49119. */
  49120. protected _environmentIntensity: number;
  49121. /**
  49122. * This is a special control allowing the reduction of the specular highlights coming from the
  49123. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49124. */
  49125. protected _specularIntensity: number;
  49126. /**
  49127. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49128. */
  49129. private _lightingInfos;
  49130. /**
  49131. * Debug Control allowing disabling the bump map on this material.
  49132. */
  49133. protected _disableBumpMap: boolean;
  49134. /**
  49135. * AKA Diffuse Texture in standard nomenclature.
  49136. */
  49137. protected _albedoTexture: Nullable<BaseTexture>;
  49138. /**
  49139. * AKA Occlusion Texture in other nomenclature.
  49140. */
  49141. protected _ambientTexture: Nullable<BaseTexture>;
  49142. /**
  49143. * AKA Occlusion Texture Intensity in other nomenclature.
  49144. */
  49145. protected _ambientTextureStrength: number;
  49146. /**
  49147. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49148. * 1 means it completely occludes it
  49149. * 0 mean it has no impact
  49150. */
  49151. protected _ambientTextureImpactOnAnalyticalLights: number;
  49152. /**
  49153. * Stores the alpha values in a texture.
  49154. */
  49155. protected _opacityTexture: Nullable<BaseTexture>;
  49156. /**
  49157. * Stores the reflection values in a texture.
  49158. */
  49159. protected _reflectionTexture: Nullable<BaseTexture>;
  49160. /**
  49161. * Stores the emissive values in a texture.
  49162. */
  49163. protected _emissiveTexture: Nullable<BaseTexture>;
  49164. /**
  49165. * AKA Specular texture in other nomenclature.
  49166. */
  49167. protected _reflectivityTexture: Nullable<BaseTexture>;
  49168. /**
  49169. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49170. */
  49171. protected _metallicTexture: Nullable<BaseTexture>;
  49172. /**
  49173. * Specifies the metallic scalar of the metallic/roughness workflow.
  49174. * Can also be used to scale the metalness values of the metallic texture.
  49175. */
  49176. protected _metallic: Nullable<number>;
  49177. /**
  49178. * Specifies the roughness scalar of the metallic/roughness workflow.
  49179. * Can also be used to scale the roughness values of the metallic texture.
  49180. */
  49181. protected _roughness: Nullable<number>;
  49182. /**
  49183. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49184. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49185. */
  49186. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49187. /**
  49188. * Stores surface normal data used to displace a mesh in a texture.
  49189. */
  49190. protected _bumpTexture: Nullable<BaseTexture>;
  49191. /**
  49192. * Stores the pre-calculated light information of a mesh in a texture.
  49193. */
  49194. protected _lightmapTexture: Nullable<BaseTexture>;
  49195. /**
  49196. * The color of a material in ambient lighting.
  49197. */
  49198. protected _ambientColor: Color3;
  49199. /**
  49200. * AKA Diffuse Color in other nomenclature.
  49201. */
  49202. protected _albedoColor: Color3;
  49203. /**
  49204. * AKA Specular Color in other nomenclature.
  49205. */
  49206. protected _reflectivityColor: Color3;
  49207. /**
  49208. * The color applied when light is reflected from a material.
  49209. */
  49210. protected _reflectionColor: Color3;
  49211. /**
  49212. * The color applied when light is emitted from a material.
  49213. */
  49214. protected _emissiveColor: Color3;
  49215. /**
  49216. * AKA Glossiness in other nomenclature.
  49217. */
  49218. protected _microSurface: number;
  49219. /**
  49220. * Specifies that the material will use the light map as a show map.
  49221. */
  49222. protected _useLightmapAsShadowmap: boolean;
  49223. /**
  49224. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49225. * makes the reflect vector face the model (under horizon).
  49226. */
  49227. protected _useHorizonOcclusion: boolean;
  49228. /**
  49229. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49230. * too much the area relying on ambient texture to define their ambient occlusion.
  49231. */
  49232. protected _useRadianceOcclusion: boolean;
  49233. /**
  49234. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49235. */
  49236. protected _useAlphaFromAlbedoTexture: boolean;
  49237. /**
  49238. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49239. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49240. */
  49241. protected _useSpecularOverAlpha: boolean;
  49242. /**
  49243. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49244. */
  49245. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49246. /**
  49247. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49248. */
  49249. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49250. /**
  49251. * Specifies if the metallic texture contains the roughness information in its green channel.
  49252. */
  49253. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49254. /**
  49255. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49256. */
  49257. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49258. /**
  49259. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49260. */
  49261. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49262. /**
  49263. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49264. */
  49265. protected _useAmbientInGrayScale: boolean;
  49266. /**
  49267. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49268. * The material will try to infer what glossiness each pixel should be.
  49269. */
  49270. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49271. /**
  49272. * Defines the falloff type used in this material.
  49273. * It by default is Physical.
  49274. */
  49275. protected _lightFalloff: number;
  49276. /**
  49277. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49278. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49279. */
  49280. protected _useRadianceOverAlpha: boolean;
  49281. /**
  49282. * Allows using an object space normal map (instead of tangent space).
  49283. */
  49284. protected _useObjectSpaceNormalMap: boolean;
  49285. /**
  49286. * Allows using the bump map in parallax mode.
  49287. */
  49288. protected _useParallax: boolean;
  49289. /**
  49290. * Allows using the bump map in parallax occlusion mode.
  49291. */
  49292. protected _useParallaxOcclusion: boolean;
  49293. /**
  49294. * Controls the scale bias of the parallax mode.
  49295. */
  49296. protected _parallaxScaleBias: number;
  49297. /**
  49298. * If sets to true, disables all the lights affecting the material.
  49299. */
  49300. protected _disableLighting: boolean;
  49301. /**
  49302. * Number of Simultaneous lights allowed on the material.
  49303. */
  49304. protected _maxSimultaneousLights: number;
  49305. /**
  49306. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49307. */
  49308. protected _invertNormalMapX: boolean;
  49309. /**
  49310. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49311. */
  49312. protected _invertNormalMapY: boolean;
  49313. /**
  49314. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49315. */
  49316. protected _twoSidedLighting: boolean;
  49317. /**
  49318. * Defines the alpha limits in alpha test mode.
  49319. */
  49320. protected _alphaCutOff: number;
  49321. /**
  49322. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49323. */
  49324. protected _forceAlphaTest: boolean;
  49325. /**
  49326. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49327. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49328. */
  49329. protected _useAlphaFresnel: boolean;
  49330. /**
  49331. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49332. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49333. */
  49334. protected _useLinearAlphaFresnel: boolean;
  49335. /**
  49336. * The transparency mode of the material.
  49337. */
  49338. protected _transparencyMode: Nullable<number>;
  49339. /**
  49340. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49341. * from cos thetav and roughness:
  49342. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49343. */
  49344. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49345. /**
  49346. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49347. */
  49348. protected _forceIrradianceInFragment: boolean;
  49349. /**
  49350. * Force normal to face away from face.
  49351. */
  49352. protected _forceNormalForward: boolean;
  49353. /**
  49354. * Enables specular anti aliasing in the PBR shader.
  49355. * It will both interacts on the Geometry for analytical and IBL lighting.
  49356. * It also prefilter the roughness map based on the bump values.
  49357. */
  49358. protected _enableSpecularAntiAliasing: boolean;
  49359. /**
  49360. * Default configuration related to image processing available in the PBR Material.
  49361. */
  49362. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49363. /**
  49364. * Keep track of the image processing observer to allow dispose and replace.
  49365. */
  49366. private _imageProcessingObserver;
  49367. /**
  49368. * Attaches a new image processing configuration to the PBR Material.
  49369. * @param configuration
  49370. */
  49371. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49372. /**
  49373. * Stores the available render targets.
  49374. */
  49375. private _renderTargets;
  49376. /**
  49377. * Sets the global ambient color for the material used in lighting calculations.
  49378. */
  49379. private _globalAmbientColor;
  49380. /**
  49381. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49382. */
  49383. private _useLogarithmicDepth;
  49384. /**
  49385. * If set to true, no lighting calculations will be applied.
  49386. */
  49387. private _unlit;
  49388. private _debugMode;
  49389. /**
  49390. * @hidden
  49391. * This is reserved for the inspector.
  49392. * Defines the material debug mode.
  49393. * It helps seeing only some components of the material while troubleshooting.
  49394. */
  49395. debugMode: number;
  49396. /**
  49397. * @hidden
  49398. * This is reserved for the inspector.
  49399. * Specify from where on screen the debug mode should start.
  49400. * The value goes from -1 (full screen) to 1 (not visible)
  49401. * It helps with side by side comparison against the final render
  49402. * This defaults to -1
  49403. */
  49404. private debugLimit;
  49405. /**
  49406. * @hidden
  49407. * This is reserved for the inspector.
  49408. * As the default viewing range might not be enough (if the ambient is really small for instance)
  49409. * You can use the factor to better multiply the final value.
  49410. */
  49411. private debugFactor;
  49412. /**
  49413. * Defines the clear coat layer parameters for the material.
  49414. */
  49415. readonly clearCoat: PBRClearCoatConfiguration;
  49416. /**
  49417. * Defines the anisotropic parameters for the material.
  49418. */
  49419. readonly anisotropy: PBRAnisotropicConfiguration;
  49420. /**
  49421. * Defines the BRDF parameters for the material.
  49422. */
  49423. readonly brdf: PBRBRDFConfiguration;
  49424. /**
  49425. * Defines the Sheen parameters for the material.
  49426. */
  49427. readonly sheen: PBRSheenConfiguration;
  49428. /**
  49429. * Defines the SubSurface parameters for the material.
  49430. */
  49431. readonly subSurface: PBRSubSurfaceConfiguration;
  49432. /**
  49433. * Custom callback helping to override the default shader used in the material.
  49434. */
  49435. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  49436. protected _rebuildInParallel: boolean;
  49437. /**
  49438. * Instantiates a new PBRMaterial instance.
  49439. *
  49440. * @param name The material name
  49441. * @param scene The scene the material will be use in.
  49442. */
  49443. constructor(name: string, scene: Scene);
  49444. /**
  49445. * Gets a boolean indicating that current material needs to register RTT
  49446. */
  49447. readonly hasRenderTargetTextures: boolean;
  49448. /**
  49449. * Gets the name of the material class.
  49450. */
  49451. getClassName(): string;
  49452. /**
  49453. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49454. */
  49455. /**
  49456. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49457. */
  49458. useLogarithmicDepth: boolean;
  49459. /**
  49460. * Gets the current transparency mode.
  49461. */
  49462. /**
  49463. * Sets the transparency mode of the material.
  49464. *
  49465. * | Value | Type | Description |
  49466. * | ----- | ----------------------------------- | ----------- |
  49467. * | 0 | OPAQUE | |
  49468. * | 1 | ALPHATEST | |
  49469. * | 2 | ALPHABLEND | |
  49470. * | 3 | ALPHATESTANDBLEND | |
  49471. *
  49472. */
  49473. transparencyMode: Nullable<number>;
  49474. /**
  49475. * Returns true if alpha blending should be disabled.
  49476. */
  49477. private readonly _disableAlphaBlending;
  49478. /**
  49479. * Specifies whether or not this material should be rendered in alpha blend mode.
  49480. */
  49481. needAlphaBlending(): boolean;
  49482. /**
  49483. * Specifies if the mesh will require alpha blending.
  49484. * @param mesh - BJS mesh.
  49485. */
  49486. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  49487. /**
  49488. * Specifies whether or not this material should be rendered in alpha test mode.
  49489. */
  49490. needAlphaTesting(): boolean;
  49491. /**
  49492. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  49493. */
  49494. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  49495. /**
  49496. * Gets the texture used for the alpha test.
  49497. */
  49498. getAlphaTestTexture(): Nullable<BaseTexture>;
  49499. /**
  49500. * Specifies that the submesh is ready to be used.
  49501. * @param mesh - BJS mesh.
  49502. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  49503. * @param useInstances - Specifies that instances should be used.
  49504. * @returns - boolean indicating that the submesh is ready or not.
  49505. */
  49506. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49507. /**
  49508. * Specifies if the material uses metallic roughness workflow.
  49509. * @returns boolean specifiying if the material uses metallic roughness workflow.
  49510. */
  49511. isMetallicWorkflow(): boolean;
  49512. private _prepareEffect;
  49513. private _prepareDefines;
  49514. /**
  49515. * Force shader compilation
  49516. */
  49517. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  49518. clipPlane: boolean;
  49519. }>): void;
  49520. /**
  49521. * Initializes the uniform buffer layout for the shader.
  49522. */
  49523. buildUniformLayout(): void;
  49524. /**
  49525. * Unbinds the material from the mesh
  49526. */
  49527. unbind(): void;
  49528. /**
  49529. * Binds the submesh data.
  49530. * @param world - The world matrix.
  49531. * @param mesh - The BJS mesh.
  49532. * @param subMesh - A submesh of the BJS mesh.
  49533. */
  49534. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49535. /**
  49536. * Returns the animatable textures.
  49537. * @returns - Array of animatable textures.
  49538. */
  49539. getAnimatables(): IAnimatable[];
  49540. /**
  49541. * Returns the texture used for reflections.
  49542. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  49543. */
  49544. private _getReflectionTexture;
  49545. /**
  49546. * Returns an array of the actively used textures.
  49547. * @returns - Array of BaseTextures
  49548. */
  49549. getActiveTextures(): BaseTexture[];
  49550. /**
  49551. * Checks to see if a texture is used in the material.
  49552. * @param texture - Base texture to use.
  49553. * @returns - Boolean specifying if a texture is used in the material.
  49554. */
  49555. hasTexture(texture: BaseTexture): boolean;
  49556. /**
  49557. * Disposes the resources of the material.
  49558. * @param forceDisposeEffect - Forces the disposal of effects.
  49559. * @param forceDisposeTextures - Forces the disposal of all textures.
  49560. */
  49561. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49562. }
  49563. }
  49564. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  49565. import { Nullable } from "babylonjs/types";
  49566. import { Scene } from "babylonjs/scene";
  49567. import { Color3 } from "babylonjs/Maths/math.color";
  49568. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  49569. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  49570. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49571. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49572. /**
  49573. * The Physically based material of BJS.
  49574. *
  49575. * This offers the main features of a standard PBR material.
  49576. * For more information, please refer to the documentation :
  49577. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49578. */
  49579. export class PBRMaterial extends PBRBaseMaterial {
  49580. /**
  49581. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49582. */
  49583. static readonly PBRMATERIAL_OPAQUE: number;
  49584. /**
  49585. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49586. */
  49587. static readonly PBRMATERIAL_ALPHATEST: number;
  49588. /**
  49589. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49590. */
  49591. static readonly PBRMATERIAL_ALPHABLEND: number;
  49592. /**
  49593. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49594. * They are also discarded below the alpha cutoff threshold to improve performances.
  49595. */
  49596. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49597. /**
  49598. * Defines the default value of how much AO map is occluding the analytical lights
  49599. * (point spot...).
  49600. */
  49601. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49602. /**
  49603. * Intensity of the direct lights e.g. the four lights available in your scene.
  49604. * This impacts both the direct diffuse and specular highlights.
  49605. */
  49606. directIntensity: number;
  49607. /**
  49608. * Intensity of the emissive part of the material.
  49609. * This helps controlling the emissive effect without modifying the emissive color.
  49610. */
  49611. emissiveIntensity: number;
  49612. /**
  49613. * Intensity of the environment e.g. how much the environment will light the object
  49614. * either through harmonics for rough material or through the refelction for shiny ones.
  49615. */
  49616. environmentIntensity: number;
  49617. /**
  49618. * This is a special control allowing the reduction of the specular highlights coming from the
  49619. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49620. */
  49621. specularIntensity: number;
  49622. /**
  49623. * Debug Control allowing disabling the bump map on this material.
  49624. */
  49625. disableBumpMap: boolean;
  49626. /**
  49627. * AKA Diffuse Texture in standard nomenclature.
  49628. */
  49629. albedoTexture: BaseTexture;
  49630. /**
  49631. * AKA Occlusion Texture in other nomenclature.
  49632. */
  49633. ambientTexture: BaseTexture;
  49634. /**
  49635. * AKA Occlusion Texture Intensity in other nomenclature.
  49636. */
  49637. ambientTextureStrength: number;
  49638. /**
  49639. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49640. * 1 means it completely occludes it
  49641. * 0 mean it has no impact
  49642. */
  49643. ambientTextureImpactOnAnalyticalLights: number;
  49644. /**
  49645. * Stores the alpha values in a texture.
  49646. */
  49647. opacityTexture: BaseTexture;
  49648. /**
  49649. * Stores the reflection values in a texture.
  49650. */
  49651. reflectionTexture: Nullable<BaseTexture>;
  49652. /**
  49653. * Stores the emissive values in a texture.
  49654. */
  49655. emissiveTexture: BaseTexture;
  49656. /**
  49657. * AKA Specular texture in other nomenclature.
  49658. */
  49659. reflectivityTexture: BaseTexture;
  49660. /**
  49661. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49662. */
  49663. metallicTexture: BaseTexture;
  49664. /**
  49665. * Specifies the metallic scalar of the metallic/roughness workflow.
  49666. * Can also be used to scale the metalness values of the metallic texture.
  49667. */
  49668. metallic: Nullable<number>;
  49669. /**
  49670. * Specifies the roughness scalar of the metallic/roughness workflow.
  49671. * Can also be used to scale the roughness values of the metallic texture.
  49672. */
  49673. roughness: Nullable<number>;
  49674. /**
  49675. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49676. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49677. */
  49678. microSurfaceTexture: BaseTexture;
  49679. /**
  49680. * Stores surface normal data used to displace a mesh in a texture.
  49681. */
  49682. bumpTexture: BaseTexture;
  49683. /**
  49684. * Stores the pre-calculated light information of a mesh in a texture.
  49685. */
  49686. lightmapTexture: BaseTexture;
  49687. /**
  49688. * Stores the refracted light information in a texture.
  49689. */
  49690. refractionTexture: Nullable<BaseTexture>;
  49691. /**
  49692. * The color of a material in ambient lighting.
  49693. */
  49694. ambientColor: Color3;
  49695. /**
  49696. * AKA Diffuse Color in other nomenclature.
  49697. */
  49698. albedoColor: Color3;
  49699. /**
  49700. * AKA Specular Color in other nomenclature.
  49701. */
  49702. reflectivityColor: Color3;
  49703. /**
  49704. * The color reflected from the material.
  49705. */
  49706. reflectionColor: Color3;
  49707. /**
  49708. * The color emitted from the material.
  49709. */
  49710. emissiveColor: Color3;
  49711. /**
  49712. * AKA Glossiness in other nomenclature.
  49713. */
  49714. microSurface: number;
  49715. /**
  49716. * source material index of refraction (IOR)' / 'destination material IOR.
  49717. */
  49718. indexOfRefraction: number;
  49719. /**
  49720. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49721. */
  49722. invertRefractionY: boolean;
  49723. /**
  49724. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49725. * Materials half opaque for instance using refraction could benefit from this control.
  49726. */
  49727. linkRefractionWithTransparency: boolean;
  49728. /**
  49729. * If true, the light map contains occlusion information instead of lighting info.
  49730. */
  49731. useLightmapAsShadowmap: boolean;
  49732. /**
  49733. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49734. */
  49735. useAlphaFromAlbedoTexture: boolean;
  49736. /**
  49737. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49738. */
  49739. forceAlphaTest: boolean;
  49740. /**
  49741. * Defines the alpha limits in alpha test mode.
  49742. */
  49743. alphaCutOff: number;
  49744. /**
  49745. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  49746. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49747. */
  49748. useSpecularOverAlpha: boolean;
  49749. /**
  49750. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49751. */
  49752. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49753. /**
  49754. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49755. */
  49756. useRoughnessFromMetallicTextureAlpha: boolean;
  49757. /**
  49758. * Specifies if the metallic texture contains the roughness information in its green channel.
  49759. */
  49760. useRoughnessFromMetallicTextureGreen: boolean;
  49761. /**
  49762. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49763. */
  49764. useMetallnessFromMetallicTextureBlue: boolean;
  49765. /**
  49766. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49767. */
  49768. useAmbientOcclusionFromMetallicTextureRed: boolean;
  49769. /**
  49770. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49771. */
  49772. useAmbientInGrayScale: boolean;
  49773. /**
  49774. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49775. * The material will try to infer what glossiness each pixel should be.
  49776. */
  49777. useAutoMicroSurfaceFromReflectivityMap: boolean;
  49778. /**
  49779. * BJS is using an harcoded light falloff based on a manually sets up range.
  49780. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49781. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49782. */
  49783. /**
  49784. * BJS is using an harcoded light falloff based on a manually sets up range.
  49785. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49786. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49787. */
  49788. usePhysicalLightFalloff: boolean;
  49789. /**
  49790. * In order to support the falloff compatibility with gltf, a special mode has been added
  49791. * to reproduce the gltf light falloff.
  49792. */
  49793. /**
  49794. * In order to support the falloff compatibility with gltf, a special mode has been added
  49795. * to reproduce the gltf light falloff.
  49796. */
  49797. useGLTFLightFalloff: boolean;
  49798. /**
  49799. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49800. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49801. */
  49802. useRadianceOverAlpha: boolean;
  49803. /**
  49804. * Allows using an object space normal map (instead of tangent space).
  49805. */
  49806. useObjectSpaceNormalMap: boolean;
  49807. /**
  49808. * Allows using the bump map in parallax mode.
  49809. */
  49810. useParallax: boolean;
  49811. /**
  49812. * Allows using the bump map in parallax occlusion mode.
  49813. */
  49814. useParallaxOcclusion: boolean;
  49815. /**
  49816. * Controls the scale bias of the parallax mode.
  49817. */
  49818. parallaxScaleBias: number;
  49819. /**
  49820. * If sets to true, disables all the lights affecting the material.
  49821. */
  49822. disableLighting: boolean;
  49823. /**
  49824. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49825. */
  49826. forceIrradianceInFragment: boolean;
  49827. /**
  49828. * Number of Simultaneous lights allowed on the material.
  49829. */
  49830. maxSimultaneousLights: number;
  49831. /**
  49832. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49833. */
  49834. invertNormalMapX: boolean;
  49835. /**
  49836. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49837. */
  49838. invertNormalMapY: boolean;
  49839. /**
  49840. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49841. */
  49842. twoSidedLighting: boolean;
  49843. /**
  49844. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49845. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49846. */
  49847. useAlphaFresnel: boolean;
  49848. /**
  49849. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49850. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49851. */
  49852. useLinearAlphaFresnel: boolean;
  49853. /**
  49854. * Let user defines the brdf lookup texture used for IBL.
  49855. * A default 8bit version is embedded but you could point at :
  49856. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  49857. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  49858. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  49859. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  49860. */
  49861. environmentBRDFTexture: Nullable<BaseTexture>;
  49862. /**
  49863. * Force normal to face away from face.
  49864. */
  49865. forceNormalForward: boolean;
  49866. /**
  49867. * Enables specular anti aliasing in the PBR shader.
  49868. * It will both interacts on the Geometry for analytical and IBL lighting.
  49869. * It also prefilter the roughness map based on the bump values.
  49870. */
  49871. enableSpecularAntiAliasing: boolean;
  49872. /**
  49873. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49874. * makes the reflect vector face the model (under horizon).
  49875. */
  49876. useHorizonOcclusion: boolean;
  49877. /**
  49878. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49879. * too much the area relying on ambient texture to define their ambient occlusion.
  49880. */
  49881. useRadianceOcclusion: boolean;
  49882. /**
  49883. * If set to true, no lighting calculations will be applied.
  49884. */
  49885. unlit: boolean;
  49886. /**
  49887. * Gets the image processing configuration used either in this material.
  49888. */
  49889. /**
  49890. * Sets the Default image processing configuration used either in the this material.
  49891. *
  49892. * If sets to null, the scene one is in use.
  49893. */
  49894. imageProcessingConfiguration: ImageProcessingConfiguration;
  49895. /**
  49896. * Gets wether the color curves effect is enabled.
  49897. */
  49898. /**
  49899. * Sets wether the color curves effect is enabled.
  49900. */
  49901. cameraColorCurvesEnabled: boolean;
  49902. /**
  49903. * Gets wether the color grading effect is enabled.
  49904. */
  49905. /**
  49906. * Gets wether the color grading effect is enabled.
  49907. */
  49908. cameraColorGradingEnabled: boolean;
  49909. /**
  49910. * Gets wether tonemapping is enabled or not.
  49911. */
  49912. /**
  49913. * Sets wether tonemapping is enabled or not
  49914. */
  49915. cameraToneMappingEnabled: boolean;
  49916. /**
  49917. * The camera exposure used on this material.
  49918. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49919. * This corresponds to a photographic exposure.
  49920. */
  49921. /**
  49922. * The camera exposure used on this material.
  49923. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49924. * This corresponds to a photographic exposure.
  49925. */
  49926. cameraExposure: number;
  49927. /**
  49928. * Gets The camera contrast used on this material.
  49929. */
  49930. /**
  49931. * Sets The camera contrast used on this material.
  49932. */
  49933. cameraContrast: number;
  49934. /**
  49935. * Gets the Color Grading 2D Lookup Texture.
  49936. */
  49937. /**
  49938. * Sets the Color Grading 2D Lookup Texture.
  49939. */
  49940. cameraColorGradingTexture: Nullable<BaseTexture>;
  49941. /**
  49942. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49943. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49944. * 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;
  49945. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49946. */
  49947. /**
  49948. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49949. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49950. * 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;
  49951. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49952. */
  49953. cameraColorCurves: Nullable<ColorCurves>;
  49954. /**
  49955. * Instantiates a new PBRMaterial instance.
  49956. *
  49957. * @param name The material name
  49958. * @param scene The scene the material will be use in.
  49959. */
  49960. constructor(name: string, scene: Scene);
  49961. /**
  49962. * Returns the name of this material class.
  49963. */
  49964. getClassName(): string;
  49965. /**
  49966. * Makes a duplicate of the current material.
  49967. * @param name - name to use for the new material.
  49968. */
  49969. clone(name: string): PBRMaterial;
  49970. /**
  49971. * Serializes this PBR Material.
  49972. * @returns - An object with the serialized material.
  49973. */
  49974. serialize(): any;
  49975. /**
  49976. * Parses a PBR Material from a serialized object.
  49977. * @param source - Serialized object.
  49978. * @param scene - BJS scene instance.
  49979. * @param rootUrl - url for the scene object
  49980. * @returns - PBRMaterial
  49981. */
  49982. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  49983. }
  49984. }
  49985. declare module "babylonjs/Misc/dds" {
  49986. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49987. import { Engine } from "babylonjs/Engines/engine";
  49988. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49989. import { Nullable } from "babylonjs/types";
  49990. import { Scene } from "babylonjs/scene";
  49991. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  49992. /**
  49993. * Direct draw surface info
  49994. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  49995. */
  49996. export interface DDSInfo {
  49997. /**
  49998. * Width of the texture
  49999. */
  50000. width: number;
  50001. /**
  50002. * Width of the texture
  50003. */
  50004. height: number;
  50005. /**
  50006. * Number of Mipmaps for the texture
  50007. * @see https://en.wikipedia.org/wiki/Mipmap
  50008. */
  50009. mipmapCount: number;
  50010. /**
  50011. * If the textures format is a known fourCC format
  50012. * @see https://www.fourcc.org/
  50013. */
  50014. isFourCC: boolean;
  50015. /**
  50016. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50017. */
  50018. isRGB: boolean;
  50019. /**
  50020. * If the texture is a lumincance format
  50021. */
  50022. isLuminance: boolean;
  50023. /**
  50024. * If this is a cube texture
  50025. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50026. */
  50027. isCube: boolean;
  50028. /**
  50029. * If the texture is a compressed format eg. FOURCC_DXT1
  50030. */
  50031. isCompressed: boolean;
  50032. /**
  50033. * The dxgiFormat of the texture
  50034. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50035. */
  50036. dxgiFormat: number;
  50037. /**
  50038. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50039. */
  50040. textureType: number;
  50041. /**
  50042. * Sphericle polynomial created for the dds texture
  50043. */
  50044. sphericalPolynomial?: SphericalPolynomial;
  50045. }
  50046. /**
  50047. * Class used to provide DDS decompression tools
  50048. */
  50049. export class DDSTools {
  50050. /**
  50051. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50052. */
  50053. static StoreLODInAlphaChannel: boolean;
  50054. /**
  50055. * Gets DDS information from an array buffer
  50056. * @param arrayBuffer defines the array buffer to read data from
  50057. * @returns the DDS information
  50058. */
  50059. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50060. private static _FloatView;
  50061. private static _Int32View;
  50062. private static _ToHalfFloat;
  50063. private static _FromHalfFloat;
  50064. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50065. private static _GetHalfFloatRGBAArrayBuffer;
  50066. private static _GetFloatRGBAArrayBuffer;
  50067. private static _GetFloatAsUIntRGBAArrayBuffer;
  50068. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50069. private static _GetRGBAArrayBuffer;
  50070. private static _ExtractLongWordOrder;
  50071. private static _GetRGBArrayBuffer;
  50072. private static _GetLuminanceArrayBuffer;
  50073. /**
  50074. * Uploads DDS Levels to a Babylon Texture
  50075. * @hidden
  50076. */
  50077. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50078. }
  50079. module "babylonjs/Engines/engine" {
  50080. interface Engine {
  50081. /**
  50082. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50083. * @param rootUrl defines the url where the file to load is located
  50084. * @param scene defines the current scene
  50085. * @param lodScale defines scale to apply to the mip map selection
  50086. * @param lodOffset defines offset to apply to the mip map selection
  50087. * @param onLoad defines an optional callback raised when the texture is loaded
  50088. * @param onError defines an optional callback raised if there is an issue to load the texture
  50089. * @param format defines the format of the data
  50090. * @param forcedExtension defines the extension to use to pick the right loader
  50091. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50092. * @returns the cube texture as an InternalTexture
  50093. */
  50094. 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;
  50095. }
  50096. }
  50097. }
  50098. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50099. import { Nullable } from "babylonjs/types";
  50100. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50101. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50102. /**
  50103. * Implementation of the DDS Texture Loader.
  50104. * @hidden
  50105. */
  50106. export class _DDSTextureLoader implements IInternalTextureLoader {
  50107. /**
  50108. * Defines wether the loader supports cascade loading the different faces.
  50109. */
  50110. readonly supportCascades: boolean;
  50111. /**
  50112. * This returns if the loader support the current file information.
  50113. * @param extension defines the file extension of the file being loaded
  50114. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50115. * @param fallback defines the fallback internal texture if any
  50116. * @param isBase64 defines whether the texture is encoded as a base64
  50117. * @param isBuffer defines whether the texture data are stored as a buffer
  50118. * @returns true if the loader can load the specified file
  50119. */
  50120. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50121. /**
  50122. * Transform the url before loading if required.
  50123. * @param rootUrl the url of the texture
  50124. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50125. * @returns the transformed texture
  50126. */
  50127. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50128. /**
  50129. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50130. * @param rootUrl the url of the texture
  50131. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50132. * @returns the fallback texture
  50133. */
  50134. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50135. /**
  50136. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50137. * @param data contains the texture data
  50138. * @param texture defines the BabylonJS internal texture
  50139. * @param createPolynomials will be true if polynomials have been requested
  50140. * @param onLoad defines the callback to trigger once the texture is ready
  50141. * @param onError defines the callback to trigger in case of error
  50142. */
  50143. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50144. /**
  50145. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50146. * @param data contains the texture data
  50147. * @param texture defines the BabylonJS internal texture
  50148. * @param callback defines the method to call once ready to upload
  50149. */
  50150. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50151. }
  50152. }
  50153. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50154. import { Nullable } from "babylonjs/types";
  50155. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50156. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50157. /**
  50158. * Implementation of the ENV Texture Loader.
  50159. * @hidden
  50160. */
  50161. export class _ENVTextureLoader implements IInternalTextureLoader {
  50162. /**
  50163. * Defines wether the loader supports cascade loading the different faces.
  50164. */
  50165. readonly supportCascades: boolean;
  50166. /**
  50167. * This returns if the loader support the current file information.
  50168. * @param extension defines the file extension of the file being loaded
  50169. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50170. * @param fallback defines the fallback internal texture if any
  50171. * @param isBase64 defines whether the texture is encoded as a base64
  50172. * @param isBuffer defines whether the texture data are stored as a buffer
  50173. * @returns true if the loader can load the specified file
  50174. */
  50175. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50176. /**
  50177. * Transform the url before loading if required.
  50178. * @param rootUrl the url of the texture
  50179. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50180. * @returns the transformed texture
  50181. */
  50182. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50183. /**
  50184. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50185. * @param rootUrl the url of the texture
  50186. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50187. * @returns the fallback texture
  50188. */
  50189. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50190. /**
  50191. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50192. * @param data contains the texture data
  50193. * @param texture defines the BabylonJS internal texture
  50194. * @param createPolynomials will be true if polynomials have been requested
  50195. * @param onLoad defines the callback to trigger once the texture is ready
  50196. * @param onError defines the callback to trigger in case of error
  50197. */
  50198. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50199. /**
  50200. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50201. * @param data contains the texture data
  50202. * @param texture defines the BabylonJS internal texture
  50203. * @param callback defines the method to call once ready to upload
  50204. */
  50205. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50206. }
  50207. }
  50208. declare module "babylonjs/Misc/khronosTextureContainer" {
  50209. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50210. /**
  50211. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50212. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50213. */
  50214. export class KhronosTextureContainer {
  50215. /** contents of the KTX container file */
  50216. arrayBuffer: any;
  50217. private static HEADER_LEN;
  50218. private static COMPRESSED_2D;
  50219. private static COMPRESSED_3D;
  50220. private static TEX_2D;
  50221. private static TEX_3D;
  50222. /**
  50223. * Gets the openGL type
  50224. */
  50225. glType: number;
  50226. /**
  50227. * Gets the openGL type size
  50228. */
  50229. glTypeSize: number;
  50230. /**
  50231. * Gets the openGL format
  50232. */
  50233. glFormat: number;
  50234. /**
  50235. * Gets the openGL internal format
  50236. */
  50237. glInternalFormat: number;
  50238. /**
  50239. * Gets the base internal format
  50240. */
  50241. glBaseInternalFormat: number;
  50242. /**
  50243. * Gets image width in pixel
  50244. */
  50245. pixelWidth: number;
  50246. /**
  50247. * Gets image height in pixel
  50248. */
  50249. pixelHeight: number;
  50250. /**
  50251. * Gets image depth in pixels
  50252. */
  50253. pixelDepth: number;
  50254. /**
  50255. * Gets the number of array elements
  50256. */
  50257. numberOfArrayElements: number;
  50258. /**
  50259. * Gets the number of faces
  50260. */
  50261. numberOfFaces: number;
  50262. /**
  50263. * Gets the number of mipmap levels
  50264. */
  50265. numberOfMipmapLevels: number;
  50266. /**
  50267. * Gets the bytes of key value data
  50268. */
  50269. bytesOfKeyValueData: number;
  50270. /**
  50271. * Gets the load type
  50272. */
  50273. loadType: number;
  50274. /**
  50275. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50276. */
  50277. isInvalid: boolean;
  50278. /**
  50279. * Creates a new KhronosTextureContainer
  50280. * @param arrayBuffer contents of the KTX container file
  50281. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50282. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50283. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50284. */
  50285. constructor(
  50286. /** contents of the KTX container file */
  50287. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50288. /**
  50289. * Uploads KTX content to a Babylon Texture.
  50290. * It is assumed that the texture has already been created & is currently bound
  50291. * @hidden
  50292. */
  50293. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50294. private _upload2DCompressedLevels;
  50295. }
  50296. }
  50297. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  50298. import { Nullable } from "babylonjs/types";
  50299. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50300. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50301. /**
  50302. * Implementation of the KTX Texture Loader.
  50303. * @hidden
  50304. */
  50305. export class _KTXTextureLoader implements IInternalTextureLoader {
  50306. /**
  50307. * Defines wether the loader supports cascade loading the different faces.
  50308. */
  50309. readonly supportCascades: boolean;
  50310. /**
  50311. * This returns if the loader support the current file information.
  50312. * @param extension defines the file extension of the file being loaded
  50313. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50314. * @param fallback defines the fallback internal texture if any
  50315. * @param isBase64 defines whether the texture is encoded as a base64
  50316. * @param isBuffer defines whether the texture data are stored as a buffer
  50317. * @returns true if the loader can load the specified file
  50318. */
  50319. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50320. /**
  50321. * Transform the url before loading if required.
  50322. * @param rootUrl the url of the texture
  50323. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50324. * @returns the transformed texture
  50325. */
  50326. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50327. /**
  50328. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50329. * @param rootUrl the url of the texture
  50330. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50331. * @returns the fallback texture
  50332. */
  50333. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50334. /**
  50335. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50336. * @param data contains the texture data
  50337. * @param texture defines the BabylonJS internal texture
  50338. * @param createPolynomials will be true if polynomials have been requested
  50339. * @param onLoad defines the callback to trigger once the texture is ready
  50340. * @param onError defines the callback to trigger in case of error
  50341. */
  50342. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50343. /**
  50344. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50345. * @param data contains the texture data
  50346. * @param texture defines the BabylonJS internal texture
  50347. * @param callback defines the method to call once ready to upload
  50348. */
  50349. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50350. }
  50351. }
  50352. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  50353. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  50354. import { Scene } from "babylonjs/scene";
  50355. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  50356. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  50357. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  50358. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  50359. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  50360. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  50361. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50362. /**
  50363. * Options for the default xr helper
  50364. */
  50365. export class WebXRDefaultExperienceOptions {
  50366. /**
  50367. * Floor meshes that should be used for teleporting
  50368. */
  50369. floorMeshes: Array<AbstractMesh>;
  50370. }
  50371. /**
  50372. * Default experience which provides a similar setup to the previous webVRExperience
  50373. */
  50374. export class WebXRDefaultExperience {
  50375. /**
  50376. * Base experience
  50377. */
  50378. baseExperience: WebXRExperienceHelper;
  50379. /**
  50380. * Input experience extension
  50381. */
  50382. input: WebXRInput;
  50383. /**
  50384. * Loads the controller models
  50385. */
  50386. controllerModelLoader: WebXRControllerModelLoader;
  50387. /**
  50388. * Enables laser pointer and selection
  50389. */
  50390. pointerSelection: WebXRControllerPointerSelection;
  50391. /**
  50392. * Enables teleportation
  50393. */
  50394. teleportation: WebXRControllerTeleportation;
  50395. /**
  50396. * Enables ui for enetering/exiting xr
  50397. */
  50398. enterExitUI: WebXREnterExitUI;
  50399. /**
  50400. * Default output canvas xr should render to
  50401. */
  50402. outputCanvas: WebXRManagedOutputCanvas;
  50403. /**
  50404. * Creates the default xr experience
  50405. * @param scene scene
  50406. * @param options options for basic configuration
  50407. * @returns resulting WebXRDefaultExperience
  50408. */
  50409. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50410. private constructor();
  50411. /**
  50412. * DIsposes of the experience helper
  50413. */
  50414. dispose(): void;
  50415. }
  50416. }
  50417. declare module "babylonjs/Helpers/sceneHelpers" {
  50418. import { Nullable } from "babylonjs/types";
  50419. import { Mesh } from "babylonjs/Meshes/mesh";
  50420. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50421. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  50422. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  50423. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  50424. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  50425. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  50426. import "babylonjs/Meshes/Builders/boxBuilder";
  50427. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  50428. /** @hidden */
  50429. export var _forceSceneHelpersToBundle: boolean;
  50430. module "babylonjs/scene" {
  50431. interface Scene {
  50432. /**
  50433. * Creates a default light for the scene.
  50434. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  50435. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  50436. */
  50437. createDefaultLight(replace?: boolean): void;
  50438. /**
  50439. * Creates a default camera for the scene.
  50440. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  50441. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50442. * @param replace has default false, when true replaces the active camera in the scene
  50443. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  50444. */
  50445. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50446. /**
  50447. * Creates a default camera and a default light.
  50448. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  50449. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50450. * @param replace has the default false, when true replaces the active camera/light in the scene
  50451. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  50452. */
  50453. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50454. /**
  50455. * Creates a new sky box
  50456. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  50457. * @param environmentTexture defines the texture to use as environment texture
  50458. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  50459. * @param scale defines the overall scale of the skybox
  50460. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  50461. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  50462. * @returns a new mesh holding the sky box
  50463. */
  50464. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  50465. /**
  50466. * Creates a new environment
  50467. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  50468. * @param options defines the options you can use to configure the environment
  50469. * @returns the new EnvironmentHelper
  50470. */
  50471. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  50472. /**
  50473. * Creates a new VREXperienceHelper
  50474. * @see http://doc.babylonjs.com/how_to/webvr_helper
  50475. * @param webVROptions defines the options used to create the new VREXperienceHelper
  50476. * @returns a new VREXperienceHelper
  50477. */
  50478. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  50479. /**
  50480. * Creates a new WebXRDefaultExperience
  50481. * @see http://doc.babylonjs.com/how_to/webxr
  50482. * @param options experience options
  50483. * @returns a promise for a new WebXRDefaultExperience
  50484. */
  50485. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50486. }
  50487. }
  50488. }
  50489. declare module "babylonjs/Helpers/videoDome" {
  50490. import { Scene } from "babylonjs/scene";
  50491. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50492. import { Mesh } from "babylonjs/Meshes/mesh";
  50493. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  50494. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50495. import "babylonjs/Meshes/Builders/sphereBuilder";
  50496. /**
  50497. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  50498. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  50499. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  50500. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50501. */
  50502. export class VideoDome extends TransformNode {
  50503. /**
  50504. * Define the video source as a Monoscopic panoramic 360 video.
  50505. */
  50506. static readonly MODE_MONOSCOPIC: number;
  50507. /**
  50508. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50509. */
  50510. static readonly MODE_TOPBOTTOM: number;
  50511. /**
  50512. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50513. */
  50514. static readonly MODE_SIDEBYSIDE: number;
  50515. private _halfDome;
  50516. private _useDirectMapping;
  50517. /**
  50518. * The video texture being displayed on the sphere
  50519. */
  50520. protected _videoTexture: VideoTexture;
  50521. /**
  50522. * Gets the video texture being displayed on the sphere
  50523. */
  50524. readonly videoTexture: VideoTexture;
  50525. /**
  50526. * The skybox material
  50527. */
  50528. protected _material: BackgroundMaterial;
  50529. /**
  50530. * The surface used for the skybox
  50531. */
  50532. protected _mesh: Mesh;
  50533. /**
  50534. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  50535. */
  50536. private _halfDomeMask;
  50537. /**
  50538. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50539. * Also see the options.resolution property.
  50540. */
  50541. fovMultiplier: number;
  50542. private _videoMode;
  50543. /**
  50544. * Gets or set the current video mode for the video. It can be:
  50545. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  50546. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50547. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50548. */
  50549. videoMode: number;
  50550. /**
  50551. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  50552. *
  50553. */
  50554. /**
  50555. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  50556. */
  50557. halfDome: boolean;
  50558. /**
  50559. * Oberserver used in Stereoscopic VR Mode.
  50560. */
  50561. private _onBeforeCameraRenderObserver;
  50562. /**
  50563. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  50564. * @param name Element's name, child elements will append suffixes for their own names.
  50565. * @param urlsOrVideo defines the url(s) or the video element to use
  50566. * @param options An object containing optional or exposed sub element properties
  50567. */
  50568. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  50569. resolution?: number;
  50570. clickToPlay?: boolean;
  50571. autoPlay?: boolean;
  50572. loop?: boolean;
  50573. size?: number;
  50574. poster?: string;
  50575. faceForward?: boolean;
  50576. useDirectMapping?: boolean;
  50577. halfDomeMode?: boolean;
  50578. }, scene: Scene);
  50579. private _changeVideoMode;
  50580. /**
  50581. * Releases resources associated with this node.
  50582. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50583. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50584. */
  50585. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50586. }
  50587. }
  50588. declare module "babylonjs/Helpers/index" {
  50589. export * from "babylonjs/Helpers/environmentHelper";
  50590. export * from "babylonjs/Helpers/photoDome";
  50591. export * from "babylonjs/Helpers/sceneHelpers";
  50592. export * from "babylonjs/Helpers/videoDome";
  50593. }
  50594. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  50595. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50596. import { IDisposable } from "babylonjs/scene";
  50597. import { Engine } from "babylonjs/Engines/engine";
  50598. /**
  50599. * This class can be used to get instrumentation data from a Babylon engine
  50600. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50601. */
  50602. export class EngineInstrumentation implements IDisposable {
  50603. /**
  50604. * Define the instrumented engine.
  50605. */
  50606. engine: Engine;
  50607. private _captureGPUFrameTime;
  50608. private _gpuFrameTimeToken;
  50609. private _gpuFrameTime;
  50610. private _captureShaderCompilationTime;
  50611. private _shaderCompilationTime;
  50612. private _onBeginFrameObserver;
  50613. private _onEndFrameObserver;
  50614. private _onBeforeShaderCompilationObserver;
  50615. private _onAfterShaderCompilationObserver;
  50616. /**
  50617. * Gets the perf counter used for GPU frame time
  50618. */
  50619. readonly gpuFrameTimeCounter: PerfCounter;
  50620. /**
  50621. * Gets the GPU frame time capture status
  50622. */
  50623. /**
  50624. * Enable or disable the GPU frame time capture
  50625. */
  50626. captureGPUFrameTime: boolean;
  50627. /**
  50628. * Gets the perf counter used for shader compilation time
  50629. */
  50630. readonly shaderCompilationTimeCounter: PerfCounter;
  50631. /**
  50632. * Gets the shader compilation time capture status
  50633. */
  50634. /**
  50635. * Enable or disable the shader compilation time capture
  50636. */
  50637. captureShaderCompilationTime: boolean;
  50638. /**
  50639. * Instantiates a new engine instrumentation.
  50640. * This class can be used to get instrumentation data from a Babylon engine
  50641. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50642. * @param engine Defines the engine to instrument
  50643. */
  50644. constructor(
  50645. /**
  50646. * Define the instrumented engine.
  50647. */
  50648. engine: Engine);
  50649. /**
  50650. * Dispose and release associated resources.
  50651. */
  50652. dispose(): void;
  50653. }
  50654. }
  50655. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  50656. import { Scene, IDisposable } from "babylonjs/scene";
  50657. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50658. /**
  50659. * This class can be used to get instrumentation data from a Babylon engine
  50660. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50661. */
  50662. export class SceneInstrumentation implements IDisposable {
  50663. /**
  50664. * Defines the scene to instrument
  50665. */
  50666. scene: Scene;
  50667. private _captureActiveMeshesEvaluationTime;
  50668. private _activeMeshesEvaluationTime;
  50669. private _captureRenderTargetsRenderTime;
  50670. private _renderTargetsRenderTime;
  50671. private _captureFrameTime;
  50672. private _frameTime;
  50673. private _captureRenderTime;
  50674. private _renderTime;
  50675. private _captureInterFrameTime;
  50676. private _interFrameTime;
  50677. private _captureParticlesRenderTime;
  50678. private _particlesRenderTime;
  50679. private _captureSpritesRenderTime;
  50680. private _spritesRenderTime;
  50681. private _capturePhysicsTime;
  50682. private _physicsTime;
  50683. private _captureAnimationsTime;
  50684. private _animationsTime;
  50685. private _captureCameraRenderTime;
  50686. private _cameraRenderTime;
  50687. private _onBeforeActiveMeshesEvaluationObserver;
  50688. private _onAfterActiveMeshesEvaluationObserver;
  50689. private _onBeforeRenderTargetsRenderObserver;
  50690. private _onAfterRenderTargetsRenderObserver;
  50691. private _onAfterRenderObserver;
  50692. private _onBeforeDrawPhaseObserver;
  50693. private _onAfterDrawPhaseObserver;
  50694. private _onBeforeAnimationsObserver;
  50695. private _onBeforeParticlesRenderingObserver;
  50696. private _onAfterParticlesRenderingObserver;
  50697. private _onBeforeSpritesRenderingObserver;
  50698. private _onAfterSpritesRenderingObserver;
  50699. private _onBeforePhysicsObserver;
  50700. private _onAfterPhysicsObserver;
  50701. private _onAfterAnimationsObserver;
  50702. private _onBeforeCameraRenderObserver;
  50703. private _onAfterCameraRenderObserver;
  50704. /**
  50705. * Gets the perf counter used for active meshes evaluation time
  50706. */
  50707. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  50708. /**
  50709. * Gets the active meshes evaluation time capture status
  50710. */
  50711. /**
  50712. * Enable or disable the active meshes evaluation time capture
  50713. */
  50714. captureActiveMeshesEvaluationTime: boolean;
  50715. /**
  50716. * Gets the perf counter used for render targets render time
  50717. */
  50718. readonly renderTargetsRenderTimeCounter: PerfCounter;
  50719. /**
  50720. * Gets the render targets render time capture status
  50721. */
  50722. /**
  50723. * Enable or disable the render targets render time capture
  50724. */
  50725. captureRenderTargetsRenderTime: boolean;
  50726. /**
  50727. * Gets the perf counter used for particles render time
  50728. */
  50729. readonly particlesRenderTimeCounter: PerfCounter;
  50730. /**
  50731. * Gets the particles render time capture status
  50732. */
  50733. /**
  50734. * Enable or disable the particles render time capture
  50735. */
  50736. captureParticlesRenderTime: boolean;
  50737. /**
  50738. * Gets the perf counter used for sprites render time
  50739. */
  50740. readonly spritesRenderTimeCounter: PerfCounter;
  50741. /**
  50742. * Gets the sprites render time capture status
  50743. */
  50744. /**
  50745. * Enable or disable the sprites render time capture
  50746. */
  50747. captureSpritesRenderTime: boolean;
  50748. /**
  50749. * Gets the perf counter used for physics time
  50750. */
  50751. readonly physicsTimeCounter: PerfCounter;
  50752. /**
  50753. * Gets the physics time capture status
  50754. */
  50755. /**
  50756. * Enable or disable the physics time capture
  50757. */
  50758. capturePhysicsTime: boolean;
  50759. /**
  50760. * Gets the perf counter used for animations time
  50761. */
  50762. readonly animationsTimeCounter: PerfCounter;
  50763. /**
  50764. * Gets the animations time capture status
  50765. */
  50766. /**
  50767. * Enable or disable the animations time capture
  50768. */
  50769. captureAnimationsTime: boolean;
  50770. /**
  50771. * Gets the perf counter used for frame time capture
  50772. */
  50773. readonly frameTimeCounter: PerfCounter;
  50774. /**
  50775. * Gets the frame time capture status
  50776. */
  50777. /**
  50778. * Enable or disable the frame time capture
  50779. */
  50780. captureFrameTime: boolean;
  50781. /**
  50782. * Gets the perf counter used for inter-frames time capture
  50783. */
  50784. readonly interFrameTimeCounter: PerfCounter;
  50785. /**
  50786. * Gets the inter-frames time capture status
  50787. */
  50788. /**
  50789. * Enable or disable the inter-frames time capture
  50790. */
  50791. captureInterFrameTime: boolean;
  50792. /**
  50793. * Gets the perf counter used for render time capture
  50794. */
  50795. readonly renderTimeCounter: PerfCounter;
  50796. /**
  50797. * Gets the render time capture status
  50798. */
  50799. /**
  50800. * Enable or disable the render time capture
  50801. */
  50802. captureRenderTime: boolean;
  50803. /**
  50804. * Gets the perf counter used for camera render time capture
  50805. */
  50806. readonly cameraRenderTimeCounter: PerfCounter;
  50807. /**
  50808. * Gets the camera render time capture status
  50809. */
  50810. /**
  50811. * Enable or disable the camera render time capture
  50812. */
  50813. captureCameraRenderTime: boolean;
  50814. /**
  50815. * Gets the perf counter used for draw calls
  50816. */
  50817. readonly drawCallsCounter: PerfCounter;
  50818. /**
  50819. * Instantiates a new scene instrumentation.
  50820. * This class can be used to get instrumentation data from a Babylon engine
  50821. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50822. * @param scene Defines the scene to instrument
  50823. */
  50824. constructor(
  50825. /**
  50826. * Defines the scene to instrument
  50827. */
  50828. scene: Scene);
  50829. /**
  50830. * Dispose and release associated resources.
  50831. */
  50832. dispose(): void;
  50833. }
  50834. }
  50835. declare module "babylonjs/Instrumentation/index" {
  50836. export * from "babylonjs/Instrumentation/engineInstrumentation";
  50837. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  50838. export * from "babylonjs/Instrumentation/timeToken";
  50839. }
  50840. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  50841. /** @hidden */
  50842. export var glowMapGenerationPixelShader: {
  50843. name: string;
  50844. shader: string;
  50845. };
  50846. }
  50847. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  50848. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50849. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50850. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50851. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50852. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50853. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50854. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50855. /** @hidden */
  50856. export var glowMapGenerationVertexShader: {
  50857. name: string;
  50858. shader: string;
  50859. };
  50860. }
  50861. declare module "babylonjs/Layers/effectLayer" {
  50862. import { Observable } from "babylonjs/Misc/observable";
  50863. import { Nullable } from "babylonjs/types";
  50864. import { Camera } from "babylonjs/Cameras/camera";
  50865. import { Scene } from "babylonjs/scene";
  50866. import { ISize } from "babylonjs/Maths/math.size";
  50867. import { Color4 } from "babylonjs/Maths/math.color";
  50868. import { Engine } from "babylonjs/Engines/engine";
  50869. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50870. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50871. import { Mesh } from "babylonjs/Meshes/mesh";
  50872. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  50873. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50874. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50875. import { Effect } from "babylonjs/Materials/effect";
  50876. import { Material } from "babylonjs/Materials/material";
  50877. import "babylonjs/Shaders/glowMapGeneration.fragment";
  50878. import "babylonjs/Shaders/glowMapGeneration.vertex";
  50879. /**
  50880. * Effect layer options. This helps customizing the behaviour
  50881. * of the effect layer.
  50882. */
  50883. export interface IEffectLayerOptions {
  50884. /**
  50885. * Multiplication factor apply to the canvas size to compute the render target size
  50886. * used to generated the objects (the smaller the faster).
  50887. */
  50888. mainTextureRatio: number;
  50889. /**
  50890. * Enforces a fixed size texture to ensure effect stability across devices.
  50891. */
  50892. mainTextureFixedSize?: number;
  50893. /**
  50894. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  50895. */
  50896. alphaBlendingMode: number;
  50897. /**
  50898. * The camera attached to the layer.
  50899. */
  50900. camera: Nullable<Camera>;
  50901. /**
  50902. * The rendering group to draw the layer in.
  50903. */
  50904. renderingGroupId: number;
  50905. }
  50906. /**
  50907. * The effect layer Helps adding post process effect blended with the main pass.
  50908. *
  50909. * This can be for instance use to generate glow or higlight effects on the scene.
  50910. *
  50911. * The effect layer class can not be used directly and is intented to inherited from to be
  50912. * customized per effects.
  50913. */
  50914. export abstract class EffectLayer {
  50915. private _vertexBuffers;
  50916. private _indexBuffer;
  50917. private _cachedDefines;
  50918. private _effectLayerMapGenerationEffect;
  50919. private _effectLayerOptions;
  50920. private _mergeEffect;
  50921. protected _scene: Scene;
  50922. protected _engine: Engine;
  50923. protected _maxSize: number;
  50924. protected _mainTextureDesiredSize: ISize;
  50925. protected _mainTexture: RenderTargetTexture;
  50926. protected _shouldRender: boolean;
  50927. protected _postProcesses: PostProcess[];
  50928. protected _textures: BaseTexture[];
  50929. protected _emissiveTextureAndColor: {
  50930. texture: Nullable<BaseTexture>;
  50931. color: Color4;
  50932. };
  50933. /**
  50934. * The name of the layer
  50935. */
  50936. name: string;
  50937. /**
  50938. * The clear color of the texture used to generate the glow map.
  50939. */
  50940. neutralColor: Color4;
  50941. /**
  50942. * Specifies wether the highlight layer is enabled or not.
  50943. */
  50944. isEnabled: boolean;
  50945. /**
  50946. * Gets the camera attached to the layer.
  50947. */
  50948. readonly camera: Nullable<Camera>;
  50949. /**
  50950. * Gets the rendering group id the layer should render in.
  50951. */
  50952. renderingGroupId: number;
  50953. /**
  50954. * An event triggered when the effect layer has been disposed.
  50955. */
  50956. onDisposeObservable: Observable<EffectLayer>;
  50957. /**
  50958. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50959. */
  50960. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50961. /**
  50962. * An event triggered when the generated texture is being merged in the scene.
  50963. */
  50964. onBeforeComposeObservable: Observable<EffectLayer>;
  50965. /**
  50966. * An event triggered when the generated texture has been merged in the scene.
  50967. */
  50968. onAfterComposeObservable: Observable<EffectLayer>;
  50969. /**
  50970. * An event triggered when the efffect layer changes its size.
  50971. */
  50972. onSizeChangedObservable: Observable<EffectLayer>;
  50973. /** @hidden */
  50974. static _SceneComponentInitialization: (scene: Scene) => void;
  50975. /**
  50976. * Instantiates a new effect Layer and references it in the scene.
  50977. * @param name The name of the layer
  50978. * @param scene The scene to use the layer in
  50979. */
  50980. constructor(
  50981. /** The Friendly of the effect in the scene */
  50982. name: string, scene: Scene);
  50983. /**
  50984. * Get the effect name of the layer.
  50985. * @return The effect name
  50986. */
  50987. abstract getEffectName(): string;
  50988. /**
  50989. * Checks for the readiness of the element composing the layer.
  50990. * @param subMesh the mesh to check for
  50991. * @param useInstances specify wether or not to use instances to render the mesh
  50992. * @return true if ready otherwise, false
  50993. */
  50994. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50995. /**
  50996. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50997. * @returns true if the effect requires stencil during the main canvas render pass.
  50998. */
  50999. abstract needStencil(): boolean;
  51000. /**
  51001. * Create the merge effect. This is the shader use to blit the information back
  51002. * to the main canvas at the end of the scene rendering.
  51003. * @returns The effect containing the shader used to merge the effect on the main canvas
  51004. */
  51005. protected abstract _createMergeEffect(): Effect;
  51006. /**
  51007. * Creates the render target textures and post processes used in the effect layer.
  51008. */
  51009. protected abstract _createTextureAndPostProcesses(): void;
  51010. /**
  51011. * Implementation specific of rendering the generating effect on the main canvas.
  51012. * @param effect The effect used to render through
  51013. */
  51014. protected abstract _internalRender(effect: Effect): void;
  51015. /**
  51016. * Sets the required values for both the emissive texture and and the main color.
  51017. */
  51018. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51019. /**
  51020. * Free any resources and references associated to a mesh.
  51021. * Internal use
  51022. * @param mesh The mesh to free.
  51023. */
  51024. abstract _disposeMesh(mesh: Mesh): void;
  51025. /**
  51026. * Serializes this layer (Glow or Highlight for example)
  51027. * @returns a serialized layer object
  51028. */
  51029. abstract serialize?(): any;
  51030. /**
  51031. * Initializes the effect layer with the required options.
  51032. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51033. */
  51034. protected _init(options: Partial<IEffectLayerOptions>): void;
  51035. /**
  51036. * Generates the index buffer of the full screen quad blending to the main canvas.
  51037. */
  51038. private _generateIndexBuffer;
  51039. /**
  51040. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51041. */
  51042. private _generateVertexBuffer;
  51043. /**
  51044. * Sets the main texture desired size which is the closest power of two
  51045. * of the engine canvas size.
  51046. */
  51047. private _setMainTextureSize;
  51048. /**
  51049. * Creates the main texture for the effect layer.
  51050. */
  51051. protected _createMainTexture(): void;
  51052. /**
  51053. * Adds specific effects defines.
  51054. * @param defines The defines to add specifics to.
  51055. */
  51056. protected _addCustomEffectDefines(defines: string[]): void;
  51057. /**
  51058. * Checks for the readiness of the element composing the layer.
  51059. * @param subMesh the mesh to check for
  51060. * @param useInstances specify wether or not to use instances to render the mesh
  51061. * @param emissiveTexture the associated emissive texture used to generate the glow
  51062. * @return true if ready otherwise, false
  51063. */
  51064. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51065. /**
  51066. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51067. */
  51068. render(): void;
  51069. /**
  51070. * Determine if a given mesh will be used in the current effect.
  51071. * @param mesh mesh to test
  51072. * @returns true if the mesh will be used
  51073. */
  51074. hasMesh(mesh: AbstractMesh): boolean;
  51075. /**
  51076. * Returns true if the layer contains information to display, otherwise false.
  51077. * @returns true if the glow layer should be rendered
  51078. */
  51079. shouldRender(): boolean;
  51080. /**
  51081. * Returns true if the mesh should render, otherwise false.
  51082. * @param mesh The mesh to render
  51083. * @returns true if it should render otherwise false
  51084. */
  51085. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51086. /**
  51087. * Returns true if the mesh can be rendered, otherwise false.
  51088. * @param mesh The mesh to render
  51089. * @param material The material used on the mesh
  51090. * @returns true if it can be rendered otherwise false
  51091. */
  51092. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51093. /**
  51094. * Returns true if the mesh should render, otherwise false.
  51095. * @param mesh The mesh to render
  51096. * @returns true if it should render otherwise false
  51097. */
  51098. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51099. /**
  51100. * Renders the submesh passed in parameter to the generation map.
  51101. */
  51102. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51103. /**
  51104. * Rebuild the required buffers.
  51105. * @hidden Internal use only.
  51106. */
  51107. _rebuild(): void;
  51108. /**
  51109. * Dispose only the render target textures and post process.
  51110. */
  51111. private _disposeTextureAndPostProcesses;
  51112. /**
  51113. * Dispose the highlight layer and free resources.
  51114. */
  51115. dispose(): void;
  51116. /**
  51117. * Gets the class name of the effect layer
  51118. * @returns the string with the class name of the effect layer
  51119. */
  51120. getClassName(): string;
  51121. /**
  51122. * Creates an effect layer from parsed effect layer data
  51123. * @param parsedEffectLayer defines effect layer data
  51124. * @param scene defines the current scene
  51125. * @param rootUrl defines the root URL containing the effect layer information
  51126. * @returns a parsed effect Layer
  51127. */
  51128. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51129. }
  51130. }
  51131. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51132. import { Scene } from "babylonjs/scene";
  51133. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51134. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51135. import { AbstractScene } from "babylonjs/abstractScene";
  51136. module "babylonjs/abstractScene" {
  51137. interface AbstractScene {
  51138. /**
  51139. * The list of effect layers (highlights/glow) added to the scene
  51140. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51141. * @see http://doc.babylonjs.com/how_to/glow_layer
  51142. */
  51143. effectLayers: Array<EffectLayer>;
  51144. /**
  51145. * Removes the given effect layer from this scene.
  51146. * @param toRemove defines the effect layer to remove
  51147. * @returns the index of the removed effect layer
  51148. */
  51149. removeEffectLayer(toRemove: EffectLayer): number;
  51150. /**
  51151. * Adds the given effect layer to this scene
  51152. * @param newEffectLayer defines the effect layer to add
  51153. */
  51154. addEffectLayer(newEffectLayer: EffectLayer): void;
  51155. }
  51156. }
  51157. /**
  51158. * Defines the layer scene component responsible to manage any effect layers
  51159. * in a given scene.
  51160. */
  51161. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51162. /**
  51163. * The component name helpfull to identify the component in the list of scene components.
  51164. */
  51165. readonly name: string;
  51166. /**
  51167. * The scene the component belongs to.
  51168. */
  51169. scene: Scene;
  51170. private _engine;
  51171. private _renderEffects;
  51172. private _needStencil;
  51173. private _previousStencilState;
  51174. /**
  51175. * Creates a new instance of the component for the given scene
  51176. * @param scene Defines the scene to register the component in
  51177. */
  51178. constructor(scene: Scene);
  51179. /**
  51180. * Registers the component in a given scene
  51181. */
  51182. register(): void;
  51183. /**
  51184. * Rebuilds the elements related to this component in case of
  51185. * context lost for instance.
  51186. */
  51187. rebuild(): void;
  51188. /**
  51189. * Serializes the component data to the specified json object
  51190. * @param serializationObject The object to serialize to
  51191. */
  51192. serialize(serializationObject: any): void;
  51193. /**
  51194. * Adds all the elements from the container to the scene
  51195. * @param container the container holding the elements
  51196. */
  51197. addFromContainer(container: AbstractScene): void;
  51198. /**
  51199. * Removes all the elements in the container from the scene
  51200. * @param container contains the elements to remove
  51201. * @param dispose if the removed element should be disposed (default: false)
  51202. */
  51203. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51204. /**
  51205. * Disposes the component and the associated ressources.
  51206. */
  51207. dispose(): void;
  51208. private _isReadyForMesh;
  51209. private _renderMainTexture;
  51210. private _setStencil;
  51211. private _setStencilBack;
  51212. private _draw;
  51213. private _drawCamera;
  51214. private _drawRenderingGroup;
  51215. }
  51216. }
  51217. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51218. /** @hidden */
  51219. export var glowMapMergePixelShader: {
  51220. name: string;
  51221. shader: string;
  51222. };
  51223. }
  51224. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51225. /** @hidden */
  51226. export var glowMapMergeVertexShader: {
  51227. name: string;
  51228. shader: string;
  51229. };
  51230. }
  51231. declare module "babylonjs/Layers/glowLayer" {
  51232. import { Nullable } from "babylonjs/types";
  51233. import { Camera } from "babylonjs/Cameras/camera";
  51234. import { Scene } from "babylonjs/scene";
  51235. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51237. import { Mesh } from "babylonjs/Meshes/mesh";
  51238. import { Texture } from "babylonjs/Materials/Textures/texture";
  51239. import { Effect } from "babylonjs/Materials/effect";
  51240. import { Material } from "babylonjs/Materials/material";
  51241. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51242. import { Color4 } from "babylonjs/Maths/math.color";
  51243. import "babylonjs/Shaders/glowMapMerge.fragment";
  51244. import "babylonjs/Shaders/glowMapMerge.vertex";
  51245. import "babylonjs/Layers/effectLayerSceneComponent";
  51246. module "babylonjs/abstractScene" {
  51247. interface AbstractScene {
  51248. /**
  51249. * Return a the first highlight layer of the scene with a given name.
  51250. * @param name The name of the highlight layer to look for.
  51251. * @return The highlight layer if found otherwise null.
  51252. */
  51253. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51254. }
  51255. }
  51256. /**
  51257. * Glow layer options. This helps customizing the behaviour
  51258. * of the glow layer.
  51259. */
  51260. export interface IGlowLayerOptions {
  51261. /**
  51262. * Multiplication factor apply to the canvas size to compute the render target size
  51263. * used to generated the glowing objects (the smaller the faster).
  51264. */
  51265. mainTextureRatio: number;
  51266. /**
  51267. * Enforces a fixed size texture to ensure resize independant blur.
  51268. */
  51269. mainTextureFixedSize?: number;
  51270. /**
  51271. * How big is the kernel of the blur texture.
  51272. */
  51273. blurKernelSize: number;
  51274. /**
  51275. * The camera attached to the layer.
  51276. */
  51277. camera: Nullable<Camera>;
  51278. /**
  51279. * Enable MSAA by chosing the number of samples.
  51280. */
  51281. mainTextureSamples?: number;
  51282. /**
  51283. * The rendering group to draw the layer in.
  51284. */
  51285. renderingGroupId: number;
  51286. }
  51287. /**
  51288. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51289. *
  51290. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51291. * glowy meshes to your scene.
  51292. *
  51293. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51294. */
  51295. export class GlowLayer extends EffectLayer {
  51296. /**
  51297. * Effect Name of the layer.
  51298. */
  51299. static readonly EffectName: string;
  51300. /**
  51301. * The default blur kernel size used for the glow.
  51302. */
  51303. static DefaultBlurKernelSize: number;
  51304. /**
  51305. * The default texture size ratio used for the glow.
  51306. */
  51307. static DefaultTextureRatio: number;
  51308. /**
  51309. * Sets the kernel size of the blur.
  51310. */
  51311. /**
  51312. * Gets the kernel size of the blur.
  51313. */
  51314. blurKernelSize: number;
  51315. /**
  51316. * Sets the glow intensity.
  51317. */
  51318. /**
  51319. * Gets the glow intensity.
  51320. */
  51321. intensity: number;
  51322. private _options;
  51323. private _intensity;
  51324. private _horizontalBlurPostprocess1;
  51325. private _verticalBlurPostprocess1;
  51326. private _horizontalBlurPostprocess2;
  51327. private _verticalBlurPostprocess2;
  51328. private _blurTexture1;
  51329. private _blurTexture2;
  51330. private _postProcesses1;
  51331. private _postProcesses2;
  51332. private _includedOnlyMeshes;
  51333. private _excludedMeshes;
  51334. /**
  51335. * Callback used to let the user override the color selection on a per mesh basis
  51336. */
  51337. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51338. /**
  51339. * Callback used to let the user override the texture selection on a per mesh basis
  51340. */
  51341. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51342. /**
  51343. * Instantiates a new glow Layer and references it to the scene.
  51344. * @param name The name of the layer
  51345. * @param scene The scene to use the layer in
  51346. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51347. */
  51348. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51349. /**
  51350. * Get the effect name of the layer.
  51351. * @return The effect name
  51352. */
  51353. getEffectName(): string;
  51354. /**
  51355. * Create the merge effect. This is the shader use to blit the information back
  51356. * to the main canvas at the end of the scene rendering.
  51357. */
  51358. protected _createMergeEffect(): Effect;
  51359. /**
  51360. * Creates the render target textures and post processes used in the glow layer.
  51361. */
  51362. protected _createTextureAndPostProcesses(): void;
  51363. /**
  51364. * Checks for the readiness of the element composing the layer.
  51365. * @param subMesh the mesh to check for
  51366. * @param useInstances specify wether or not to use instances to render the mesh
  51367. * @param emissiveTexture the associated emissive texture used to generate the glow
  51368. * @return true if ready otherwise, false
  51369. */
  51370. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51371. /**
  51372. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51373. */
  51374. needStencil(): boolean;
  51375. /**
  51376. * Returns true if the mesh can be rendered, otherwise false.
  51377. * @param mesh The mesh to render
  51378. * @param material The material used on the mesh
  51379. * @returns true if it can be rendered otherwise false
  51380. */
  51381. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51382. /**
  51383. * Implementation specific of rendering the generating effect on the main canvas.
  51384. * @param effect The effect used to render through
  51385. */
  51386. protected _internalRender(effect: Effect): void;
  51387. /**
  51388. * Sets the required values for both the emissive texture and and the main color.
  51389. */
  51390. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51391. /**
  51392. * Returns true if the mesh should render, otherwise false.
  51393. * @param mesh The mesh to render
  51394. * @returns true if it should render otherwise false
  51395. */
  51396. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51397. /**
  51398. * Adds specific effects defines.
  51399. * @param defines The defines to add specifics to.
  51400. */
  51401. protected _addCustomEffectDefines(defines: string[]): void;
  51402. /**
  51403. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  51404. * @param mesh The mesh to exclude from the glow layer
  51405. */
  51406. addExcludedMesh(mesh: Mesh): void;
  51407. /**
  51408. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  51409. * @param mesh The mesh to remove
  51410. */
  51411. removeExcludedMesh(mesh: Mesh): void;
  51412. /**
  51413. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  51414. * @param mesh The mesh to include in the glow layer
  51415. */
  51416. addIncludedOnlyMesh(mesh: Mesh): void;
  51417. /**
  51418. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  51419. * @param mesh The mesh to remove
  51420. */
  51421. removeIncludedOnlyMesh(mesh: Mesh): void;
  51422. /**
  51423. * Determine if a given mesh will be used in the glow layer
  51424. * @param mesh The mesh to test
  51425. * @returns true if the mesh will be highlighted by the current glow layer
  51426. */
  51427. hasMesh(mesh: AbstractMesh): boolean;
  51428. /**
  51429. * Free any resources and references associated to a mesh.
  51430. * Internal use
  51431. * @param mesh The mesh to free.
  51432. * @hidden
  51433. */
  51434. _disposeMesh(mesh: Mesh): void;
  51435. /**
  51436. * Gets the class name of the effect layer
  51437. * @returns the string with the class name of the effect layer
  51438. */
  51439. getClassName(): string;
  51440. /**
  51441. * Serializes this glow layer
  51442. * @returns a serialized glow layer object
  51443. */
  51444. serialize(): any;
  51445. /**
  51446. * Creates a Glow Layer from parsed glow layer data
  51447. * @param parsedGlowLayer defines glow layer data
  51448. * @param scene defines the current scene
  51449. * @param rootUrl defines the root URL containing the glow layer information
  51450. * @returns a parsed Glow Layer
  51451. */
  51452. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  51453. }
  51454. }
  51455. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  51456. /** @hidden */
  51457. export var glowBlurPostProcessPixelShader: {
  51458. name: string;
  51459. shader: string;
  51460. };
  51461. }
  51462. declare module "babylonjs/Layers/highlightLayer" {
  51463. import { Observable } from "babylonjs/Misc/observable";
  51464. import { Nullable } from "babylonjs/types";
  51465. import { Camera } from "babylonjs/Cameras/camera";
  51466. import { Scene } from "babylonjs/scene";
  51467. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51468. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51469. import { Mesh } from "babylonjs/Meshes/mesh";
  51470. import { Effect } from "babylonjs/Materials/effect";
  51471. import { Material } from "babylonjs/Materials/material";
  51472. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51473. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  51474. import "babylonjs/Shaders/glowMapMerge.fragment";
  51475. import "babylonjs/Shaders/glowMapMerge.vertex";
  51476. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  51477. module "babylonjs/abstractScene" {
  51478. interface AbstractScene {
  51479. /**
  51480. * Return a the first highlight layer of the scene with a given name.
  51481. * @param name The name of the highlight layer to look for.
  51482. * @return The highlight layer if found otherwise null.
  51483. */
  51484. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  51485. }
  51486. }
  51487. /**
  51488. * Highlight layer options. This helps customizing the behaviour
  51489. * of the highlight layer.
  51490. */
  51491. export interface IHighlightLayerOptions {
  51492. /**
  51493. * Multiplication factor apply to the canvas size to compute the render target size
  51494. * used to generated the glowing objects (the smaller the faster).
  51495. */
  51496. mainTextureRatio: number;
  51497. /**
  51498. * Enforces a fixed size texture to ensure resize independant blur.
  51499. */
  51500. mainTextureFixedSize?: number;
  51501. /**
  51502. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  51503. * of the picture to blur (the smaller the faster).
  51504. */
  51505. blurTextureSizeRatio: number;
  51506. /**
  51507. * How big in texel of the blur texture is the vertical blur.
  51508. */
  51509. blurVerticalSize: number;
  51510. /**
  51511. * How big in texel of the blur texture is the horizontal blur.
  51512. */
  51513. blurHorizontalSize: number;
  51514. /**
  51515. * Alpha blending mode used to apply the blur. Default is combine.
  51516. */
  51517. alphaBlendingMode: number;
  51518. /**
  51519. * The camera attached to the layer.
  51520. */
  51521. camera: Nullable<Camera>;
  51522. /**
  51523. * Should we display highlight as a solid stroke?
  51524. */
  51525. isStroke?: boolean;
  51526. /**
  51527. * The rendering group to draw the layer in.
  51528. */
  51529. renderingGroupId: number;
  51530. }
  51531. /**
  51532. * The highlight layer Helps adding a glow effect around a mesh.
  51533. *
  51534. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51535. * glowy meshes to your scene.
  51536. *
  51537. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  51538. */
  51539. export class HighlightLayer extends EffectLayer {
  51540. name: string;
  51541. /**
  51542. * Effect Name of the highlight layer.
  51543. */
  51544. static readonly EffectName: string;
  51545. /**
  51546. * The neutral color used during the preparation of the glow effect.
  51547. * This is black by default as the blend operation is a blend operation.
  51548. */
  51549. static NeutralColor: Color4;
  51550. /**
  51551. * Stencil value used for glowing meshes.
  51552. */
  51553. static GlowingMeshStencilReference: number;
  51554. /**
  51555. * Stencil value used for the other meshes in the scene.
  51556. */
  51557. static NormalMeshStencilReference: number;
  51558. /**
  51559. * Specifies whether or not the inner glow is ACTIVE in the layer.
  51560. */
  51561. innerGlow: boolean;
  51562. /**
  51563. * Specifies whether or not the outer glow is ACTIVE in the layer.
  51564. */
  51565. outerGlow: boolean;
  51566. /**
  51567. * Specifies the horizontal size of the blur.
  51568. */
  51569. /**
  51570. * Gets the horizontal size of the blur.
  51571. */
  51572. blurHorizontalSize: number;
  51573. /**
  51574. * Specifies the vertical size of the blur.
  51575. */
  51576. /**
  51577. * Gets the vertical size of the blur.
  51578. */
  51579. blurVerticalSize: number;
  51580. /**
  51581. * An event triggered when the highlight layer is being blurred.
  51582. */
  51583. onBeforeBlurObservable: Observable<HighlightLayer>;
  51584. /**
  51585. * An event triggered when the highlight layer has been blurred.
  51586. */
  51587. onAfterBlurObservable: Observable<HighlightLayer>;
  51588. private _instanceGlowingMeshStencilReference;
  51589. private _options;
  51590. private _downSamplePostprocess;
  51591. private _horizontalBlurPostprocess;
  51592. private _verticalBlurPostprocess;
  51593. private _blurTexture;
  51594. private _meshes;
  51595. private _excludedMeshes;
  51596. /**
  51597. * Instantiates a new highlight Layer and references it to the scene..
  51598. * @param name The name of the layer
  51599. * @param scene The scene to use the layer in
  51600. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  51601. */
  51602. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  51603. /**
  51604. * Get the effect name of the layer.
  51605. * @return The effect name
  51606. */
  51607. getEffectName(): string;
  51608. /**
  51609. * Create the merge effect. This is the shader use to blit the information back
  51610. * to the main canvas at the end of the scene rendering.
  51611. */
  51612. protected _createMergeEffect(): Effect;
  51613. /**
  51614. * Creates the render target textures and post processes used in the highlight layer.
  51615. */
  51616. protected _createTextureAndPostProcesses(): void;
  51617. /**
  51618. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51619. */
  51620. needStencil(): boolean;
  51621. /**
  51622. * Checks for the readiness of the element composing the layer.
  51623. * @param subMesh the mesh to check for
  51624. * @param useInstances specify wether or not to use instances to render the mesh
  51625. * @param emissiveTexture the associated emissive texture used to generate the glow
  51626. * @return true if ready otherwise, false
  51627. */
  51628. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51629. /**
  51630. * Implementation specific of rendering the generating effect on the main canvas.
  51631. * @param effect The effect used to render through
  51632. */
  51633. protected _internalRender(effect: Effect): void;
  51634. /**
  51635. * Returns true if the layer contains information to display, otherwise false.
  51636. */
  51637. shouldRender(): boolean;
  51638. /**
  51639. * Returns true if the mesh should render, otherwise false.
  51640. * @param mesh The mesh to render
  51641. * @returns true if it should render otherwise false
  51642. */
  51643. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51644. /**
  51645. * Sets the required values for both the emissive texture and and the main color.
  51646. */
  51647. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51648. /**
  51649. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  51650. * @param mesh The mesh to exclude from the highlight layer
  51651. */
  51652. addExcludedMesh(mesh: Mesh): void;
  51653. /**
  51654. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  51655. * @param mesh The mesh to highlight
  51656. */
  51657. removeExcludedMesh(mesh: Mesh): void;
  51658. /**
  51659. * Determine if a given mesh will be highlighted by the current HighlightLayer
  51660. * @param mesh mesh to test
  51661. * @returns true if the mesh will be highlighted by the current HighlightLayer
  51662. */
  51663. hasMesh(mesh: AbstractMesh): boolean;
  51664. /**
  51665. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  51666. * @param mesh The mesh to highlight
  51667. * @param color The color of the highlight
  51668. * @param glowEmissiveOnly Extract the glow from the emissive texture
  51669. */
  51670. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  51671. /**
  51672. * Remove a mesh from the highlight layer in order to make it stop glowing.
  51673. * @param mesh The mesh to highlight
  51674. */
  51675. removeMesh(mesh: Mesh): void;
  51676. /**
  51677. * Force the stencil to the normal expected value for none glowing parts
  51678. */
  51679. private _defaultStencilReference;
  51680. /**
  51681. * Free any resources and references associated to a mesh.
  51682. * Internal use
  51683. * @param mesh The mesh to free.
  51684. * @hidden
  51685. */
  51686. _disposeMesh(mesh: Mesh): void;
  51687. /**
  51688. * Dispose the highlight layer and free resources.
  51689. */
  51690. dispose(): void;
  51691. /**
  51692. * Gets the class name of the effect layer
  51693. * @returns the string with the class name of the effect layer
  51694. */
  51695. getClassName(): string;
  51696. /**
  51697. * Serializes this Highlight layer
  51698. * @returns a serialized Highlight layer object
  51699. */
  51700. serialize(): any;
  51701. /**
  51702. * Creates a Highlight layer from parsed Highlight layer data
  51703. * @param parsedHightlightLayer defines the Highlight layer data
  51704. * @param scene defines the current scene
  51705. * @param rootUrl defines the root URL containing the Highlight layer information
  51706. * @returns a parsed Highlight layer
  51707. */
  51708. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  51709. }
  51710. }
  51711. declare module "babylonjs/Layers/layerSceneComponent" {
  51712. import { Scene } from "babylonjs/scene";
  51713. import { ISceneComponent } from "babylonjs/sceneComponent";
  51714. import { Layer } from "babylonjs/Layers/layer";
  51715. import { AbstractScene } from "babylonjs/abstractScene";
  51716. module "babylonjs/abstractScene" {
  51717. interface AbstractScene {
  51718. /**
  51719. * The list of layers (background and foreground) of the scene
  51720. */
  51721. layers: Array<Layer>;
  51722. }
  51723. }
  51724. /**
  51725. * Defines the layer scene component responsible to manage any layers
  51726. * in a given scene.
  51727. */
  51728. export class LayerSceneComponent implements ISceneComponent {
  51729. /**
  51730. * The component name helpfull to identify the component in the list of scene components.
  51731. */
  51732. readonly name: string;
  51733. /**
  51734. * The scene the component belongs to.
  51735. */
  51736. scene: Scene;
  51737. private _engine;
  51738. /**
  51739. * Creates a new instance of the component for the given scene
  51740. * @param scene Defines the scene to register the component in
  51741. */
  51742. constructor(scene: Scene);
  51743. /**
  51744. * Registers the component in a given scene
  51745. */
  51746. register(): void;
  51747. /**
  51748. * Rebuilds the elements related to this component in case of
  51749. * context lost for instance.
  51750. */
  51751. rebuild(): void;
  51752. /**
  51753. * Disposes the component and the associated ressources.
  51754. */
  51755. dispose(): void;
  51756. private _draw;
  51757. private _drawCameraPredicate;
  51758. private _drawCameraBackground;
  51759. private _drawCameraForeground;
  51760. private _drawRenderTargetPredicate;
  51761. private _drawRenderTargetBackground;
  51762. private _drawRenderTargetForeground;
  51763. /**
  51764. * Adds all the elements from the container to the scene
  51765. * @param container the container holding the elements
  51766. */
  51767. addFromContainer(container: AbstractScene): void;
  51768. /**
  51769. * Removes all the elements in the container from the scene
  51770. * @param container contains the elements to remove
  51771. * @param dispose if the removed element should be disposed (default: false)
  51772. */
  51773. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51774. }
  51775. }
  51776. declare module "babylonjs/Shaders/layer.fragment" {
  51777. /** @hidden */
  51778. export var layerPixelShader: {
  51779. name: string;
  51780. shader: string;
  51781. };
  51782. }
  51783. declare module "babylonjs/Shaders/layer.vertex" {
  51784. /** @hidden */
  51785. export var layerVertexShader: {
  51786. name: string;
  51787. shader: string;
  51788. };
  51789. }
  51790. declare module "babylonjs/Layers/layer" {
  51791. import { Observable } from "babylonjs/Misc/observable";
  51792. import { Nullable } from "babylonjs/types";
  51793. import { Scene } from "babylonjs/scene";
  51794. import { Vector2 } from "babylonjs/Maths/math.vector";
  51795. import { Color4 } from "babylonjs/Maths/math.color";
  51796. import { Texture } from "babylonjs/Materials/Textures/texture";
  51797. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51798. import "babylonjs/Shaders/layer.fragment";
  51799. import "babylonjs/Shaders/layer.vertex";
  51800. /**
  51801. * This represents a full screen 2d layer.
  51802. * This can be useful to display a picture in the background of your scene for instance.
  51803. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51804. */
  51805. export class Layer {
  51806. /**
  51807. * Define the name of the layer.
  51808. */
  51809. name: string;
  51810. /**
  51811. * Define the texture the layer should display.
  51812. */
  51813. texture: Nullable<Texture>;
  51814. /**
  51815. * Is the layer in background or foreground.
  51816. */
  51817. isBackground: boolean;
  51818. /**
  51819. * Define the color of the layer (instead of texture).
  51820. */
  51821. color: Color4;
  51822. /**
  51823. * Define the scale of the layer in order to zoom in out of the texture.
  51824. */
  51825. scale: Vector2;
  51826. /**
  51827. * Define an offset for the layer in order to shift the texture.
  51828. */
  51829. offset: Vector2;
  51830. /**
  51831. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  51832. */
  51833. alphaBlendingMode: number;
  51834. /**
  51835. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  51836. * Alpha test will not mix with the background color in case of transparency.
  51837. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  51838. */
  51839. alphaTest: boolean;
  51840. /**
  51841. * Define a mask to restrict the layer to only some of the scene cameras.
  51842. */
  51843. layerMask: number;
  51844. /**
  51845. * Define the list of render target the layer is visible into.
  51846. */
  51847. renderTargetTextures: RenderTargetTexture[];
  51848. /**
  51849. * Define if the layer is only used in renderTarget or if it also
  51850. * renders in the main frame buffer of the canvas.
  51851. */
  51852. renderOnlyInRenderTargetTextures: boolean;
  51853. private _scene;
  51854. private _vertexBuffers;
  51855. private _indexBuffer;
  51856. private _effect;
  51857. private _alphaTestEffect;
  51858. /**
  51859. * An event triggered when the layer is disposed.
  51860. */
  51861. onDisposeObservable: Observable<Layer>;
  51862. private _onDisposeObserver;
  51863. /**
  51864. * Back compatibility with callback before the onDisposeObservable existed.
  51865. * The set callback will be triggered when the layer has been disposed.
  51866. */
  51867. onDispose: () => void;
  51868. /**
  51869. * An event triggered before rendering the scene
  51870. */
  51871. onBeforeRenderObservable: Observable<Layer>;
  51872. private _onBeforeRenderObserver;
  51873. /**
  51874. * Back compatibility with callback before the onBeforeRenderObservable existed.
  51875. * The set callback will be triggered just before rendering the layer.
  51876. */
  51877. onBeforeRender: () => void;
  51878. /**
  51879. * An event triggered after rendering the scene
  51880. */
  51881. onAfterRenderObservable: Observable<Layer>;
  51882. private _onAfterRenderObserver;
  51883. /**
  51884. * Back compatibility with callback before the onAfterRenderObservable existed.
  51885. * The set callback will be triggered just after rendering the layer.
  51886. */
  51887. onAfterRender: () => void;
  51888. /**
  51889. * Instantiates a new layer.
  51890. * This represents a full screen 2d layer.
  51891. * This can be useful to display a picture in the background of your scene for instance.
  51892. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51893. * @param name Define the name of the layer in the scene
  51894. * @param imgUrl Define the url of the texture to display in the layer
  51895. * @param scene Define the scene the layer belongs to
  51896. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  51897. * @param color Defines a color for the layer
  51898. */
  51899. constructor(
  51900. /**
  51901. * Define the name of the layer.
  51902. */
  51903. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  51904. private _createIndexBuffer;
  51905. /** @hidden */
  51906. _rebuild(): void;
  51907. /**
  51908. * Renders the layer in the scene.
  51909. */
  51910. render(): void;
  51911. /**
  51912. * Disposes and releases the associated ressources.
  51913. */
  51914. dispose(): void;
  51915. }
  51916. }
  51917. declare module "babylonjs/Layers/index" {
  51918. export * from "babylonjs/Layers/effectLayer";
  51919. export * from "babylonjs/Layers/effectLayerSceneComponent";
  51920. export * from "babylonjs/Layers/glowLayer";
  51921. export * from "babylonjs/Layers/highlightLayer";
  51922. export * from "babylonjs/Layers/layer";
  51923. export * from "babylonjs/Layers/layerSceneComponent";
  51924. }
  51925. declare module "babylonjs/Shaders/lensFlare.fragment" {
  51926. /** @hidden */
  51927. export var lensFlarePixelShader: {
  51928. name: string;
  51929. shader: string;
  51930. };
  51931. }
  51932. declare module "babylonjs/Shaders/lensFlare.vertex" {
  51933. /** @hidden */
  51934. export var lensFlareVertexShader: {
  51935. name: string;
  51936. shader: string;
  51937. };
  51938. }
  51939. declare module "babylonjs/LensFlares/lensFlareSystem" {
  51940. import { Scene } from "babylonjs/scene";
  51941. import { Vector3 } from "babylonjs/Maths/math.vector";
  51942. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51943. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  51944. import "babylonjs/Shaders/lensFlare.fragment";
  51945. import "babylonjs/Shaders/lensFlare.vertex";
  51946. import { Viewport } from "babylonjs/Maths/math.viewport";
  51947. /**
  51948. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51949. * It is usually composed of several `lensFlare`.
  51950. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51951. */
  51952. export class LensFlareSystem {
  51953. /**
  51954. * Define the name of the lens flare system
  51955. */
  51956. name: string;
  51957. /**
  51958. * List of lens flares used in this system.
  51959. */
  51960. lensFlares: LensFlare[];
  51961. /**
  51962. * Define a limit from the border the lens flare can be visible.
  51963. */
  51964. borderLimit: number;
  51965. /**
  51966. * Define a viewport border we do not want to see the lens flare in.
  51967. */
  51968. viewportBorder: number;
  51969. /**
  51970. * Define a predicate which could limit the list of meshes able to occlude the effect.
  51971. */
  51972. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51973. /**
  51974. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  51975. */
  51976. layerMask: number;
  51977. /**
  51978. * Define the id of the lens flare system in the scene.
  51979. * (equal to name by default)
  51980. */
  51981. id: string;
  51982. private _scene;
  51983. private _emitter;
  51984. private _vertexBuffers;
  51985. private _indexBuffer;
  51986. private _effect;
  51987. private _positionX;
  51988. private _positionY;
  51989. private _isEnabled;
  51990. /** @hidden */
  51991. static _SceneComponentInitialization: (scene: Scene) => void;
  51992. /**
  51993. * Instantiates a lens flare system.
  51994. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51995. * It is usually composed of several `lensFlare`.
  51996. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51997. * @param name Define the name of the lens flare system in the scene
  51998. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  51999. * @param scene Define the scene the lens flare system belongs to
  52000. */
  52001. constructor(
  52002. /**
  52003. * Define the name of the lens flare system
  52004. */
  52005. name: string, emitter: any, scene: Scene);
  52006. /**
  52007. * Define if the lens flare system is enabled.
  52008. */
  52009. isEnabled: boolean;
  52010. /**
  52011. * Get the scene the effects belongs to.
  52012. * @returns the scene holding the lens flare system
  52013. */
  52014. getScene(): Scene;
  52015. /**
  52016. * Get the emitter of the lens flare system.
  52017. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52018. * @returns the emitter of the lens flare system
  52019. */
  52020. getEmitter(): any;
  52021. /**
  52022. * Set the emitter of the lens flare system.
  52023. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52024. * @param newEmitter Define the new emitter of the system
  52025. */
  52026. setEmitter(newEmitter: any): void;
  52027. /**
  52028. * Get the lens flare system emitter position.
  52029. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52030. * @returns the position
  52031. */
  52032. getEmitterPosition(): Vector3;
  52033. /**
  52034. * @hidden
  52035. */
  52036. computeEffectivePosition(globalViewport: Viewport): boolean;
  52037. /** @hidden */
  52038. _isVisible(): boolean;
  52039. /**
  52040. * @hidden
  52041. */
  52042. render(): boolean;
  52043. /**
  52044. * Dispose and release the lens flare with its associated resources.
  52045. */
  52046. dispose(): void;
  52047. /**
  52048. * Parse a lens flare system from a JSON repressentation
  52049. * @param parsedLensFlareSystem Define the JSON to parse
  52050. * @param scene Define the scene the parsed system should be instantiated in
  52051. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52052. * @returns the parsed system
  52053. */
  52054. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52055. /**
  52056. * Serialize the current Lens Flare System into a JSON representation.
  52057. * @returns the serialized JSON
  52058. */
  52059. serialize(): any;
  52060. }
  52061. }
  52062. declare module "babylonjs/LensFlares/lensFlare" {
  52063. import { Nullable } from "babylonjs/types";
  52064. import { Color3 } from "babylonjs/Maths/math.color";
  52065. import { Texture } from "babylonjs/Materials/Textures/texture";
  52066. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52067. /**
  52068. * This represents one of the lens effect in a `lensFlareSystem`.
  52069. * It controls one of the indiviual texture used in the effect.
  52070. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52071. */
  52072. export class LensFlare {
  52073. /**
  52074. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52075. */
  52076. size: number;
  52077. /**
  52078. * 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.
  52079. */
  52080. position: number;
  52081. /**
  52082. * Define the lens color.
  52083. */
  52084. color: Color3;
  52085. /**
  52086. * Define the lens texture.
  52087. */
  52088. texture: Nullable<Texture>;
  52089. /**
  52090. * Define the alpha mode to render this particular lens.
  52091. */
  52092. alphaMode: number;
  52093. private _system;
  52094. /**
  52095. * Creates a new Lens Flare.
  52096. * This represents one of the lens effect in a `lensFlareSystem`.
  52097. * It controls one of the indiviual texture used in the effect.
  52098. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52099. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52100. * @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.
  52101. * @param color Define the lens color
  52102. * @param imgUrl Define the lens texture url
  52103. * @param system Define the `lensFlareSystem` this flare is part of
  52104. * @returns The newly created Lens Flare
  52105. */
  52106. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52107. /**
  52108. * Instantiates a new Lens Flare.
  52109. * This represents one of the lens effect in a `lensFlareSystem`.
  52110. * It controls one of the indiviual texture used in the effect.
  52111. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52112. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52113. * @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.
  52114. * @param color Define the lens color
  52115. * @param imgUrl Define the lens texture url
  52116. * @param system Define the `lensFlareSystem` this flare is part of
  52117. */
  52118. constructor(
  52119. /**
  52120. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52121. */
  52122. size: number,
  52123. /**
  52124. * 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.
  52125. */
  52126. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52127. /**
  52128. * Dispose and release the lens flare with its associated resources.
  52129. */
  52130. dispose(): void;
  52131. }
  52132. }
  52133. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52134. import { Nullable } from "babylonjs/types";
  52135. import { Scene } from "babylonjs/scene";
  52136. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52137. import { AbstractScene } from "babylonjs/abstractScene";
  52138. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52139. module "babylonjs/abstractScene" {
  52140. interface AbstractScene {
  52141. /**
  52142. * The list of lens flare system added to the scene
  52143. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52144. */
  52145. lensFlareSystems: Array<LensFlareSystem>;
  52146. /**
  52147. * Removes the given lens flare system from this scene.
  52148. * @param toRemove The lens flare system to remove
  52149. * @returns The index of the removed lens flare system
  52150. */
  52151. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52152. /**
  52153. * Adds the given lens flare system to this scene
  52154. * @param newLensFlareSystem The lens flare system to add
  52155. */
  52156. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52157. /**
  52158. * Gets a lens flare system using its name
  52159. * @param name defines the name to look for
  52160. * @returns the lens flare system or null if not found
  52161. */
  52162. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52163. /**
  52164. * Gets a lens flare system using its id
  52165. * @param id defines the id to look for
  52166. * @returns the lens flare system or null if not found
  52167. */
  52168. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52169. }
  52170. }
  52171. /**
  52172. * Defines the lens flare scene component responsible to manage any lens flares
  52173. * in a given scene.
  52174. */
  52175. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52176. /**
  52177. * The component name helpfull to identify the component in the list of scene components.
  52178. */
  52179. readonly name: string;
  52180. /**
  52181. * The scene the component belongs to.
  52182. */
  52183. scene: Scene;
  52184. /**
  52185. * Creates a new instance of the component for the given scene
  52186. * @param scene Defines the scene to register the component in
  52187. */
  52188. constructor(scene: Scene);
  52189. /**
  52190. * Registers the component in a given scene
  52191. */
  52192. register(): void;
  52193. /**
  52194. * Rebuilds the elements related to this component in case of
  52195. * context lost for instance.
  52196. */
  52197. rebuild(): void;
  52198. /**
  52199. * Adds all the elements from the container to the scene
  52200. * @param container the container holding the elements
  52201. */
  52202. addFromContainer(container: AbstractScene): void;
  52203. /**
  52204. * Removes all the elements in the container from the scene
  52205. * @param container contains the elements to remove
  52206. * @param dispose if the removed element should be disposed (default: false)
  52207. */
  52208. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52209. /**
  52210. * Serializes the component data to the specified json object
  52211. * @param serializationObject The object to serialize to
  52212. */
  52213. serialize(serializationObject: any): void;
  52214. /**
  52215. * Disposes the component and the associated ressources.
  52216. */
  52217. dispose(): void;
  52218. private _draw;
  52219. }
  52220. }
  52221. declare module "babylonjs/LensFlares/index" {
  52222. export * from "babylonjs/LensFlares/lensFlare";
  52223. export * from "babylonjs/LensFlares/lensFlareSystem";
  52224. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52225. }
  52226. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52227. import { Scene } from "babylonjs/scene";
  52228. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52229. import { AbstractScene } from "babylonjs/abstractScene";
  52230. /**
  52231. * Defines the shadow generator component responsible to manage any shadow generators
  52232. * in a given scene.
  52233. */
  52234. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52235. /**
  52236. * The component name helpfull to identify the component in the list of scene components.
  52237. */
  52238. readonly name: string;
  52239. /**
  52240. * The scene the component belongs to.
  52241. */
  52242. scene: Scene;
  52243. /**
  52244. * Creates a new instance of the component for the given scene
  52245. * @param scene Defines the scene to register the component in
  52246. */
  52247. constructor(scene: Scene);
  52248. /**
  52249. * Registers the component in a given scene
  52250. */
  52251. register(): void;
  52252. /**
  52253. * Rebuilds the elements related to this component in case of
  52254. * context lost for instance.
  52255. */
  52256. rebuild(): void;
  52257. /**
  52258. * Serializes the component data to the specified json object
  52259. * @param serializationObject The object to serialize to
  52260. */
  52261. serialize(serializationObject: any): void;
  52262. /**
  52263. * Adds all the elements from the container to the scene
  52264. * @param container the container holding the elements
  52265. */
  52266. addFromContainer(container: AbstractScene): void;
  52267. /**
  52268. * Removes all the elements in the container from the scene
  52269. * @param container contains the elements to remove
  52270. * @param dispose if the removed element should be disposed (default: false)
  52271. */
  52272. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52273. /**
  52274. * Rebuilds the elements related to this component in case of
  52275. * context lost for instance.
  52276. */
  52277. dispose(): void;
  52278. private _gatherRenderTargets;
  52279. }
  52280. }
  52281. declare module "babylonjs/Lights/Shadows/index" {
  52282. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  52283. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  52284. }
  52285. declare module "babylonjs/Lights/pointLight" {
  52286. import { Scene } from "babylonjs/scene";
  52287. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52289. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  52290. import { Effect } from "babylonjs/Materials/effect";
  52291. /**
  52292. * A point light is a light defined by an unique point in world space.
  52293. * The light is emitted in every direction from this point.
  52294. * A good example of a point light is a standard light bulb.
  52295. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52296. */
  52297. export class PointLight extends ShadowLight {
  52298. private _shadowAngle;
  52299. /**
  52300. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52301. * This specifies what angle the shadow will use to be created.
  52302. *
  52303. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52304. */
  52305. /**
  52306. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52307. * This specifies what angle the shadow will use to be created.
  52308. *
  52309. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52310. */
  52311. shadowAngle: number;
  52312. /**
  52313. * Gets the direction if it has been set.
  52314. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52315. */
  52316. /**
  52317. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52318. */
  52319. direction: Vector3;
  52320. /**
  52321. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52322. * A PointLight emits the light in every direction.
  52323. * It can cast shadows.
  52324. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52325. * ```javascript
  52326. * var pointLight = new PointLight("pl", camera.position, scene);
  52327. * ```
  52328. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52329. * @param name The light friendly name
  52330. * @param position The position of the point light in the scene
  52331. * @param scene The scene the lights belongs to
  52332. */
  52333. constructor(name: string, position: Vector3, scene: Scene);
  52334. /**
  52335. * Returns the string "PointLight"
  52336. * @returns the class name
  52337. */
  52338. getClassName(): string;
  52339. /**
  52340. * Returns the integer 0.
  52341. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52342. */
  52343. getTypeID(): number;
  52344. /**
  52345. * Specifies wether or not the shadowmap should be a cube texture.
  52346. * @returns true if the shadowmap needs to be a cube texture.
  52347. */
  52348. needCube(): boolean;
  52349. /**
  52350. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52351. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52352. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52353. */
  52354. getShadowDirection(faceIndex?: number): Vector3;
  52355. /**
  52356. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52357. * - fov = PI / 2
  52358. * - aspect ratio : 1.0
  52359. * - z-near and far equal to the active camera minZ and maxZ.
  52360. * Returns the PointLight.
  52361. */
  52362. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52363. protected _buildUniformLayout(): void;
  52364. /**
  52365. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52366. * @param effect The effect to update
  52367. * @param lightIndex The index of the light in the effect to update
  52368. * @returns The point light
  52369. */
  52370. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52371. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52372. /**
  52373. * Prepares the list of defines specific to the light type.
  52374. * @param defines the list of defines
  52375. * @param lightIndex defines the index of the light for the effect
  52376. */
  52377. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52378. }
  52379. }
  52380. declare module "babylonjs/Lights/index" {
  52381. export * from "babylonjs/Lights/light";
  52382. export * from "babylonjs/Lights/shadowLight";
  52383. export * from "babylonjs/Lights/Shadows/index";
  52384. export * from "babylonjs/Lights/directionalLight";
  52385. export * from "babylonjs/Lights/hemisphericLight";
  52386. export * from "babylonjs/Lights/pointLight";
  52387. export * from "babylonjs/Lights/spotLight";
  52388. }
  52389. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  52390. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52391. /**
  52392. * Header information of HDR texture files.
  52393. */
  52394. export interface HDRInfo {
  52395. /**
  52396. * The height of the texture in pixels.
  52397. */
  52398. height: number;
  52399. /**
  52400. * The width of the texture in pixels.
  52401. */
  52402. width: number;
  52403. /**
  52404. * The index of the beginning of the data in the binary file.
  52405. */
  52406. dataPosition: number;
  52407. }
  52408. /**
  52409. * This groups tools to convert HDR texture to native colors array.
  52410. */
  52411. export class HDRTools {
  52412. private static Ldexp;
  52413. private static Rgbe2float;
  52414. private static readStringLine;
  52415. /**
  52416. * Reads header information from an RGBE texture stored in a native array.
  52417. * More information on this format are available here:
  52418. * https://en.wikipedia.org/wiki/RGBE_image_format
  52419. *
  52420. * @param uint8array The binary file stored in native array.
  52421. * @return The header information.
  52422. */
  52423. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  52424. /**
  52425. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  52426. * This RGBE texture needs to store the information as a panorama.
  52427. *
  52428. * More information on this format are available here:
  52429. * https://en.wikipedia.org/wiki/RGBE_image_format
  52430. *
  52431. * @param buffer The binary file stored in an array buffer.
  52432. * @param size The expected size of the extracted cubemap.
  52433. * @return The Cube Map information.
  52434. */
  52435. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  52436. /**
  52437. * Returns the pixels data extracted from an RGBE texture.
  52438. * This pixels will be stored left to right up to down in the R G B order in one array.
  52439. *
  52440. * More information on this format are available here:
  52441. * https://en.wikipedia.org/wiki/RGBE_image_format
  52442. *
  52443. * @param uint8array The binary file stored in an array buffer.
  52444. * @param hdrInfo The header information of the file.
  52445. * @return The pixels data in RGB right to left up to down order.
  52446. */
  52447. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  52448. private static RGBE_ReadPixels_RLE;
  52449. }
  52450. }
  52451. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  52452. import { Nullable } from "babylonjs/types";
  52453. import { Scene } from "babylonjs/scene";
  52454. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52455. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52456. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52457. /**
  52458. * This represents a texture coming from an HDR input.
  52459. *
  52460. * The only supported format is currently panorama picture stored in RGBE format.
  52461. * Example of such files can be found on HDRLib: http://hdrlib.com/
  52462. */
  52463. export class HDRCubeTexture extends BaseTexture {
  52464. private static _facesMapping;
  52465. private _generateHarmonics;
  52466. private _noMipmap;
  52467. private _textureMatrix;
  52468. private _size;
  52469. private _onLoad;
  52470. private _onError;
  52471. /**
  52472. * The texture URL.
  52473. */
  52474. url: string;
  52475. /**
  52476. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  52477. */
  52478. coordinatesMode: number;
  52479. protected _isBlocking: boolean;
  52480. /**
  52481. * Sets wether or not the texture is blocking during loading.
  52482. */
  52483. /**
  52484. * Gets wether or not the texture is blocking during loading.
  52485. */
  52486. isBlocking: boolean;
  52487. protected _rotationY: number;
  52488. /**
  52489. * Sets texture matrix rotation angle around Y axis in radians.
  52490. */
  52491. /**
  52492. * Gets texture matrix rotation angle around Y axis radians.
  52493. */
  52494. rotationY: number;
  52495. /**
  52496. * Gets or sets the center of the bounding box associated with the cube texture
  52497. * It must define where the camera used to render the texture was set
  52498. */
  52499. boundingBoxPosition: Vector3;
  52500. private _boundingBoxSize;
  52501. /**
  52502. * Gets or sets the size of the bounding box associated with the cube texture
  52503. * When defined, the cubemap will switch to local mode
  52504. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  52505. * @example https://www.babylonjs-playground.com/#RNASML
  52506. */
  52507. boundingBoxSize: Vector3;
  52508. /**
  52509. * Instantiates an HDRTexture from the following parameters.
  52510. *
  52511. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  52512. * @param scene The scene the texture will be used in
  52513. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52514. * @param noMipmap Forces to not generate the mipmap if true
  52515. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  52516. * @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)
  52517. * @param reserved Reserved flag for internal use.
  52518. */
  52519. 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>);
  52520. /**
  52521. * Get the current class name of the texture useful for serialization or dynamic coding.
  52522. * @returns "HDRCubeTexture"
  52523. */
  52524. getClassName(): string;
  52525. /**
  52526. * Occurs when the file is raw .hdr file.
  52527. */
  52528. private loadTexture;
  52529. clone(): HDRCubeTexture;
  52530. delayLoad(): void;
  52531. /**
  52532. * Get the texture reflection matrix used to rotate/transform the reflection.
  52533. * @returns the reflection matrix
  52534. */
  52535. getReflectionTextureMatrix(): Matrix;
  52536. /**
  52537. * Set the texture reflection matrix used to rotate/transform the reflection.
  52538. * @param value Define the reflection matrix to set
  52539. */
  52540. setReflectionTextureMatrix(value: Matrix): void;
  52541. /**
  52542. * Parses a JSON representation of an HDR Texture in order to create the texture
  52543. * @param parsedTexture Define the JSON representation
  52544. * @param scene Define the scene the texture should be created in
  52545. * @param rootUrl Define the root url in case we need to load relative dependencies
  52546. * @returns the newly created texture after parsing
  52547. */
  52548. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  52549. serialize(): any;
  52550. }
  52551. }
  52552. declare module "babylonjs/Physics/physicsEngine" {
  52553. import { Nullable } from "babylonjs/types";
  52554. import { Vector3 } from "babylonjs/Maths/math.vector";
  52555. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52556. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  52557. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  52558. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52559. /**
  52560. * Class used to control physics engine
  52561. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52562. */
  52563. export class PhysicsEngine implements IPhysicsEngine {
  52564. private _physicsPlugin;
  52565. /**
  52566. * Global value used to control the smallest number supported by the simulation
  52567. */
  52568. static Epsilon: number;
  52569. private _impostors;
  52570. private _joints;
  52571. /**
  52572. * Gets the gravity vector used by the simulation
  52573. */
  52574. gravity: Vector3;
  52575. /**
  52576. * Factory used to create the default physics plugin.
  52577. * @returns The default physics plugin
  52578. */
  52579. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  52580. /**
  52581. * Creates a new Physics Engine
  52582. * @param gravity defines the gravity vector used by the simulation
  52583. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  52584. */
  52585. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  52586. /**
  52587. * Sets the gravity vector used by the simulation
  52588. * @param gravity defines the gravity vector to use
  52589. */
  52590. setGravity(gravity: Vector3): void;
  52591. /**
  52592. * Set the time step of the physics engine.
  52593. * Default is 1/60.
  52594. * To slow it down, enter 1/600 for example.
  52595. * To speed it up, 1/30
  52596. * @param newTimeStep defines the new timestep to apply to this world.
  52597. */
  52598. setTimeStep(newTimeStep?: number): void;
  52599. /**
  52600. * Get the time step of the physics engine.
  52601. * @returns the current time step
  52602. */
  52603. getTimeStep(): number;
  52604. /**
  52605. * Release all resources
  52606. */
  52607. dispose(): void;
  52608. /**
  52609. * Gets the name of the current physics plugin
  52610. * @returns the name of the plugin
  52611. */
  52612. getPhysicsPluginName(): string;
  52613. /**
  52614. * Adding a new impostor for the impostor tracking.
  52615. * This will be done by the impostor itself.
  52616. * @param impostor the impostor to add
  52617. */
  52618. addImpostor(impostor: PhysicsImpostor): void;
  52619. /**
  52620. * Remove an impostor from the engine.
  52621. * This impostor and its mesh will not longer be updated by the physics engine.
  52622. * @param impostor the impostor to remove
  52623. */
  52624. removeImpostor(impostor: PhysicsImpostor): void;
  52625. /**
  52626. * Add a joint to the physics engine
  52627. * @param mainImpostor defines the main impostor to which the joint is added.
  52628. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  52629. * @param joint defines the joint that will connect both impostors.
  52630. */
  52631. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52632. /**
  52633. * Removes a joint from the simulation
  52634. * @param mainImpostor defines the impostor used with the joint
  52635. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  52636. * @param joint defines the joint to remove
  52637. */
  52638. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52639. /**
  52640. * Called by the scene. No need to call it.
  52641. * @param delta defines the timespam between frames
  52642. */
  52643. _step(delta: number): void;
  52644. /**
  52645. * Gets the current plugin used to run the simulation
  52646. * @returns current plugin
  52647. */
  52648. getPhysicsPlugin(): IPhysicsEnginePlugin;
  52649. /**
  52650. * Gets the list of physic impostors
  52651. * @returns an array of PhysicsImpostor
  52652. */
  52653. getImpostors(): Array<PhysicsImpostor>;
  52654. /**
  52655. * Gets the impostor for a physics enabled object
  52656. * @param object defines the object impersonated by the impostor
  52657. * @returns the PhysicsImpostor or null if not found
  52658. */
  52659. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  52660. /**
  52661. * Gets the impostor for a physics body object
  52662. * @param body defines physics body used by the impostor
  52663. * @returns the PhysicsImpostor or null if not found
  52664. */
  52665. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  52666. /**
  52667. * Does a raycast in the physics world
  52668. * @param from when should the ray start?
  52669. * @param to when should the ray end?
  52670. * @returns PhysicsRaycastResult
  52671. */
  52672. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52673. }
  52674. }
  52675. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  52676. import { Nullable } from "babylonjs/types";
  52677. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52679. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52680. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52681. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52682. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52683. /** @hidden */
  52684. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  52685. private _useDeltaForWorldStep;
  52686. world: any;
  52687. name: string;
  52688. private _physicsMaterials;
  52689. private _fixedTimeStep;
  52690. private _cannonRaycastResult;
  52691. private _raycastResult;
  52692. private _physicsBodysToRemoveAfterStep;
  52693. BJSCANNON: any;
  52694. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  52695. setGravity(gravity: Vector3): void;
  52696. setTimeStep(timeStep: number): void;
  52697. getTimeStep(): number;
  52698. executeStep(delta: number): void;
  52699. private _removeMarkedPhysicsBodiesFromWorld;
  52700. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52701. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52702. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52703. private _processChildMeshes;
  52704. removePhysicsBody(impostor: PhysicsImpostor): void;
  52705. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52706. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52707. private _addMaterial;
  52708. private _checkWithEpsilon;
  52709. private _createShape;
  52710. private _createHeightmap;
  52711. private _minus90X;
  52712. private _plus90X;
  52713. private _tmpPosition;
  52714. private _tmpDeltaPosition;
  52715. private _tmpUnityRotation;
  52716. private _updatePhysicsBodyTransformation;
  52717. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52718. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52719. isSupported(): boolean;
  52720. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52721. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52722. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52723. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52724. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52725. getBodyMass(impostor: PhysicsImpostor): number;
  52726. getBodyFriction(impostor: PhysicsImpostor): number;
  52727. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52728. getBodyRestitution(impostor: PhysicsImpostor): number;
  52729. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52730. sleepBody(impostor: PhysicsImpostor): void;
  52731. wakeUpBody(impostor: PhysicsImpostor): void;
  52732. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  52733. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52734. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52735. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52736. getRadius(impostor: PhysicsImpostor): number;
  52737. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52738. dispose(): void;
  52739. private _extendNamespace;
  52740. /**
  52741. * Does a raycast in the physics world
  52742. * @param from when should the ray start?
  52743. * @param to when should the ray end?
  52744. * @returns PhysicsRaycastResult
  52745. */
  52746. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52747. }
  52748. }
  52749. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  52750. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52751. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52752. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52753. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52754. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52755. import { Nullable } from "babylonjs/types";
  52756. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52757. /** @hidden */
  52758. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  52759. world: any;
  52760. name: string;
  52761. BJSOIMO: any;
  52762. private _raycastResult;
  52763. constructor(iterations?: number, oimoInjection?: any);
  52764. setGravity(gravity: Vector3): void;
  52765. setTimeStep(timeStep: number): void;
  52766. getTimeStep(): number;
  52767. private _tmpImpostorsArray;
  52768. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52769. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52770. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52771. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52772. private _tmpPositionVector;
  52773. removePhysicsBody(impostor: PhysicsImpostor): void;
  52774. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52775. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52776. isSupported(): boolean;
  52777. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52778. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52779. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52780. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52781. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52782. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52783. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52784. getBodyMass(impostor: PhysicsImpostor): number;
  52785. getBodyFriction(impostor: PhysicsImpostor): number;
  52786. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52787. getBodyRestitution(impostor: PhysicsImpostor): number;
  52788. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52789. sleepBody(impostor: PhysicsImpostor): void;
  52790. wakeUpBody(impostor: PhysicsImpostor): void;
  52791. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52792. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  52793. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  52794. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52795. getRadius(impostor: PhysicsImpostor): number;
  52796. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52797. dispose(): void;
  52798. /**
  52799. * Does a raycast in the physics world
  52800. * @param from when should the ray start?
  52801. * @param to when should the ray end?
  52802. * @returns PhysicsRaycastResult
  52803. */
  52804. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52805. }
  52806. }
  52807. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  52808. import { Nullable } from "babylonjs/types";
  52809. import { Scene } from "babylonjs/scene";
  52810. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  52811. import { Color4 } from "babylonjs/Maths/math.color";
  52812. import { Mesh } from "babylonjs/Meshes/mesh";
  52813. /**
  52814. * Class containing static functions to help procedurally build meshes
  52815. */
  52816. export class RibbonBuilder {
  52817. /**
  52818. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52819. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52820. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52821. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52822. * * 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
  52823. * * 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
  52824. * * 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
  52825. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52826. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52827. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52828. * * 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
  52829. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52830. * * 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
  52831. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52832. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52833. * @param name defines the name of the mesh
  52834. * @param options defines the options used to create the mesh
  52835. * @param scene defines the hosting scene
  52836. * @returns the ribbon mesh
  52837. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52838. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52839. */
  52840. static CreateRibbon(name: string, options: {
  52841. pathArray: Vector3[][];
  52842. closeArray?: boolean;
  52843. closePath?: boolean;
  52844. offset?: number;
  52845. updatable?: boolean;
  52846. sideOrientation?: number;
  52847. frontUVs?: Vector4;
  52848. backUVs?: Vector4;
  52849. instance?: Mesh;
  52850. invertUV?: boolean;
  52851. uvs?: Vector2[];
  52852. colors?: Color4[];
  52853. }, scene?: Nullable<Scene>): Mesh;
  52854. }
  52855. }
  52856. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  52857. import { Nullable } from "babylonjs/types";
  52858. import { Scene } from "babylonjs/scene";
  52859. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  52860. import { Mesh } from "babylonjs/Meshes/mesh";
  52861. /**
  52862. * Class containing static functions to help procedurally build meshes
  52863. */
  52864. export class ShapeBuilder {
  52865. /**
  52866. * 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.
  52867. * * 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.
  52868. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52869. * * 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.
  52870. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52871. * * 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
  52872. * * 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
  52873. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52874. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52875. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52876. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52877. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52878. * @param name defines the name of the mesh
  52879. * @param options defines the options used to create the mesh
  52880. * @param scene defines the hosting scene
  52881. * @returns the extruded shape mesh
  52882. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52883. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52884. */
  52885. static ExtrudeShape(name: string, options: {
  52886. shape: Vector3[];
  52887. path: Vector3[];
  52888. scale?: number;
  52889. rotation?: number;
  52890. cap?: number;
  52891. updatable?: boolean;
  52892. sideOrientation?: number;
  52893. frontUVs?: Vector4;
  52894. backUVs?: Vector4;
  52895. instance?: Mesh;
  52896. invertUV?: boolean;
  52897. }, scene?: Nullable<Scene>): Mesh;
  52898. /**
  52899. * Creates an custom extruded shape mesh.
  52900. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52901. * * 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.
  52902. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52903. * * 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
  52904. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52905. * * 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
  52906. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52907. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52908. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52909. * * 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
  52910. * * 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
  52911. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52912. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52913. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52914. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52915. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52916. * @param name defines the name of the mesh
  52917. * @param options defines the options used to create the mesh
  52918. * @param scene defines the hosting scene
  52919. * @returns the custom extruded shape mesh
  52920. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52921. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52922. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52923. */
  52924. static ExtrudeShapeCustom(name: string, options: {
  52925. shape: Vector3[];
  52926. path: Vector3[];
  52927. scaleFunction?: any;
  52928. rotationFunction?: any;
  52929. ribbonCloseArray?: boolean;
  52930. ribbonClosePath?: boolean;
  52931. cap?: number;
  52932. updatable?: boolean;
  52933. sideOrientation?: number;
  52934. frontUVs?: Vector4;
  52935. backUVs?: Vector4;
  52936. instance?: Mesh;
  52937. invertUV?: boolean;
  52938. }, scene?: Nullable<Scene>): Mesh;
  52939. private static _ExtrudeShapeGeneric;
  52940. }
  52941. }
  52942. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52943. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  52944. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52945. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52946. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52947. import { Nullable } from "babylonjs/types";
  52948. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52949. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52950. /**
  52951. * AmmoJS Physics plugin
  52952. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52953. * @see https://github.com/kripken/ammo.js/
  52954. */
  52955. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52956. private _useDeltaForWorldStep;
  52957. /**
  52958. * Reference to the Ammo library
  52959. */
  52960. bjsAMMO: any;
  52961. /**
  52962. * Created ammoJS world which physics bodies are added to
  52963. */
  52964. world: any;
  52965. /**
  52966. * Name of the plugin
  52967. */
  52968. name: string;
  52969. private _timeStep;
  52970. private _fixedTimeStep;
  52971. private _maxSteps;
  52972. private _tmpQuaternion;
  52973. private _tmpAmmoTransform;
  52974. private _tmpAmmoQuaternion;
  52975. private _tmpAmmoConcreteContactResultCallback;
  52976. private _collisionConfiguration;
  52977. private _dispatcher;
  52978. private _overlappingPairCache;
  52979. private _solver;
  52980. private _softBodySolver;
  52981. private _tmpAmmoVectorA;
  52982. private _tmpAmmoVectorB;
  52983. private _tmpAmmoVectorC;
  52984. private _tmpAmmoVectorD;
  52985. private _tmpContactCallbackResult;
  52986. private _tmpAmmoVectorRCA;
  52987. private _tmpAmmoVectorRCB;
  52988. private _raycastResult;
  52989. private static readonly DISABLE_COLLISION_FLAG;
  52990. private static readonly KINEMATIC_FLAG;
  52991. private static readonly DISABLE_DEACTIVATION_FLAG;
  52992. /**
  52993. * Initializes the ammoJS plugin
  52994. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52995. * @param ammoInjection can be used to inject your own ammo reference
  52996. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  52997. */
  52998. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  52999. /**
  53000. * Sets the gravity of the physics world (m/(s^2))
  53001. * @param gravity Gravity to set
  53002. */
  53003. setGravity(gravity: Vector3): void;
  53004. /**
  53005. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53006. * @param timeStep timestep to use in seconds
  53007. */
  53008. setTimeStep(timeStep: number): void;
  53009. /**
  53010. * 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)
  53011. * @param fixedTimeStep fixedTimeStep to use in seconds
  53012. */
  53013. setFixedTimeStep(fixedTimeStep: number): void;
  53014. /**
  53015. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53016. * @param maxSteps the maximum number of steps by the physics engine per frame
  53017. */
  53018. setMaxSteps(maxSteps: number): void;
  53019. /**
  53020. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53021. * @returns the current timestep in seconds
  53022. */
  53023. getTimeStep(): number;
  53024. private _isImpostorInContact;
  53025. private _isImpostorPairInContact;
  53026. private _stepSimulation;
  53027. /**
  53028. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53029. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53030. * After the step the babylon meshes are set to the position of the physics imposters
  53031. * @param delta amount of time to step forward
  53032. * @param impostors array of imposters to update before/after the step
  53033. */
  53034. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53035. /**
  53036. * Update babylon mesh to match physics world object
  53037. * @param impostor imposter to match
  53038. */
  53039. private _afterSoftStep;
  53040. /**
  53041. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53042. * @param impostor imposter to match
  53043. */
  53044. private _ropeStep;
  53045. /**
  53046. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53047. * @param impostor imposter to match
  53048. */
  53049. private _softbodyOrClothStep;
  53050. private _tmpVector;
  53051. private _tmpMatrix;
  53052. /**
  53053. * Applies an impulse on the imposter
  53054. * @param impostor imposter to apply impulse to
  53055. * @param force amount of force to be applied to the imposter
  53056. * @param contactPoint the location to apply the impulse on the imposter
  53057. */
  53058. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53059. /**
  53060. * Applies a force on the imposter
  53061. * @param impostor imposter to apply force
  53062. * @param force amount of force to be applied to the imposter
  53063. * @param contactPoint the location to apply the force on the imposter
  53064. */
  53065. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53066. /**
  53067. * Creates a physics body using the plugin
  53068. * @param impostor the imposter to create the physics body on
  53069. */
  53070. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53071. /**
  53072. * Removes the physics body from the imposter and disposes of the body's memory
  53073. * @param impostor imposter to remove the physics body from
  53074. */
  53075. removePhysicsBody(impostor: PhysicsImpostor): void;
  53076. /**
  53077. * Generates a joint
  53078. * @param impostorJoint the imposter joint to create the joint with
  53079. */
  53080. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53081. /**
  53082. * Removes a joint
  53083. * @param impostorJoint the imposter joint to remove the joint from
  53084. */
  53085. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53086. private _addMeshVerts;
  53087. /**
  53088. * Initialise the soft body vertices to match its object's (mesh) vertices
  53089. * Softbody vertices (nodes) are in world space and to match this
  53090. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53091. * @param impostor to create the softbody for
  53092. */
  53093. private _softVertexData;
  53094. /**
  53095. * Create an impostor's soft body
  53096. * @param impostor to create the softbody for
  53097. */
  53098. private _createSoftbody;
  53099. /**
  53100. * Create cloth for an impostor
  53101. * @param impostor to create the softbody for
  53102. */
  53103. private _createCloth;
  53104. /**
  53105. * Create rope for an impostor
  53106. * @param impostor to create the softbody for
  53107. */
  53108. private _createRope;
  53109. private _addHullVerts;
  53110. private _createShape;
  53111. /**
  53112. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53113. * @param impostor imposter containing the physics body and babylon object
  53114. */
  53115. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53116. /**
  53117. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53118. * @param impostor imposter containing the physics body and babylon object
  53119. * @param newPosition new position
  53120. * @param newRotation new rotation
  53121. */
  53122. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53123. /**
  53124. * If this plugin is supported
  53125. * @returns true if its supported
  53126. */
  53127. isSupported(): boolean;
  53128. /**
  53129. * Sets the linear velocity of the physics body
  53130. * @param impostor imposter to set the velocity on
  53131. * @param velocity velocity to set
  53132. */
  53133. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53134. /**
  53135. * Sets the angular velocity of the physics body
  53136. * @param impostor imposter to set the velocity on
  53137. * @param velocity velocity to set
  53138. */
  53139. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53140. /**
  53141. * gets the linear velocity
  53142. * @param impostor imposter to get linear velocity from
  53143. * @returns linear velocity
  53144. */
  53145. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53146. /**
  53147. * gets the angular velocity
  53148. * @param impostor imposter to get angular velocity from
  53149. * @returns angular velocity
  53150. */
  53151. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53152. /**
  53153. * Sets the mass of physics body
  53154. * @param impostor imposter to set the mass on
  53155. * @param mass mass to set
  53156. */
  53157. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53158. /**
  53159. * Gets the mass of the physics body
  53160. * @param impostor imposter to get the mass from
  53161. * @returns mass
  53162. */
  53163. getBodyMass(impostor: PhysicsImpostor): number;
  53164. /**
  53165. * Gets friction of the impostor
  53166. * @param impostor impostor to get friction from
  53167. * @returns friction value
  53168. */
  53169. getBodyFriction(impostor: PhysicsImpostor): number;
  53170. /**
  53171. * Sets friction of the impostor
  53172. * @param impostor impostor to set friction on
  53173. * @param friction friction value
  53174. */
  53175. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53176. /**
  53177. * Gets restitution of the impostor
  53178. * @param impostor impostor to get restitution from
  53179. * @returns restitution value
  53180. */
  53181. getBodyRestitution(impostor: PhysicsImpostor): number;
  53182. /**
  53183. * Sets resitution of the impostor
  53184. * @param impostor impostor to set resitution on
  53185. * @param restitution resitution value
  53186. */
  53187. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53188. /**
  53189. * Gets pressure inside the impostor
  53190. * @param impostor impostor to get pressure from
  53191. * @returns pressure value
  53192. */
  53193. getBodyPressure(impostor: PhysicsImpostor): number;
  53194. /**
  53195. * Sets pressure inside a soft body impostor
  53196. * Cloth and rope must remain 0 pressure
  53197. * @param impostor impostor to set pressure on
  53198. * @param pressure pressure value
  53199. */
  53200. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53201. /**
  53202. * Gets stiffness of the impostor
  53203. * @param impostor impostor to get stiffness from
  53204. * @returns pressure value
  53205. */
  53206. getBodyStiffness(impostor: PhysicsImpostor): number;
  53207. /**
  53208. * Sets stiffness of the impostor
  53209. * @param impostor impostor to set stiffness on
  53210. * @param stiffness stiffness value from 0 to 1
  53211. */
  53212. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53213. /**
  53214. * Gets velocityIterations of the impostor
  53215. * @param impostor impostor to get velocity iterations from
  53216. * @returns velocityIterations value
  53217. */
  53218. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53219. /**
  53220. * Sets velocityIterations of the impostor
  53221. * @param impostor impostor to set velocity iterations on
  53222. * @param velocityIterations velocityIterations value
  53223. */
  53224. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53225. /**
  53226. * Gets positionIterations of the impostor
  53227. * @param impostor impostor to get position iterations from
  53228. * @returns positionIterations value
  53229. */
  53230. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53231. /**
  53232. * Sets positionIterations of the impostor
  53233. * @param impostor impostor to set position on
  53234. * @param positionIterations positionIterations value
  53235. */
  53236. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53237. /**
  53238. * Append an anchor to a cloth object
  53239. * @param impostor is the cloth impostor to add anchor to
  53240. * @param otherImpostor is the rigid impostor to anchor to
  53241. * @param width ratio across width from 0 to 1
  53242. * @param height ratio up height from 0 to 1
  53243. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53244. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53245. */
  53246. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53247. /**
  53248. * Append an hook to a rope object
  53249. * @param impostor is the rope impostor to add hook to
  53250. * @param otherImpostor is the rigid impostor to hook to
  53251. * @param length ratio along the rope from 0 to 1
  53252. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53253. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53254. */
  53255. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53256. /**
  53257. * Sleeps the physics body and stops it from being active
  53258. * @param impostor impostor to sleep
  53259. */
  53260. sleepBody(impostor: PhysicsImpostor): void;
  53261. /**
  53262. * Activates the physics body
  53263. * @param impostor impostor to activate
  53264. */
  53265. wakeUpBody(impostor: PhysicsImpostor): void;
  53266. /**
  53267. * Updates the distance parameters of the joint
  53268. * @param joint joint to update
  53269. * @param maxDistance maximum distance of the joint
  53270. * @param minDistance minimum distance of the joint
  53271. */
  53272. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53273. /**
  53274. * Sets a motor on the joint
  53275. * @param joint joint to set motor on
  53276. * @param speed speed of the motor
  53277. * @param maxForce maximum force of the motor
  53278. * @param motorIndex index of the motor
  53279. */
  53280. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53281. /**
  53282. * Sets the motors limit
  53283. * @param joint joint to set limit on
  53284. * @param upperLimit upper limit
  53285. * @param lowerLimit lower limit
  53286. */
  53287. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53288. /**
  53289. * Syncs the position and rotation of a mesh with the impostor
  53290. * @param mesh mesh to sync
  53291. * @param impostor impostor to update the mesh with
  53292. */
  53293. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53294. /**
  53295. * Gets the radius of the impostor
  53296. * @param impostor impostor to get radius from
  53297. * @returns the radius
  53298. */
  53299. getRadius(impostor: PhysicsImpostor): number;
  53300. /**
  53301. * Gets the box size of the impostor
  53302. * @param impostor impostor to get box size from
  53303. * @param result the resulting box size
  53304. */
  53305. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53306. /**
  53307. * Disposes of the impostor
  53308. */
  53309. dispose(): void;
  53310. /**
  53311. * Does a raycast in the physics world
  53312. * @param from when should the ray start?
  53313. * @param to when should the ray end?
  53314. * @returns PhysicsRaycastResult
  53315. */
  53316. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53317. }
  53318. }
  53319. declare module "babylonjs/Probes/reflectionProbe" {
  53320. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53321. import { Vector3 } from "babylonjs/Maths/math.vector";
  53322. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53323. import { Nullable } from "babylonjs/types";
  53324. import { Scene } from "babylonjs/scene";
  53325. module "babylonjs/abstractScene" {
  53326. interface AbstractScene {
  53327. /**
  53328. * The list of reflection probes added to the scene
  53329. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53330. */
  53331. reflectionProbes: Array<ReflectionProbe>;
  53332. /**
  53333. * Removes the given reflection probe from this scene.
  53334. * @param toRemove The reflection probe to remove
  53335. * @returns The index of the removed reflection probe
  53336. */
  53337. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53338. /**
  53339. * Adds the given reflection probe to this scene.
  53340. * @param newReflectionProbe The reflection probe to add
  53341. */
  53342. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53343. }
  53344. }
  53345. /**
  53346. * Class used to generate realtime reflection / refraction cube textures
  53347. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53348. */
  53349. export class ReflectionProbe {
  53350. /** defines the name of the probe */
  53351. name: string;
  53352. private _scene;
  53353. private _renderTargetTexture;
  53354. private _projectionMatrix;
  53355. private _viewMatrix;
  53356. private _target;
  53357. private _add;
  53358. private _attachedMesh;
  53359. private _invertYAxis;
  53360. /** Gets or sets probe position (center of the cube map) */
  53361. position: Vector3;
  53362. /**
  53363. * Creates a new reflection probe
  53364. * @param name defines the name of the probe
  53365. * @param size defines the texture resolution (for each face)
  53366. * @param scene defines the hosting scene
  53367. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53368. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53369. */
  53370. constructor(
  53371. /** defines the name of the probe */
  53372. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53373. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53374. samples: number;
  53375. /** Gets or sets the refresh rate to use (on every frame by default) */
  53376. refreshRate: number;
  53377. /**
  53378. * Gets the hosting scene
  53379. * @returns a Scene
  53380. */
  53381. getScene(): Scene;
  53382. /** Gets the internal CubeTexture used to render to */
  53383. readonly cubeTexture: RenderTargetTexture;
  53384. /** Gets the list of meshes to render */
  53385. readonly renderList: Nullable<AbstractMesh[]>;
  53386. /**
  53387. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53388. * @param mesh defines the mesh to attach to
  53389. */
  53390. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53391. /**
  53392. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  53393. * @param renderingGroupId The rendering group id corresponding to its index
  53394. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  53395. */
  53396. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  53397. /**
  53398. * Clean all associated resources
  53399. */
  53400. dispose(): void;
  53401. /**
  53402. * Converts the reflection probe information to a readable string for debug purpose.
  53403. * @param fullDetails Supports for multiple levels of logging within scene loading
  53404. * @returns the human readable reflection probe info
  53405. */
  53406. toString(fullDetails?: boolean): string;
  53407. /**
  53408. * Get the class name of the relfection probe.
  53409. * @returns "ReflectionProbe"
  53410. */
  53411. getClassName(): string;
  53412. /**
  53413. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  53414. * @returns The JSON representation of the texture
  53415. */
  53416. serialize(): any;
  53417. /**
  53418. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  53419. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  53420. * @param scene Define the scene the parsed reflection probe should be instantiated in
  53421. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  53422. * @returns The parsed reflection probe if successful
  53423. */
  53424. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  53425. }
  53426. }
  53427. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  53428. /** @hidden */
  53429. export var _BabylonLoaderRegistered: boolean;
  53430. }
  53431. declare module "babylonjs/Loading/Plugins/index" {
  53432. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  53433. }
  53434. declare module "babylonjs/Loading/index" {
  53435. export * from "babylonjs/Loading/loadingScreen";
  53436. export * from "babylonjs/Loading/Plugins/index";
  53437. export * from "babylonjs/Loading/sceneLoader";
  53438. export * from "babylonjs/Loading/sceneLoaderFlags";
  53439. }
  53440. declare module "babylonjs/Materials/Background/index" {
  53441. export * from "babylonjs/Materials/Background/backgroundMaterial";
  53442. }
  53443. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  53444. import { Scene } from "babylonjs/scene";
  53445. import { Color3 } from "babylonjs/Maths/math.color";
  53446. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53447. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53448. /**
  53449. * The Physically based simple base material of BJS.
  53450. *
  53451. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53452. * It is used as the base class for both the specGloss and metalRough conventions.
  53453. */
  53454. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  53455. /**
  53456. * Number of Simultaneous lights allowed on the material.
  53457. */
  53458. maxSimultaneousLights: number;
  53459. /**
  53460. * If sets to true, disables all the lights affecting the material.
  53461. */
  53462. disableLighting: boolean;
  53463. /**
  53464. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  53465. */
  53466. environmentTexture: BaseTexture;
  53467. /**
  53468. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53469. */
  53470. invertNormalMapX: boolean;
  53471. /**
  53472. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53473. */
  53474. invertNormalMapY: boolean;
  53475. /**
  53476. * Normal map used in the model.
  53477. */
  53478. normalTexture: BaseTexture;
  53479. /**
  53480. * Emissivie color used to self-illuminate the model.
  53481. */
  53482. emissiveColor: Color3;
  53483. /**
  53484. * Emissivie texture used to self-illuminate the model.
  53485. */
  53486. emissiveTexture: BaseTexture;
  53487. /**
  53488. * Occlusion Channel Strenght.
  53489. */
  53490. occlusionStrength: number;
  53491. /**
  53492. * Occlusion Texture of the material (adding extra occlusion effects).
  53493. */
  53494. occlusionTexture: BaseTexture;
  53495. /**
  53496. * Defines the alpha limits in alpha test mode.
  53497. */
  53498. alphaCutOff: number;
  53499. /**
  53500. * Gets the current double sided mode.
  53501. */
  53502. /**
  53503. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53504. */
  53505. doubleSided: boolean;
  53506. /**
  53507. * Stores the pre-calculated light information of a mesh in a texture.
  53508. */
  53509. lightmapTexture: BaseTexture;
  53510. /**
  53511. * If true, the light map contains occlusion information instead of lighting info.
  53512. */
  53513. useLightmapAsShadowmap: boolean;
  53514. /**
  53515. * Instantiates a new PBRMaterial instance.
  53516. *
  53517. * @param name The material name
  53518. * @param scene The scene the material will be use in.
  53519. */
  53520. constructor(name: string, scene: Scene);
  53521. getClassName(): string;
  53522. }
  53523. }
  53524. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  53525. import { Scene } from "babylonjs/scene";
  53526. import { Color3 } from "babylonjs/Maths/math.color";
  53527. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53528. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53529. /**
  53530. * The PBR material of BJS following the metal roughness convention.
  53531. *
  53532. * This fits to the PBR convention in the GLTF definition:
  53533. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  53534. */
  53535. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  53536. /**
  53537. * The base color has two different interpretations depending on the value of metalness.
  53538. * When the material is a metal, the base color is the specific measured reflectance value
  53539. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  53540. * of the material.
  53541. */
  53542. baseColor: Color3;
  53543. /**
  53544. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  53545. * well as opacity information in the alpha channel.
  53546. */
  53547. baseTexture: BaseTexture;
  53548. /**
  53549. * Specifies the metallic scalar value of the material.
  53550. * Can also be used to scale the metalness values of the metallic texture.
  53551. */
  53552. metallic: number;
  53553. /**
  53554. * Specifies the roughness scalar value of the material.
  53555. * Can also be used to scale the roughness values of the metallic texture.
  53556. */
  53557. roughness: number;
  53558. /**
  53559. * Texture containing both the metallic value in the B channel and the
  53560. * roughness value in the G channel to keep better precision.
  53561. */
  53562. metallicRoughnessTexture: BaseTexture;
  53563. /**
  53564. * Instantiates a new PBRMetalRoughnessMaterial instance.
  53565. *
  53566. * @param name The material name
  53567. * @param scene The scene the material will be use in.
  53568. */
  53569. constructor(name: string, scene: Scene);
  53570. /**
  53571. * Return the currrent class name of the material.
  53572. */
  53573. getClassName(): string;
  53574. /**
  53575. * Makes a duplicate of the current material.
  53576. * @param name - name to use for the new material.
  53577. */
  53578. clone(name: string): PBRMetallicRoughnessMaterial;
  53579. /**
  53580. * Serialize the material to a parsable JSON object.
  53581. */
  53582. serialize(): any;
  53583. /**
  53584. * Parses a JSON object correponding to the serialize function.
  53585. */
  53586. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  53587. }
  53588. }
  53589. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  53590. import { Scene } from "babylonjs/scene";
  53591. import { Color3 } from "babylonjs/Maths/math.color";
  53592. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53593. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53594. /**
  53595. * The PBR material of BJS following the specular glossiness convention.
  53596. *
  53597. * This fits to the PBR convention in the GLTF definition:
  53598. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53599. */
  53600. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  53601. /**
  53602. * Specifies the diffuse color of the material.
  53603. */
  53604. diffuseColor: Color3;
  53605. /**
  53606. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  53607. * channel.
  53608. */
  53609. diffuseTexture: BaseTexture;
  53610. /**
  53611. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  53612. */
  53613. specularColor: Color3;
  53614. /**
  53615. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  53616. */
  53617. glossiness: number;
  53618. /**
  53619. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  53620. */
  53621. specularGlossinessTexture: BaseTexture;
  53622. /**
  53623. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53624. *
  53625. * @param name The material name
  53626. * @param scene The scene the material will be use in.
  53627. */
  53628. constructor(name: string, scene: Scene);
  53629. /**
  53630. * Return the currrent class name of the material.
  53631. */
  53632. getClassName(): string;
  53633. /**
  53634. * Makes a duplicate of the current material.
  53635. * @param name - name to use for the new material.
  53636. */
  53637. clone(name: string): PBRSpecularGlossinessMaterial;
  53638. /**
  53639. * Serialize the material to a parsable JSON object.
  53640. */
  53641. serialize(): any;
  53642. /**
  53643. * Parses a JSON object correponding to the serialize function.
  53644. */
  53645. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  53646. }
  53647. }
  53648. declare module "babylonjs/Materials/PBR/index" {
  53649. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53650. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53651. export * from "babylonjs/Materials/PBR/pbrMaterial";
  53652. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  53653. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  53654. }
  53655. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  53656. import { Nullable } from "babylonjs/types";
  53657. import { Scene } from "babylonjs/scene";
  53658. import { Matrix } from "babylonjs/Maths/math.vector";
  53659. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53660. /**
  53661. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  53662. * It can help converting any input color in a desired output one. This can then be used to create effects
  53663. * from sepia, black and white to sixties or futuristic rendering...
  53664. *
  53665. * The only supported format is currently 3dl.
  53666. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  53667. */
  53668. export class ColorGradingTexture extends BaseTexture {
  53669. /**
  53670. * The current texture matrix. (will always be identity in color grading texture)
  53671. */
  53672. private _textureMatrix;
  53673. /**
  53674. * The texture URL.
  53675. */
  53676. url: string;
  53677. /**
  53678. * Empty line regex stored for GC.
  53679. */
  53680. private static _noneEmptyLineRegex;
  53681. private _engine;
  53682. /**
  53683. * Instantiates a ColorGradingTexture from the following parameters.
  53684. *
  53685. * @param url The location of the color gradind data (currently only supporting 3dl)
  53686. * @param scene The scene the texture will be used in
  53687. */
  53688. constructor(url: string, scene: Scene);
  53689. /**
  53690. * Returns the texture matrix used in most of the material.
  53691. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  53692. */
  53693. getTextureMatrix(): Matrix;
  53694. /**
  53695. * Occurs when the file being loaded is a .3dl LUT file.
  53696. */
  53697. private load3dlTexture;
  53698. /**
  53699. * Starts the loading process of the texture.
  53700. */
  53701. private loadTexture;
  53702. /**
  53703. * Clones the color gradind texture.
  53704. */
  53705. clone(): ColorGradingTexture;
  53706. /**
  53707. * Called during delayed load for textures.
  53708. */
  53709. delayLoad(): void;
  53710. /**
  53711. * Parses a color grading texture serialized by Babylon.
  53712. * @param parsedTexture The texture information being parsedTexture
  53713. * @param scene The scene to load the texture in
  53714. * @param rootUrl The root url of the data assets to load
  53715. * @return A color gradind texture
  53716. */
  53717. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  53718. /**
  53719. * Serializes the LUT texture to json format.
  53720. */
  53721. serialize(): any;
  53722. }
  53723. }
  53724. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  53725. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53726. import { Scene } from "babylonjs/scene";
  53727. import { Nullable } from "babylonjs/types";
  53728. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53729. /**
  53730. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  53731. */
  53732. export class EquiRectangularCubeTexture extends BaseTexture {
  53733. /** The six faces of the cube. */
  53734. private static _FacesMapping;
  53735. private _noMipmap;
  53736. private _onLoad;
  53737. private _onError;
  53738. /** The size of the cubemap. */
  53739. private _size;
  53740. /** The buffer of the image. */
  53741. private _buffer;
  53742. /** The width of the input image. */
  53743. private _width;
  53744. /** The height of the input image. */
  53745. private _height;
  53746. /** The URL to the image. */
  53747. url: string;
  53748. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  53749. coordinatesMode: number;
  53750. /**
  53751. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  53752. * @param url The location of the image
  53753. * @param scene The scene the texture will be used in
  53754. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53755. * @param noMipmap Forces to not generate the mipmap if true
  53756. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  53757. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  53758. * @param onLoad — defines a callback called when texture is loaded
  53759. * @param onError — defines a callback called if there is an error
  53760. */
  53761. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  53762. /**
  53763. * Load the image data, by putting the image on a canvas and extracting its buffer.
  53764. */
  53765. private loadImage;
  53766. /**
  53767. * Convert the image buffer into a cubemap and create a CubeTexture.
  53768. */
  53769. private loadTexture;
  53770. /**
  53771. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  53772. * @param buffer The ArrayBuffer that should be converted.
  53773. * @returns The buffer as Float32Array.
  53774. */
  53775. private getFloat32ArrayFromArrayBuffer;
  53776. /**
  53777. * Get the current class name of the texture useful for serialization or dynamic coding.
  53778. * @returns "EquiRectangularCubeTexture"
  53779. */
  53780. getClassName(): string;
  53781. /**
  53782. * Create a clone of the current EquiRectangularCubeTexture and return it.
  53783. * @returns A clone of the current EquiRectangularCubeTexture.
  53784. */
  53785. clone(): EquiRectangularCubeTexture;
  53786. }
  53787. }
  53788. declare module "babylonjs/Misc/tga" {
  53789. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53790. /**
  53791. * Based on jsTGALoader - Javascript loader for TGA file
  53792. * By Vincent Thibault
  53793. * @see http://blog.robrowser.com/javascript-tga-loader.html
  53794. */
  53795. export class TGATools {
  53796. private static _TYPE_INDEXED;
  53797. private static _TYPE_RGB;
  53798. private static _TYPE_GREY;
  53799. private static _TYPE_RLE_INDEXED;
  53800. private static _TYPE_RLE_RGB;
  53801. private static _TYPE_RLE_GREY;
  53802. private static _ORIGIN_MASK;
  53803. private static _ORIGIN_SHIFT;
  53804. private static _ORIGIN_BL;
  53805. private static _ORIGIN_BR;
  53806. private static _ORIGIN_UL;
  53807. private static _ORIGIN_UR;
  53808. /**
  53809. * Gets the header of a TGA file
  53810. * @param data defines the TGA data
  53811. * @returns the header
  53812. */
  53813. static GetTGAHeader(data: Uint8Array): any;
  53814. /**
  53815. * Uploads TGA content to a Babylon Texture
  53816. * @hidden
  53817. */
  53818. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  53819. /** @hidden */
  53820. 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;
  53821. /** @hidden */
  53822. 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;
  53823. /** @hidden */
  53824. 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;
  53825. /** @hidden */
  53826. 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;
  53827. /** @hidden */
  53828. 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;
  53829. /** @hidden */
  53830. 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;
  53831. }
  53832. }
  53833. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  53834. import { Nullable } from "babylonjs/types";
  53835. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53836. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53837. /**
  53838. * Implementation of the TGA Texture Loader.
  53839. * @hidden
  53840. */
  53841. export class _TGATextureLoader implements IInternalTextureLoader {
  53842. /**
  53843. * Defines wether the loader supports cascade loading the different faces.
  53844. */
  53845. readonly supportCascades: boolean;
  53846. /**
  53847. * This returns if the loader support the current file information.
  53848. * @param extension defines the file extension of the file being loaded
  53849. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53850. * @param fallback defines the fallback internal texture if any
  53851. * @param isBase64 defines whether the texture is encoded as a base64
  53852. * @param isBuffer defines whether the texture data are stored as a buffer
  53853. * @returns true if the loader can load the specified file
  53854. */
  53855. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53856. /**
  53857. * Transform the url before loading if required.
  53858. * @param rootUrl the url of the texture
  53859. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53860. * @returns the transformed texture
  53861. */
  53862. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53863. /**
  53864. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53865. * @param rootUrl the url of the texture
  53866. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53867. * @returns the fallback texture
  53868. */
  53869. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53870. /**
  53871. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53872. * @param data contains the texture data
  53873. * @param texture defines the BabylonJS internal texture
  53874. * @param createPolynomials will be true if polynomials have been requested
  53875. * @param onLoad defines the callback to trigger once the texture is ready
  53876. * @param onError defines the callback to trigger in case of error
  53877. */
  53878. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53879. /**
  53880. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53881. * @param data contains the texture data
  53882. * @param texture defines the BabylonJS internal texture
  53883. * @param callback defines the method to call once ready to upload
  53884. */
  53885. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53886. }
  53887. }
  53888. declare module "babylonjs/Misc/basis" {
  53889. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53890. /**
  53891. * Info about the .basis files
  53892. */
  53893. class BasisFileInfo {
  53894. /**
  53895. * If the file has alpha
  53896. */
  53897. hasAlpha: boolean;
  53898. /**
  53899. * Info about each image of the basis file
  53900. */
  53901. images: Array<{
  53902. levels: Array<{
  53903. width: number;
  53904. height: number;
  53905. transcodedPixels: ArrayBufferView;
  53906. }>;
  53907. }>;
  53908. }
  53909. /**
  53910. * Result of transcoding a basis file
  53911. */
  53912. class TranscodeResult {
  53913. /**
  53914. * Info about the .basis file
  53915. */
  53916. fileInfo: BasisFileInfo;
  53917. /**
  53918. * Format to use when loading the file
  53919. */
  53920. format: number;
  53921. }
  53922. /**
  53923. * Configuration options for the Basis transcoder
  53924. */
  53925. export class BasisTranscodeConfiguration {
  53926. /**
  53927. * Supported compression formats used to determine the supported output format of the transcoder
  53928. */
  53929. supportedCompressionFormats?: {
  53930. /**
  53931. * etc1 compression format
  53932. */
  53933. etc1?: boolean;
  53934. /**
  53935. * s3tc compression format
  53936. */
  53937. s3tc?: boolean;
  53938. /**
  53939. * pvrtc compression format
  53940. */
  53941. pvrtc?: boolean;
  53942. /**
  53943. * etc2 compression format
  53944. */
  53945. etc2?: boolean;
  53946. };
  53947. /**
  53948. * If mipmap levels should be loaded for transcoded images (Default: true)
  53949. */
  53950. loadMipmapLevels?: boolean;
  53951. /**
  53952. * Index of a single image to load (Default: all images)
  53953. */
  53954. loadSingleImage?: number;
  53955. }
  53956. /**
  53957. * Used to load .Basis files
  53958. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  53959. */
  53960. export class BasisTools {
  53961. private static _IgnoreSupportedFormats;
  53962. /**
  53963. * URL to use when loading the basis transcoder
  53964. */
  53965. static JSModuleURL: string;
  53966. /**
  53967. * URL to use when loading the wasm module for the transcoder
  53968. */
  53969. static WasmModuleURL: string;
  53970. /**
  53971. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  53972. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  53973. * @returns internal format corresponding to the Basis format
  53974. */
  53975. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  53976. private static _WorkerPromise;
  53977. private static _Worker;
  53978. private static _actionId;
  53979. private static _CreateWorkerAsync;
  53980. /**
  53981. * Transcodes a loaded image file to compressed pixel data
  53982. * @param imageData image data to transcode
  53983. * @param config configuration options for the transcoding
  53984. * @returns a promise resulting in the transcoded image
  53985. */
  53986. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  53987. /**
  53988. * Loads a texture from the transcode result
  53989. * @param texture texture load to
  53990. * @param transcodeResult the result of transcoding the basis file to load from
  53991. */
  53992. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  53993. }
  53994. }
  53995. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  53996. import { Nullable } from "babylonjs/types";
  53997. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53998. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53999. /**
  54000. * Loader for .basis file format
  54001. */
  54002. export class _BasisTextureLoader implements IInternalTextureLoader {
  54003. /**
  54004. * Defines whether the loader supports cascade loading the different faces.
  54005. */
  54006. readonly supportCascades: boolean;
  54007. /**
  54008. * This returns if the loader support the current file information.
  54009. * @param extension defines the file extension of the file being loaded
  54010. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54011. * @param fallback defines the fallback internal texture if any
  54012. * @param isBase64 defines whether the texture is encoded as a base64
  54013. * @param isBuffer defines whether the texture data are stored as a buffer
  54014. * @returns true if the loader can load the specified file
  54015. */
  54016. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54017. /**
  54018. * Transform the url before loading if required.
  54019. * @param rootUrl the url of the texture
  54020. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54021. * @returns the transformed texture
  54022. */
  54023. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54024. /**
  54025. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54026. * @param rootUrl the url of the texture
  54027. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54028. * @returns the fallback texture
  54029. */
  54030. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54031. /**
  54032. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54033. * @param data contains the texture data
  54034. * @param texture defines the BabylonJS internal texture
  54035. * @param createPolynomials will be true if polynomials have been requested
  54036. * @param onLoad defines the callback to trigger once the texture is ready
  54037. * @param onError defines the callback to trigger in case of error
  54038. */
  54039. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54040. /**
  54041. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54042. * @param data contains the texture data
  54043. * @param texture defines the BabylonJS internal texture
  54044. * @param callback defines the method to call once ready to upload
  54045. */
  54046. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54047. }
  54048. }
  54049. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54050. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54051. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54052. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54053. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54054. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54055. }
  54056. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54057. import { Scene } from "babylonjs/scene";
  54058. import { Texture } from "babylonjs/Materials/Textures/texture";
  54059. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54060. /**
  54061. * 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.
  54062. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54063. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54064. */
  54065. export class CustomProceduralTexture extends ProceduralTexture {
  54066. private _animate;
  54067. private _time;
  54068. private _config;
  54069. private _texturePath;
  54070. /**
  54071. * Instantiates a new Custom Procedural Texture.
  54072. * 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.
  54073. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54074. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54075. * @param name Define the name of the texture
  54076. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54077. * @param size Define the size of the texture to create
  54078. * @param scene Define the scene the texture belongs to
  54079. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54080. * @param generateMipMaps Define if the texture should creates mip maps or not
  54081. */
  54082. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54083. private _loadJson;
  54084. /**
  54085. * Is the texture ready to be used ? (rendered at least once)
  54086. * @returns true if ready, otherwise, false.
  54087. */
  54088. isReady(): boolean;
  54089. /**
  54090. * Render the texture to its associated render target.
  54091. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54092. */
  54093. render(useCameraPostProcess?: boolean): void;
  54094. /**
  54095. * Update the list of dependant textures samplers in the shader.
  54096. */
  54097. updateTextures(): void;
  54098. /**
  54099. * Update the uniform values of the procedural texture in the shader.
  54100. */
  54101. updateShaderUniforms(): void;
  54102. /**
  54103. * Define if the texture animates or not.
  54104. */
  54105. animate: boolean;
  54106. }
  54107. }
  54108. declare module "babylonjs/Shaders/noise.fragment" {
  54109. /** @hidden */
  54110. export var noisePixelShader: {
  54111. name: string;
  54112. shader: string;
  54113. };
  54114. }
  54115. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54116. import { Nullable } from "babylonjs/types";
  54117. import { Scene } from "babylonjs/scene";
  54118. import { Texture } from "babylonjs/Materials/Textures/texture";
  54119. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54120. import "babylonjs/Shaders/noise.fragment";
  54121. /**
  54122. * Class used to generate noise procedural textures
  54123. */
  54124. export class NoiseProceduralTexture extends ProceduralTexture {
  54125. private _time;
  54126. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54127. brightness: number;
  54128. /** Defines the number of octaves to process */
  54129. octaves: number;
  54130. /** Defines the level of persistence (0.8 by default) */
  54131. persistence: number;
  54132. /** Gets or sets animation speed factor (default is 1) */
  54133. animationSpeedFactor: number;
  54134. /**
  54135. * Creates a new NoiseProceduralTexture
  54136. * @param name defines the name fo the texture
  54137. * @param size defines the size of the texture (default is 256)
  54138. * @param scene defines the hosting scene
  54139. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54140. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54141. */
  54142. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54143. private _updateShaderUniforms;
  54144. protected _getDefines(): string;
  54145. /** Generate the current state of the procedural texture */
  54146. render(useCameraPostProcess?: boolean): void;
  54147. /**
  54148. * Serializes this noise procedural texture
  54149. * @returns a serialized noise procedural texture object
  54150. */
  54151. serialize(): any;
  54152. /**
  54153. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54154. * @param parsedTexture defines parsed texture data
  54155. * @param scene defines the current scene
  54156. * @param rootUrl defines the root URL containing noise procedural texture information
  54157. * @returns a parsed NoiseProceduralTexture
  54158. */
  54159. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54160. }
  54161. }
  54162. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54163. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54164. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54165. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54166. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54167. }
  54168. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54169. import { Nullable } from "babylonjs/types";
  54170. import { Scene } from "babylonjs/scene";
  54171. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54172. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54173. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54174. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54175. /**
  54176. * Raw cube texture where the raw buffers are passed in
  54177. */
  54178. export class RawCubeTexture extends CubeTexture {
  54179. /**
  54180. * Creates a cube texture where the raw buffers are passed in.
  54181. * @param scene defines the scene the texture is attached to
  54182. * @param data defines the array of data to use to create each face
  54183. * @param size defines the size of the textures
  54184. * @param format defines the format of the data
  54185. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54186. * @param generateMipMaps defines if the engine should generate the mip levels
  54187. * @param invertY defines if data must be stored with Y axis inverted
  54188. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54189. * @param compression defines the compression used (null by default)
  54190. */
  54191. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54192. /**
  54193. * Updates the raw cube texture.
  54194. * @param data defines the data to store
  54195. * @param format defines the data format
  54196. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54197. * @param invertY defines if data must be stored with Y axis inverted
  54198. * @param compression defines the compression used (null by default)
  54199. * @param level defines which level of the texture to update
  54200. */
  54201. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54202. /**
  54203. * Updates a raw cube texture with RGBD encoded data.
  54204. * @param data defines the array of data [mipmap][face] to use to create each face
  54205. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54206. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54207. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54208. * @returns a promsie that resolves when the operation is complete
  54209. */
  54210. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54211. /**
  54212. * Clones the raw cube texture.
  54213. * @return a new cube texture
  54214. */
  54215. clone(): CubeTexture;
  54216. /** @hidden */
  54217. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54218. }
  54219. }
  54220. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54221. import { Scene } from "babylonjs/scene";
  54222. import { Texture } from "babylonjs/Materials/Textures/texture";
  54223. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54224. /**
  54225. * Class used to store 3D textures containing user data
  54226. */
  54227. export class RawTexture3D extends Texture {
  54228. /** Gets or sets the texture format to use */
  54229. format: number;
  54230. private _engine;
  54231. /**
  54232. * Create a new RawTexture3D
  54233. * @param data defines the data of the texture
  54234. * @param width defines the width of the texture
  54235. * @param height defines the height of the texture
  54236. * @param depth defines the depth of the texture
  54237. * @param format defines the texture format to use
  54238. * @param scene defines the hosting scene
  54239. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54240. * @param invertY defines if texture must be stored with Y axis inverted
  54241. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54242. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54243. */
  54244. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54245. /** Gets or sets the texture format to use */
  54246. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54247. /**
  54248. * Update the texture with new data
  54249. * @param data defines the data to store in the texture
  54250. */
  54251. update(data: ArrayBufferView): void;
  54252. }
  54253. }
  54254. declare module "babylonjs/Materials/Textures/refractionTexture" {
  54255. import { Scene } from "babylonjs/scene";
  54256. import { Plane } from "babylonjs/Maths/math.plane";
  54257. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54258. /**
  54259. * Creates a refraction texture used by refraction channel of the standard material.
  54260. * It is like a mirror but to see through a material.
  54261. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54262. */
  54263. export class RefractionTexture extends RenderTargetTexture {
  54264. /**
  54265. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54266. * 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.
  54267. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54268. */
  54269. refractionPlane: Plane;
  54270. /**
  54271. * Define how deep under the surface we should see.
  54272. */
  54273. depth: number;
  54274. /**
  54275. * Creates a refraction texture used by refraction channel of the standard material.
  54276. * It is like a mirror but to see through a material.
  54277. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54278. * @param name Define the texture name
  54279. * @param size Define the size of the underlying texture
  54280. * @param scene Define the scene the refraction belongs to
  54281. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54282. */
  54283. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54284. /**
  54285. * Clone the refraction texture.
  54286. * @returns the cloned texture
  54287. */
  54288. clone(): RefractionTexture;
  54289. /**
  54290. * Serialize the texture to a JSON representation you could use in Parse later on
  54291. * @returns the serialized JSON representation
  54292. */
  54293. serialize(): any;
  54294. }
  54295. }
  54296. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  54297. import { Nullable } from "babylonjs/types";
  54298. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54299. import { Matrix } from "babylonjs/Maths/math.vector";
  54300. import { Engine } from "babylonjs/Engines/engine";
  54301. import { Scene } from "babylonjs/scene";
  54302. /**
  54303. * Defines the options related to the creation of an HtmlElementTexture
  54304. */
  54305. export interface IHtmlElementTextureOptions {
  54306. /**
  54307. * Defines wether mip maps should be created or not.
  54308. */
  54309. generateMipMaps?: boolean;
  54310. /**
  54311. * Defines the sampling mode of the texture.
  54312. */
  54313. samplingMode?: number;
  54314. /**
  54315. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54316. */
  54317. engine: Nullable<Engine>;
  54318. /**
  54319. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54320. */
  54321. scene: Nullable<Scene>;
  54322. }
  54323. /**
  54324. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54325. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54326. * is automatically managed.
  54327. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54328. * in your application.
  54329. *
  54330. * As the update is not automatic, you need to call them manually.
  54331. */
  54332. export class HtmlElementTexture extends BaseTexture {
  54333. /**
  54334. * The texture URL.
  54335. */
  54336. element: HTMLVideoElement | HTMLCanvasElement;
  54337. private static readonly DefaultOptions;
  54338. private _textureMatrix;
  54339. private _engine;
  54340. private _isVideo;
  54341. private _generateMipMaps;
  54342. private _samplingMode;
  54343. /**
  54344. * Instantiates a HtmlElementTexture from the following parameters.
  54345. *
  54346. * @param name Defines the name of the texture
  54347. * @param element Defines the video or canvas the texture is filled with
  54348. * @param options Defines the other none mandatory texture creation options
  54349. */
  54350. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54351. private _createInternalTexture;
  54352. /**
  54353. * Returns the texture matrix used in most of the material.
  54354. */
  54355. getTextureMatrix(): Matrix;
  54356. /**
  54357. * Updates the content of the texture.
  54358. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54359. */
  54360. update(invertY?: Nullable<boolean>): void;
  54361. }
  54362. }
  54363. declare module "babylonjs/Materials/Textures/index" {
  54364. export * from "babylonjs/Materials/Textures/baseTexture";
  54365. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  54366. export * from "babylonjs/Materials/Textures/cubeTexture";
  54367. export * from "babylonjs/Materials/Textures/dynamicTexture";
  54368. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  54369. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  54370. export * from "babylonjs/Materials/Textures/internalTexture";
  54371. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54372. export * from "babylonjs/Materials/Textures/Loaders/index";
  54373. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54374. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54375. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54376. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54377. export * from "babylonjs/Materials/Textures/rawTexture";
  54378. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54379. export * from "babylonjs/Materials/Textures/refractionTexture";
  54380. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54381. export * from "babylonjs/Materials/Textures/texture";
  54382. export * from "babylonjs/Materials/Textures/videoTexture";
  54383. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  54384. }
  54385. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  54386. /**
  54387. * Enum used to define the target of a block
  54388. */
  54389. export enum NodeMaterialBlockTargets {
  54390. /** Vertex shader */
  54391. Vertex = 1,
  54392. /** Fragment shader */
  54393. Fragment = 2,
  54394. /** Neutral */
  54395. Neutral = 4,
  54396. /** Vertex and Fragment */
  54397. VertexAndFragment = 3
  54398. }
  54399. }
  54400. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  54401. /**
  54402. * Defines the kind of connection point for node based material
  54403. */
  54404. export enum NodeMaterialBlockConnectionPointTypes {
  54405. /** Float */
  54406. Float = 1,
  54407. /** Int */
  54408. Int = 2,
  54409. /** Vector2 */
  54410. Vector2 = 4,
  54411. /** Vector3 */
  54412. Vector3 = 8,
  54413. /** Vector4 */
  54414. Vector4 = 16,
  54415. /** Color3 */
  54416. Color3 = 32,
  54417. /** Color4 */
  54418. Color4 = 64,
  54419. /** Matrix */
  54420. Matrix = 128,
  54421. /** Detect type based on connection */
  54422. AutoDetect = 1024,
  54423. /** Output type that will be defined by input type */
  54424. BasedOnInput = 2048
  54425. }
  54426. }
  54427. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  54428. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54429. /**
  54430. * Root class for all node material optimizers
  54431. */
  54432. export class NodeMaterialOptimizer {
  54433. /**
  54434. * Function used to optimize a NodeMaterial graph
  54435. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  54436. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  54437. */
  54438. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  54439. }
  54440. }
  54441. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  54442. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54443. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54444. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54445. import { Scene } from "babylonjs/scene";
  54446. /**
  54447. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  54448. */
  54449. export class TransformBlock extends NodeMaterialBlock {
  54450. /**
  54451. * Defines the value to use to complement W value to transform it to a Vector4
  54452. */
  54453. complementW: number;
  54454. /**
  54455. * Defines the value to use to complement z value to transform it to a Vector4
  54456. */
  54457. complementZ: number;
  54458. /**
  54459. * Creates a new TransformBlock
  54460. * @param name defines the block name
  54461. */
  54462. constructor(name: string);
  54463. /**
  54464. * Gets the current class name
  54465. * @returns the class name
  54466. */
  54467. getClassName(): string;
  54468. /**
  54469. * Gets the vector input
  54470. */
  54471. readonly vector: NodeMaterialConnectionPoint;
  54472. /**
  54473. * Gets the output component
  54474. */
  54475. readonly output: NodeMaterialConnectionPoint;
  54476. /**
  54477. * Gets the matrix transform input
  54478. */
  54479. readonly transform: NodeMaterialConnectionPoint;
  54480. protected _buildBlock(state: NodeMaterialBuildState): this;
  54481. serialize(): any;
  54482. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54483. protected _dumpPropertiesCode(): string;
  54484. }
  54485. }
  54486. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  54487. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54488. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54489. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54490. /**
  54491. * Block used to output the vertex position
  54492. */
  54493. export class VertexOutputBlock extends NodeMaterialBlock {
  54494. /**
  54495. * Creates a new VertexOutputBlock
  54496. * @param name defines the block name
  54497. */
  54498. constructor(name: string);
  54499. /**
  54500. * Gets the current class name
  54501. * @returns the class name
  54502. */
  54503. getClassName(): string;
  54504. /**
  54505. * Gets the vector input component
  54506. */
  54507. readonly vector: NodeMaterialConnectionPoint;
  54508. protected _buildBlock(state: NodeMaterialBuildState): this;
  54509. }
  54510. }
  54511. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  54512. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54513. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54514. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54515. /**
  54516. * Block used to output the final color
  54517. */
  54518. export class FragmentOutputBlock extends NodeMaterialBlock {
  54519. /**
  54520. * Create a new FragmentOutputBlock
  54521. * @param name defines the block name
  54522. */
  54523. constructor(name: string);
  54524. /**
  54525. * Gets the current class name
  54526. * @returns the class name
  54527. */
  54528. getClassName(): string;
  54529. /**
  54530. * Gets the rgba input component
  54531. */
  54532. readonly rgba: NodeMaterialConnectionPoint;
  54533. /**
  54534. * Gets the rgb input component
  54535. */
  54536. readonly rgb: NodeMaterialConnectionPoint;
  54537. /**
  54538. * Gets the a input component
  54539. */
  54540. readonly a: NodeMaterialConnectionPoint;
  54541. protected _buildBlock(state: NodeMaterialBuildState): this;
  54542. }
  54543. }
  54544. declare module "babylonjs/Materials/Node/nodeMaterialSystemValues" {
  54545. /**
  54546. * Enum used to define system values e.g. values automatically provided by the system
  54547. */
  54548. export enum NodeMaterialSystemValues {
  54549. /** World */
  54550. World = 1,
  54551. /** View */
  54552. View = 2,
  54553. /** Projection */
  54554. Projection = 3,
  54555. /** ViewProjection */
  54556. ViewProjection = 4,
  54557. /** WorldView */
  54558. WorldView = 5,
  54559. /** WorldViewProjection */
  54560. WorldViewProjection = 6,
  54561. /** CameraPosition */
  54562. CameraPosition = 7,
  54563. /** Fog Color */
  54564. FogColor = 8
  54565. }
  54566. }
  54567. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  54568. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54569. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54570. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54571. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54573. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54574. import { Effect } from "babylonjs/Materials/effect";
  54575. import { Mesh } from "babylonjs/Meshes/mesh";
  54576. import { Nullable } from "babylonjs/types";
  54577. import { Scene } from "babylonjs/scene";
  54578. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  54579. /**
  54580. * Block used to read a reflection texture from a sampler
  54581. */
  54582. export class ReflectionTextureBlock extends NodeMaterialBlock {
  54583. private _define3DName;
  54584. private _defineCubicName;
  54585. private _defineExplicitName;
  54586. private _defineProjectionName;
  54587. private _defineLocalCubicName;
  54588. private _defineSphericalName;
  54589. private _definePlanarName;
  54590. private _defineEquirectangularName;
  54591. private _defineMirroredEquirectangularFixedName;
  54592. private _defineEquirectangularFixedName;
  54593. private _defineSkyboxName;
  54594. private _cubeSamplerName;
  54595. private _2DSamplerName;
  54596. private _positionUVWName;
  54597. private _directionWName;
  54598. private _reflectionCoordsName;
  54599. private _reflection2DCoordsName;
  54600. private _reflectionColorName;
  54601. private _reflectionMatrixName;
  54602. /**
  54603. * Gets or sets the texture associated with the node
  54604. */
  54605. texture: Nullable<BaseTexture>;
  54606. /**
  54607. * Create a new TextureBlock
  54608. * @param name defines the block name
  54609. */
  54610. constructor(name: string);
  54611. /**
  54612. * Gets the current class name
  54613. * @returns the class name
  54614. */
  54615. getClassName(): string;
  54616. /**
  54617. * Gets the world position input component
  54618. */
  54619. readonly position: NodeMaterialConnectionPoint;
  54620. /**
  54621. * Gets the world position input component
  54622. */
  54623. readonly worldPosition: NodeMaterialConnectionPoint;
  54624. /**
  54625. * Gets the world normal input component
  54626. */
  54627. readonly worldNormal: NodeMaterialConnectionPoint;
  54628. /**
  54629. * Gets the world input component
  54630. */
  54631. readonly world: NodeMaterialConnectionPoint;
  54632. /**
  54633. * Gets the camera (or eye) position component
  54634. */
  54635. readonly cameraPosition: NodeMaterialConnectionPoint;
  54636. /**
  54637. * Gets the view input component
  54638. */
  54639. readonly view: NodeMaterialConnectionPoint;
  54640. /**
  54641. * Gets the rgb output component
  54642. */
  54643. readonly rgb: NodeMaterialConnectionPoint;
  54644. /**
  54645. * Gets the r output component
  54646. */
  54647. readonly r: NodeMaterialConnectionPoint;
  54648. /**
  54649. * Gets the g output component
  54650. */
  54651. readonly g: NodeMaterialConnectionPoint;
  54652. /**
  54653. * Gets the b output component
  54654. */
  54655. readonly b: NodeMaterialConnectionPoint;
  54656. autoConfigure(material: NodeMaterial): void;
  54657. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54658. isReady(): boolean;
  54659. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54660. private _injectVertexCode;
  54661. private _writeOutput;
  54662. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54663. serialize(): any;
  54664. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54665. }
  54666. }
  54667. declare module "babylonjs/Materials/Node/nodeMaterial" {
  54668. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54669. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  54670. import { Scene } from "babylonjs/scene";
  54671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54672. import { Matrix } from "babylonjs/Maths/math.vector";
  54673. import { Mesh } from "babylonjs/Meshes/mesh";
  54674. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54675. import { Observable } from "babylonjs/Misc/observable";
  54676. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54677. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  54678. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54679. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  54680. import { Nullable } from "babylonjs/types";
  54681. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54682. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54683. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  54684. /**
  54685. * Interface used to configure the node material editor
  54686. */
  54687. export interface INodeMaterialEditorOptions {
  54688. /** Define the URl to load node editor script */
  54689. editorURL?: string;
  54690. }
  54691. /** @hidden */
  54692. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  54693. /** BONES */
  54694. NUM_BONE_INFLUENCERS: number;
  54695. BonesPerMesh: number;
  54696. BONETEXTURE: boolean;
  54697. /** MORPH TARGETS */
  54698. MORPHTARGETS: boolean;
  54699. MORPHTARGETS_NORMAL: boolean;
  54700. MORPHTARGETS_TANGENT: boolean;
  54701. MORPHTARGETS_UV: boolean;
  54702. NUM_MORPH_INFLUENCERS: number;
  54703. /** IMAGE PROCESSING */
  54704. IMAGEPROCESSING: boolean;
  54705. VIGNETTE: boolean;
  54706. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54707. VIGNETTEBLENDMODEOPAQUE: boolean;
  54708. TONEMAPPING: boolean;
  54709. TONEMAPPING_ACES: boolean;
  54710. CONTRAST: boolean;
  54711. EXPOSURE: boolean;
  54712. COLORCURVES: boolean;
  54713. COLORGRADING: boolean;
  54714. COLORGRADING3D: boolean;
  54715. SAMPLER3DGREENDEPTH: boolean;
  54716. SAMPLER3DBGRMAP: boolean;
  54717. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54718. /** MISC. */
  54719. BUMPDIRECTUV: number;
  54720. constructor();
  54721. setValue(name: string, value: boolean): void;
  54722. }
  54723. /**
  54724. * Class used to configure NodeMaterial
  54725. */
  54726. export interface INodeMaterialOptions {
  54727. /**
  54728. * Defines if blocks should emit comments
  54729. */
  54730. emitComments: boolean;
  54731. }
  54732. /**
  54733. * Class used to create a node based material built by assembling shader blocks
  54734. */
  54735. export class NodeMaterial extends PushMaterial {
  54736. private static _BuildIdGenerator;
  54737. private _options;
  54738. private _vertexCompilationState;
  54739. private _fragmentCompilationState;
  54740. private _sharedData;
  54741. private _buildId;
  54742. private _buildWasSuccessful;
  54743. private _cachedWorldViewMatrix;
  54744. private _cachedWorldViewProjectionMatrix;
  54745. private _optimizers;
  54746. private _animationFrame;
  54747. /** Define the URl to load node editor script */
  54748. static EditorURL: string;
  54749. private BJSNODEMATERIALEDITOR;
  54750. /** Get the inspector from bundle or global */
  54751. private _getGlobalNodeMaterialEditor;
  54752. /**
  54753. * 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)
  54754. */
  54755. ignoreAlpha: boolean;
  54756. /**
  54757. * Defines the maximum number of lights that can be used in the material
  54758. */
  54759. maxSimultaneousLights: number;
  54760. /**
  54761. * Observable raised when the material is built
  54762. */
  54763. onBuildObservable: Observable<NodeMaterial>;
  54764. /**
  54765. * Gets or sets the root nodes of the material vertex shader
  54766. */
  54767. _vertexOutputNodes: NodeMaterialBlock[];
  54768. /**
  54769. * Gets or sets the root nodes of the material fragment (pixel) shader
  54770. */
  54771. _fragmentOutputNodes: NodeMaterialBlock[];
  54772. /** Gets or sets options to control the node material overall behavior */
  54773. options: INodeMaterialOptions;
  54774. /**
  54775. * Default configuration related to image processing available in the standard Material.
  54776. */
  54777. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54778. /**
  54779. * Gets the image processing configuration used either in this material.
  54780. */
  54781. /**
  54782. * Sets the Default image processing configuration used either in the this material.
  54783. *
  54784. * If sets to null, the scene one is in use.
  54785. */
  54786. imageProcessingConfiguration: ImageProcessingConfiguration;
  54787. /**
  54788. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  54789. */
  54790. attachedBlocks: NodeMaterialBlock[];
  54791. /**
  54792. * Create a new node based material
  54793. * @param name defines the material name
  54794. * @param scene defines the hosting scene
  54795. * @param options defines creation option
  54796. */
  54797. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  54798. /**
  54799. * Gets the current class name of the material e.g. "NodeMaterial"
  54800. * @returns the class name
  54801. */
  54802. getClassName(): string;
  54803. /**
  54804. * Keep track of the image processing observer to allow dispose and replace.
  54805. */
  54806. private _imageProcessingObserver;
  54807. /**
  54808. * Attaches a new image processing configuration to the Standard Material.
  54809. * @param configuration
  54810. */
  54811. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54812. /**
  54813. * Get a block by its name
  54814. * @param name defines the name of the block to retrieve
  54815. * @returns the required block or null if not found
  54816. */
  54817. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  54818. /**
  54819. * Get a block by its name
  54820. * @param predicate defines the predicate used to find the good candidate
  54821. * @returns the required block or null if not found
  54822. */
  54823. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  54824. /**
  54825. * Get an input block by its name
  54826. * @param predicate defines the predicate used to find the good candidate
  54827. * @returns the required input block or null if not found
  54828. */
  54829. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  54830. /**
  54831. * Gets the list of input blocks attached to this material
  54832. * @returns an array of InputBlocks
  54833. */
  54834. getInputBlocks(): InputBlock[];
  54835. /**
  54836. * Adds a new optimizer to the list of optimizers
  54837. * @param optimizer defines the optimizers to add
  54838. * @returns the current material
  54839. */
  54840. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54841. /**
  54842. * Remove an optimizer from the list of optimizers
  54843. * @param optimizer defines the optimizers to remove
  54844. * @returns the current material
  54845. */
  54846. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54847. /**
  54848. * Add a new block to the list of output nodes
  54849. * @param node defines the node to add
  54850. * @returns the current material
  54851. */
  54852. addOutputNode(node: NodeMaterialBlock): this;
  54853. /**
  54854. * Remove a block from the list of root nodes
  54855. * @param node defines the node to remove
  54856. * @returns the current material
  54857. */
  54858. removeOutputNode(node: NodeMaterialBlock): this;
  54859. private _addVertexOutputNode;
  54860. private _removeVertexOutputNode;
  54861. private _addFragmentOutputNode;
  54862. private _removeFragmentOutputNode;
  54863. /**
  54864. * Specifies if the material will require alpha blending
  54865. * @returns a boolean specifying if alpha blending is needed
  54866. */
  54867. needAlphaBlending(): boolean;
  54868. /**
  54869. * Specifies if this material should be rendered in alpha test mode
  54870. * @returns a boolean specifying if an alpha test is needed.
  54871. */
  54872. needAlphaTesting(): boolean;
  54873. private _initializeBlock;
  54874. private _resetDualBlocks;
  54875. /**
  54876. * Build the material and generates the inner effect
  54877. * @param verbose defines if the build should log activity
  54878. */
  54879. build(verbose?: boolean): void;
  54880. /**
  54881. * Runs an otpimization phase to try to improve the shader code
  54882. */
  54883. optimize(): void;
  54884. private _prepareDefinesForAttributes;
  54885. /**
  54886. * Get if the submesh is ready to be used and all its information available.
  54887. * Child classes can use it to update shaders
  54888. * @param mesh defines the mesh to check
  54889. * @param subMesh defines which submesh to check
  54890. * @param useInstances specifies that instances should be used
  54891. * @returns a boolean indicating that the submesh is ready or not
  54892. */
  54893. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54894. /**
  54895. * Get a string representing the shaders built by the current node graph
  54896. */
  54897. readonly compiledShaders: string;
  54898. /**
  54899. * Binds the world matrix to the material
  54900. * @param world defines the world transformation matrix
  54901. */
  54902. bindOnlyWorldMatrix(world: Matrix): void;
  54903. /**
  54904. * Binds the submesh to this material by preparing the effect and shader to draw
  54905. * @param world defines the world transformation matrix
  54906. * @param mesh defines the mesh containing the submesh
  54907. * @param subMesh defines the submesh to bind the material to
  54908. */
  54909. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54910. /**
  54911. * Gets the active textures from the material
  54912. * @returns an array of textures
  54913. */
  54914. getActiveTextures(): BaseTexture[];
  54915. /**
  54916. * Gets the list of texture blocks
  54917. * @returns an array of texture blocks
  54918. */
  54919. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  54920. /**
  54921. * Specifies if the material uses a texture
  54922. * @param texture defines the texture to check against the material
  54923. * @returns a boolean specifying if the material uses the texture
  54924. */
  54925. hasTexture(texture: BaseTexture): boolean;
  54926. /**
  54927. * Disposes the material
  54928. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  54929. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  54930. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  54931. */
  54932. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  54933. /** Creates the node editor window. */
  54934. private _createNodeEditor;
  54935. /**
  54936. * Launch the node material editor
  54937. * @param config Define the configuration of the editor
  54938. * @return a promise fulfilled when the node editor is visible
  54939. */
  54940. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  54941. /**
  54942. * Clear the current material
  54943. */
  54944. clear(): void;
  54945. /**
  54946. * Clear the current material and set it to a default state
  54947. */
  54948. setToDefault(): void;
  54949. /**
  54950. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  54951. * @param url defines the url to load from
  54952. * @returns a promise that will fullfil when the material is fully loaded
  54953. */
  54954. loadAsync(url: string): Promise<unknown>;
  54955. private _gatherBlocks;
  54956. /**
  54957. * Generate a string containing the code declaration required to create an equivalent of this material
  54958. * @returns a string
  54959. */
  54960. generateCode(): string;
  54961. /**
  54962. * Serializes this material in a JSON representation
  54963. * @returns the serialized material object
  54964. */
  54965. serialize(): any;
  54966. private _restoreConnections;
  54967. /**
  54968. * Clear the current graph and load a new one from a serialization object
  54969. * @param source defines the JSON representation of the material
  54970. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54971. */
  54972. loadFromSerialization(source: any, rootUrl?: string): void;
  54973. /**
  54974. * Creates a node material from parsed material data
  54975. * @param source defines the JSON representation of the material
  54976. * @param scene defines the hosting scene
  54977. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54978. * @returns a new node material
  54979. */
  54980. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  54981. /**
  54982. * Creates a new node material set to default basic configuration
  54983. * @param name defines the name of the material
  54984. * @param scene defines the hosting scene
  54985. * @returns a new NodeMaterial
  54986. */
  54987. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  54988. }
  54989. }
  54990. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  54991. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54992. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54993. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54994. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54996. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54997. import { Effect } from "babylonjs/Materials/effect";
  54998. import { Mesh } from "babylonjs/Meshes/mesh";
  54999. import { Nullable } from "babylonjs/types";
  55000. import { Texture } from "babylonjs/Materials/Textures/texture";
  55001. import { Scene } from "babylonjs/scene";
  55002. /**
  55003. * Block used to read a texture from a sampler
  55004. */
  55005. export class TextureBlock extends NodeMaterialBlock {
  55006. private _defineName;
  55007. private _samplerName;
  55008. private _transformedUVName;
  55009. private _textureTransformName;
  55010. private _textureInfoName;
  55011. /**
  55012. * Gets or sets the texture associated with the node
  55013. */
  55014. texture: Nullable<Texture>;
  55015. /**
  55016. * Create a new TextureBlock
  55017. * @param name defines the block name
  55018. */
  55019. constructor(name: string);
  55020. /**
  55021. * Gets the current class name
  55022. * @returns the class name
  55023. */
  55024. getClassName(): string;
  55025. /**
  55026. * Gets the uv input component
  55027. */
  55028. readonly uv: NodeMaterialConnectionPoint;
  55029. /**
  55030. * Gets the rgba output component
  55031. */
  55032. readonly rgba: NodeMaterialConnectionPoint;
  55033. /**
  55034. * Gets the rgb output component
  55035. */
  55036. readonly rgb: NodeMaterialConnectionPoint;
  55037. /**
  55038. * Gets the r output component
  55039. */
  55040. readonly r: NodeMaterialConnectionPoint;
  55041. /**
  55042. * Gets the g output component
  55043. */
  55044. readonly g: NodeMaterialConnectionPoint;
  55045. /**
  55046. * Gets the b output component
  55047. */
  55048. readonly b: NodeMaterialConnectionPoint;
  55049. /**
  55050. * Gets the a output component
  55051. */
  55052. readonly a: NodeMaterialConnectionPoint;
  55053. readonly target: NodeMaterialBlockTargets;
  55054. autoConfigure(material: NodeMaterial): void;
  55055. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55056. isReady(): boolean;
  55057. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55058. private readonly _isMixed;
  55059. private _injectVertexCode;
  55060. private _writeOutput;
  55061. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55062. protected _dumpPropertiesCode(): string;
  55063. serialize(): any;
  55064. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55065. }
  55066. }
  55067. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55068. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55069. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55070. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55071. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55072. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55073. import { Scene } from "babylonjs/scene";
  55074. /**
  55075. * Class used to store shared data between 2 NodeMaterialBuildState
  55076. */
  55077. export class NodeMaterialBuildStateSharedData {
  55078. /**
  55079. * Gets the list of emitted varyings
  55080. */
  55081. temps: string[];
  55082. /**
  55083. * Gets the list of emitted varyings
  55084. */
  55085. varyings: string[];
  55086. /**
  55087. * Gets the varying declaration string
  55088. */
  55089. varyingDeclaration: string;
  55090. /**
  55091. * Input blocks
  55092. */
  55093. inputBlocks: InputBlock[];
  55094. /**
  55095. * Input blocks
  55096. */
  55097. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55098. /**
  55099. * Bindable blocks (Blocks that need to set data to the effect)
  55100. */
  55101. bindableBlocks: NodeMaterialBlock[];
  55102. /**
  55103. * List of blocks that can provide a compilation fallback
  55104. */
  55105. blocksWithFallbacks: NodeMaterialBlock[];
  55106. /**
  55107. * List of blocks that can provide a define update
  55108. */
  55109. blocksWithDefines: NodeMaterialBlock[];
  55110. /**
  55111. * List of blocks that can provide a repeatable content
  55112. */
  55113. repeatableContentBlocks: NodeMaterialBlock[];
  55114. /**
  55115. * List of blocks that can provide a dynamic list of uniforms
  55116. */
  55117. dynamicUniformBlocks: NodeMaterialBlock[];
  55118. /**
  55119. * List of blocks that can block the isReady function for the material
  55120. */
  55121. blockingBlocks: NodeMaterialBlock[];
  55122. /**
  55123. * Gets the list of animated inputs
  55124. */
  55125. animatedInputs: InputBlock[];
  55126. /**
  55127. * Build Id used to avoid multiple recompilations
  55128. */
  55129. buildId: number;
  55130. /** List of emitted variables */
  55131. variableNames: {
  55132. [key: string]: number;
  55133. };
  55134. /** List of emitted defines */
  55135. defineNames: {
  55136. [key: string]: number;
  55137. };
  55138. /** Should emit comments? */
  55139. emitComments: boolean;
  55140. /** Emit build activity */
  55141. verbose: boolean;
  55142. /** Gets or sets the hosting scene */
  55143. scene: Scene;
  55144. /**
  55145. * Gets the compilation hints emitted at compilation time
  55146. */
  55147. hints: {
  55148. needWorldViewMatrix: boolean;
  55149. needWorldViewProjectionMatrix: boolean;
  55150. needAlphaBlending: boolean;
  55151. needAlphaTesting: boolean;
  55152. };
  55153. /**
  55154. * List of compilation checks
  55155. */
  55156. checks: {
  55157. emitVertex: boolean;
  55158. emitFragment: boolean;
  55159. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55160. };
  55161. /** Creates a new shared data */
  55162. constructor();
  55163. /**
  55164. * Emits console errors and exceptions if there is a failing check
  55165. */
  55166. emitErrors(): void;
  55167. }
  55168. }
  55169. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55170. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55171. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55172. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55173. /**
  55174. * Class used to store node based material build state
  55175. */
  55176. export class NodeMaterialBuildState {
  55177. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55178. supportUniformBuffers: boolean;
  55179. /**
  55180. * Gets the list of emitted attributes
  55181. */
  55182. attributes: string[];
  55183. /**
  55184. * Gets the list of emitted uniforms
  55185. */
  55186. uniforms: string[];
  55187. /**
  55188. * Gets the list of emitted uniform buffers
  55189. */
  55190. uniformBuffers: string[];
  55191. /**
  55192. * Gets the list of emitted samplers
  55193. */
  55194. samplers: string[];
  55195. /**
  55196. * Gets the list of emitted functions
  55197. */
  55198. functions: {
  55199. [key: string]: string;
  55200. };
  55201. /**
  55202. * Gets the list of emitted extensions
  55203. */
  55204. extensions: {
  55205. [key: string]: string;
  55206. };
  55207. /**
  55208. * Gets the target of the compilation state
  55209. */
  55210. target: NodeMaterialBlockTargets;
  55211. /**
  55212. * Gets the list of emitted counters
  55213. */
  55214. counters: {
  55215. [key: string]: number;
  55216. };
  55217. /**
  55218. * Shared data between multiple NodeMaterialBuildState instances
  55219. */
  55220. sharedData: NodeMaterialBuildStateSharedData;
  55221. /** @hidden */
  55222. _vertexState: NodeMaterialBuildState;
  55223. /** @hidden */
  55224. _attributeDeclaration: string;
  55225. /** @hidden */
  55226. _uniformDeclaration: string;
  55227. /** @hidden */
  55228. _samplerDeclaration: string;
  55229. /** @hidden */
  55230. _varyingTransfer: string;
  55231. private _repeatableContentAnchorIndex;
  55232. /** @hidden */
  55233. _builtCompilationString: string;
  55234. /**
  55235. * Gets the emitted compilation strings
  55236. */
  55237. compilationString: string;
  55238. /**
  55239. * Finalize the compilation strings
  55240. * @param state defines the current compilation state
  55241. */
  55242. finalize(state: NodeMaterialBuildState): void;
  55243. /** @hidden */
  55244. readonly _repeatableContentAnchor: string;
  55245. /** @hidden */
  55246. _getFreeVariableName(prefix: string): string;
  55247. /** @hidden */
  55248. _getFreeDefineName(prefix: string): string;
  55249. /** @hidden */
  55250. _excludeVariableName(name: string): void;
  55251. /** @hidden */
  55252. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55253. /** @hidden */
  55254. _emitExtension(name: string, extension: string): void;
  55255. /** @hidden */
  55256. _emitFunction(name: string, code: string, comments: string): void;
  55257. /** @hidden */
  55258. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55259. replaceStrings?: {
  55260. search: RegExp;
  55261. replace: string;
  55262. }[];
  55263. repeatKey?: string;
  55264. }): string;
  55265. /** @hidden */
  55266. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55267. repeatKey?: string;
  55268. removeAttributes?: boolean;
  55269. removeUniforms?: boolean;
  55270. removeVaryings?: boolean;
  55271. removeIfDef?: boolean;
  55272. replaceStrings?: {
  55273. search: RegExp;
  55274. replace: string;
  55275. }[];
  55276. }, storeKey?: string): void;
  55277. /** @hidden */
  55278. _registerTempVariable(name: string): boolean;
  55279. /** @hidden */
  55280. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55281. /** @hidden */
  55282. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55283. }
  55284. }
  55285. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  55286. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55287. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55288. import { Nullable } from "babylonjs/types";
  55289. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55290. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55291. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55292. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55293. import { Mesh } from "babylonjs/Meshes/mesh";
  55294. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55295. import { Scene } from "babylonjs/scene";
  55296. /**
  55297. * Defines a block that can be used inside a node based material
  55298. */
  55299. export class NodeMaterialBlock {
  55300. private _buildId;
  55301. private _buildTarget;
  55302. private _target;
  55303. private _isFinalMerger;
  55304. private _isInput;
  55305. /** @hidden */
  55306. _codeVariableName: string;
  55307. /** @hidden */
  55308. _inputs: NodeMaterialConnectionPoint[];
  55309. /** @hidden */
  55310. _outputs: NodeMaterialConnectionPoint[];
  55311. /** @hidden */
  55312. _preparationId: number;
  55313. /**
  55314. * Gets or sets the name of the block
  55315. */
  55316. name: string;
  55317. /**
  55318. * Gets or sets the unique id of the node
  55319. */
  55320. uniqueId: number;
  55321. /**
  55322. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55323. */
  55324. readonly isFinalMerger: boolean;
  55325. /**
  55326. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55327. */
  55328. readonly isInput: boolean;
  55329. /**
  55330. * Gets or sets the build Id
  55331. */
  55332. buildId: number;
  55333. /**
  55334. * Gets or sets the target of the block
  55335. */
  55336. target: NodeMaterialBlockTargets;
  55337. /**
  55338. * Gets the list of input points
  55339. */
  55340. readonly inputs: NodeMaterialConnectionPoint[];
  55341. /** Gets the list of output points */
  55342. readonly outputs: NodeMaterialConnectionPoint[];
  55343. /**
  55344. * Find an input by its name
  55345. * @param name defines the name of the input to look for
  55346. * @returns the input or null if not found
  55347. */
  55348. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55349. /**
  55350. * Find an output by its name
  55351. * @param name defines the name of the outputto look for
  55352. * @returns the output or null if not found
  55353. */
  55354. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55355. /**
  55356. * Creates a new NodeMaterialBlock
  55357. * @param name defines the block name
  55358. * @param target defines the target of that block (Vertex by default)
  55359. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55360. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55361. */
  55362. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  55363. /**
  55364. * Initialize the block and prepare the context for build
  55365. * @param state defines the state that will be used for the build
  55366. */
  55367. initialize(state: NodeMaterialBuildState): void;
  55368. /**
  55369. * Bind data to effect. Will only be called for blocks with isBindable === true
  55370. * @param effect defines the effect to bind data to
  55371. * @param nodeMaterial defines the hosting NodeMaterial
  55372. * @param mesh defines the mesh that will be rendered
  55373. */
  55374. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55375. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  55376. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  55377. protected _writeFloat(value: number): string;
  55378. /**
  55379. * Gets the current class name e.g. "NodeMaterialBlock"
  55380. * @returns the class name
  55381. */
  55382. getClassName(): string;
  55383. /**
  55384. * Register a new input. Must be called inside a block constructor
  55385. * @param name defines the connection point name
  55386. * @param type defines the connection point type
  55387. * @param isOptional defines a boolean indicating that this input can be omitted
  55388. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55389. * @returns the current block
  55390. */
  55391. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  55392. /**
  55393. * Register a new output. Must be called inside a block constructor
  55394. * @param name defines the connection point name
  55395. * @param type defines the connection point type
  55396. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55397. * @returns the current block
  55398. */
  55399. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  55400. /**
  55401. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  55402. * @param forOutput defines an optional connection point to check compatibility with
  55403. * @returns the first available input or null
  55404. */
  55405. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  55406. /**
  55407. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  55408. * @param forBlock defines an optional block to check compatibility with
  55409. * @returns the first available input or null
  55410. */
  55411. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  55412. /**
  55413. * Gets the sibling of the given output
  55414. * @param current defines the current output
  55415. * @returns the next output in the list or null
  55416. */
  55417. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  55418. /**
  55419. * Connect current block with another block
  55420. * @param other defines the block to connect with
  55421. * @param options define the various options to help pick the right connections
  55422. * @returns the current block
  55423. */
  55424. connectTo(other: NodeMaterialBlock, options?: {
  55425. input?: string;
  55426. output?: string;
  55427. outputSwizzle?: string;
  55428. }): this | undefined;
  55429. protected _buildBlock(state: NodeMaterialBuildState): void;
  55430. /**
  55431. * Add uniforms, samplers and uniform buffers at compilation time
  55432. * @param state defines the state to update
  55433. * @param nodeMaterial defines the node material requesting the update
  55434. * @param defines defines the material defines to update
  55435. */
  55436. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55437. /**
  55438. * Add potential fallbacks if shader compilation fails
  55439. * @param mesh defines the mesh to be rendered
  55440. * @param fallbacks defines the current prioritized list of fallbacks
  55441. */
  55442. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55443. /**
  55444. * Update defines for shader compilation
  55445. * @param mesh defines the mesh to be rendered
  55446. * @param nodeMaterial defines the node material requesting the update
  55447. * @param defines defines the material defines to update
  55448. * @param useInstances specifies that instances should be used
  55449. */
  55450. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55451. /**
  55452. * Lets the block try to connect some inputs automatically
  55453. * @param material defines the hosting NodeMaterial
  55454. */
  55455. autoConfigure(material: NodeMaterial): void;
  55456. /**
  55457. * Function called when a block is declared as repeatable content generator
  55458. * @param vertexShaderState defines the current compilation state for the vertex shader
  55459. * @param fragmentShaderState defines the current compilation state for the fragment shader
  55460. * @param mesh defines the mesh to be rendered
  55461. * @param defines defines the material defines to update
  55462. */
  55463. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55464. /**
  55465. * Checks if the block is ready
  55466. * @param mesh defines the mesh to be rendered
  55467. * @param nodeMaterial defines the node material requesting the update
  55468. * @param defines defines the material defines to update
  55469. * @param useInstances specifies that instances should be used
  55470. * @returns true if the block is ready
  55471. */
  55472. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  55473. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  55474. private _processBuild;
  55475. /**
  55476. * Compile the current node and generate the shader code
  55477. * @param state defines the current compilation state (uniforms, samplers, current string)
  55478. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  55479. * @returns true if already built
  55480. */
  55481. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  55482. protected _inputRename(name: string): string;
  55483. protected _outputRename(name: string): string;
  55484. protected _dumpPropertiesCode(): string;
  55485. /** @hidden */
  55486. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  55487. /**
  55488. * Clone the current block to a new identical block
  55489. * @param scene defines the hosting scene
  55490. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55491. * @returns a copy of the current block
  55492. */
  55493. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  55494. /**
  55495. * Serializes this block in a JSON representation
  55496. * @returns the serialized block object
  55497. */
  55498. serialize(): any;
  55499. /** @hidden */
  55500. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55501. }
  55502. }
  55503. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  55504. /**
  55505. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55506. */
  55507. export enum NodeMaterialBlockConnectionPointMode {
  55508. /** Value is an uniform */
  55509. Uniform = 0,
  55510. /** Value is a mesh attribute */
  55511. Attribute = 1,
  55512. /** Value is a varying between vertex and fragment shaders */
  55513. Varying = 2,
  55514. /** Mode is undefined */
  55515. Undefined = 3
  55516. }
  55517. }
  55518. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  55519. /**
  55520. * Enum defining the type of animations supported by InputBlock
  55521. */
  55522. export enum AnimatedInputBlockTypes {
  55523. /** No animation */
  55524. None = 0,
  55525. /** Time based animation. Will only work for floats */
  55526. Time = 1
  55527. }
  55528. }
  55529. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  55530. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55531. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55532. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/nodeMaterialSystemValues";
  55533. import { Nullable } from "babylonjs/types";
  55534. import { Effect } from "babylonjs/Materials/effect";
  55535. import { Matrix } from "babylonjs/Maths/math.vector";
  55536. import { Scene } from "babylonjs/scene";
  55537. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55538. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55539. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55540. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  55541. /**
  55542. * Block used to expose an input value
  55543. */
  55544. export class InputBlock extends NodeMaterialBlock {
  55545. private _mode;
  55546. private _associatedVariableName;
  55547. private _storedValue;
  55548. private _valueCallback;
  55549. private _type;
  55550. private _animationType;
  55551. /** Gets or set a value used to limit the range of float values */
  55552. min: number;
  55553. /** Gets or set a value used to limit the range of float values */
  55554. max: number;
  55555. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  55556. matrixMode: number;
  55557. /** @hidden */
  55558. _systemValue: Nullable<NodeMaterialSystemValues>;
  55559. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  55560. visibleInInspector: boolean;
  55561. /**
  55562. * Gets or sets the connection point type (default is float)
  55563. */
  55564. readonly type: NodeMaterialBlockConnectionPointTypes;
  55565. /**
  55566. * Creates a new InputBlock
  55567. * @param name defines the block name
  55568. * @param target defines the target of that block (Vertex by default)
  55569. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  55570. */
  55571. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  55572. /**
  55573. * Gets the output component
  55574. */
  55575. readonly output: NodeMaterialConnectionPoint;
  55576. /**
  55577. * Set the source of this connection point to a vertex attribute
  55578. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  55579. * @returns the current connection point
  55580. */
  55581. setAsAttribute(attributeName?: string): InputBlock;
  55582. /**
  55583. * Set the source of this connection point to a system value
  55584. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  55585. * @returns the current connection point
  55586. */
  55587. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  55588. /**
  55589. * Gets or sets the value of that point.
  55590. * Please note that this value will be ignored if valueCallback is defined
  55591. */
  55592. value: any;
  55593. /**
  55594. * Gets or sets a callback used to get the value of that point.
  55595. * Please note that setting this value will force the connection point to ignore the value property
  55596. */
  55597. valueCallback: () => any;
  55598. /**
  55599. * Gets or sets the associated variable name in the shader
  55600. */
  55601. associatedVariableName: string;
  55602. /** Gets or sets the type of animation applied to the input */
  55603. animationType: AnimatedInputBlockTypes;
  55604. /**
  55605. * Gets a boolean indicating that this connection point not defined yet
  55606. */
  55607. readonly isUndefined: boolean;
  55608. /**
  55609. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  55610. * In this case the connection point name must be the name of the uniform to use.
  55611. * Can only be set on inputs
  55612. */
  55613. isUniform: boolean;
  55614. /**
  55615. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  55616. * In this case the connection point name must be the name of the attribute to use
  55617. * Can only be set on inputs
  55618. */
  55619. isAttribute: boolean;
  55620. /**
  55621. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  55622. * Can only be set on exit points
  55623. */
  55624. isVarying: boolean;
  55625. /**
  55626. * Gets a boolean indicating that the current connection point is a system value
  55627. */
  55628. readonly isSystemValue: boolean;
  55629. /**
  55630. * Gets or sets the current well known value or null if not defined as a system value
  55631. */
  55632. systemValue: Nullable<NodeMaterialSystemValues>;
  55633. /**
  55634. * Gets the current class name
  55635. * @returns the class name
  55636. */
  55637. getClassName(): string;
  55638. /**
  55639. * Animate the input if animationType !== None
  55640. * @param scene defines the rendering scene
  55641. */
  55642. animate(scene: Scene): void;
  55643. private _emitDefine;
  55644. initialize(state: NodeMaterialBuildState): void;
  55645. /**
  55646. * Set the input block to its default value (based on its type)
  55647. */
  55648. setDefaultValue(): void;
  55649. protected _dumpPropertiesCode(): string;
  55650. private _emit;
  55651. /** @hidden */
  55652. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  55653. /** @hidden */
  55654. _transmit(effect: Effect, scene: Scene): void;
  55655. protected _buildBlock(state: NodeMaterialBuildState): void;
  55656. serialize(): any;
  55657. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55658. }
  55659. }
  55660. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  55661. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55662. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55663. import { Nullable } from "babylonjs/types";
  55664. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55665. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55666. /**
  55667. * Defines a connection point for a block
  55668. */
  55669. export class NodeMaterialConnectionPoint {
  55670. /** @hidden */
  55671. _ownerBlock: NodeMaterialBlock;
  55672. /** @hidden */
  55673. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55674. private _endpoints;
  55675. private _associatedVariableName;
  55676. /** @hidden */
  55677. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55678. /** @hidden */
  55679. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55680. private _type;
  55681. /** @hidden */
  55682. _enforceAssociatedVariableName: boolean;
  55683. /**
  55684. * Gets or sets the additional types supported byt this connection point
  55685. */
  55686. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55687. /**
  55688. * Gets or sets the associated variable name in the shader
  55689. */
  55690. associatedVariableName: string;
  55691. /**
  55692. * Gets or sets the connection point type (default is float)
  55693. */
  55694. type: NodeMaterialBlockConnectionPointTypes;
  55695. /**
  55696. * Gets or sets the connection point name
  55697. */
  55698. name: string;
  55699. /**
  55700. * Gets or sets a boolean indicating that this connection point can be omitted
  55701. */
  55702. isOptional: boolean;
  55703. /**
  55704. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  55705. */
  55706. define: string;
  55707. /** Gets or sets the target of that connection point */
  55708. target: NodeMaterialBlockTargets;
  55709. /**
  55710. * Gets a boolean indicating that the current point is connected
  55711. */
  55712. readonly isConnected: boolean;
  55713. /**
  55714. * Gets a boolean indicating that the current point is connected to an input block
  55715. */
  55716. readonly isConnectedToInputBlock: boolean;
  55717. /**
  55718. * Gets a the connected input block (if any)
  55719. */
  55720. readonly connectInputBlock: Nullable<InputBlock>;
  55721. /** Get the other side of the connection (if any) */
  55722. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55723. /** Get the block that owns this connection point */
  55724. readonly ownerBlock: NodeMaterialBlock;
  55725. /** Get the block connected on the other side of this connection (if any) */
  55726. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  55727. /** Get the block connected on the endpoints of this connection (if any) */
  55728. readonly connectedBlocks: Array<NodeMaterialBlock>;
  55729. /** Gets the list of connected endpoints */
  55730. readonly endpoints: NodeMaterialConnectionPoint[];
  55731. /** Gets a boolean indicating if that output point is connected to at least one input */
  55732. readonly hasEndpoints: boolean;
  55733. /**
  55734. * Creates a new connection point
  55735. * @param name defines the connection point name
  55736. * @param ownerBlock defines the block hosting this connection point
  55737. */
  55738. constructor(name: string, ownerBlock: NodeMaterialBlock);
  55739. /**
  55740. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  55741. * @returns the class name
  55742. */
  55743. getClassName(): string;
  55744. /**
  55745. * Gets an boolean indicating if the current point can be connected to another point
  55746. * @param connectionPoint defines the other connection point
  55747. * @returns true if the connection is possible
  55748. */
  55749. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  55750. /**
  55751. * Connect this point to another connection point
  55752. * @param connectionPoint defines the other connection point
  55753. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  55754. * @returns the current connection point
  55755. */
  55756. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  55757. /**
  55758. * Disconnect this point from one of his endpoint
  55759. * @param endpoint defines the other connection point
  55760. * @returns the current connection point
  55761. */
  55762. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55763. /**
  55764. * Serializes this point in a JSON representation
  55765. * @returns the serialized point object
  55766. */
  55767. serialize(): any;
  55768. }
  55769. }
  55770. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  55771. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55772. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55774. import { Mesh } from "babylonjs/Meshes/mesh";
  55775. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55776. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55777. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55778. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55779. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55780. /**
  55781. * Block used to add support for vertex skinning (bones)
  55782. */
  55783. export class BonesBlock extends NodeMaterialBlock {
  55784. /**
  55785. * Creates a new BonesBlock
  55786. * @param name defines the block name
  55787. */
  55788. constructor(name: string);
  55789. /**
  55790. * Initialize the block and prepare the context for build
  55791. * @param state defines the state that will be used for the build
  55792. */
  55793. initialize(state: NodeMaterialBuildState): void;
  55794. /**
  55795. * Gets the current class name
  55796. * @returns the class name
  55797. */
  55798. getClassName(): string;
  55799. /**
  55800. * Gets the matrix indices input component
  55801. */
  55802. readonly matricesIndices: NodeMaterialConnectionPoint;
  55803. /**
  55804. * Gets the matrix weights input component
  55805. */
  55806. readonly matricesWeights: NodeMaterialConnectionPoint;
  55807. /**
  55808. * Gets the extra matrix indices input component
  55809. */
  55810. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  55811. /**
  55812. * Gets the extra matrix weights input component
  55813. */
  55814. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  55815. /**
  55816. * Gets the world input component
  55817. */
  55818. readonly world: NodeMaterialConnectionPoint;
  55819. /**
  55820. * Gets the output component
  55821. */
  55822. readonly output: NodeMaterialConnectionPoint;
  55823. autoConfigure(material: NodeMaterial): void;
  55824. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55825. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55826. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55827. protected _buildBlock(state: NodeMaterialBuildState): this;
  55828. }
  55829. }
  55830. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  55831. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55832. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55833. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55834. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55835. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55836. /**
  55837. * Block used to add support for instances
  55838. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  55839. */
  55840. export class InstancesBlock extends NodeMaterialBlock {
  55841. /**
  55842. * Creates a new InstancesBlock
  55843. * @param name defines the block name
  55844. */
  55845. constructor(name: string);
  55846. /**
  55847. * Gets the current class name
  55848. * @returns the class name
  55849. */
  55850. getClassName(): string;
  55851. /**
  55852. * Gets the first world row input component
  55853. */
  55854. readonly world0: NodeMaterialConnectionPoint;
  55855. /**
  55856. * Gets the second world row input component
  55857. */
  55858. readonly world1: NodeMaterialConnectionPoint;
  55859. /**
  55860. * Gets the third world row input component
  55861. */
  55862. readonly world2: NodeMaterialConnectionPoint;
  55863. /**
  55864. * Gets the forth world row input component
  55865. */
  55866. readonly world3: NodeMaterialConnectionPoint;
  55867. /**
  55868. * Gets the world input component
  55869. */
  55870. readonly world: NodeMaterialConnectionPoint;
  55871. /**
  55872. * Gets the output component
  55873. */
  55874. readonly output: NodeMaterialConnectionPoint;
  55875. autoConfigure(material: NodeMaterial): void;
  55876. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55877. protected _buildBlock(state: NodeMaterialBuildState): this;
  55878. }
  55879. }
  55880. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  55881. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55882. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55883. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55884. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55885. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55886. import { Effect } from "babylonjs/Materials/effect";
  55887. import { Mesh } from "babylonjs/Meshes/mesh";
  55888. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  55889. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  55890. /**
  55891. * Block used to add morph targets support to vertex shader
  55892. */
  55893. export class MorphTargetsBlock extends NodeMaterialBlock {
  55894. private _repeatableContentAnchor;
  55895. private _repeatebleContentGenerated;
  55896. /**
  55897. * Create a new MorphTargetsBlock
  55898. * @param name defines the block name
  55899. */
  55900. constructor(name: string);
  55901. /**
  55902. * Gets the current class name
  55903. * @returns the class name
  55904. */
  55905. getClassName(): string;
  55906. /**
  55907. * Gets the position input component
  55908. */
  55909. readonly position: NodeMaterialConnectionPoint;
  55910. /**
  55911. * Gets the normal input component
  55912. */
  55913. readonly normal: NodeMaterialConnectionPoint;
  55914. /**
  55915. * Gets the tangent input component
  55916. */
  55917. readonly tangent: NodeMaterialConnectionPoint;
  55918. /**
  55919. * Gets the tangent input component
  55920. */
  55921. readonly uv: NodeMaterialConnectionPoint;
  55922. /**
  55923. * Gets the position output component
  55924. */
  55925. readonly positionOutput: NodeMaterialConnectionPoint;
  55926. /**
  55927. * Gets the normal output component
  55928. */
  55929. readonly normalOutput: NodeMaterialConnectionPoint;
  55930. /**
  55931. * Gets the tangent output component
  55932. */
  55933. readonly tangentOutput: NodeMaterialConnectionPoint;
  55934. /**
  55935. * Gets the tangent output component
  55936. */
  55937. readonly uvOutput: NodeMaterialConnectionPoint;
  55938. initialize(state: NodeMaterialBuildState): void;
  55939. autoConfigure(material: NodeMaterial): void;
  55940. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55941. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55942. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55943. protected _buildBlock(state: NodeMaterialBuildState): this;
  55944. }
  55945. }
  55946. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  55947. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55948. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55949. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55950. import { Nullable } from "babylonjs/types";
  55951. import { Scene } from "babylonjs/scene";
  55952. import { Effect } from "babylonjs/Materials/effect";
  55953. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  55954. import { Mesh } from "babylonjs/Meshes/mesh";
  55955. import { Light } from "babylonjs/Lights/light";
  55956. /**
  55957. * Block used to get data information from a light
  55958. */
  55959. export class LightInformationBlock extends NodeMaterialBlock {
  55960. private _lightDataDefineName;
  55961. private _lightColorDefineName;
  55962. /**
  55963. * Gets or sets the light associated with this block
  55964. */
  55965. light: Nullable<Light>;
  55966. /**
  55967. * Creates a new LightInformationBlock
  55968. * @param name defines the block name
  55969. */
  55970. constructor(name: string);
  55971. /**
  55972. * Gets the current class name
  55973. * @returns the class name
  55974. */
  55975. getClassName(): string;
  55976. /**
  55977. * Gets the world position input component
  55978. */
  55979. readonly worldPosition: NodeMaterialConnectionPoint;
  55980. /**
  55981. * Gets the direction output component
  55982. */
  55983. readonly direction: NodeMaterialConnectionPoint;
  55984. /**
  55985. * Gets the direction output component
  55986. */
  55987. readonly color: NodeMaterialConnectionPoint;
  55988. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55989. protected _buildBlock(state: NodeMaterialBuildState): this;
  55990. serialize(): any;
  55991. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55992. }
  55993. }
  55994. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  55995. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  55996. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  55997. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  55998. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  55999. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56000. }
  56001. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  56002. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56003. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56004. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56005. import { Scene } from "babylonjs/scene";
  56006. /**
  56007. * Block used to add an alpha test in the fragment shader
  56008. */
  56009. export class AlphaTestBlock extends NodeMaterialBlock {
  56010. /**
  56011. * Gets or sets the alpha value where alpha testing happens
  56012. */
  56013. alphaCutOff: number;
  56014. /**
  56015. * Create a new AlphaTestBlock
  56016. * @param name defines the block name
  56017. */
  56018. constructor(name: string);
  56019. /**
  56020. * Gets the current class name
  56021. * @returns the class name
  56022. */
  56023. getClassName(): string;
  56024. /**
  56025. * Gets the color input component
  56026. */
  56027. readonly color: NodeMaterialConnectionPoint;
  56028. /**
  56029. * Gets the alpha input component
  56030. */
  56031. readonly alpha: NodeMaterialConnectionPoint;
  56032. protected _buildBlock(state: NodeMaterialBuildState): this;
  56033. protected _dumpPropertiesCode(): string;
  56034. serialize(): any;
  56035. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56036. }
  56037. }
  56038. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56039. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56040. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56041. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56043. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56044. import { Effect } from "babylonjs/Materials/effect";
  56045. import { Mesh } from "babylonjs/Meshes/mesh";
  56046. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56047. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56048. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56049. /**
  56050. * Block used to add image processing support to fragment shader
  56051. */
  56052. export class ImageProcessingBlock extends NodeMaterialBlock {
  56053. /**
  56054. * Create a new ImageProcessingBlock
  56055. * @param name defines the block name
  56056. */
  56057. constructor(name: string);
  56058. /**
  56059. * Gets the current class name
  56060. * @returns the class name
  56061. */
  56062. getClassName(): string;
  56063. /**
  56064. * Gets the color input component
  56065. */
  56066. readonly color: NodeMaterialConnectionPoint;
  56067. /**
  56068. * Gets the output component
  56069. */
  56070. readonly output: NodeMaterialConnectionPoint;
  56071. /**
  56072. * Initialize the block and prepare the context for build
  56073. * @param state defines the state that will be used for the build
  56074. */
  56075. initialize(state: NodeMaterialBuildState): void;
  56076. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56077. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56078. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56079. protected _buildBlock(state: NodeMaterialBuildState): this;
  56080. }
  56081. }
  56082. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56083. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56084. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56085. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56086. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56087. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56088. import { Effect } from "babylonjs/Materials/effect";
  56089. import { Mesh } from "babylonjs/Meshes/mesh";
  56090. import { Scene } from "babylonjs/scene";
  56091. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56092. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56093. /**
  56094. * Block used to pertub normals based on a normal map
  56095. */
  56096. export class PerturbNormalBlock extends NodeMaterialBlock {
  56097. private _tangentSpaceParameterName;
  56098. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56099. invertX: boolean;
  56100. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56101. invertY: boolean;
  56102. /**
  56103. * Create a new PerturbNormalBlock
  56104. * @param name defines the block name
  56105. */
  56106. constructor(name: string);
  56107. /**
  56108. * Gets the current class name
  56109. * @returns the class name
  56110. */
  56111. getClassName(): string;
  56112. /**
  56113. * Gets the world position input component
  56114. */
  56115. readonly worldPosition: NodeMaterialConnectionPoint;
  56116. /**
  56117. * Gets the world normal input component
  56118. */
  56119. readonly worldNormal: NodeMaterialConnectionPoint;
  56120. /**
  56121. * Gets the uv input component
  56122. */
  56123. readonly uv: NodeMaterialConnectionPoint;
  56124. /**
  56125. * Gets the normal map color input component
  56126. */
  56127. readonly normalMapColor: NodeMaterialConnectionPoint;
  56128. /**
  56129. * Gets the strength input component
  56130. */
  56131. readonly strength: NodeMaterialConnectionPoint;
  56132. /**
  56133. * Gets the output component
  56134. */
  56135. readonly output: NodeMaterialConnectionPoint;
  56136. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56137. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56138. autoConfigure(material: NodeMaterial): void;
  56139. protected _buildBlock(state: NodeMaterialBuildState): this;
  56140. protected _dumpPropertiesCode(): string;
  56141. serialize(): any;
  56142. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56143. }
  56144. }
  56145. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56146. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56147. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  56148. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56149. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56150. }
  56151. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56152. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56153. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56154. import { Mesh } from "babylonjs/Meshes/mesh";
  56155. import { Effect } from "babylonjs/Materials/effect";
  56156. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56158. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56159. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56160. /**
  56161. * Block used to add support for scene fog
  56162. */
  56163. export class FogBlock extends NodeMaterialBlock {
  56164. private _fogDistanceName;
  56165. private _fogParameters;
  56166. /**
  56167. * Create a new FogBlock
  56168. * @param name defines the block name
  56169. */
  56170. constructor(name: string);
  56171. /**
  56172. * Gets the current class name
  56173. * @returns the class name
  56174. */
  56175. getClassName(): string;
  56176. /**
  56177. * Gets the world position input component
  56178. */
  56179. readonly worldPosition: NodeMaterialConnectionPoint;
  56180. /**
  56181. * Gets the view input component
  56182. */
  56183. readonly view: NodeMaterialConnectionPoint;
  56184. /**
  56185. * Gets the color input component
  56186. */
  56187. readonly input: NodeMaterialConnectionPoint;
  56188. /**
  56189. * Gets the fog color input component
  56190. */
  56191. readonly fogColor: NodeMaterialConnectionPoint;
  56192. /**
  56193. * Gets the output component
  56194. */
  56195. readonly output: NodeMaterialConnectionPoint;
  56196. autoConfigure(material: NodeMaterial): void;
  56197. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56198. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56199. protected _buildBlock(state: NodeMaterialBuildState): this;
  56200. }
  56201. }
  56202. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  56203. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56204. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56205. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56207. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56208. import { Effect } from "babylonjs/Materials/effect";
  56209. import { Mesh } from "babylonjs/Meshes/mesh";
  56210. import { Light } from "babylonjs/Lights/light";
  56211. import { Nullable } from "babylonjs/types";
  56212. import { Scene } from "babylonjs/scene";
  56213. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56214. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56215. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56216. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56217. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56218. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56219. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56220. /**
  56221. * Block used to add light in the fragment shader
  56222. */
  56223. export class LightBlock extends NodeMaterialBlock {
  56224. private _lightId;
  56225. /**
  56226. * Gets or sets the light associated with this block
  56227. */
  56228. light: Nullable<Light>;
  56229. /**
  56230. * Create a new LightBlock
  56231. * @param name defines the block name
  56232. */
  56233. constructor(name: string);
  56234. /**
  56235. * Gets the current class name
  56236. * @returns the class name
  56237. */
  56238. getClassName(): string;
  56239. /**
  56240. * Gets the world position input component
  56241. */
  56242. readonly worldPosition: NodeMaterialConnectionPoint;
  56243. /**
  56244. * Gets the world normal input component
  56245. */
  56246. readonly worldNormal: NodeMaterialConnectionPoint;
  56247. /**
  56248. * Gets the camera (or eye) position component
  56249. */
  56250. readonly cameraPosition: NodeMaterialConnectionPoint;
  56251. /**
  56252. * Gets the diffuse output component
  56253. */
  56254. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56255. /**
  56256. * Gets the specular output component
  56257. */
  56258. readonly specularOutput: NodeMaterialConnectionPoint;
  56259. autoConfigure(material: NodeMaterial): void;
  56260. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56261. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56262. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56263. private _injectVertexCode;
  56264. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56265. serialize(): any;
  56266. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56267. }
  56268. }
  56269. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  56270. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  56271. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  56272. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56273. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56274. }
  56275. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  56276. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56277. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56278. }
  56279. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  56280. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56281. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56282. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56283. /**
  56284. * Block used to multiply 2 values
  56285. */
  56286. export class MultiplyBlock extends NodeMaterialBlock {
  56287. /**
  56288. * Creates a new MultiplyBlock
  56289. * @param name defines the block name
  56290. */
  56291. constructor(name: string);
  56292. /**
  56293. * Gets the current class name
  56294. * @returns the class name
  56295. */
  56296. getClassName(): string;
  56297. /**
  56298. * Gets the left operand input component
  56299. */
  56300. readonly left: NodeMaterialConnectionPoint;
  56301. /**
  56302. * Gets the right operand input component
  56303. */
  56304. readonly right: NodeMaterialConnectionPoint;
  56305. /**
  56306. * Gets the output component
  56307. */
  56308. readonly output: NodeMaterialConnectionPoint;
  56309. protected _buildBlock(state: NodeMaterialBuildState): this;
  56310. }
  56311. }
  56312. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  56313. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56314. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56315. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56316. /**
  56317. * Block used to add 2 vectors
  56318. */
  56319. export class AddBlock extends NodeMaterialBlock {
  56320. /**
  56321. * Creates a new AddBlock
  56322. * @param name defines the block name
  56323. */
  56324. constructor(name: string);
  56325. /**
  56326. * Gets the current class name
  56327. * @returns the class name
  56328. */
  56329. getClassName(): string;
  56330. /**
  56331. * Gets the left operand input component
  56332. */
  56333. readonly left: NodeMaterialConnectionPoint;
  56334. /**
  56335. * Gets the right operand input component
  56336. */
  56337. readonly right: NodeMaterialConnectionPoint;
  56338. /**
  56339. * Gets the output component
  56340. */
  56341. readonly output: NodeMaterialConnectionPoint;
  56342. protected _buildBlock(state: NodeMaterialBuildState): this;
  56343. }
  56344. }
  56345. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  56346. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56347. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56348. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56349. /**
  56350. * Block used to scale a vector by a float
  56351. */
  56352. export class ScaleBlock extends NodeMaterialBlock {
  56353. /**
  56354. * Creates a new ScaleBlock
  56355. * @param name defines the block name
  56356. */
  56357. constructor(name: string);
  56358. /**
  56359. * Gets the current class name
  56360. * @returns the class name
  56361. */
  56362. getClassName(): string;
  56363. /**
  56364. * Gets the input component
  56365. */
  56366. readonly input: NodeMaterialConnectionPoint;
  56367. /**
  56368. * Gets the factor input component
  56369. */
  56370. readonly factor: NodeMaterialConnectionPoint;
  56371. /**
  56372. * Gets the output component
  56373. */
  56374. readonly output: NodeMaterialConnectionPoint;
  56375. protected _buildBlock(state: NodeMaterialBuildState): this;
  56376. }
  56377. }
  56378. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  56379. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56380. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56381. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56382. import { Scene } from "babylonjs/scene";
  56383. /**
  56384. * Block used to clamp a float
  56385. */
  56386. export class ClampBlock extends NodeMaterialBlock {
  56387. /** Gets or sets the minimum range */
  56388. minimum: number;
  56389. /** Gets or sets the maximum range */
  56390. maximum: number;
  56391. /**
  56392. * Creates a new ClampBlock
  56393. * @param name defines the block name
  56394. */
  56395. constructor(name: string);
  56396. /**
  56397. * Gets the current class name
  56398. * @returns the class name
  56399. */
  56400. getClassName(): string;
  56401. /**
  56402. * Gets the value input component
  56403. */
  56404. readonly value: NodeMaterialConnectionPoint;
  56405. /**
  56406. * Gets the output component
  56407. */
  56408. readonly output: NodeMaterialConnectionPoint;
  56409. protected _buildBlock(state: NodeMaterialBuildState): this;
  56410. protected _dumpPropertiesCode(): string;
  56411. serialize(): any;
  56412. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56413. }
  56414. }
  56415. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  56416. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56417. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56418. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56419. /**
  56420. * Block used to apply a cross product between 2 vectors
  56421. */
  56422. export class CrossBlock extends NodeMaterialBlock {
  56423. /**
  56424. * Creates a new CrossBlock
  56425. * @param name defines the block name
  56426. */
  56427. constructor(name: string);
  56428. /**
  56429. * Gets the current class name
  56430. * @returns the class name
  56431. */
  56432. getClassName(): string;
  56433. /**
  56434. * Gets the left operand input component
  56435. */
  56436. readonly left: NodeMaterialConnectionPoint;
  56437. /**
  56438. * Gets the right operand input component
  56439. */
  56440. readonly right: NodeMaterialConnectionPoint;
  56441. /**
  56442. * Gets the output component
  56443. */
  56444. readonly output: NodeMaterialConnectionPoint;
  56445. protected _buildBlock(state: NodeMaterialBuildState): this;
  56446. }
  56447. }
  56448. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  56449. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56450. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56451. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56452. /**
  56453. * Block used to apply a dot product between 2 vectors
  56454. */
  56455. export class DotBlock extends NodeMaterialBlock {
  56456. /**
  56457. * Creates a new DotBlock
  56458. * @param name defines the block name
  56459. */
  56460. constructor(name: string);
  56461. /**
  56462. * Gets the current class name
  56463. * @returns the class name
  56464. */
  56465. getClassName(): string;
  56466. /**
  56467. * Gets the left operand input component
  56468. */
  56469. readonly left: NodeMaterialConnectionPoint;
  56470. /**
  56471. * Gets the right operand input component
  56472. */
  56473. readonly right: NodeMaterialConnectionPoint;
  56474. /**
  56475. * Gets the output component
  56476. */
  56477. readonly output: NodeMaterialConnectionPoint;
  56478. protected _buildBlock(state: NodeMaterialBuildState): this;
  56479. }
  56480. }
  56481. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  56482. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56483. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56484. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56485. import { Vector2 } from "babylonjs/Maths/math.vector";
  56486. import { Scene } from "babylonjs/scene";
  56487. /**
  56488. * Block used to remap a float from a range to a new one
  56489. */
  56490. export class RemapBlock extends NodeMaterialBlock {
  56491. /**
  56492. * Gets or sets the source range
  56493. */
  56494. sourceRange: Vector2;
  56495. /**
  56496. * Gets or sets the target range
  56497. */
  56498. targetRange: Vector2;
  56499. /**
  56500. * Creates a new RemapBlock
  56501. * @param name defines the block name
  56502. */
  56503. constructor(name: string);
  56504. /**
  56505. * Gets the current class name
  56506. * @returns the class name
  56507. */
  56508. getClassName(): string;
  56509. /**
  56510. * Gets the input component
  56511. */
  56512. readonly input: NodeMaterialConnectionPoint;
  56513. /**
  56514. * Gets the source min input component
  56515. */
  56516. readonly sourceMin: NodeMaterialConnectionPoint;
  56517. /**
  56518. * Gets the source max input component
  56519. */
  56520. readonly sourceMax: NodeMaterialConnectionPoint;
  56521. /**
  56522. * Gets the target min input component
  56523. */
  56524. readonly targetMin: NodeMaterialConnectionPoint;
  56525. /**
  56526. * Gets the target max input component
  56527. */
  56528. readonly targetMax: NodeMaterialConnectionPoint;
  56529. /**
  56530. * Gets the output component
  56531. */
  56532. readonly output: NodeMaterialConnectionPoint;
  56533. protected _buildBlock(state: NodeMaterialBuildState): this;
  56534. protected _dumpPropertiesCode(): string;
  56535. serialize(): any;
  56536. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56537. }
  56538. }
  56539. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  56540. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56541. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56542. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56543. /**
  56544. * Block used to normalize a vector
  56545. */
  56546. export class NormalizeBlock extends NodeMaterialBlock {
  56547. /**
  56548. * Creates a new NormalizeBlock
  56549. * @param name defines the block name
  56550. */
  56551. constructor(name: string);
  56552. /**
  56553. * Gets the current class name
  56554. * @returns the class name
  56555. */
  56556. getClassName(): string;
  56557. /**
  56558. * Gets the input component
  56559. */
  56560. readonly input: NodeMaterialConnectionPoint;
  56561. /**
  56562. * Gets the output component
  56563. */
  56564. readonly output: NodeMaterialConnectionPoint;
  56565. protected _buildBlock(state: NodeMaterialBuildState): this;
  56566. }
  56567. }
  56568. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  56569. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56570. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56571. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56572. import { Scene } from "babylonjs/scene";
  56573. /**
  56574. * Operations supported by the Trigonometry block
  56575. */
  56576. export enum TrigonometryBlockOperations {
  56577. /** Cos */
  56578. Cos = 0,
  56579. /** Sin */
  56580. Sin = 1,
  56581. /** Abs */
  56582. Abs = 2,
  56583. /** Exp */
  56584. Exp = 3,
  56585. /** Exp2 */
  56586. Exp2 = 4,
  56587. /** Round */
  56588. Round = 5,
  56589. /** Floor */
  56590. Floor = 6,
  56591. /** Ceiling */
  56592. Ceiling = 7,
  56593. /** Square root */
  56594. Sqrt = 8
  56595. }
  56596. /**
  56597. * Block used to apply trigonometry operation to floats
  56598. */
  56599. export class TrigonometryBlock extends NodeMaterialBlock {
  56600. /**
  56601. * Gets or sets the operation applied by the block
  56602. */
  56603. operation: TrigonometryBlockOperations;
  56604. /**
  56605. * Creates a new TrigonometryBlock
  56606. * @param name defines the block name
  56607. */
  56608. constructor(name: string);
  56609. /**
  56610. * Gets the current class name
  56611. * @returns the class name
  56612. */
  56613. getClassName(): string;
  56614. /**
  56615. * Gets the input component
  56616. */
  56617. readonly input: NodeMaterialConnectionPoint;
  56618. /**
  56619. * Gets the output component
  56620. */
  56621. readonly output: NodeMaterialConnectionPoint;
  56622. protected _buildBlock(state: NodeMaterialBuildState): this;
  56623. serialize(): any;
  56624. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56625. }
  56626. }
  56627. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  56628. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56629. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56630. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56631. /**
  56632. * Block used to create a Color3/4 out of individual inputs (one for each component)
  56633. */
  56634. export class ColorMergerBlock extends NodeMaterialBlock {
  56635. /**
  56636. * Create a new ColorMergerBlock
  56637. * @param name defines the block name
  56638. */
  56639. constructor(name: string);
  56640. /**
  56641. * Gets the current class name
  56642. * @returns the class name
  56643. */
  56644. getClassName(): string;
  56645. /**
  56646. * Gets the r component (input)
  56647. */
  56648. readonly r: NodeMaterialConnectionPoint;
  56649. /**
  56650. * Gets the g component (input)
  56651. */
  56652. readonly g: NodeMaterialConnectionPoint;
  56653. /**
  56654. * Gets the b component (input)
  56655. */
  56656. readonly b: NodeMaterialConnectionPoint;
  56657. /**
  56658. * Gets the a component (input)
  56659. */
  56660. readonly a: NodeMaterialConnectionPoint;
  56661. /**
  56662. * Gets the rgba component (output)
  56663. */
  56664. readonly rgba: NodeMaterialConnectionPoint;
  56665. /**
  56666. * Gets the rgb component (output)
  56667. */
  56668. readonly rgb: NodeMaterialConnectionPoint;
  56669. protected _buildBlock(state: NodeMaterialBuildState): this;
  56670. }
  56671. }
  56672. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  56673. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56674. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56675. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56676. /**
  56677. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  56678. */
  56679. export class VectorMergerBlock extends NodeMaterialBlock {
  56680. /**
  56681. * Create a new VectorMergerBlock
  56682. * @param name defines the block name
  56683. */
  56684. constructor(name: string);
  56685. /**
  56686. * Gets the current class name
  56687. * @returns the class name
  56688. */
  56689. getClassName(): string;
  56690. /**
  56691. * Gets the x component (input)
  56692. */
  56693. readonly x: NodeMaterialConnectionPoint;
  56694. /**
  56695. * Gets the y component (input)
  56696. */
  56697. readonly y: NodeMaterialConnectionPoint;
  56698. /**
  56699. * Gets the z component (input)
  56700. */
  56701. readonly z: NodeMaterialConnectionPoint;
  56702. /**
  56703. * Gets the w component (input)
  56704. */
  56705. readonly w: NodeMaterialConnectionPoint;
  56706. /**
  56707. * Gets the xyzw component (output)
  56708. */
  56709. readonly xyzw: NodeMaterialConnectionPoint;
  56710. /**
  56711. * Gets the xyz component (output)
  56712. */
  56713. readonly xyz: NodeMaterialConnectionPoint;
  56714. /**
  56715. * Gets the xy component (output)
  56716. */
  56717. readonly xy: NodeMaterialConnectionPoint;
  56718. protected _buildBlock(state: NodeMaterialBuildState): this;
  56719. }
  56720. }
  56721. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  56722. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56723. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56724. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56725. /**
  56726. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  56727. */
  56728. export class ColorSplitterBlock extends NodeMaterialBlock {
  56729. /**
  56730. * Create a new ColorSplitterBlock
  56731. * @param name defines the block name
  56732. */
  56733. constructor(name: string);
  56734. /**
  56735. * Gets the current class name
  56736. * @returns the class name
  56737. */
  56738. getClassName(): string;
  56739. /**
  56740. * Gets the rgba component (input)
  56741. */
  56742. readonly rgba: NodeMaterialConnectionPoint;
  56743. /**
  56744. * Gets the rgb component (input)
  56745. */
  56746. readonly rgbIn: NodeMaterialConnectionPoint;
  56747. /**
  56748. * Gets the rgb component (output)
  56749. */
  56750. readonly rgbOut: NodeMaterialConnectionPoint;
  56751. /**
  56752. * Gets the r component (output)
  56753. */
  56754. readonly r: NodeMaterialConnectionPoint;
  56755. /**
  56756. * Gets the g component (output)
  56757. */
  56758. readonly g: NodeMaterialConnectionPoint;
  56759. /**
  56760. * Gets the b component (output)
  56761. */
  56762. readonly b: NodeMaterialConnectionPoint;
  56763. /**
  56764. * Gets the a component (output)
  56765. */
  56766. readonly a: NodeMaterialConnectionPoint;
  56767. protected _inputRename(name: string): string;
  56768. protected _outputRename(name: string): string;
  56769. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56770. }
  56771. }
  56772. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  56773. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56774. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56775. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56776. /**
  56777. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  56778. */
  56779. export class VectorSplitterBlock extends NodeMaterialBlock {
  56780. /**
  56781. * Create a new VectorSplitterBlock
  56782. * @param name defines the block name
  56783. */
  56784. constructor(name: string);
  56785. /**
  56786. * Gets the current class name
  56787. * @returns the class name
  56788. */
  56789. getClassName(): string;
  56790. /**
  56791. * Gets the xyzw component (input)
  56792. */
  56793. readonly xyzw: NodeMaterialConnectionPoint;
  56794. /**
  56795. * Gets the xyz component (input)
  56796. */
  56797. readonly xyzIn: NodeMaterialConnectionPoint;
  56798. /**
  56799. * Gets the xy component (input)
  56800. */
  56801. readonly xyIn: NodeMaterialConnectionPoint;
  56802. /**
  56803. * Gets the xyz component (output)
  56804. */
  56805. readonly xyzOut: NodeMaterialConnectionPoint;
  56806. /**
  56807. * Gets the xy component (output)
  56808. */
  56809. readonly xyOut: NodeMaterialConnectionPoint;
  56810. /**
  56811. * Gets the x component (output)
  56812. */
  56813. readonly x: NodeMaterialConnectionPoint;
  56814. /**
  56815. * Gets the y component (output)
  56816. */
  56817. readonly y: NodeMaterialConnectionPoint;
  56818. /**
  56819. * Gets the z component (output)
  56820. */
  56821. readonly z: NodeMaterialConnectionPoint;
  56822. /**
  56823. * Gets the w component (output)
  56824. */
  56825. readonly w: NodeMaterialConnectionPoint;
  56826. protected _inputRename(name: string): string;
  56827. protected _outputRename(name: string): string;
  56828. protected _buildBlock(state: NodeMaterialBuildState): this;
  56829. }
  56830. }
  56831. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  56832. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56833. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56834. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56835. /**
  56836. * Block used to lerp 2 values
  56837. */
  56838. export class LerpBlock extends NodeMaterialBlock {
  56839. /**
  56840. * Creates a new LerpBlock
  56841. * @param name defines the block name
  56842. */
  56843. constructor(name: string);
  56844. /**
  56845. * Gets the current class name
  56846. * @returns the class name
  56847. */
  56848. getClassName(): string;
  56849. /**
  56850. * Gets the left operand input component
  56851. */
  56852. readonly left: NodeMaterialConnectionPoint;
  56853. /**
  56854. * Gets the right operand input component
  56855. */
  56856. readonly right: NodeMaterialConnectionPoint;
  56857. /**
  56858. * Gets the gradient operand input component
  56859. */
  56860. readonly gradient: NodeMaterialConnectionPoint;
  56861. /**
  56862. * Gets the output component
  56863. */
  56864. readonly output: NodeMaterialConnectionPoint;
  56865. protected _buildBlock(state: NodeMaterialBuildState): this;
  56866. }
  56867. }
  56868. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  56869. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56870. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56871. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56872. /**
  56873. * Block used to divide 2 vectors
  56874. */
  56875. export class DivideBlock extends NodeMaterialBlock {
  56876. /**
  56877. * Creates a new DivideBlock
  56878. * @param name defines the block name
  56879. */
  56880. constructor(name: string);
  56881. /**
  56882. * Gets the current class name
  56883. * @returns the class name
  56884. */
  56885. getClassName(): string;
  56886. /**
  56887. * Gets the left operand input component
  56888. */
  56889. readonly left: NodeMaterialConnectionPoint;
  56890. /**
  56891. * Gets the right operand input component
  56892. */
  56893. readonly right: NodeMaterialConnectionPoint;
  56894. /**
  56895. * Gets the output component
  56896. */
  56897. readonly output: NodeMaterialConnectionPoint;
  56898. protected _buildBlock(state: NodeMaterialBuildState): this;
  56899. }
  56900. }
  56901. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  56902. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56903. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56904. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56905. /**
  56906. * Block used to subtract 2 vectors
  56907. */
  56908. export class SubtractBlock extends NodeMaterialBlock {
  56909. /**
  56910. * Creates a new SubtractBlock
  56911. * @param name defines the block name
  56912. */
  56913. constructor(name: string);
  56914. /**
  56915. * Gets the current class name
  56916. * @returns the class name
  56917. */
  56918. getClassName(): string;
  56919. /**
  56920. * Gets the left operand input component
  56921. */
  56922. readonly left: NodeMaterialConnectionPoint;
  56923. /**
  56924. * Gets the right operand input component
  56925. */
  56926. readonly right: NodeMaterialConnectionPoint;
  56927. /**
  56928. * Gets the output component
  56929. */
  56930. readonly output: NodeMaterialConnectionPoint;
  56931. protected _buildBlock(state: NodeMaterialBuildState): this;
  56932. }
  56933. }
  56934. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  56935. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56936. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56937. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56938. /**
  56939. * Block used to step a value
  56940. */
  56941. export class StepBlock extends NodeMaterialBlock {
  56942. /**
  56943. * Creates a new AddBlock
  56944. * @param name defines the block name
  56945. */
  56946. constructor(name: string);
  56947. /**
  56948. * Gets the current class name
  56949. * @returns the class name
  56950. */
  56951. getClassName(): string;
  56952. /**
  56953. * Gets the value operand input component
  56954. */
  56955. readonly value: NodeMaterialConnectionPoint;
  56956. /**
  56957. * Gets the edge operand input component
  56958. */
  56959. readonly edge: NodeMaterialConnectionPoint;
  56960. /**
  56961. * Gets the output component
  56962. */
  56963. readonly output: NodeMaterialConnectionPoint;
  56964. protected _buildBlock(state: NodeMaterialBuildState): this;
  56965. }
  56966. }
  56967. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  56968. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56969. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56970. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56971. /**
  56972. * Block used to get the opposite (1 - x) of a value
  56973. */
  56974. export class OneMinusBlock extends NodeMaterialBlock {
  56975. /**
  56976. * Creates a new OneMinusBlock
  56977. * @param name defines the block name
  56978. */
  56979. constructor(name: string);
  56980. /**
  56981. * Gets the current class name
  56982. * @returns the class name
  56983. */
  56984. getClassName(): string;
  56985. /**
  56986. * Gets the input component
  56987. */
  56988. readonly input: NodeMaterialConnectionPoint;
  56989. /**
  56990. * Gets the output component
  56991. */
  56992. readonly output: NodeMaterialConnectionPoint;
  56993. protected _buildBlock(state: NodeMaterialBuildState): this;
  56994. }
  56995. }
  56996. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  56997. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56998. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56999. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57000. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57001. /**
  57002. * Block used to get the view direction
  57003. */
  57004. export class ViewDirectionBlock extends NodeMaterialBlock {
  57005. /**
  57006. * Creates a new ViewDirectionBlock
  57007. * @param name defines the block name
  57008. */
  57009. constructor(name: string);
  57010. /**
  57011. * Gets the current class name
  57012. * @returns the class name
  57013. */
  57014. getClassName(): string;
  57015. /**
  57016. * Gets the world position component
  57017. */
  57018. readonly worldPosition: NodeMaterialConnectionPoint;
  57019. /**
  57020. * Gets the camera position component
  57021. */
  57022. readonly cameraPosition: NodeMaterialConnectionPoint;
  57023. /**
  57024. * Gets the output component
  57025. */
  57026. readonly output: NodeMaterialConnectionPoint;
  57027. autoConfigure(material: NodeMaterial): void;
  57028. protected _buildBlock(state: NodeMaterialBuildState): this;
  57029. }
  57030. }
  57031. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57032. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57033. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57034. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57035. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57036. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57037. /**
  57038. * Block used to compute fresnel value
  57039. */
  57040. export class FresnelBlock extends NodeMaterialBlock {
  57041. /**
  57042. * Create a new FresnelBlock
  57043. * @param name defines the block name
  57044. */
  57045. constructor(name: string);
  57046. /**
  57047. * Gets the current class name
  57048. * @returns the class name
  57049. */
  57050. getClassName(): string;
  57051. /**
  57052. * Gets the world normal input component
  57053. */
  57054. readonly worldNormal: NodeMaterialConnectionPoint;
  57055. /**
  57056. * Gets the view direction input component
  57057. */
  57058. readonly viewDirection: NodeMaterialConnectionPoint;
  57059. /**
  57060. * Gets the bias input component
  57061. */
  57062. readonly bias: NodeMaterialConnectionPoint;
  57063. /**
  57064. * Gets the camera (or eye) position component
  57065. */
  57066. readonly power: NodeMaterialConnectionPoint;
  57067. /**
  57068. * Gets the fresnel output component
  57069. */
  57070. readonly fresnel: NodeMaterialConnectionPoint;
  57071. autoConfigure(material: NodeMaterial): void;
  57072. protected _buildBlock(state: NodeMaterialBuildState): this;
  57073. }
  57074. }
  57075. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57076. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57077. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57078. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57079. /**
  57080. * Block used to get the max of 2 values
  57081. */
  57082. export class MaxBlock extends NodeMaterialBlock {
  57083. /**
  57084. * Creates a new MaxBlock
  57085. * @param name defines the block name
  57086. */
  57087. constructor(name: string);
  57088. /**
  57089. * Gets the current class name
  57090. * @returns the class name
  57091. */
  57092. getClassName(): string;
  57093. /**
  57094. * Gets the left operand input component
  57095. */
  57096. readonly left: NodeMaterialConnectionPoint;
  57097. /**
  57098. * Gets the right operand input component
  57099. */
  57100. readonly right: NodeMaterialConnectionPoint;
  57101. /**
  57102. * Gets the output component
  57103. */
  57104. readonly output: NodeMaterialConnectionPoint;
  57105. protected _buildBlock(state: NodeMaterialBuildState): this;
  57106. }
  57107. }
  57108. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57109. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57110. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57111. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57112. /**
  57113. * Block used to get the min of 2 values
  57114. */
  57115. export class MinBlock extends NodeMaterialBlock {
  57116. /**
  57117. * Creates a new MinBlock
  57118. * @param name defines the block name
  57119. */
  57120. constructor(name: string);
  57121. /**
  57122. * Gets the current class name
  57123. * @returns the class name
  57124. */
  57125. getClassName(): string;
  57126. /**
  57127. * Gets the left operand input component
  57128. */
  57129. readonly left: NodeMaterialConnectionPoint;
  57130. /**
  57131. * Gets the right operand input component
  57132. */
  57133. readonly right: NodeMaterialConnectionPoint;
  57134. /**
  57135. * Gets the output component
  57136. */
  57137. readonly output: NodeMaterialConnectionPoint;
  57138. protected _buildBlock(state: NodeMaterialBuildState): this;
  57139. }
  57140. }
  57141. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  57142. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57143. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57144. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57145. /**
  57146. * Block used to get the distance between 2 values
  57147. */
  57148. export class DistanceBlock extends NodeMaterialBlock {
  57149. /**
  57150. * Creates a new DistanceBlock
  57151. * @param name defines the block name
  57152. */
  57153. constructor(name: string);
  57154. /**
  57155. * Gets the current class name
  57156. * @returns the class name
  57157. */
  57158. getClassName(): string;
  57159. /**
  57160. * Gets the left operand input component
  57161. */
  57162. readonly left: NodeMaterialConnectionPoint;
  57163. /**
  57164. * Gets the right operand input component
  57165. */
  57166. readonly right: NodeMaterialConnectionPoint;
  57167. /**
  57168. * Gets the output component
  57169. */
  57170. readonly output: NodeMaterialConnectionPoint;
  57171. protected _buildBlock(state: NodeMaterialBuildState): this;
  57172. }
  57173. }
  57174. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  57175. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57176. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57177. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57178. /**
  57179. * Block used to get the length of a vector
  57180. */
  57181. export class LengthBlock extends NodeMaterialBlock {
  57182. /**
  57183. * Creates a new LengthBlock
  57184. * @param name defines the block name
  57185. */
  57186. constructor(name: string);
  57187. /**
  57188. * Gets the current class name
  57189. * @returns the class name
  57190. */
  57191. getClassName(): string;
  57192. /**
  57193. * Gets the value input component
  57194. */
  57195. readonly value: NodeMaterialConnectionPoint;
  57196. /**
  57197. * Gets the output component
  57198. */
  57199. readonly output: NodeMaterialConnectionPoint;
  57200. protected _buildBlock(state: NodeMaterialBuildState): this;
  57201. }
  57202. }
  57203. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  57204. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57205. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57206. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57207. /**
  57208. * Block used to get negative version of a value (i.e. x * -1)
  57209. */
  57210. export class NegateBlock extends NodeMaterialBlock {
  57211. /**
  57212. * Creates a new NegateBlock
  57213. * @param name defines the block name
  57214. */
  57215. constructor(name: string);
  57216. /**
  57217. * Gets the current class name
  57218. * @returns the class name
  57219. */
  57220. getClassName(): string;
  57221. /**
  57222. * Gets the value input component
  57223. */
  57224. readonly value: NodeMaterialConnectionPoint;
  57225. /**
  57226. * Gets the output component
  57227. */
  57228. readonly output: NodeMaterialConnectionPoint;
  57229. protected _buildBlock(state: NodeMaterialBuildState): this;
  57230. }
  57231. }
  57232. declare module "babylonjs/Materials/Node/Blocks/index" {
  57233. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  57234. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  57235. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  57236. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  57237. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  57238. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  57239. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  57240. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  57241. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  57242. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  57243. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  57244. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  57245. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  57246. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  57247. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  57248. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  57249. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  57250. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  57251. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  57252. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  57253. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  57254. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  57255. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  57256. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  57257. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  57258. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  57259. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  57260. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  57261. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  57262. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  57263. }
  57264. declare module "babylonjs/Materials/Node/Optimizers/index" {
  57265. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  57266. }
  57267. declare module "babylonjs/Materials/Node/index" {
  57268. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  57269. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  57270. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57271. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  57272. export * from "babylonjs/Materials/Node/nodeMaterial";
  57273. export * from "babylonjs/Materials/Node/nodeMaterialSystemValues";
  57274. export * from "babylonjs/Materials/Node/Blocks/index";
  57275. export * from "babylonjs/Materials/Node/Optimizers/index";
  57276. }
  57277. declare module "babylonjs/Materials/effectRenderer" {
  57278. import { Nullable } from "babylonjs/types";
  57279. import { Texture } from "babylonjs/Materials/Textures/texture";
  57280. import { Engine } from "babylonjs/Engines/engine";
  57281. import { Viewport } from "babylonjs/Maths/math.viewport";
  57282. import { Observable } from "babylonjs/Misc/observable";
  57283. import { Effect } from "babylonjs/Materials/effect";
  57284. import "babylonjs/Shaders/postprocess.vertex";
  57285. /**
  57286. * Effect Render Options
  57287. */
  57288. export interface IEffectRendererOptions {
  57289. /**
  57290. * Defines the vertices positions.
  57291. */
  57292. positions?: number[];
  57293. /**
  57294. * Defines the indices.
  57295. */
  57296. indices?: number[];
  57297. }
  57298. /**
  57299. * Helper class to render one or more effects
  57300. */
  57301. export class EffectRenderer {
  57302. private engine;
  57303. private static _DefaultOptions;
  57304. private _vertexBuffers;
  57305. private _indexBuffer;
  57306. private _ringBufferIndex;
  57307. private _ringScreenBuffer;
  57308. private _fullscreenViewport;
  57309. private _getNextFrameBuffer;
  57310. /**
  57311. * Creates an effect renderer
  57312. * @param engine the engine to use for rendering
  57313. * @param options defines the options of the effect renderer
  57314. */
  57315. constructor(engine: Engine, options?: IEffectRendererOptions);
  57316. /**
  57317. * Sets the current viewport in normalized coordinates 0-1
  57318. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  57319. */
  57320. setViewport(viewport?: Viewport): void;
  57321. /**
  57322. * Binds the embedded attributes buffer to the effect.
  57323. * @param effect Defines the effect to bind the attributes for
  57324. */
  57325. bindBuffers(effect: Effect): void;
  57326. /**
  57327. * Sets the current effect wrapper to use during draw.
  57328. * The effect needs to be ready before calling this api.
  57329. * This also sets the default full screen position attribute.
  57330. * @param effectWrapper Defines the effect to draw with
  57331. */
  57332. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  57333. /**
  57334. * Draws a full screen quad.
  57335. */
  57336. draw(): void;
  57337. /**
  57338. * renders one or more effects to a specified texture
  57339. * @param effectWrappers list of effects to renderer
  57340. * @param outputTexture texture to draw to, if null it will render to the screen
  57341. */
  57342. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  57343. /**
  57344. * Disposes of the effect renderer
  57345. */
  57346. dispose(): void;
  57347. }
  57348. /**
  57349. * Options to create an EffectWrapper
  57350. */
  57351. interface EffectWrapperCreationOptions {
  57352. /**
  57353. * Engine to use to create the effect
  57354. */
  57355. engine: Engine;
  57356. /**
  57357. * Fragment shader for the effect
  57358. */
  57359. fragmentShader: string;
  57360. /**
  57361. * Vertex shader for the effect
  57362. */
  57363. vertexShader?: string;
  57364. /**
  57365. * Attributes to use in the shader
  57366. */
  57367. attributeNames?: Array<string>;
  57368. /**
  57369. * Uniforms to use in the shader
  57370. */
  57371. uniformNames?: Array<string>;
  57372. /**
  57373. * Texture sampler names to use in the shader
  57374. */
  57375. samplerNames?: Array<string>;
  57376. /**
  57377. * The friendly name of the effect displayed in Spector.
  57378. */
  57379. name?: string;
  57380. }
  57381. /**
  57382. * Wraps an effect to be used for rendering
  57383. */
  57384. export class EffectWrapper {
  57385. /**
  57386. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  57387. */
  57388. onApplyObservable: Observable<{}>;
  57389. /**
  57390. * The underlying effect
  57391. */
  57392. effect: Effect;
  57393. /**
  57394. * Creates an effect to be renderer
  57395. * @param creationOptions options to create the effect
  57396. */
  57397. constructor(creationOptions: EffectWrapperCreationOptions);
  57398. /**
  57399. * Disposes of the effect wrapper
  57400. */
  57401. dispose(): void;
  57402. }
  57403. }
  57404. declare module "babylonjs/Materials/index" {
  57405. export * from "babylonjs/Materials/Background/index";
  57406. export * from "babylonjs/Materials/colorCurves";
  57407. export * from "babylonjs/Materials/effect";
  57408. export * from "babylonjs/Materials/fresnelParameters";
  57409. export * from "babylonjs/Materials/imageProcessingConfiguration";
  57410. export * from "babylonjs/Materials/material";
  57411. export * from "babylonjs/Materials/materialDefines";
  57412. export * from "babylonjs/Materials/materialHelper";
  57413. export * from "babylonjs/Materials/multiMaterial";
  57414. export * from "babylonjs/Materials/PBR/index";
  57415. export * from "babylonjs/Materials/pushMaterial";
  57416. export * from "babylonjs/Materials/shaderMaterial";
  57417. export * from "babylonjs/Materials/standardMaterial";
  57418. export * from "babylonjs/Materials/Textures/index";
  57419. export * from "babylonjs/Materials/uniformBuffer";
  57420. export * from "babylonjs/Materials/materialFlags";
  57421. export * from "babylonjs/Materials/Node/index";
  57422. export * from "babylonjs/Materials/effectRenderer";
  57423. }
  57424. declare module "babylonjs/Maths/index" {
  57425. export * from "babylonjs/Maths/math.scalar";
  57426. export * from "babylonjs/Maths/math";
  57427. export * from "babylonjs/Maths/sphericalPolynomial";
  57428. }
  57429. declare module "babylonjs/Misc/workerPool" {
  57430. import { IDisposable } from "babylonjs/scene";
  57431. /**
  57432. * Helper class to push actions to a pool of workers.
  57433. */
  57434. export class WorkerPool implements IDisposable {
  57435. private _workerInfos;
  57436. private _pendingActions;
  57437. /**
  57438. * Constructor
  57439. * @param workers Array of workers to use for actions
  57440. */
  57441. constructor(workers: Array<Worker>);
  57442. /**
  57443. * Terminates all workers and clears any pending actions.
  57444. */
  57445. dispose(): void;
  57446. /**
  57447. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57448. * pended until a worker has completed its action.
  57449. * @param action The action to perform. Call onComplete when the action is complete.
  57450. */
  57451. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57452. private _execute;
  57453. }
  57454. }
  57455. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  57456. import { IDisposable } from "babylonjs/scene";
  57457. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  57458. /**
  57459. * Configuration for Draco compression
  57460. */
  57461. export interface IDracoCompressionConfiguration {
  57462. /**
  57463. * Configuration for the decoder.
  57464. */
  57465. decoder: {
  57466. /**
  57467. * The url to the WebAssembly module.
  57468. */
  57469. wasmUrl?: string;
  57470. /**
  57471. * The url to the WebAssembly binary.
  57472. */
  57473. wasmBinaryUrl?: string;
  57474. /**
  57475. * The url to the fallback JavaScript module.
  57476. */
  57477. fallbackUrl?: string;
  57478. };
  57479. }
  57480. /**
  57481. * Draco compression (https://google.github.io/draco/)
  57482. *
  57483. * This class wraps the Draco module.
  57484. *
  57485. * **Encoder**
  57486. *
  57487. * The encoder is not currently implemented.
  57488. *
  57489. * **Decoder**
  57490. *
  57491. * 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.
  57492. *
  57493. * To update the configuration, use the following code:
  57494. * ```javascript
  57495. * DracoCompression.Configuration = {
  57496. * decoder: {
  57497. * wasmUrl: "<url to the WebAssembly library>",
  57498. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  57499. * fallbackUrl: "<url to the fallback JavaScript library>",
  57500. * }
  57501. * };
  57502. * ```
  57503. *
  57504. * 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.
  57505. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  57506. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  57507. *
  57508. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  57509. * ```javascript
  57510. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  57511. * ```
  57512. *
  57513. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  57514. */
  57515. export class DracoCompression implements IDisposable {
  57516. private _workerPoolPromise?;
  57517. private _decoderModulePromise?;
  57518. /**
  57519. * The configuration. Defaults to the following urls:
  57520. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  57521. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  57522. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  57523. */
  57524. static Configuration: IDracoCompressionConfiguration;
  57525. /**
  57526. * Returns true if the decoder configuration is available.
  57527. */
  57528. static readonly DecoderAvailable: boolean;
  57529. /**
  57530. * Default number of workers to create when creating the draco compression object.
  57531. */
  57532. static DefaultNumWorkers: number;
  57533. private static GetDefaultNumWorkers;
  57534. private static _Default;
  57535. /**
  57536. * Default instance for the draco compression object.
  57537. */
  57538. static readonly Default: DracoCompression;
  57539. /**
  57540. * Constructor
  57541. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  57542. */
  57543. constructor(numWorkers?: number);
  57544. /**
  57545. * Stop all async operations and release resources.
  57546. */
  57547. dispose(): void;
  57548. /**
  57549. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  57550. * @returns a promise that resolves when ready
  57551. */
  57552. whenReadyAsync(): Promise<void>;
  57553. /**
  57554. * Decode Draco compressed mesh data to vertex data.
  57555. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  57556. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  57557. * @returns A promise that resolves with the decoded vertex data
  57558. */
  57559. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  57560. [kind: string]: number;
  57561. }): Promise<VertexData>;
  57562. }
  57563. }
  57564. declare module "babylonjs/Meshes/Compression/index" {
  57565. export * from "babylonjs/Meshes/Compression/dracoCompression";
  57566. }
  57567. declare module "babylonjs/Meshes/csg" {
  57568. import { Nullable } from "babylonjs/types";
  57569. import { Scene } from "babylonjs/scene";
  57570. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57571. import { Mesh } from "babylonjs/Meshes/mesh";
  57572. import { Material } from "babylonjs/Materials/material";
  57573. /**
  57574. * Class for building Constructive Solid Geometry
  57575. */
  57576. export class CSG {
  57577. private polygons;
  57578. /**
  57579. * The world matrix
  57580. */
  57581. matrix: Matrix;
  57582. /**
  57583. * Stores the position
  57584. */
  57585. position: Vector3;
  57586. /**
  57587. * Stores the rotation
  57588. */
  57589. rotation: Vector3;
  57590. /**
  57591. * Stores the rotation quaternion
  57592. */
  57593. rotationQuaternion: Nullable<Quaternion>;
  57594. /**
  57595. * Stores the scaling vector
  57596. */
  57597. scaling: Vector3;
  57598. /**
  57599. * Convert the Mesh to CSG
  57600. * @param mesh The Mesh to convert to CSG
  57601. * @returns A new CSG from the Mesh
  57602. */
  57603. static FromMesh(mesh: Mesh): CSG;
  57604. /**
  57605. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  57606. * @param polygons Polygons used to construct a CSG solid
  57607. */
  57608. private static FromPolygons;
  57609. /**
  57610. * Clones, or makes a deep copy, of the CSG
  57611. * @returns A new CSG
  57612. */
  57613. clone(): CSG;
  57614. /**
  57615. * Unions this CSG with another CSG
  57616. * @param csg The CSG to union against this CSG
  57617. * @returns The unioned CSG
  57618. */
  57619. union(csg: CSG): CSG;
  57620. /**
  57621. * Unions this CSG with another CSG in place
  57622. * @param csg The CSG to union against this CSG
  57623. */
  57624. unionInPlace(csg: CSG): void;
  57625. /**
  57626. * Subtracts this CSG with another CSG
  57627. * @param csg The CSG to subtract against this CSG
  57628. * @returns A new CSG
  57629. */
  57630. subtract(csg: CSG): CSG;
  57631. /**
  57632. * Subtracts this CSG with another CSG in place
  57633. * @param csg The CSG to subtact against this CSG
  57634. */
  57635. subtractInPlace(csg: CSG): void;
  57636. /**
  57637. * Intersect this CSG with another CSG
  57638. * @param csg The CSG to intersect against this CSG
  57639. * @returns A new CSG
  57640. */
  57641. intersect(csg: CSG): CSG;
  57642. /**
  57643. * Intersects this CSG with another CSG in place
  57644. * @param csg The CSG to intersect against this CSG
  57645. */
  57646. intersectInPlace(csg: CSG): void;
  57647. /**
  57648. * Return a new CSG solid with solid and empty space switched. This solid is
  57649. * not modified.
  57650. * @returns A new CSG solid with solid and empty space switched
  57651. */
  57652. inverse(): CSG;
  57653. /**
  57654. * Inverses the CSG in place
  57655. */
  57656. inverseInPlace(): void;
  57657. /**
  57658. * This is used to keep meshes transformations so they can be restored
  57659. * when we build back a Babylon Mesh
  57660. * NB : All CSG operations are performed in world coordinates
  57661. * @param csg The CSG to copy the transform attributes from
  57662. * @returns This CSG
  57663. */
  57664. copyTransformAttributes(csg: CSG): CSG;
  57665. /**
  57666. * Build Raw mesh from CSG
  57667. * Coordinates here are in world space
  57668. * @param name The name of the mesh geometry
  57669. * @param scene The Scene
  57670. * @param keepSubMeshes Specifies if the submeshes should be kept
  57671. * @returns A new Mesh
  57672. */
  57673. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57674. /**
  57675. * Build Mesh from CSG taking material and transforms into account
  57676. * @param name The name of the Mesh
  57677. * @param material The material of the Mesh
  57678. * @param scene The Scene
  57679. * @param keepSubMeshes Specifies if submeshes should be kept
  57680. * @returns The new Mesh
  57681. */
  57682. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57683. }
  57684. }
  57685. declare module "babylonjs/Meshes/trailMesh" {
  57686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57687. import { Mesh } from "babylonjs/Meshes/mesh";
  57688. import { Scene } from "babylonjs/scene";
  57689. /**
  57690. * Class used to create a trail following a mesh
  57691. */
  57692. export class TrailMesh extends Mesh {
  57693. private _generator;
  57694. private _autoStart;
  57695. private _running;
  57696. private _diameter;
  57697. private _length;
  57698. private _sectionPolygonPointsCount;
  57699. private _sectionVectors;
  57700. private _sectionNormalVectors;
  57701. private _beforeRenderObserver;
  57702. /**
  57703. * @constructor
  57704. * @param name The value used by scene.getMeshByName() to do a lookup.
  57705. * @param generator The mesh to generate a trail.
  57706. * @param scene The scene to add this mesh to.
  57707. * @param diameter Diameter of trailing mesh. Default is 1.
  57708. * @param length Length of trailing mesh. Default is 60.
  57709. * @param autoStart Automatically start trailing mesh. Default true.
  57710. */
  57711. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  57712. /**
  57713. * "TrailMesh"
  57714. * @returns "TrailMesh"
  57715. */
  57716. getClassName(): string;
  57717. private _createMesh;
  57718. /**
  57719. * Start trailing mesh.
  57720. */
  57721. start(): void;
  57722. /**
  57723. * Stop trailing mesh.
  57724. */
  57725. stop(): void;
  57726. /**
  57727. * Update trailing mesh geometry.
  57728. */
  57729. update(): void;
  57730. /**
  57731. * Returns a new TrailMesh object.
  57732. * @param name is a string, the name given to the new mesh
  57733. * @param newGenerator use new generator object for cloned trail mesh
  57734. * @returns a new mesh
  57735. */
  57736. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  57737. /**
  57738. * Serializes this trail mesh
  57739. * @param serializationObject object to write serialization to
  57740. */
  57741. serialize(serializationObject: any): void;
  57742. /**
  57743. * Parses a serialized trail mesh
  57744. * @param parsedMesh the serialized mesh
  57745. * @param scene the scene to create the trail mesh in
  57746. * @returns the created trail mesh
  57747. */
  57748. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  57749. }
  57750. }
  57751. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  57752. import { Nullable } from "babylonjs/types";
  57753. import { Scene } from "babylonjs/scene";
  57754. import { Vector4 } from "babylonjs/Maths/math.vector";
  57755. import { Color4 } from "babylonjs/Maths/math.color";
  57756. import { Mesh } from "babylonjs/Meshes/mesh";
  57757. /**
  57758. * Class containing static functions to help procedurally build meshes
  57759. */
  57760. export class TiledBoxBuilder {
  57761. /**
  57762. * Creates a box mesh
  57763. * 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)
  57764. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57765. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57766. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57768. * @param name defines the name of the mesh
  57769. * @param options defines the options used to create the mesh
  57770. * @param scene defines the hosting scene
  57771. * @returns the box mesh
  57772. */
  57773. static CreateTiledBox(name: string, options: {
  57774. pattern?: number;
  57775. width?: number;
  57776. height?: number;
  57777. depth?: number;
  57778. tileSize?: number;
  57779. tileWidth?: number;
  57780. tileHeight?: number;
  57781. alignHorizontal?: number;
  57782. alignVertical?: number;
  57783. faceUV?: Vector4[];
  57784. faceColors?: Color4[];
  57785. sideOrientation?: number;
  57786. updatable?: boolean;
  57787. }, scene?: Nullable<Scene>): Mesh;
  57788. }
  57789. }
  57790. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  57791. import { Vector4 } from "babylonjs/Maths/math.vector";
  57792. import { Mesh } from "babylonjs/Meshes/mesh";
  57793. /**
  57794. * Class containing static functions to help procedurally build meshes
  57795. */
  57796. export class TorusKnotBuilder {
  57797. /**
  57798. * Creates a torus knot mesh
  57799. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57800. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57801. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57802. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57803. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57804. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57806. * @param name defines the name of the mesh
  57807. * @param options defines the options used to create the mesh
  57808. * @param scene defines the hosting scene
  57809. * @returns the torus knot mesh
  57810. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57811. */
  57812. static CreateTorusKnot(name: string, options: {
  57813. radius?: number;
  57814. tube?: number;
  57815. radialSegments?: number;
  57816. tubularSegments?: number;
  57817. p?: number;
  57818. q?: number;
  57819. updatable?: boolean;
  57820. sideOrientation?: number;
  57821. frontUVs?: Vector4;
  57822. backUVs?: Vector4;
  57823. }, scene: any): Mesh;
  57824. }
  57825. }
  57826. declare module "babylonjs/Meshes/polygonMesh" {
  57827. import { Scene } from "babylonjs/scene";
  57828. import { Vector2 } from "babylonjs/Maths/math.vector";
  57829. import { Mesh } from "babylonjs/Meshes/mesh";
  57830. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  57831. import { Path2 } from "babylonjs/Maths/math.path";
  57832. /**
  57833. * Polygon
  57834. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  57835. */
  57836. export class Polygon {
  57837. /**
  57838. * Creates a rectangle
  57839. * @param xmin bottom X coord
  57840. * @param ymin bottom Y coord
  57841. * @param xmax top X coord
  57842. * @param ymax top Y coord
  57843. * @returns points that make the resulting rectation
  57844. */
  57845. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  57846. /**
  57847. * Creates a circle
  57848. * @param radius radius of circle
  57849. * @param cx scale in x
  57850. * @param cy scale in y
  57851. * @param numberOfSides number of sides that make up the circle
  57852. * @returns points that make the resulting circle
  57853. */
  57854. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  57855. /**
  57856. * Creates a polygon from input string
  57857. * @param input Input polygon data
  57858. * @returns the parsed points
  57859. */
  57860. static Parse(input: string): Vector2[];
  57861. /**
  57862. * Starts building a polygon from x and y coordinates
  57863. * @param x x coordinate
  57864. * @param y y coordinate
  57865. * @returns the started path2
  57866. */
  57867. static StartingAt(x: number, y: number): Path2;
  57868. }
  57869. /**
  57870. * Builds a polygon
  57871. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  57872. */
  57873. export class PolygonMeshBuilder {
  57874. private _points;
  57875. private _outlinepoints;
  57876. private _holes;
  57877. private _name;
  57878. private _scene;
  57879. private _epoints;
  57880. private _eholes;
  57881. private _addToepoint;
  57882. /**
  57883. * Babylon reference to the earcut plugin.
  57884. */
  57885. bjsEarcut: any;
  57886. /**
  57887. * Creates a PolygonMeshBuilder
  57888. * @param name name of the builder
  57889. * @param contours Path of the polygon
  57890. * @param scene scene to add to when creating the mesh
  57891. * @param earcutInjection can be used to inject your own earcut reference
  57892. */
  57893. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  57894. /**
  57895. * Adds a whole within the polygon
  57896. * @param hole Array of points defining the hole
  57897. * @returns this
  57898. */
  57899. addHole(hole: Vector2[]): PolygonMeshBuilder;
  57900. /**
  57901. * Creates the polygon
  57902. * @param updatable If the mesh should be updatable
  57903. * @param depth The depth of the mesh created
  57904. * @returns the created mesh
  57905. */
  57906. build(updatable?: boolean, depth?: number): Mesh;
  57907. /**
  57908. * Creates the polygon
  57909. * @param depth The depth of the mesh created
  57910. * @returns the created VertexData
  57911. */
  57912. buildVertexData(depth?: number): VertexData;
  57913. /**
  57914. * Adds a side to the polygon
  57915. * @param positions points that make the polygon
  57916. * @param normals normals of the polygon
  57917. * @param uvs uvs of the polygon
  57918. * @param indices indices of the polygon
  57919. * @param bounds bounds of the polygon
  57920. * @param points points of the polygon
  57921. * @param depth depth of the polygon
  57922. * @param flip flip of the polygon
  57923. */
  57924. private addSide;
  57925. }
  57926. }
  57927. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  57928. import { Scene } from "babylonjs/scene";
  57929. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57930. import { Color4 } from "babylonjs/Maths/math.color";
  57931. import { Mesh } from "babylonjs/Meshes/mesh";
  57932. import { Nullable } from "babylonjs/types";
  57933. /**
  57934. * Class containing static functions to help procedurally build meshes
  57935. */
  57936. export class PolygonBuilder {
  57937. /**
  57938. * Creates a polygon mesh
  57939. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57940. * * 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
  57941. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57942. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57943. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  57944. * * Remember you can only change the shape positions, not their number when updating a polygon
  57945. * @param name defines the name of the mesh
  57946. * @param options defines the options used to create the mesh
  57947. * @param scene defines the hosting scene
  57948. * @param earcutInjection can be used to inject your own earcut reference
  57949. * @returns the polygon mesh
  57950. */
  57951. static CreatePolygon(name: string, options: {
  57952. shape: Vector3[];
  57953. holes?: Vector3[][];
  57954. depth?: number;
  57955. faceUV?: Vector4[];
  57956. faceColors?: Color4[];
  57957. updatable?: boolean;
  57958. sideOrientation?: number;
  57959. frontUVs?: Vector4;
  57960. backUVs?: Vector4;
  57961. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57962. /**
  57963. * Creates an extruded polygon mesh, with depth in the Y direction.
  57964. * * 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)
  57965. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57966. * @param name defines the name of the mesh
  57967. * @param options defines the options used to create the mesh
  57968. * @param scene defines the hosting scene
  57969. * @param earcutInjection can be used to inject your own earcut reference
  57970. * @returns the polygon mesh
  57971. */
  57972. static ExtrudePolygon(name: string, options: {
  57973. shape: Vector3[];
  57974. holes?: Vector3[][];
  57975. depth?: number;
  57976. faceUV?: Vector4[];
  57977. faceColors?: Color4[];
  57978. updatable?: boolean;
  57979. sideOrientation?: number;
  57980. frontUVs?: Vector4;
  57981. backUVs?: Vector4;
  57982. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57983. }
  57984. }
  57985. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  57986. import { Scene } from "babylonjs/scene";
  57987. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57988. import { Mesh } from "babylonjs/Meshes/mesh";
  57989. import { Nullable } from "babylonjs/types";
  57990. /**
  57991. * Class containing static functions to help procedurally build meshes
  57992. */
  57993. export class LatheBuilder {
  57994. /**
  57995. * Creates lathe mesh.
  57996. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  57997. * * 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
  57998. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  57999. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58000. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58001. * * 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
  58002. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58003. * * 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
  58004. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58005. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58006. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58008. * @param name defines the name of the mesh
  58009. * @param options defines the options used to create the mesh
  58010. * @param scene defines the hosting scene
  58011. * @returns the lathe mesh
  58012. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58013. */
  58014. static CreateLathe(name: string, options: {
  58015. shape: Vector3[];
  58016. radius?: number;
  58017. tessellation?: number;
  58018. clip?: number;
  58019. arc?: number;
  58020. closed?: boolean;
  58021. updatable?: boolean;
  58022. sideOrientation?: number;
  58023. frontUVs?: Vector4;
  58024. backUVs?: Vector4;
  58025. cap?: number;
  58026. invertUV?: boolean;
  58027. }, scene?: Nullable<Scene>): Mesh;
  58028. }
  58029. }
  58030. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  58031. import { Nullable } from "babylonjs/types";
  58032. import { Scene } from "babylonjs/scene";
  58033. import { Vector4 } from "babylonjs/Maths/math.vector";
  58034. import { Mesh } from "babylonjs/Meshes/mesh";
  58035. /**
  58036. * Class containing static functions to help procedurally build meshes
  58037. */
  58038. export class TiledPlaneBuilder {
  58039. /**
  58040. * Creates a tiled plane mesh
  58041. * * The parameter `pattern` will, depending on value, do nothing or
  58042. * * * flip (reflect about central vertical) alternate tiles across and up
  58043. * * * flip every tile on alternate rows
  58044. * * * rotate (180 degs) alternate tiles across and up
  58045. * * * rotate every tile on alternate rows
  58046. * * * flip and rotate alternate tiles across and up
  58047. * * * flip and rotate every tile on alternate rows
  58048. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  58049. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  58050. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58051. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58052. * * 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)
  58053. * * 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)
  58054. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58055. * @param name defines the name of the mesh
  58056. * @param options defines the options used to create the mesh
  58057. * @param scene defines the hosting scene
  58058. * @returns the box mesh
  58059. */
  58060. static CreateTiledPlane(name: string, options: {
  58061. pattern?: number;
  58062. tileSize?: number;
  58063. tileWidth?: number;
  58064. tileHeight?: number;
  58065. size?: number;
  58066. width?: number;
  58067. height?: number;
  58068. alignHorizontal?: number;
  58069. alignVertical?: number;
  58070. sideOrientation?: number;
  58071. frontUVs?: Vector4;
  58072. backUVs?: Vector4;
  58073. updatable?: boolean;
  58074. }, scene?: Nullable<Scene>): Mesh;
  58075. }
  58076. }
  58077. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  58078. import { Nullable } from "babylonjs/types";
  58079. import { Scene } from "babylonjs/scene";
  58080. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58081. import { Mesh } from "babylonjs/Meshes/mesh";
  58082. /**
  58083. * Class containing static functions to help procedurally build meshes
  58084. */
  58085. export class TubeBuilder {
  58086. /**
  58087. * Creates a tube mesh.
  58088. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58089. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58090. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58091. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58092. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58093. * * 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)
  58094. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58095. * * 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
  58096. * * 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
  58097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58098. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58099. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58101. * @param name defines the name of the mesh
  58102. * @param options defines the options used to create the mesh
  58103. * @param scene defines the hosting scene
  58104. * @returns the tube mesh
  58105. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58106. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58107. */
  58108. static CreateTube(name: string, options: {
  58109. path: Vector3[];
  58110. radius?: number;
  58111. tessellation?: number;
  58112. radiusFunction?: {
  58113. (i: number, distance: number): number;
  58114. };
  58115. cap?: number;
  58116. arc?: number;
  58117. updatable?: boolean;
  58118. sideOrientation?: number;
  58119. frontUVs?: Vector4;
  58120. backUVs?: Vector4;
  58121. instance?: Mesh;
  58122. invertUV?: boolean;
  58123. }, scene?: Nullable<Scene>): Mesh;
  58124. }
  58125. }
  58126. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  58127. import { Scene } from "babylonjs/scene";
  58128. import { Vector4 } from "babylonjs/Maths/math.vector";
  58129. import { Mesh } from "babylonjs/Meshes/mesh";
  58130. import { Nullable } from "babylonjs/types";
  58131. /**
  58132. * Class containing static functions to help procedurally build meshes
  58133. */
  58134. export class IcoSphereBuilder {
  58135. /**
  58136. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58137. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58138. * * 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`)
  58139. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58140. * * 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
  58141. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58142. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58144. * @param name defines the name of the mesh
  58145. * @param options defines the options used to create the mesh
  58146. * @param scene defines the hosting scene
  58147. * @returns the icosahedron mesh
  58148. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58149. */
  58150. static CreateIcoSphere(name: string, options: {
  58151. radius?: number;
  58152. radiusX?: number;
  58153. radiusY?: number;
  58154. radiusZ?: number;
  58155. flat?: boolean;
  58156. subdivisions?: number;
  58157. sideOrientation?: number;
  58158. frontUVs?: Vector4;
  58159. backUVs?: Vector4;
  58160. updatable?: boolean;
  58161. }, scene?: Nullable<Scene>): Mesh;
  58162. }
  58163. }
  58164. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  58165. import { Vector3 } from "babylonjs/Maths/math.vector";
  58166. import { Mesh } from "babylonjs/Meshes/mesh";
  58167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58168. /**
  58169. * Class containing static functions to help procedurally build meshes
  58170. */
  58171. export class DecalBuilder {
  58172. /**
  58173. * Creates a decal mesh.
  58174. * 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
  58175. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58176. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58177. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58178. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58179. * @param name defines the name of the mesh
  58180. * @param sourceMesh defines the mesh where the decal must be applied
  58181. * @param options defines the options used to create the mesh
  58182. * @param scene defines the hosting scene
  58183. * @returns the decal mesh
  58184. * @see https://doc.babylonjs.com/how_to/decals
  58185. */
  58186. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58187. position?: Vector3;
  58188. normal?: Vector3;
  58189. size?: Vector3;
  58190. angle?: number;
  58191. }): Mesh;
  58192. }
  58193. }
  58194. declare module "babylonjs/Meshes/meshBuilder" {
  58195. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  58196. import { Nullable } from "babylonjs/types";
  58197. import { Scene } from "babylonjs/scene";
  58198. import { Mesh } from "babylonjs/Meshes/mesh";
  58199. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  58200. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  58201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58202. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  58203. import { Plane } from "babylonjs/Maths/math.plane";
  58204. /**
  58205. * Class containing static functions to help procedurally build meshes
  58206. */
  58207. export class MeshBuilder {
  58208. /**
  58209. * Creates a box mesh
  58210. * * The parameter `size` sets the size (float) of each box side (default 1)
  58211. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  58212. * * 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)
  58213. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58214. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58215. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58217. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58218. * @param name defines the name of the mesh
  58219. * @param options defines the options used to create the mesh
  58220. * @param scene defines the hosting scene
  58221. * @returns the box mesh
  58222. */
  58223. static CreateBox(name: string, options: {
  58224. size?: number;
  58225. width?: number;
  58226. height?: number;
  58227. depth?: number;
  58228. faceUV?: Vector4[];
  58229. faceColors?: Color4[];
  58230. sideOrientation?: number;
  58231. frontUVs?: Vector4;
  58232. backUVs?: Vector4;
  58233. updatable?: boolean;
  58234. }, scene?: Nullable<Scene>): Mesh;
  58235. /**
  58236. * Creates a tiled box mesh
  58237. * * faceTiles sets the pattern, tile size and number of tiles for a face
  58238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58239. * @param name defines the name of the mesh
  58240. * @param options defines the options used to create the mesh
  58241. * @param scene defines the hosting scene
  58242. * @returns the tiled box mesh
  58243. */
  58244. static CreateTiledBox(name: string, options: {
  58245. pattern?: number;
  58246. size?: number;
  58247. width?: number;
  58248. height?: number;
  58249. depth: number;
  58250. tileSize?: number;
  58251. tileWidth?: number;
  58252. tileHeight?: number;
  58253. faceUV?: Vector4[];
  58254. faceColors?: Color4[];
  58255. alignHorizontal?: number;
  58256. alignVertical?: number;
  58257. sideOrientation?: number;
  58258. updatable?: boolean;
  58259. }, scene?: Nullable<Scene>): Mesh;
  58260. /**
  58261. * Creates a sphere mesh
  58262. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  58263. * * 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`)
  58264. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  58265. * * 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
  58266. * * 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)
  58267. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58268. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58270. * @param name defines the name of the mesh
  58271. * @param options defines the options used to create the mesh
  58272. * @param scene defines the hosting scene
  58273. * @returns the sphere mesh
  58274. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  58275. */
  58276. static CreateSphere(name: string, options: {
  58277. segments?: number;
  58278. diameter?: number;
  58279. diameterX?: number;
  58280. diameterY?: number;
  58281. diameterZ?: number;
  58282. arc?: number;
  58283. slice?: number;
  58284. sideOrientation?: number;
  58285. frontUVs?: Vector4;
  58286. backUVs?: Vector4;
  58287. updatable?: boolean;
  58288. }, scene?: Nullable<Scene>): Mesh;
  58289. /**
  58290. * Creates a plane polygonal mesh. By default, this is a disc
  58291. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  58292. * * 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
  58293. * * 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
  58294. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58295. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58297. * @param name defines the name of the mesh
  58298. * @param options defines the options used to create the mesh
  58299. * @param scene defines the hosting scene
  58300. * @returns the plane polygonal mesh
  58301. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  58302. */
  58303. static CreateDisc(name: string, options: {
  58304. radius?: number;
  58305. tessellation?: number;
  58306. arc?: number;
  58307. updatable?: boolean;
  58308. sideOrientation?: number;
  58309. frontUVs?: Vector4;
  58310. backUVs?: Vector4;
  58311. }, scene?: Nullable<Scene>): Mesh;
  58312. /**
  58313. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58314. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58315. * * 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`)
  58316. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58317. * * 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
  58318. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58319. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58321. * @param name defines the name of the mesh
  58322. * @param options defines the options used to create the mesh
  58323. * @param scene defines the hosting scene
  58324. * @returns the icosahedron mesh
  58325. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58326. */
  58327. static CreateIcoSphere(name: string, options: {
  58328. radius?: number;
  58329. radiusX?: number;
  58330. radiusY?: number;
  58331. radiusZ?: number;
  58332. flat?: boolean;
  58333. subdivisions?: number;
  58334. sideOrientation?: number;
  58335. frontUVs?: Vector4;
  58336. backUVs?: Vector4;
  58337. updatable?: boolean;
  58338. }, scene?: Nullable<Scene>): Mesh;
  58339. /**
  58340. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58341. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58342. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58343. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58344. * * 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
  58345. * * 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
  58346. * * 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
  58347. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58348. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58349. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58350. * * 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
  58351. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58352. * * 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
  58353. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58355. * @param name defines the name of the mesh
  58356. * @param options defines the options used to create the mesh
  58357. * @param scene defines the hosting scene
  58358. * @returns the ribbon mesh
  58359. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58360. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58361. */
  58362. static CreateRibbon(name: string, options: {
  58363. pathArray: Vector3[][];
  58364. closeArray?: boolean;
  58365. closePath?: boolean;
  58366. offset?: number;
  58367. updatable?: boolean;
  58368. sideOrientation?: number;
  58369. frontUVs?: Vector4;
  58370. backUVs?: Vector4;
  58371. instance?: Mesh;
  58372. invertUV?: boolean;
  58373. uvs?: Vector2[];
  58374. colors?: Color4[];
  58375. }, scene?: Nullable<Scene>): Mesh;
  58376. /**
  58377. * Creates a cylinder or a cone mesh
  58378. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  58379. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  58380. * * 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.
  58381. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  58382. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  58383. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  58384. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  58385. * * 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).
  58386. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  58387. * * 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).
  58388. * * 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
  58389. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  58390. * * 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
  58391. * * 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.
  58392. * * If `enclose` is false, a ring surface is one element.
  58393. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  58394. * * 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
  58395. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58396. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58398. * @param name defines the name of the mesh
  58399. * @param options defines the options used to create the mesh
  58400. * @param scene defines the hosting scene
  58401. * @returns the cylinder mesh
  58402. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  58403. */
  58404. static CreateCylinder(name: string, options: {
  58405. height?: number;
  58406. diameterTop?: number;
  58407. diameterBottom?: number;
  58408. diameter?: number;
  58409. tessellation?: number;
  58410. subdivisions?: number;
  58411. arc?: number;
  58412. faceColors?: Color4[];
  58413. faceUV?: Vector4[];
  58414. updatable?: boolean;
  58415. hasRings?: boolean;
  58416. enclose?: boolean;
  58417. cap?: number;
  58418. sideOrientation?: number;
  58419. frontUVs?: Vector4;
  58420. backUVs?: Vector4;
  58421. }, scene?: Nullable<Scene>): Mesh;
  58422. /**
  58423. * Creates a torus mesh
  58424. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  58425. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  58426. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  58427. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58428. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58430. * @param name defines the name of the mesh
  58431. * @param options defines the options used to create the mesh
  58432. * @param scene defines the hosting scene
  58433. * @returns the torus mesh
  58434. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  58435. */
  58436. static CreateTorus(name: string, options: {
  58437. diameter?: number;
  58438. thickness?: number;
  58439. tessellation?: number;
  58440. updatable?: boolean;
  58441. sideOrientation?: number;
  58442. frontUVs?: Vector4;
  58443. backUVs?: Vector4;
  58444. }, scene?: Nullable<Scene>): Mesh;
  58445. /**
  58446. * Creates a torus knot mesh
  58447. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58448. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58449. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58450. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58451. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58452. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58454. * @param name defines the name of the mesh
  58455. * @param options defines the options used to create the mesh
  58456. * @param scene defines the hosting scene
  58457. * @returns the torus knot mesh
  58458. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58459. */
  58460. static CreateTorusKnot(name: string, options: {
  58461. radius?: number;
  58462. tube?: number;
  58463. radialSegments?: number;
  58464. tubularSegments?: number;
  58465. p?: number;
  58466. q?: number;
  58467. updatable?: boolean;
  58468. sideOrientation?: number;
  58469. frontUVs?: Vector4;
  58470. backUVs?: Vector4;
  58471. }, scene?: Nullable<Scene>): Mesh;
  58472. /**
  58473. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  58474. * * 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
  58475. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  58476. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  58477. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  58478. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  58479. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  58480. * * 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
  58481. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  58482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58483. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  58484. * @param name defines the name of the new line system
  58485. * @param options defines the options used to create the line system
  58486. * @param scene defines the hosting scene
  58487. * @returns a new line system mesh
  58488. */
  58489. static CreateLineSystem(name: string, options: {
  58490. lines: Vector3[][];
  58491. updatable?: boolean;
  58492. instance?: Nullable<LinesMesh>;
  58493. colors?: Nullable<Color4[][]>;
  58494. useVertexAlpha?: boolean;
  58495. }, scene: Nullable<Scene>): LinesMesh;
  58496. /**
  58497. * Creates a line mesh
  58498. * 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
  58499. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58500. * * The parameter `points` is an array successive Vector3
  58501. * * 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
  58502. * * The optional parameter `colors` is an array of successive Color4, one per line point
  58503. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  58504. * * When updating an instance, remember that only point positions can change, not the number of points
  58505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58506. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  58507. * @param name defines the name of the new line system
  58508. * @param options defines the options used to create the line system
  58509. * @param scene defines the hosting scene
  58510. * @returns a new line mesh
  58511. */
  58512. static CreateLines(name: string, options: {
  58513. points: Vector3[];
  58514. updatable?: boolean;
  58515. instance?: Nullable<LinesMesh>;
  58516. colors?: Color4[];
  58517. useVertexAlpha?: boolean;
  58518. }, scene?: Nullable<Scene>): LinesMesh;
  58519. /**
  58520. * Creates a dashed line mesh
  58521. * * 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
  58522. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58523. * * The parameter `points` is an array successive Vector3
  58524. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  58525. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  58526. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  58527. * * 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
  58528. * * When updating an instance, remember that only point positions can change, not the number of points
  58529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58530. * @param name defines the name of the mesh
  58531. * @param options defines the options used to create the mesh
  58532. * @param scene defines the hosting scene
  58533. * @returns the dashed line mesh
  58534. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  58535. */
  58536. static CreateDashedLines(name: string, options: {
  58537. points: Vector3[];
  58538. dashSize?: number;
  58539. gapSize?: number;
  58540. dashNb?: number;
  58541. updatable?: boolean;
  58542. instance?: LinesMesh;
  58543. }, scene?: Nullable<Scene>): LinesMesh;
  58544. /**
  58545. * 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.
  58546. * * 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.
  58547. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58548. * * 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.
  58549. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58550. * * 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
  58551. * * 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
  58552. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58553. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58554. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58555. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58556. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58557. * @param name defines the name of the mesh
  58558. * @param options defines the options used to create the mesh
  58559. * @param scene defines the hosting scene
  58560. * @returns the extruded shape mesh
  58561. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58562. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58563. */
  58564. static ExtrudeShape(name: string, options: {
  58565. shape: Vector3[];
  58566. path: Vector3[];
  58567. scale?: number;
  58568. rotation?: number;
  58569. cap?: number;
  58570. updatable?: boolean;
  58571. sideOrientation?: number;
  58572. frontUVs?: Vector4;
  58573. backUVs?: Vector4;
  58574. instance?: Mesh;
  58575. invertUV?: boolean;
  58576. }, scene?: Nullable<Scene>): Mesh;
  58577. /**
  58578. * Creates an custom extruded shape mesh.
  58579. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58580. * * 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.
  58581. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58582. * * 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
  58583. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58584. * * 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
  58585. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58586. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58587. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58588. * * 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
  58589. * * 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
  58590. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58591. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58592. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58593. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58595. * @param name defines the name of the mesh
  58596. * @param options defines the options used to create the mesh
  58597. * @param scene defines the hosting scene
  58598. * @returns the custom extruded shape mesh
  58599. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58600. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58601. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58602. */
  58603. static ExtrudeShapeCustom(name: string, options: {
  58604. shape: Vector3[];
  58605. path: Vector3[];
  58606. scaleFunction?: any;
  58607. rotationFunction?: any;
  58608. ribbonCloseArray?: boolean;
  58609. ribbonClosePath?: boolean;
  58610. cap?: number;
  58611. updatable?: boolean;
  58612. sideOrientation?: number;
  58613. frontUVs?: Vector4;
  58614. backUVs?: Vector4;
  58615. instance?: Mesh;
  58616. invertUV?: boolean;
  58617. }, scene?: Nullable<Scene>): Mesh;
  58618. /**
  58619. * Creates lathe mesh.
  58620. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58621. * * 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
  58622. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58623. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58624. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58625. * * 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
  58626. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58627. * * 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
  58628. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58629. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58630. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58632. * @param name defines the name of the mesh
  58633. * @param options defines the options used to create the mesh
  58634. * @param scene defines the hosting scene
  58635. * @returns the lathe mesh
  58636. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58637. */
  58638. static CreateLathe(name: string, options: {
  58639. shape: Vector3[];
  58640. radius?: number;
  58641. tessellation?: number;
  58642. clip?: number;
  58643. arc?: number;
  58644. closed?: boolean;
  58645. updatable?: boolean;
  58646. sideOrientation?: number;
  58647. frontUVs?: Vector4;
  58648. backUVs?: Vector4;
  58649. cap?: number;
  58650. invertUV?: boolean;
  58651. }, scene?: Nullable<Scene>): Mesh;
  58652. /**
  58653. * Creates a tiled plane mesh
  58654. * * You can set a limited pattern arrangement with the tiles
  58655. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58656. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58658. * @param name defines the name of the mesh
  58659. * @param options defines the options used to create the mesh
  58660. * @param scene defines the hosting scene
  58661. * @returns the plane mesh
  58662. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58663. */
  58664. static CreateTiledPlane(name: string, options: {
  58665. pattern?: number;
  58666. tileSize?: number;
  58667. tileWidth?: number;
  58668. tileHeight?: number;
  58669. size?: number;
  58670. width?: number;
  58671. height?: number;
  58672. alignHorizontal?: number;
  58673. alignVertical?: number;
  58674. sideOrientation?: number;
  58675. frontUVs?: Vector4;
  58676. backUVs?: Vector4;
  58677. updatable?: boolean;
  58678. }, scene?: Nullable<Scene>): Mesh;
  58679. /**
  58680. * Creates a plane mesh
  58681. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  58682. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  58683. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  58684. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58685. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58687. * @param name defines the name of the mesh
  58688. * @param options defines the options used to create the mesh
  58689. * @param scene defines the hosting scene
  58690. * @returns the plane mesh
  58691. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58692. */
  58693. static CreatePlane(name: string, options: {
  58694. size?: number;
  58695. width?: number;
  58696. height?: number;
  58697. sideOrientation?: number;
  58698. frontUVs?: Vector4;
  58699. backUVs?: Vector4;
  58700. updatable?: boolean;
  58701. sourcePlane?: Plane;
  58702. }, scene?: Nullable<Scene>): Mesh;
  58703. /**
  58704. * Creates a ground mesh
  58705. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  58706. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  58707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58708. * @param name defines the name of the mesh
  58709. * @param options defines the options used to create the mesh
  58710. * @param scene defines the hosting scene
  58711. * @returns the ground mesh
  58712. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  58713. */
  58714. static CreateGround(name: string, options: {
  58715. width?: number;
  58716. height?: number;
  58717. subdivisions?: number;
  58718. subdivisionsX?: number;
  58719. subdivisionsY?: number;
  58720. updatable?: boolean;
  58721. }, scene?: Nullable<Scene>): Mesh;
  58722. /**
  58723. * Creates a tiled ground mesh
  58724. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  58725. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  58726. * * 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
  58727. * * 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
  58728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58729. * @param name defines the name of the mesh
  58730. * @param options defines the options used to create the mesh
  58731. * @param scene defines the hosting scene
  58732. * @returns the tiled ground mesh
  58733. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  58734. */
  58735. static CreateTiledGround(name: string, options: {
  58736. xmin: number;
  58737. zmin: number;
  58738. xmax: number;
  58739. zmax: number;
  58740. subdivisions?: {
  58741. w: number;
  58742. h: number;
  58743. };
  58744. precision?: {
  58745. w: number;
  58746. h: number;
  58747. };
  58748. updatable?: boolean;
  58749. }, scene?: Nullable<Scene>): Mesh;
  58750. /**
  58751. * Creates a ground mesh from a height map
  58752. * * The parameter `url` sets the URL of the height map image resource.
  58753. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  58754. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  58755. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  58756. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  58757. * * 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.
  58758. * * 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).
  58759. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  58760. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58761. * @param name defines the name of the mesh
  58762. * @param url defines the url to the height map
  58763. * @param options defines the options used to create the mesh
  58764. * @param scene defines the hosting scene
  58765. * @returns the ground mesh
  58766. * @see https://doc.babylonjs.com/babylon101/height_map
  58767. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  58768. */
  58769. static CreateGroundFromHeightMap(name: string, url: string, options: {
  58770. width?: number;
  58771. height?: number;
  58772. subdivisions?: number;
  58773. minHeight?: number;
  58774. maxHeight?: number;
  58775. colorFilter?: Color3;
  58776. alphaFilter?: number;
  58777. updatable?: boolean;
  58778. onReady?: (mesh: GroundMesh) => void;
  58779. }, scene?: Nullable<Scene>): GroundMesh;
  58780. /**
  58781. * Creates a polygon mesh
  58782. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58783. * * 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
  58784. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58786. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58787. * * Remember you can only change the shape positions, not their number when updating a polygon
  58788. * @param name defines the name of the mesh
  58789. * @param options defines the options used to create the mesh
  58790. * @param scene defines the hosting scene
  58791. * @param earcutInjection can be used to inject your own earcut reference
  58792. * @returns the polygon mesh
  58793. */
  58794. static CreatePolygon(name: string, options: {
  58795. shape: Vector3[];
  58796. holes?: Vector3[][];
  58797. depth?: number;
  58798. faceUV?: Vector4[];
  58799. faceColors?: Color4[];
  58800. updatable?: boolean;
  58801. sideOrientation?: number;
  58802. frontUVs?: Vector4;
  58803. backUVs?: Vector4;
  58804. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58805. /**
  58806. * Creates an extruded polygon mesh, with depth in the Y direction.
  58807. * * 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)
  58808. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58809. * @param name defines the name of the mesh
  58810. * @param options defines the options used to create the mesh
  58811. * @param scene defines the hosting scene
  58812. * @param earcutInjection can be used to inject your own earcut reference
  58813. * @returns the polygon mesh
  58814. */
  58815. static ExtrudePolygon(name: string, options: {
  58816. shape: Vector3[];
  58817. holes?: Vector3[][];
  58818. depth?: number;
  58819. faceUV?: Vector4[];
  58820. faceColors?: Color4[];
  58821. updatable?: boolean;
  58822. sideOrientation?: number;
  58823. frontUVs?: Vector4;
  58824. backUVs?: Vector4;
  58825. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58826. /**
  58827. * Creates a tube mesh.
  58828. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58829. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58830. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58831. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58832. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58833. * * 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)
  58834. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58835. * * 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
  58836. * * 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
  58837. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58838. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58839. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58841. * @param name defines the name of the mesh
  58842. * @param options defines the options used to create the mesh
  58843. * @param scene defines the hosting scene
  58844. * @returns the tube mesh
  58845. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58846. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58847. */
  58848. static CreateTube(name: string, options: {
  58849. path: Vector3[];
  58850. radius?: number;
  58851. tessellation?: number;
  58852. radiusFunction?: {
  58853. (i: number, distance: number): number;
  58854. };
  58855. cap?: number;
  58856. arc?: number;
  58857. updatable?: boolean;
  58858. sideOrientation?: number;
  58859. frontUVs?: Vector4;
  58860. backUVs?: Vector4;
  58861. instance?: Mesh;
  58862. invertUV?: boolean;
  58863. }, scene?: Nullable<Scene>): Mesh;
  58864. /**
  58865. * Creates a polyhedron mesh
  58866. * * 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
  58867. * * The parameter `size` (positive float, default 1) sets the polygon size
  58868. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  58869. * * 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`
  58870. * * 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
  58871. * * 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)`)
  58872. * * 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
  58873. * * 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
  58874. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58875. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58877. * @param name defines the name of the mesh
  58878. * @param options defines the options used to create the mesh
  58879. * @param scene defines the hosting scene
  58880. * @returns the polyhedron mesh
  58881. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  58882. */
  58883. static CreatePolyhedron(name: string, options: {
  58884. type?: number;
  58885. size?: number;
  58886. sizeX?: number;
  58887. sizeY?: number;
  58888. sizeZ?: number;
  58889. custom?: any;
  58890. faceUV?: Vector4[];
  58891. faceColors?: Color4[];
  58892. flat?: boolean;
  58893. updatable?: boolean;
  58894. sideOrientation?: number;
  58895. frontUVs?: Vector4;
  58896. backUVs?: Vector4;
  58897. }, scene?: Nullable<Scene>): Mesh;
  58898. /**
  58899. * Creates a decal mesh.
  58900. * 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
  58901. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58902. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58903. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58904. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58905. * @param name defines the name of the mesh
  58906. * @param sourceMesh defines the mesh where the decal must be applied
  58907. * @param options defines the options used to create the mesh
  58908. * @param scene defines the hosting scene
  58909. * @returns the decal mesh
  58910. * @see https://doc.babylonjs.com/how_to/decals
  58911. */
  58912. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58913. position?: Vector3;
  58914. normal?: Vector3;
  58915. size?: Vector3;
  58916. angle?: number;
  58917. }): Mesh;
  58918. }
  58919. }
  58920. declare module "babylonjs/Meshes/meshSimplification" {
  58921. import { Mesh } from "babylonjs/Meshes/mesh";
  58922. /**
  58923. * A simplifier interface for future simplification implementations
  58924. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58925. */
  58926. export interface ISimplifier {
  58927. /**
  58928. * Simplification of a given mesh according to the given settings.
  58929. * Since this requires computation, it is assumed that the function runs async.
  58930. * @param settings The settings of the simplification, including quality and distance
  58931. * @param successCallback A callback that will be called after the mesh was simplified.
  58932. * @param errorCallback in case of an error, this callback will be called. optional.
  58933. */
  58934. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  58935. }
  58936. /**
  58937. * Expected simplification settings.
  58938. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  58939. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58940. */
  58941. export interface ISimplificationSettings {
  58942. /**
  58943. * Gets or sets the expected quality
  58944. */
  58945. quality: number;
  58946. /**
  58947. * Gets or sets the distance when this optimized version should be used
  58948. */
  58949. distance: number;
  58950. /**
  58951. * Gets an already optimized mesh
  58952. */
  58953. optimizeMesh?: boolean;
  58954. }
  58955. /**
  58956. * Class used to specify simplification options
  58957. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58958. */
  58959. export class SimplificationSettings implements ISimplificationSettings {
  58960. /** expected quality */
  58961. quality: number;
  58962. /** distance when this optimized version should be used */
  58963. distance: number;
  58964. /** already optimized mesh */
  58965. optimizeMesh?: boolean | undefined;
  58966. /**
  58967. * Creates a SimplificationSettings
  58968. * @param quality expected quality
  58969. * @param distance distance when this optimized version should be used
  58970. * @param optimizeMesh already optimized mesh
  58971. */
  58972. constructor(
  58973. /** expected quality */
  58974. quality: number,
  58975. /** distance when this optimized version should be used */
  58976. distance: number,
  58977. /** already optimized mesh */
  58978. optimizeMesh?: boolean | undefined);
  58979. }
  58980. /**
  58981. * Interface used to define a simplification task
  58982. */
  58983. export interface ISimplificationTask {
  58984. /**
  58985. * Array of settings
  58986. */
  58987. settings: Array<ISimplificationSettings>;
  58988. /**
  58989. * Simplification type
  58990. */
  58991. simplificationType: SimplificationType;
  58992. /**
  58993. * Mesh to simplify
  58994. */
  58995. mesh: Mesh;
  58996. /**
  58997. * Callback called on success
  58998. */
  58999. successCallback?: () => void;
  59000. /**
  59001. * Defines if parallel processing can be used
  59002. */
  59003. parallelProcessing: boolean;
  59004. }
  59005. /**
  59006. * Queue used to order the simplification tasks
  59007. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59008. */
  59009. export class SimplificationQueue {
  59010. private _simplificationArray;
  59011. /**
  59012. * Gets a boolean indicating that the process is still running
  59013. */
  59014. running: boolean;
  59015. /**
  59016. * Creates a new queue
  59017. */
  59018. constructor();
  59019. /**
  59020. * Adds a new simplification task
  59021. * @param task defines a task to add
  59022. */
  59023. addTask(task: ISimplificationTask): void;
  59024. /**
  59025. * Execute next task
  59026. */
  59027. executeNext(): void;
  59028. /**
  59029. * Execute a simplification task
  59030. * @param task defines the task to run
  59031. */
  59032. runSimplification(task: ISimplificationTask): void;
  59033. private getSimplifier;
  59034. }
  59035. /**
  59036. * The implemented types of simplification
  59037. * At the moment only Quadratic Error Decimation is implemented
  59038. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59039. */
  59040. export enum SimplificationType {
  59041. /** Quadratic error decimation */
  59042. QUADRATIC = 0
  59043. }
  59044. }
  59045. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  59046. import { Scene } from "babylonjs/scene";
  59047. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  59048. import { ISceneComponent } from "babylonjs/sceneComponent";
  59049. module "babylonjs/scene" {
  59050. interface Scene {
  59051. /** @hidden (Backing field) */
  59052. _simplificationQueue: SimplificationQueue;
  59053. /**
  59054. * Gets or sets the simplification queue attached to the scene
  59055. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59056. */
  59057. simplificationQueue: SimplificationQueue;
  59058. }
  59059. }
  59060. module "babylonjs/Meshes/mesh" {
  59061. interface Mesh {
  59062. /**
  59063. * Simplify the mesh according to the given array of settings.
  59064. * Function will return immediately and will simplify async
  59065. * @param settings a collection of simplification settings
  59066. * @param parallelProcessing should all levels calculate parallel or one after the other
  59067. * @param simplificationType the type of simplification to run
  59068. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  59069. * @returns the current mesh
  59070. */
  59071. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  59072. }
  59073. }
  59074. /**
  59075. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  59076. * created in a scene
  59077. */
  59078. export class SimplicationQueueSceneComponent implements ISceneComponent {
  59079. /**
  59080. * The component name helpfull to identify the component in the list of scene components.
  59081. */
  59082. readonly name: string;
  59083. /**
  59084. * The scene the component belongs to.
  59085. */
  59086. scene: Scene;
  59087. /**
  59088. * Creates a new instance of the component for the given scene
  59089. * @param scene Defines the scene to register the component in
  59090. */
  59091. constructor(scene: Scene);
  59092. /**
  59093. * Registers the component in a given scene
  59094. */
  59095. register(): void;
  59096. /**
  59097. * Rebuilds the elements related to this component in case of
  59098. * context lost for instance.
  59099. */
  59100. rebuild(): void;
  59101. /**
  59102. * Disposes the component and the associated ressources
  59103. */
  59104. dispose(): void;
  59105. private _beforeCameraUpdate;
  59106. }
  59107. }
  59108. declare module "babylonjs/Meshes/Builders/index" {
  59109. export * from "babylonjs/Meshes/Builders/boxBuilder";
  59110. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  59111. export * from "babylonjs/Meshes/Builders/discBuilder";
  59112. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  59113. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  59114. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  59115. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  59116. export * from "babylonjs/Meshes/Builders/torusBuilder";
  59117. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  59118. export * from "babylonjs/Meshes/Builders/linesBuilder";
  59119. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  59120. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  59121. export * from "babylonjs/Meshes/Builders/latheBuilder";
  59122. export * from "babylonjs/Meshes/Builders/planeBuilder";
  59123. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  59124. export * from "babylonjs/Meshes/Builders/groundBuilder";
  59125. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  59126. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  59127. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  59128. export * from "babylonjs/Meshes/Builders/decalBuilder";
  59129. }
  59130. declare module "babylonjs/Meshes/index" {
  59131. export * from "babylonjs/Meshes/abstractMesh";
  59132. export * from "babylonjs/Meshes/buffer";
  59133. export * from "babylonjs/Meshes/Compression/index";
  59134. export * from "babylonjs/Meshes/csg";
  59135. export * from "babylonjs/Meshes/geometry";
  59136. export * from "babylonjs/Meshes/groundMesh";
  59137. export * from "babylonjs/Meshes/trailMesh";
  59138. export * from "babylonjs/Meshes/instancedMesh";
  59139. export * from "babylonjs/Meshes/linesMesh";
  59140. export * from "babylonjs/Meshes/mesh";
  59141. export * from "babylonjs/Meshes/mesh.vertexData";
  59142. export * from "babylonjs/Meshes/meshBuilder";
  59143. export * from "babylonjs/Meshes/meshSimplification";
  59144. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  59145. export * from "babylonjs/Meshes/polygonMesh";
  59146. export * from "babylonjs/Meshes/subMesh";
  59147. export * from "babylonjs/Meshes/meshLODLevel";
  59148. export * from "babylonjs/Meshes/transformNode";
  59149. export * from "babylonjs/Meshes/Builders/index";
  59150. export * from "babylonjs/Meshes/dataBuffer";
  59151. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  59152. }
  59153. declare module "babylonjs/Morph/index" {
  59154. export * from "babylonjs/Morph/morphTarget";
  59155. export * from "babylonjs/Morph/morphTargetManager";
  59156. }
  59157. declare module "babylonjs/Navigation/INavigationEngine" {
  59158. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59159. import { Vector3 } from "babylonjs/Maths/math";
  59160. import { Mesh } from "babylonjs/Meshes/mesh";
  59161. import { Scene } from "babylonjs/scene";
  59162. /**
  59163. * Navigation plugin interface to add navigation constrained by a navigation mesh
  59164. */
  59165. export interface INavigationEnginePlugin {
  59166. /**
  59167. * plugin name
  59168. */
  59169. name: string;
  59170. /**
  59171. * Creates a navigation mesh
  59172. * @param meshes array of all the geometry used to compute the navigatio mesh
  59173. * @param parameters bunch of parameters used to filter geometry
  59174. */
  59175. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59176. /**
  59177. * Create a navigation mesh debug mesh
  59178. * @param scene is where the mesh will be added
  59179. * @returns debug display mesh
  59180. */
  59181. createDebugNavMesh(scene: Scene): Mesh;
  59182. /**
  59183. * Get a navigation mesh constrained position, closest to the parameter position
  59184. * @param position world position
  59185. * @returns the closest point to position constrained by the navigation mesh
  59186. */
  59187. getClosestPoint(position: Vector3): Vector3;
  59188. /**
  59189. * Get a navigation mesh constrained position, within a particular radius
  59190. * @param position world position
  59191. * @param maxRadius the maximum distance to the constrained world position
  59192. * @returns the closest point to position constrained by the navigation mesh
  59193. */
  59194. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59195. /**
  59196. * Compute the final position from a segment made of destination-position
  59197. * @param position world position
  59198. * @param destination world position
  59199. * @returns the resulting point along the navmesh
  59200. */
  59201. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59202. /**
  59203. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59204. * @param start world position
  59205. * @param end world position
  59206. * @returns array containing world position composing the path
  59207. */
  59208. computePath(start: Vector3, end: Vector3): Vector3[];
  59209. /**
  59210. * If this plugin is supported
  59211. * @returns true if plugin is supported
  59212. */
  59213. isSupported(): boolean;
  59214. /**
  59215. * Create a new Crowd so you can add agents
  59216. * @param maxAgents the maximum agent count in the crowd
  59217. * @param maxAgentRadius the maximum radius an agent can have
  59218. * @param scene to attach the crowd to
  59219. * @returns the crowd you can add agents to
  59220. */
  59221. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59222. /**
  59223. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59224. * The queries will try to find a solution within those bounds
  59225. * default is (1,1,1)
  59226. * @param extent x,y,z value that define the extent around the queries point of reference
  59227. */
  59228. setDefaultQueryExtent(extent: Vector3): void;
  59229. /**
  59230. * Get the Bounding box extent specified by setDefaultQueryExtent
  59231. * @returns the box extent values
  59232. */
  59233. getDefaultQueryExtent(): Vector3;
  59234. /**
  59235. * Release all resources
  59236. */
  59237. dispose(): void;
  59238. }
  59239. /**
  59240. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  59241. */
  59242. export interface ICrowd {
  59243. /**
  59244. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59245. * You can attach anything to that node. The node position is updated in the scene update tick.
  59246. * @param pos world position that will be constrained by the navigation mesh
  59247. * @param parameters agent parameters
  59248. * @param transform hooked to the agent that will be update by the scene
  59249. * @returns agent index
  59250. */
  59251. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59252. /**
  59253. * Returns the agent position in world space
  59254. * @param index agent index returned by addAgent
  59255. * @returns world space position
  59256. */
  59257. getAgentPosition(index: number): Vector3;
  59258. /**
  59259. * Gets the agent velocity in world space
  59260. * @param index agent index returned by addAgent
  59261. * @returns world space velocity
  59262. */
  59263. getAgentVelocity(index: number): Vector3;
  59264. /**
  59265. * remove a particular agent previously created
  59266. * @param index agent index returned by addAgent
  59267. */
  59268. removeAgent(index: number): void;
  59269. /**
  59270. * get the list of all agents attached to this crowd
  59271. * @returns list of agent indices
  59272. */
  59273. getAgents(): number[];
  59274. /**
  59275. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59276. * @param deltaTime in seconds
  59277. */
  59278. update(deltaTime: number): void;
  59279. /**
  59280. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59281. * @param index agent index returned by addAgent
  59282. * @param destination targeted world position
  59283. */
  59284. agentGoto(index: number, destination: Vector3): void;
  59285. /**
  59286. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59287. * The queries will try to find a solution within those bounds
  59288. * default is (1,1,1)
  59289. * @param extent x,y,z value that define the extent around the queries point of reference
  59290. */
  59291. setDefaultQueryExtent(extent: Vector3): void;
  59292. /**
  59293. * Get the Bounding box extent specified by setDefaultQueryExtent
  59294. * @returns the box extent values
  59295. */
  59296. getDefaultQueryExtent(): Vector3;
  59297. /**
  59298. * Release all resources
  59299. */
  59300. dispose(): void;
  59301. }
  59302. /**
  59303. * Configures an agent
  59304. */
  59305. export interface IAgentParameters {
  59306. /**
  59307. * Agent radius. [Limit: >= 0]
  59308. */
  59309. radius: number;
  59310. /**
  59311. * Agent height. [Limit: > 0]
  59312. */
  59313. height: number;
  59314. /**
  59315. * Maximum allowed acceleration. [Limit: >= 0]
  59316. */
  59317. maxAcceleration: number;
  59318. /**
  59319. * Maximum allowed speed. [Limit: >= 0]
  59320. */
  59321. maxSpeed: number;
  59322. /**
  59323. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  59324. */
  59325. collisionQueryRange: number;
  59326. /**
  59327. * The path visibility optimization range. [Limit: > 0]
  59328. */
  59329. pathOptimizationRange: number;
  59330. /**
  59331. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  59332. */
  59333. separationWeight: number;
  59334. }
  59335. /**
  59336. * Configures the navigation mesh creation
  59337. */
  59338. export interface INavMeshParameters {
  59339. /**
  59340. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  59341. */
  59342. cs: number;
  59343. /**
  59344. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  59345. */
  59346. ch: number;
  59347. /**
  59348. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  59349. */
  59350. walkableSlopeAngle: number;
  59351. /**
  59352. * Minimum floor to 'ceiling' height that will still allow the floor area to
  59353. * be considered walkable. [Limit: >= 3] [Units: vx]
  59354. */
  59355. walkableHeight: number;
  59356. /**
  59357. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  59358. */
  59359. walkableClimb: number;
  59360. /**
  59361. * The distance to erode/shrink the walkable area of the heightfield away from
  59362. * obstructions. [Limit: >=0] [Units: vx]
  59363. */
  59364. walkableRadius: number;
  59365. /**
  59366. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  59367. */
  59368. maxEdgeLen: number;
  59369. /**
  59370. * The maximum distance a simplfied contour's border edges should deviate
  59371. * the original raw contour. [Limit: >=0] [Units: vx]
  59372. */
  59373. maxSimplificationError: number;
  59374. /**
  59375. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  59376. */
  59377. minRegionArea: number;
  59378. /**
  59379. * Any regions with a span count smaller than this value will, if possible,
  59380. * be merged with larger regions. [Limit: >=0] [Units: vx]
  59381. */
  59382. mergeRegionArea: number;
  59383. /**
  59384. * The maximum number of vertices allowed for polygons generated during the
  59385. * contour to polygon conversion process. [Limit: >= 3]
  59386. */
  59387. maxVertsPerPoly: number;
  59388. /**
  59389. * Sets the sampling distance to use when generating the detail mesh.
  59390. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  59391. */
  59392. detailSampleDist: number;
  59393. /**
  59394. * The maximum distance the detail mesh surface should deviate from heightfield
  59395. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  59396. */
  59397. detailSampleMaxError: number;
  59398. }
  59399. }
  59400. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  59401. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  59402. import { Mesh } from "babylonjs/Meshes/mesh";
  59403. import { Scene } from "babylonjs/scene";
  59404. import { Vector3 } from "babylonjs/Maths/math";
  59405. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59406. /**
  59407. * RecastJS navigation plugin
  59408. */
  59409. export class RecastJSPlugin implements INavigationEnginePlugin {
  59410. /**
  59411. * Reference to the Recast library
  59412. */
  59413. bjsRECAST: any;
  59414. /**
  59415. * plugin name
  59416. */
  59417. name: string;
  59418. /**
  59419. * the first navmesh created. We might extend this to support multiple navmeshes
  59420. */
  59421. navMesh: any;
  59422. /**
  59423. * Initializes the recastJS plugin
  59424. * @param recastInjection can be used to inject your own recast reference
  59425. */
  59426. constructor(recastInjection?: any);
  59427. /**
  59428. * Creates a navigation mesh
  59429. * @param meshes array of all the geometry used to compute the navigatio mesh
  59430. * @param parameters bunch of parameters used to filter geometry
  59431. */
  59432. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59433. /**
  59434. * Create a navigation mesh debug mesh
  59435. * @param scene is where the mesh will be added
  59436. * @returns debug display mesh
  59437. */
  59438. createDebugNavMesh(scene: Scene): Mesh;
  59439. /**
  59440. * Get a navigation mesh constrained position, closest to the parameter position
  59441. * @param position world position
  59442. * @returns the closest point to position constrained by the navigation mesh
  59443. */
  59444. getClosestPoint(position: Vector3): Vector3;
  59445. /**
  59446. * Get a navigation mesh constrained position, within a particular radius
  59447. * @param position world position
  59448. * @param maxRadius the maximum distance to the constrained world position
  59449. * @returns the closest point to position constrained by the navigation mesh
  59450. */
  59451. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59452. /**
  59453. * Compute the final position from a segment made of destination-position
  59454. * @param position world position
  59455. * @param destination world position
  59456. * @returns the resulting point along the navmesh
  59457. */
  59458. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59459. /**
  59460. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59461. * @param start world position
  59462. * @param end world position
  59463. * @returns array containing world position composing the path
  59464. */
  59465. computePath(start: Vector3, end: Vector3): Vector3[];
  59466. /**
  59467. * Create a new Crowd so you can add agents
  59468. * @param maxAgents the maximum agent count in the crowd
  59469. * @param maxAgentRadius the maximum radius an agent can have
  59470. * @param scene to attach the crowd to
  59471. * @returns the crowd you can add agents to
  59472. */
  59473. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59474. /**
  59475. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59476. * The queries will try to find a solution within those bounds
  59477. * default is (1,1,1)
  59478. * @param extent x,y,z value that define the extent around the queries point of reference
  59479. */
  59480. setDefaultQueryExtent(extent: Vector3): void;
  59481. /**
  59482. * Get the Bounding box extent specified by setDefaultQueryExtent
  59483. * @returns the box extent values
  59484. */
  59485. getDefaultQueryExtent(): Vector3;
  59486. /**
  59487. * Disposes
  59488. */
  59489. dispose(): void;
  59490. /**
  59491. * If this plugin is supported
  59492. * @returns true if plugin is supported
  59493. */
  59494. isSupported(): boolean;
  59495. }
  59496. /**
  59497. * Recast detour crowd implementation
  59498. */
  59499. export class RecastJSCrowd implements ICrowd {
  59500. /**
  59501. * Recast/detour plugin
  59502. */
  59503. bjsRECASTPlugin: RecastJSPlugin;
  59504. /**
  59505. * Link to the detour crowd
  59506. */
  59507. recastCrowd: any;
  59508. /**
  59509. * One transform per agent
  59510. */
  59511. transforms: TransformNode[];
  59512. /**
  59513. * All agents created
  59514. */
  59515. agents: number[];
  59516. /**
  59517. * Link to the scene is kept to unregister the crowd from the scene
  59518. */
  59519. private _scene;
  59520. /**
  59521. * Observer for crowd updates
  59522. */
  59523. private _onBeforeAnimationsObserver;
  59524. /**
  59525. * Constructor
  59526. * @param plugin recastJS plugin
  59527. * @param maxAgents the maximum agent count in the crowd
  59528. * @param maxAgentRadius the maximum radius an agent can have
  59529. * @param scene to attach the crowd to
  59530. * @returns the crowd you can add agents to
  59531. */
  59532. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  59533. /**
  59534. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59535. * You can attach anything to that node. The node position is updated in the scene update tick.
  59536. * @param pos world position that will be constrained by the navigation mesh
  59537. * @param parameters agent parameters
  59538. * @param transform hooked to the agent that will be update by the scene
  59539. * @returns agent index
  59540. */
  59541. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59542. /**
  59543. * Returns the agent position in world space
  59544. * @param index agent index returned by addAgent
  59545. * @returns world space position
  59546. */
  59547. getAgentPosition(index: number): Vector3;
  59548. /**
  59549. * Returns the agent velocity in world space
  59550. * @param index agent index returned by addAgent
  59551. * @returns world space velocity
  59552. */
  59553. getAgentVelocity(index: number): Vector3;
  59554. /**
  59555. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59556. * @param index agent index returned by addAgent
  59557. * @param destination targeted world position
  59558. */
  59559. agentGoto(index: number, destination: Vector3): void;
  59560. /**
  59561. * remove a particular agent previously created
  59562. * @param index agent index returned by addAgent
  59563. */
  59564. removeAgent(index: number): void;
  59565. /**
  59566. * get the list of all agents attached to this crowd
  59567. * @returns list of agent indices
  59568. */
  59569. getAgents(): number[];
  59570. /**
  59571. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59572. * @param deltaTime in seconds
  59573. */
  59574. update(deltaTime: number): void;
  59575. /**
  59576. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59577. * The queries will try to find a solution within those bounds
  59578. * default is (1,1,1)
  59579. * @param extent x,y,z value that define the extent around the queries point of reference
  59580. */
  59581. setDefaultQueryExtent(extent: Vector3): void;
  59582. /**
  59583. * Get the Bounding box extent specified by setDefaultQueryExtent
  59584. * @returns the box extent values
  59585. */
  59586. getDefaultQueryExtent(): Vector3;
  59587. /**
  59588. * Release all resources
  59589. */
  59590. dispose(): void;
  59591. }
  59592. }
  59593. declare module "babylonjs/Navigation/Plugins/index" {
  59594. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  59595. }
  59596. declare module "babylonjs/Navigation/index" {
  59597. export * from "babylonjs/Navigation/INavigationEngine";
  59598. export * from "babylonjs/Navigation/Plugins/index";
  59599. }
  59600. declare module "babylonjs/Offline/database" {
  59601. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  59602. /**
  59603. * Class used to enable access to IndexedDB
  59604. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  59605. */
  59606. export class Database implements IOfflineProvider {
  59607. private _callbackManifestChecked;
  59608. private _currentSceneUrl;
  59609. private _db;
  59610. private _enableSceneOffline;
  59611. private _enableTexturesOffline;
  59612. private _manifestVersionFound;
  59613. private _mustUpdateRessources;
  59614. private _hasReachedQuota;
  59615. private _isSupported;
  59616. private _idbFactory;
  59617. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  59618. private static IsUASupportingBlobStorage;
  59619. /**
  59620. * Gets a boolean indicating if Database storate is enabled (off by default)
  59621. */
  59622. static IDBStorageEnabled: boolean;
  59623. /**
  59624. * Gets a boolean indicating if scene must be saved in the database
  59625. */
  59626. readonly enableSceneOffline: boolean;
  59627. /**
  59628. * Gets a boolean indicating if textures must be saved in the database
  59629. */
  59630. readonly enableTexturesOffline: boolean;
  59631. /**
  59632. * Creates a new Database
  59633. * @param urlToScene defines the url to load the scene
  59634. * @param callbackManifestChecked defines the callback to use when manifest is checked
  59635. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  59636. */
  59637. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  59638. private static _ParseURL;
  59639. private static _ReturnFullUrlLocation;
  59640. private _checkManifestFile;
  59641. /**
  59642. * Open the database and make it available
  59643. * @param successCallback defines the callback to call on success
  59644. * @param errorCallback defines the callback to call on error
  59645. */
  59646. open(successCallback: () => void, errorCallback: () => void): void;
  59647. /**
  59648. * Loads an image from the database
  59649. * @param url defines the url to load from
  59650. * @param image defines the target DOM image
  59651. */
  59652. loadImage(url: string, image: HTMLImageElement): void;
  59653. private _loadImageFromDBAsync;
  59654. private _saveImageIntoDBAsync;
  59655. private _checkVersionFromDB;
  59656. private _loadVersionFromDBAsync;
  59657. private _saveVersionIntoDBAsync;
  59658. /**
  59659. * Loads a file from database
  59660. * @param url defines the URL to load from
  59661. * @param sceneLoaded defines a callback to call on success
  59662. * @param progressCallBack defines a callback to call when progress changed
  59663. * @param errorCallback defines a callback to call on error
  59664. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  59665. */
  59666. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  59667. private _loadFileAsync;
  59668. private _saveFileAsync;
  59669. /**
  59670. * Validates if xhr data is correct
  59671. * @param xhr defines the request to validate
  59672. * @param dataType defines the expected data type
  59673. * @returns true if data is correct
  59674. */
  59675. private static _ValidateXHRData;
  59676. }
  59677. }
  59678. declare module "babylonjs/Offline/index" {
  59679. export * from "babylonjs/Offline/database";
  59680. export * from "babylonjs/Offline/IOfflineProvider";
  59681. }
  59682. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  59683. /** @hidden */
  59684. export var gpuUpdateParticlesPixelShader: {
  59685. name: string;
  59686. shader: string;
  59687. };
  59688. }
  59689. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  59690. /** @hidden */
  59691. export var gpuUpdateParticlesVertexShader: {
  59692. name: string;
  59693. shader: string;
  59694. };
  59695. }
  59696. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  59697. /** @hidden */
  59698. export var clipPlaneFragmentDeclaration2: {
  59699. name: string;
  59700. shader: string;
  59701. };
  59702. }
  59703. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  59704. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  59705. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59706. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59707. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59708. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  59709. /** @hidden */
  59710. export var gpuRenderParticlesPixelShader: {
  59711. name: string;
  59712. shader: string;
  59713. };
  59714. }
  59715. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  59716. /** @hidden */
  59717. export var clipPlaneVertexDeclaration2: {
  59718. name: string;
  59719. shader: string;
  59720. };
  59721. }
  59722. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  59723. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  59724. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  59725. /** @hidden */
  59726. export var gpuRenderParticlesVertexShader: {
  59727. name: string;
  59728. shader: string;
  59729. };
  59730. }
  59731. declare module "babylonjs/Particles/gpuParticleSystem" {
  59732. import { Nullable } from "babylonjs/types";
  59733. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  59734. import { Observable } from "babylonjs/Misc/observable";
  59735. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59736. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59737. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  59738. import { Scene, IDisposable } from "babylonjs/scene";
  59739. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  59740. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  59741. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  59742. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  59743. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  59744. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  59745. /**
  59746. * This represents a GPU particle system in Babylon
  59747. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  59748. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  59749. */
  59750. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  59751. /**
  59752. * The layer mask we are rendering the particles through.
  59753. */
  59754. layerMask: number;
  59755. private _capacity;
  59756. private _activeCount;
  59757. private _currentActiveCount;
  59758. private _accumulatedCount;
  59759. private _renderEffect;
  59760. private _updateEffect;
  59761. private _buffer0;
  59762. private _buffer1;
  59763. private _spriteBuffer;
  59764. private _updateVAO;
  59765. private _renderVAO;
  59766. private _targetIndex;
  59767. private _sourceBuffer;
  59768. private _targetBuffer;
  59769. private _engine;
  59770. private _currentRenderId;
  59771. private _started;
  59772. private _stopped;
  59773. private _timeDelta;
  59774. private _randomTexture;
  59775. private _randomTexture2;
  59776. private _attributesStrideSize;
  59777. private _updateEffectOptions;
  59778. private _randomTextureSize;
  59779. private _actualFrame;
  59780. private readonly _rawTextureWidth;
  59781. /**
  59782. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  59783. */
  59784. static readonly IsSupported: boolean;
  59785. /**
  59786. * An event triggered when the system is disposed.
  59787. */
  59788. onDisposeObservable: Observable<GPUParticleSystem>;
  59789. /**
  59790. * Gets the maximum number of particles active at the same time.
  59791. * @returns The max number of active particles.
  59792. */
  59793. getCapacity(): number;
  59794. /**
  59795. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  59796. * to override the particles.
  59797. */
  59798. forceDepthWrite: boolean;
  59799. /**
  59800. * Gets or set the number of active particles
  59801. */
  59802. activeParticleCount: number;
  59803. private _preWarmDone;
  59804. /**
  59805. * Is this system ready to be used/rendered
  59806. * @return true if the system is ready
  59807. */
  59808. isReady(): boolean;
  59809. /**
  59810. * Gets if the system has been started. (Note: this will still be true after stop is called)
  59811. * @returns True if it has been started, otherwise false.
  59812. */
  59813. isStarted(): boolean;
  59814. /**
  59815. * Starts the particle system and begins to emit
  59816. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  59817. */
  59818. start(delay?: number): void;
  59819. /**
  59820. * Stops the particle system.
  59821. */
  59822. stop(): void;
  59823. /**
  59824. * Remove all active particles
  59825. */
  59826. reset(): void;
  59827. /**
  59828. * Returns the string "GPUParticleSystem"
  59829. * @returns a string containing the class name
  59830. */
  59831. getClassName(): string;
  59832. private _colorGradientsTexture;
  59833. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  59834. /**
  59835. * Adds a new color gradient
  59836. * @param gradient defines the gradient to use (between 0 and 1)
  59837. * @param color1 defines the color to affect to the specified gradient
  59838. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  59839. * @returns the current particle system
  59840. */
  59841. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  59842. /**
  59843. * Remove a specific color gradient
  59844. * @param gradient defines the gradient to remove
  59845. * @returns the current particle system
  59846. */
  59847. removeColorGradient(gradient: number): GPUParticleSystem;
  59848. private _angularSpeedGradientsTexture;
  59849. private _sizeGradientsTexture;
  59850. private _velocityGradientsTexture;
  59851. private _limitVelocityGradientsTexture;
  59852. private _dragGradientsTexture;
  59853. private _addFactorGradient;
  59854. /**
  59855. * Adds a new size gradient
  59856. * @param gradient defines the gradient to use (between 0 and 1)
  59857. * @param factor defines the size factor to affect to the specified gradient
  59858. * @returns the current particle system
  59859. */
  59860. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  59861. /**
  59862. * Remove a specific size gradient
  59863. * @param gradient defines the gradient to remove
  59864. * @returns the current particle system
  59865. */
  59866. removeSizeGradient(gradient: number): GPUParticleSystem;
  59867. /**
  59868. * Adds a new angular speed gradient
  59869. * @param gradient defines the gradient to use (between 0 and 1)
  59870. * @param factor defines the angular speed to affect to the specified gradient
  59871. * @returns the current particle system
  59872. */
  59873. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  59874. /**
  59875. * Remove a specific angular speed gradient
  59876. * @param gradient defines the gradient to remove
  59877. * @returns the current particle system
  59878. */
  59879. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  59880. /**
  59881. * Adds a new velocity gradient
  59882. * @param gradient defines the gradient to use (between 0 and 1)
  59883. * @param factor defines the velocity to affect to the specified gradient
  59884. * @returns the current particle system
  59885. */
  59886. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59887. /**
  59888. * Remove a specific velocity gradient
  59889. * @param gradient defines the gradient to remove
  59890. * @returns the current particle system
  59891. */
  59892. removeVelocityGradient(gradient: number): GPUParticleSystem;
  59893. /**
  59894. * Adds a new limit velocity gradient
  59895. * @param gradient defines the gradient to use (between 0 and 1)
  59896. * @param factor defines the limit velocity value to affect to the specified gradient
  59897. * @returns the current particle system
  59898. */
  59899. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59900. /**
  59901. * Remove a specific limit velocity gradient
  59902. * @param gradient defines the gradient to remove
  59903. * @returns the current particle system
  59904. */
  59905. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  59906. /**
  59907. * Adds a new drag gradient
  59908. * @param gradient defines the gradient to use (between 0 and 1)
  59909. * @param factor defines the drag value to affect to the specified gradient
  59910. * @returns the current particle system
  59911. */
  59912. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  59913. /**
  59914. * Remove a specific drag gradient
  59915. * @param gradient defines the gradient to remove
  59916. * @returns the current particle system
  59917. */
  59918. removeDragGradient(gradient: number): GPUParticleSystem;
  59919. /**
  59920. * Not supported by GPUParticleSystem
  59921. * @param gradient defines the gradient to use (between 0 and 1)
  59922. * @param factor defines the emit rate value to affect to the specified gradient
  59923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59924. * @returns the current particle system
  59925. */
  59926. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59927. /**
  59928. * Not supported by GPUParticleSystem
  59929. * @param gradient defines the gradient to remove
  59930. * @returns the current particle system
  59931. */
  59932. removeEmitRateGradient(gradient: number): IParticleSystem;
  59933. /**
  59934. * Not supported by GPUParticleSystem
  59935. * @param gradient defines the gradient to use (between 0 and 1)
  59936. * @param factor defines the start size value to affect to the specified gradient
  59937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59938. * @returns the current particle system
  59939. */
  59940. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59941. /**
  59942. * Not supported by GPUParticleSystem
  59943. * @param gradient defines the gradient to remove
  59944. * @returns the current particle system
  59945. */
  59946. removeStartSizeGradient(gradient: number): IParticleSystem;
  59947. /**
  59948. * Not supported by GPUParticleSystem
  59949. * @param gradient defines the gradient to use (between 0 and 1)
  59950. * @param min defines the color remap minimal range
  59951. * @param max defines the color remap maximal range
  59952. * @returns the current particle system
  59953. */
  59954. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  59955. /**
  59956. * Not supported by GPUParticleSystem
  59957. * @param gradient defines the gradient to remove
  59958. * @returns the current particle system
  59959. */
  59960. removeColorRemapGradient(): IParticleSystem;
  59961. /**
  59962. * Not supported by GPUParticleSystem
  59963. * @param gradient defines the gradient to use (between 0 and 1)
  59964. * @param min defines the alpha remap minimal range
  59965. * @param max defines the alpha remap maximal range
  59966. * @returns the current particle system
  59967. */
  59968. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  59969. /**
  59970. * Not supported by GPUParticleSystem
  59971. * @param gradient defines the gradient to remove
  59972. * @returns the current particle system
  59973. */
  59974. removeAlphaRemapGradient(): IParticleSystem;
  59975. /**
  59976. * Not supported by GPUParticleSystem
  59977. * @param gradient defines the gradient to use (between 0 and 1)
  59978. * @param color defines the color to affect to the specified gradient
  59979. * @returns the current particle system
  59980. */
  59981. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  59982. /**
  59983. * Not supported by GPUParticleSystem
  59984. * @param gradient defines the gradient to remove
  59985. * @returns the current particle system
  59986. */
  59987. removeRampGradient(): IParticleSystem;
  59988. /**
  59989. * Not supported by GPUParticleSystem
  59990. * @returns the list of ramp gradients
  59991. */
  59992. getRampGradients(): Nullable<Array<Color3Gradient>>;
  59993. /**
  59994. * Not supported by GPUParticleSystem
  59995. * Gets or sets a boolean indicating that ramp gradients must be used
  59996. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  59997. */
  59998. useRampGradients: boolean;
  59999. /**
  60000. * Not supported by GPUParticleSystem
  60001. * @param gradient defines the gradient to use (between 0 and 1)
  60002. * @param factor defines the life time factor to affect to the specified gradient
  60003. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60004. * @returns the current particle system
  60005. */
  60006. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60007. /**
  60008. * Not supported by GPUParticleSystem
  60009. * @param gradient defines the gradient to remove
  60010. * @returns the current particle system
  60011. */
  60012. removeLifeTimeGradient(gradient: number): IParticleSystem;
  60013. /**
  60014. * Instantiates a GPU particle system.
  60015. * 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.
  60016. * @param name The name of the particle system
  60017. * @param options The options used to create the system
  60018. * @param scene The scene the particle system belongs to
  60019. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  60020. */
  60021. constructor(name: string, options: Partial<{
  60022. capacity: number;
  60023. randomTextureSize: number;
  60024. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  60025. protected _reset(): void;
  60026. private _createUpdateVAO;
  60027. private _createRenderVAO;
  60028. private _initialize;
  60029. /** @hidden */
  60030. _recreateUpdateEffect(): void;
  60031. /** @hidden */
  60032. _recreateRenderEffect(): void;
  60033. /**
  60034. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  60035. * @param preWarm defines if we are in the pre-warmimg phase
  60036. */
  60037. animate(preWarm?: boolean): void;
  60038. private _createFactorGradientTexture;
  60039. private _createSizeGradientTexture;
  60040. private _createAngularSpeedGradientTexture;
  60041. private _createVelocityGradientTexture;
  60042. private _createLimitVelocityGradientTexture;
  60043. private _createDragGradientTexture;
  60044. private _createColorGradientTexture;
  60045. /**
  60046. * Renders the particle system in its current state
  60047. * @param preWarm defines if the system should only update the particles but not render them
  60048. * @returns the current number of particles
  60049. */
  60050. render(preWarm?: boolean): number;
  60051. /**
  60052. * Rebuilds the particle system
  60053. */
  60054. rebuild(): void;
  60055. private _releaseBuffers;
  60056. private _releaseVAOs;
  60057. /**
  60058. * Disposes the particle system and free the associated resources
  60059. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  60060. */
  60061. dispose(disposeTexture?: boolean): void;
  60062. /**
  60063. * Clones the particle system.
  60064. * @param name The name of the cloned object
  60065. * @param newEmitter The new emitter to use
  60066. * @returns the cloned particle system
  60067. */
  60068. clone(name: string, newEmitter: any): GPUParticleSystem;
  60069. /**
  60070. * Serializes the particle system to a JSON object.
  60071. * @returns the JSON object
  60072. */
  60073. serialize(): any;
  60074. /**
  60075. * Parses a JSON object to create a GPU particle system.
  60076. * @param parsedParticleSystem The JSON object to parse
  60077. * @param scene The scene to create the particle system in
  60078. * @param rootUrl The root url to use to load external dependencies like texture
  60079. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  60080. * @returns the parsed GPU particle system
  60081. */
  60082. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  60083. }
  60084. }
  60085. declare module "babylonjs/Particles/particleSystemSet" {
  60086. import { Nullable } from "babylonjs/types";
  60087. import { Color3 } from "babylonjs/Maths/math.color";
  60088. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60089. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60090. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60091. import { Scene, IDisposable } from "babylonjs/scene";
  60092. /**
  60093. * Represents a set of particle systems working together to create a specific effect
  60094. */
  60095. export class ParticleSystemSet implements IDisposable {
  60096. private _emitterCreationOptions;
  60097. private _emitterNode;
  60098. /**
  60099. * Gets the particle system list
  60100. */
  60101. systems: IParticleSystem[];
  60102. /**
  60103. * Gets the emitter node used with this set
  60104. */
  60105. readonly emitterNode: Nullable<TransformNode>;
  60106. /**
  60107. * Creates a new emitter mesh as a sphere
  60108. * @param options defines the options used to create the sphere
  60109. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  60110. * @param scene defines the hosting scene
  60111. */
  60112. setEmitterAsSphere(options: {
  60113. diameter: number;
  60114. segments: number;
  60115. color: Color3;
  60116. }, renderingGroupId: number, scene: Scene): void;
  60117. /**
  60118. * Starts all particle systems of the set
  60119. * @param emitter defines an optional mesh to use as emitter for the particle systems
  60120. */
  60121. start(emitter?: AbstractMesh): void;
  60122. /**
  60123. * Release all associated resources
  60124. */
  60125. dispose(): void;
  60126. /**
  60127. * Serialize the set into a JSON compatible object
  60128. * @returns a JSON compatible representation of the set
  60129. */
  60130. serialize(): any;
  60131. /**
  60132. * Parse a new ParticleSystemSet from a serialized source
  60133. * @param data defines a JSON compatible representation of the set
  60134. * @param scene defines the hosting scene
  60135. * @param gpu defines if we want GPU particles or CPU particles
  60136. * @returns a new ParticleSystemSet
  60137. */
  60138. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  60139. }
  60140. }
  60141. declare module "babylonjs/Particles/particleHelper" {
  60142. import { Nullable } from "babylonjs/types";
  60143. import { Scene } from "babylonjs/scene";
  60144. import { Vector3 } from "babylonjs/Maths/math.vector";
  60145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60146. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60147. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  60148. /**
  60149. * This class is made for on one-liner static method to help creating particle system set.
  60150. */
  60151. export class ParticleHelper {
  60152. /**
  60153. * Gets or sets base Assets URL
  60154. */
  60155. static BaseAssetsUrl: string;
  60156. /**
  60157. * Create a default particle system that you can tweak
  60158. * @param emitter defines the emitter to use
  60159. * @param capacity defines the system capacity (default is 500 particles)
  60160. * @param scene defines the hosting scene
  60161. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  60162. * @returns the new Particle system
  60163. */
  60164. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  60165. /**
  60166. * This is the main static method (one-liner) of this helper to create different particle systems
  60167. * @param type This string represents the type to the particle system to create
  60168. * @param scene The scene where the particle system should live
  60169. * @param gpu If the system will use gpu
  60170. * @returns the ParticleSystemSet created
  60171. */
  60172. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  60173. /**
  60174. * Static function used to export a particle system to a ParticleSystemSet variable.
  60175. * Please note that the emitter shape is not exported
  60176. * @param systems defines the particle systems to export
  60177. * @returns the created particle system set
  60178. */
  60179. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  60180. }
  60181. }
  60182. declare module "babylonjs/Particles/particleSystemComponent" {
  60183. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60184. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  60185. import "babylonjs/Shaders/particles.vertex";
  60186. module "babylonjs/Engines/engine" {
  60187. interface Engine {
  60188. /**
  60189. * Create an effect to use with particle systems.
  60190. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  60191. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  60192. * @param uniformsNames defines a list of attribute names
  60193. * @param samplers defines an array of string used to represent textures
  60194. * @param defines defines the string containing the defines to use to compile the shaders
  60195. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  60196. * @param onCompiled defines a function to call when the effect creation is successful
  60197. * @param onError defines a function to call when the effect creation has failed
  60198. * @returns the new Effect
  60199. */
  60200. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  60201. }
  60202. }
  60203. module "babylonjs/Meshes/mesh" {
  60204. interface Mesh {
  60205. /**
  60206. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  60207. * @returns an array of IParticleSystem
  60208. */
  60209. getEmittedParticleSystems(): IParticleSystem[];
  60210. /**
  60211. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  60212. * @returns an array of IParticleSystem
  60213. */
  60214. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  60215. }
  60216. }
  60217. /**
  60218. * @hidden
  60219. */
  60220. export var _IDoNeedToBeInTheBuild: number;
  60221. }
  60222. declare module "babylonjs/Particles/index" {
  60223. export * from "babylonjs/Particles/baseParticleSystem";
  60224. export * from "babylonjs/Particles/EmitterTypes/index";
  60225. export * from "babylonjs/Particles/gpuParticleSystem";
  60226. export * from "babylonjs/Particles/IParticleSystem";
  60227. export * from "babylonjs/Particles/particle";
  60228. export * from "babylonjs/Particles/particleHelper";
  60229. export * from "babylonjs/Particles/particleSystem";
  60230. export * from "babylonjs/Particles/particleSystemComponent";
  60231. export * from "babylonjs/Particles/particleSystemSet";
  60232. export * from "babylonjs/Particles/solidParticle";
  60233. export * from "babylonjs/Particles/solidParticleSystem";
  60234. export * from "babylonjs/Particles/subEmitter";
  60235. }
  60236. declare module "babylonjs/Physics/physicsEngineComponent" {
  60237. import { Nullable } from "babylonjs/types";
  60238. import { Observable, Observer } from "babylonjs/Misc/observable";
  60239. import { Vector3 } from "babylonjs/Maths/math.vector";
  60240. import { Mesh } from "babylonjs/Meshes/mesh";
  60241. import { ISceneComponent } from "babylonjs/sceneComponent";
  60242. import { Scene } from "babylonjs/scene";
  60243. import { Node } from "babylonjs/node";
  60244. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  60245. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60246. module "babylonjs/scene" {
  60247. interface Scene {
  60248. /** @hidden (Backing field) */
  60249. _physicsEngine: Nullable<IPhysicsEngine>;
  60250. /**
  60251. * Gets the current physics engine
  60252. * @returns a IPhysicsEngine or null if none attached
  60253. */
  60254. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  60255. /**
  60256. * Enables physics to the current scene
  60257. * @param gravity defines the scene's gravity for the physics engine
  60258. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  60259. * @return a boolean indicating if the physics engine was initialized
  60260. */
  60261. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  60262. /**
  60263. * Disables and disposes the physics engine associated with the scene
  60264. */
  60265. disablePhysicsEngine(): void;
  60266. /**
  60267. * Gets a boolean indicating if there is an active physics engine
  60268. * @returns a boolean indicating if there is an active physics engine
  60269. */
  60270. isPhysicsEnabled(): boolean;
  60271. /**
  60272. * Deletes a physics compound impostor
  60273. * @param compound defines the compound to delete
  60274. */
  60275. deleteCompoundImpostor(compound: any): void;
  60276. /**
  60277. * An event triggered when physic simulation is about to be run
  60278. */
  60279. onBeforePhysicsObservable: Observable<Scene>;
  60280. /**
  60281. * An event triggered when physic simulation has been done
  60282. */
  60283. onAfterPhysicsObservable: Observable<Scene>;
  60284. }
  60285. }
  60286. module "babylonjs/Meshes/abstractMesh" {
  60287. interface AbstractMesh {
  60288. /** @hidden */
  60289. _physicsImpostor: Nullable<PhysicsImpostor>;
  60290. /**
  60291. * Gets or sets impostor used for physic simulation
  60292. * @see http://doc.babylonjs.com/features/physics_engine
  60293. */
  60294. physicsImpostor: Nullable<PhysicsImpostor>;
  60295. /**
  60296. * Gets the current physics impostor
  60297. * @see http://doc.babylonjs.com/features/physics_engine
  60298. * @returns a physics impostor or null
  60299. */
  60300. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  60301. /** Apply a physic impulse to the mesh
  60302. * @param force defines the force to apply
  60303. * @param contactPoint defines where to apply the force
  60304. * @returns the current mesh
  60305. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  60306. */
  60307. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  60308. /**
  60309. * Creates a physic joint between two meshes
  60310. * @param otherMesh defines the other mesh to use
  60311. * @param pivot1 defines the pivot to use on this mesh
  60312. * @param pivot2 defines the pivot to use on the other mesh
  60313. * @param options defines additional options (can be plugin dependent)
  60314. * @returns the current mesh
  60315. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  60316. */
  60317. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  60318. /** @hidden */
  60319. _disposePhysicsObserver: Nullable<Observer<Node>>;
  60320. }
  60321. }
  60322. /**
  60323. * Defines the physics engine scene component responsible to manage a physics engine
  60324. */
  60325. export class PhysicsEngineSceneComponent implements ISceneComponent {
  60326. /**
  60327. * The component name helpful to identify the component in the list of scene components.
  60328. */
  60329. readonly name: string;
  60330. /**
  60331. * The scene the component belongs to.
  60332. */
  60333. scene: Scene;
  60334. /**
  60335. * Creates a new instance of the component for the given scene
  60336. * @param scene Defines the scene to register the component in
  60337. */
  60338. constructor(scene: Scene);
  60339. /**
  60340. * Registers the component in a given scene
  60341. */
  60342. register(): void;
  60343. /**
  60344. * Rebuilds the elements related to this component in case of
  60345. * context lost for instance.
  60346. */
  60347. rebuild(): void;
  60348. /**
  60349. * Disposes the component and the associated ressources
  60350. */
  60351. dispose(): void;
  60352. }
  60353. }
  60354. declare module "babylonjs/Physics/physicsHelper" {
  60355. import { Nullable } from "babylonjs/types";
  60356. import { Vector3 } from "babylonjs/Maths/math.vector";
  60357. import { Mesh } from "babylonjs/Meshes/mesh";
  60358. import { Scene } from "babylonjs/scene";
  60359. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60360. /**
  60361. * A helper for physics simulations
  60362. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60363. */
  60364. export class PhysicsHelper {
  60365. private _scene;
  60366. private _physicsEngine;
  60367. /**
  60368. * Initializes the Physics helper
  60369. * @param scene Babylon.js scene
  60370. */
  60371. constructor(scene: Scene);
  60372. /**
  60373. * Applies a radial explosion impulse
  60374. * @param origin the origin of the explosion
  60375. * @param radiusOrEventOptions the radius or the options of radial explosion
  60376. * @param strength the explosion strength
  60377. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60378. * @returns A physics radial explosion event, or null
  60379. */
  60380. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60381. /**
  60382. * Applies a radial explosion force
  60383. * @param origin the origin of the explosion
  60384. * @param radiusOrEventOptions the radius or the options of radial explosion
  60385. * @param strength the explosion strength
  60386. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60387. * @returns A physics radial explosion event, or null
  60388. */
  60389. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60390. /**
  60391. * Creates a gravitational field
  60392. * @param origin the origin of the explosion
  60393. * @param radiusOrEventOptions the radius or the options of radial explosion
  60394. * @param strength the explosion strength
  60395. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60396. * @returns A physics gravitational field event, or null
  60397. */
  60398. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  60399. /**
  60400. * Creates a physics updraft event
  60401. * @param origin the origin of the updraft
  60402. * @param radiusOrEventOptions the radius or the options of the updraft
  60403. * @param strength the strength of the updraft
  60404. * @param height the height of the updraft
  60405. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  60406. * @returns A physics updraft event, or null
  60407. */
  60408. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  60409. /**
  60410. * Creates a physics vortex event
  60411. * @param origin the of the vortex
  60412. * @param radiusOrEventOptions the radius or the options of the vortex
  60413. * @param strength the strength of the vortex
  60414. * @param height the height of the vortex
  60415. * @returns a Physics vortex event, or null
  60416. * A physics vortex event or null
  60417. */
  60418. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  60419. }
  60420. /**
  60421. * Represents a physics radial explosion event
  60422. */
  60423. class PhysicsRadialExplosionEvent {
  60424. private _scene;
  60425. private _options;
  60426. private _sphere;
  60427. private _dataFetched;
  60428. /**
  60429. * Initializes a radial explosioin event
  60430. * @param _scene BabylonJS scene
  60431. * @param _options The options for the vortex event
  60432. */
  60433. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  60434. /**
  60435. * Returns the data related to the radial explosion event (sphere).
  60436. * @returns The radial explosion event data
  60437. */
  60438. getData(): PhysicsRadialExplosionEventData;
  60439. /**
  60440. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  60441. * @param impostor A physics imposter
  60442. * @param origin the origin of the explosion
  60443. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  60444. */
  60445. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  60446. /**
  60447. * Triggers affecterd impostors callbacks
  60448. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  60449. */
  60450. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  60451. /**
  60452. * Disposes the sphere.
  60453. * @param force Specifies if the sphere should be disposed by force
  60454. */
  60455. dispose(force?: boolean): void;
  60456. /*** Helpers ***/
  60457. private _prepareSphere;
  60458. private _intersectsWithSphere;
  60459. }
  60460. /**
  60461. * Represents a gravitational field event
  60462. */
  60463. class PhysicsGravitationalFieldEvent {
  60464. private _physicsHelper;
  60465. private _scene;
  60466. private _origin;
  60467. private _options;
  60468. private _tickCallback;
  60469. private _sphere;
  60470. private _dataFetched;
  60471. /**
  60472. * Initializes the physics gravitational field event
  60473. * @param _physicsHelper A physics helper
  60474. * @param _scene BabylonJS scene
  60475. * @param _origin The origin position of the gravitational field event
  60476. * @param _options The options for the vortex event
  60477. */
  60478. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  60479. /**
  60480. * Returns the data related to the gravitational field event (sphere).
  60481. * @returns A gravitational field event
  60482. */
  60483. getData(): PhysicsGravitationalFieldEventData;
  60484. /**
  60485. * Enables the gravitational field.
  60486. */
  60487. enable(): void;
  60488. /**
  60489. * Disables the gravitational field.
  60490. */
  60491. disable(): void;
  60492. /**
  60493. * Disposes the sphere.
  60494. * @param force The force to dispose from the gravitational field event
  60495. */
  60496. dispose(force?: boolean): void;
  60497. private _tick;
  60498. }
  60499. /**
  60500. * Represents a physics updraft event
  60501. */
  60502. class PhysicsUpdraftEvent {
  60503. private _scene;
  60504. private _origin;
  60505. private _options;
  60506. private _physicsEngine;
  60507. private _originTop;
  60508. private _originDirection;
  60509. private _tickCallback;
  60510. private _cylinder;
  60511. private _cylinderPosition;
  60512. private _dataFetched;
  60513. /**
  60514. * Initializes the physics updraft event
  60515. * @param _scene BabylonJS scene
  60516. * @param _origin The origin position of the updraft
  60517. * @param _options The options for the updraft event
  60518. */
  60519. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  60520. /**
  60521. * Returns the data related to the updraft event (cylinder).
  60522. * @returns A physics updraft event
  60523. */
  60524. getData(): PhysicsUpdraftEventData;
  60525. /**
  60526. * Enables the updraft.
  60527. */
  60528. enable(): void;
  60529. /**
  60530. * Disables the updraft.
  60531. */
  60532. disable(): void;
  60533. /**
  60534. * Disposes the cylinder.
  60535. * @param force Specifies if the updraft should be disposed by force
  60536. */
  60537. dispose(force?: boolean): void;
  60538. private getImpostorHitData;
  60539. private _tick;
  60540. /*** Helpers ***/
  60541. private _prepareCylinder;
  60542. private _intersectsWithCylinder;
  60543. }
  60544. /**
  60545. * Represents a physics vortex event
  60546. */
  60547. class PhysicsVortexEvent {
  60548. private _scene;
  60549. private _origin;
  60550. private _options;
  60551. private _physicsEngine;
  60552. private _originTop;
  60553. private _tickCallback;
  60554. private _cylinder;
  60555. private _cylinderPosition;
  60556. private _dataFetched;
  60557. /**
  60558. * Initializes the physics vortex event
  60559. * @param _scene The BabylonJS scene
  60560. * @param _origin The origin position of the vortex
  60561. * @param _options The options for the vortex event
  60562. */
  60563. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  60564. /**
  60565. * Returns the data related to the vortex event (cylinder).
  60566. * @returns The physics vortex event data
  60567. */
  60568. getData(): PhysicsVortexEventData;
  60569. /**
  60570. * Enables the vortex.
  60571. */
  60572. enable(): void;
  60573. /**
  60574. * Disables the cortex.
  60575. */
  60576. disable(): void;
  60577. /**
  60578. * Disposes the sphere.
  60579. * @param force
  60580. */
  60581. dispose(force?: boolean): void;
  60582. private getImpostorHitData;
  60583. private _tick;
  60584. /*** Helpers ***/
  60585. private _prepareCylinder;
  60586. private _intersectsWithCylinder;
  60587. }
  60588. /**
  60589. * Options fot the radial explosion event
  60590. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60591. */
  60592. export class PhysicsRadialExplosionEventOptions {
  60593. /**
  60594. * The radius of the sphere for the radial explosion.
  60595. */
  60596. radius: number;
  60597. /**
  60598. * The strenth of the explosion.
  60599. */
  60600. strength: number;
  60601. /**
  60602. * The strenght of the force in correspondence to the distance of the affected object
  60603. */
  60604. falloff: PhysicsRadialImpulseFalloff;
  60605. /**
  60606. * Sphere options for the radial explosion.
  60607. */
  60608. sphere: {
  60609. segments: number;
  60610. diameter: number;
  60611. };
  60612. /**
  60613. * Sphere options for the radial explosion.
  60614. */
  60615. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  60616. }
  60617. /**
  60618. * Options fot the updraft event
  60619. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60620. */
  60621. export class PhysicsUpdraftEventOptions {
  60622. /**
  60623. * The radius of the cylinder for the vortex
  60624. */
  60625. radius: number;
  60626. /**
  60627. * The strenth of the updraft.
  60628. */
  60629. strength: number;
  60630. /**
  60631. * The height of the cylinder for the updraft.
  60632. */
  60633. height: number;
  60634. /**
  60635. * The mode for the the updraft.
  60636. */
  60637. updraftMode: PhysicsUpdraftMode;
  60638. }
  60639. /**
  60640. * Options fot the vortex event
  60641. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60642. */
  60643. export class PhysicsVortexEventOptions {
  60644. /**
  60645. * The radius of the cylinder for the vortex
  60646. */
  60647. radius: number;
  60648. /**
  60649. * The strenth of the vortex.
  60650. */
  60651. strength: number;
  60652. /**
  60653. * The height of the cylinder for the vortex.
  60654. */
  60655. height: number;
  60656. /**
  60657. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  60658. */
  60659. centripetalForceThreshold: number;
  60660. /**
  60661. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  60662. */
  60663. centripetalForceMultiplier: number;
  60664. /**
  60665. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  60666. */
  60667. centrifugalForceMultiplier: number;
  60668. /**
  60669. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  60670. */
  60671. updraftForceMultiplier: number;
  60672. }
  60673. /**
  60674. * The strenght of the force in correspondence to the distance of the affected object
  60675. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60676. */
  60677. export enum PhysicsRadialImpulseFalloff {
  60678. /** Defines that impulse is constant in strength across it's whole radius */
  60679. Constant = 0,
  60680. /** Defines that impulse gets weaker if it's further from the origin */
  60681. Linear = 1
  60682. }
  60683. /**
  60684. * The strength of the force in correspondence to the distance of the affected object
  60685. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60686. */
  60687. export enum PhysicsUpdraftMode {
  60688. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  60689. Center = 0,
  60690. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  60691. Perpendicular = 1
  60692. }
  60693. /**
  60694. * Interface for a physics hit data
  60695. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60696. */
  60697. export interface PhysicsHitData {
  60698. /**
  60699. * The force applied at the contact point
  60700. */
  60701. force: Vector3;
  60702. /**
  60703. * The contact point
  60704. */
  60705. contactPoint: Vector3;
  60706. /**
  60707. * The distance from the origin to the contact point
  60708. */
  60709. distanceFromOrigin: number;
  60710. }
  60711. /**
  60712. * Interface for radial explosion event data
  60713. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60714. */
  60715. export interface PhysicsRadialExplosionEventData {
  60716. /**
  60717. * A sphere used for the radial explosion event
  60718. */
  60719. sphere: Mesh;
  60720. }
  60721. /**
  60722. * Interface for gravitational field event data
  60723. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60724. */
  60725. export interface PhysicsGravitationalFieldEventData {
  60726. /**
  60727. * A sphere mesh used for the gravitational field event
  60728. */
  60729. sphere: Mesh;
  60730. }
  60731. /**
  60732. * Interface for updraft event data
  60733. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60734. */
  60735. export interface PhysicsUpdraftEventData {
  60736. /**
  60737. * A cylinder used for the updraft event
  60738. */
  60739. cylinder: Mesh;
  60740. }
  60741. /**
  60742. * Interface for vortex event data
  60743. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60744. */
  60745. export interface PhysicsVortexEventData {
  60746. /**
  60747. * A cylinder used for the vortex event
  60748. */
  60749. cylinder: Mesh;
  60750. }
  60751. /**
  60752. * Interface for an affected physics impostor
  60753. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60754. */
  60755. export interface PhysicsAffectedImpostorWithData {
  60756. /**
  60757. * The impostor affected by the effect
  60758. */
  60759. impostor: PhysicsImpostor;
  60760. /**
  60761. * The data about the hit/horce from the explosion
  60762. */
  60763. hitData: PhysicsHitData;
  60764. }
  60765. }
  60766. declare module "babylonjs/Physics/Plugins/index" {
  60767. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  60768. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  60769. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  60770. }
  60771. declare module "babylonjs/Physics/index" {
  60772. export * from "babylonjs/Physics/IPhysicsEngine";
  60773. export * from "babylonjs/Physics/physicsEngine";
  60774. export * from "babylonjs/Physics/physicsEngineComponent";
  60775. export * from "babylonjs/Physics/physicsHelper";
  60776. export * from "babylonjs/Physics/physicsImpostor";
  60777. export * from "babylonjs/Physics/physicsJoint";
  60778. export * from "babylonjs/Physics/Plugins/index";
  60779. }
  60780. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  60781. /** @hidden */
  60782. export var blackAndWhitePixelShader: {
  60783. name: string;
  60784. shader: string;
  60785. };
  60786. }
  60787. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  60788. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60789. import { Camera } from "babylonjs/Cameras/camera";
  60790. import { Engine } from "babylonjs/Engines/engine";
  60791. import "babylonjs/Shaders/blackAndWhite.fragment";
  60792. /**
  60793. * Post process used to render in black and white
  60794. */
  60795. export class BlackAndWhitePostProcess extends PostProcess {
  60796. /**
  60797. * Linear about to convert he result to black and white (default: 1)
  60798. */
  60799. degree: number;
  60800. /**
  60801. * Creates a black and white post process
  60802. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  60803. * @param name The name of the effect.
  60804. * @param options The required width/height ratio to downsize to before computing the render pass.
  60805. * @param camera The camera to apply the render pass to.
  60806. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60807. * @param engine The engine which the post process will be applied. (default: current engine)
  60808. * @param reusable If the post process can be reused on the same frame. (default: false)
  60809. */
  60810. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60811. }
  60812. }
  60813. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  60814. import { Nullable } from "babylonjs/types";
  60815. import { Camera } from "babylonjs/Cameras/camera";
  60816. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60817. import { Engine } from "babylonjs/Engines/engine";
  60818. /**
  60819. * This represents a set of one or more post processes in Babylon.
  60820. * A post process can be used to apply a shader to a texture after it is rendered.
  60821. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60822. */
  60823. export class PostProcessRenderEffect {
  60824. private _postProcesses;
  60825. private _getPostProcesses;
  60826. private _singleInstance;
  60827. private _cameras;
  60828. private _indicesForCamera;
  60829. /**
  60830. * Name of the effect
  60831. * @hidden
  60832. */
  60833. _name: string;
  60834. /**
  60835. * Instantiates a post process render effect.
  60836. * A post process can be used to apply a shader to a texture after it is rendered.
  60837. * @param engine The engine the effect is tied to
  60838. * @param name The name of the effect
  60839. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  60840. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  60841. */
  60842. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  60843. /**
  60844. * Checks if all the post processes in the effect are supported.
  60845. */
  60846. readonly isSupported: boolean;
  60847. /**
  60848. * Updates the current state of the effect
  60849. * @hidden
  60850. */
  60851. _update(): void;
  60852. /**
  60853. * Attaches the effect on cameras
  60854. * @param cameras The camera to attach to.
  60855. * @hidden
  60856. */
  60857. _attachCameras(cameras: Camera): void;
  60858. /**
  60859. * Attaches the effect on cameras
  60860. * @param cameras The camera to attach to.
  60861. * @hidden
  60862. */
  60863. _attachCameras(cameras: Camera[]): void;
  60864. /**
  60865. * Detaches the effect on cameras
  60866. * @param cameras The camera to detatch from.
  60867. * @hidden
  60868. */
  60869. _detachCameras(cameras: Camera): void;
  60870. /**
  60871. * Detatches the effect on cameras
  60872. * @param cameras The camera to detatch from.
  60873. * @hidden
  60874. */
  60875. _detachCameras(cameras: Camera[]): void;
  60876. /**
  60877. * Enables the effect on given cameras
  60878. * @param cameras The camera to enable.
  60879. * @hidden
  60880. */
  60881. _enable(cameras: Camera): void;
  60882. /**
  60883. * Enables the effect on given cameras
  60884. * @param cameras The camera to enable.
  60885. * @hidden
  60886. */
  60887. _enable(cameras: Nullable<Camera[]>): void;
  60888. /**
  60889. * Disables the effect on the given cameras
  60890. * @param cameras The camera to disable.
  60891. * @hidden
  60892. */
  60893. _disable(cameras: Camera): void;
  60894. /**
  60895. * Disables the effect on the given cameras
  60896. * @param cameras The camera to disable.
  60897. * @hidden
  60898. */
  60899. _disable(cameras: Nullable<Camera[]>): void;
  60900. /**
  60901. * Gets a list of the post processes contained in the effect.
  60902. * @param camera The camera to get the post processes on.
  60903. * @returns The list of the post processes in the effect.
  60904. */
  60905. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  60906. }
  60907. }
  60908. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  60909. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60910. /** @hidden */
  60911. export var extractHighlightsPixelShader: {
  60912. name: string;
  60913. shader: string;
  60914. };
  60915. }
  60916. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  60917. import { Nullable } from "babylonjs/types";
  60918. import { Camera } from "babylonjs/Cameras/camera";
  60919. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60920. import { Engine } from "babylonjs/Engines/engine";
  60921. import "babylonjs/Shaders/extractHighlights.fragment";
  60922. /**
  60923. * 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.
  60924. */
  60925. export class ExtractHighlightsPostProcess extends PostProcess {
  60926. /**
  60927. * The luminance threshold, pixels below this value will be set to black.
  60928. */
  60929. threshold: number;
  60930. /** @hidden */
  60931. _exposure: number;
  60932. /**
  60933. * Post process which has the input texture to be used when performing highlight extraction
  60934. * @hidden
  60935. */
  60936. _inputPostProcess: Nullable<PostProcess>;
  60937. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60938. }
  60939. }
  60940. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  60941. /** @hidden */
  60942. export var bloomMergePixelShader: {
  60943. name: string;
  60944. shader: string;
  60945. };
  60946. }
  60947. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  60948. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60949. import { Nullable } from "babylonjs/types";
  60950. import { Engine } from "babylonjs/Engines/engine";
  60951. import { Camera } from "babylonjs/Cameras/camera";
  60952. import "babylonjs/Shaders/bloomMerge.fragment";
  60953. /**
  60954. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  60955. */
  60956. export class BloomMergePostProcess extends PostProcess {
  60957. /** Weight of the bloom to be added to the original input. */
  60958. weight: number;
  60959. /**
  60960. * Creates a new instance of @see BloomMergePostProcess
  60961. * @param name The name of the effect.
  60962. * @param originalFromInput Post process which's input will be used for the merge.
  60963. * @param blurred Blurred highlights post process which's output will be used.
  60964. * @param weight Weight of the bloom to be added to the original input.
  60965. * @param options The required width/height ratio to downsize to before computing the render pass.
  60966. * @param camera The camera to apply the render pass to.
  60967. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60968. * @param engine The engine which the post process will be applied. (default: current engine)
  60969. * @param reusable If the post process can be reused on the same frame. (default: false)
  60970. * @param textureType Type of textures used when performing the post process. (default: 0)
  60971. * @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)
  60972. */
  60973. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  60974. /** Weight of the bloom to be added to the original input. */
  60975. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60976. }
  60977. }
  60978. declare module "babylonjs/PostProcesses/bloomEffect" {
  60979. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60980. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60981. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  60982. import { Camera } from "babylonjs/Cameras/camera";
  60983. import { Scene } from "babylonjs/scene";
  60984. /**
  60985. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  60986. */
  60987. export class BloomEffect extends PostProcessRenderEffect {
  60988. private bloomScale;
  60989. /**
  60990. * @hidden Internal
  60991. */
  60992. _effects: Array<PostProcess>;
  60993. /**
  60994. * @hidden Internal
  60995. */
  60996. _downscale: ExtractHighlightsPostProcess;
  60997. private _blurX;
  60998. private _blurY;
  60999. private _merge;
  61000. /**
  61001. * The luminance threshold to find bright areas of the image to bloom.
  61002. */
  61003. threshold: number;
  61004. /**
  61005. * The strength of the bloom.
  61006. */
  61007. weight: number;
  61008. /**
  61009. * Specifies the size of the bloom blur kernel, relative to the final output size
  61010. */
  61011. kernel: number;
  61012. /**
  61013. * Creates a new instance of @see BloomEffect
  61014. * @param scene The scene the effect belongs to.
  61015. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  61016. * @param bloomKernel The size of the kernel to be used when applying the blur.
  61017. * @param bloomWeight The the strength of bloom.
  61018. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61019. * @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)
  61020. */
  61021. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  61022. /**
  61023. * Disposes each of the internal effects for a given camera.
  61024. * @param camera The camera to dispose the effect on.
  61025. */
  61026. disposeEffects(camera: Camera): void;
  61027. /**
  61028. * @hidden Internal
  61029. */
  61030. _updateEffects(): void;
  61031. /**
  61032. * Internal
  61033. * @returns if all the contained post processes are ready.
  61034. * @hidden
  61035. */
  61036. _isReady(): boolean;
  61037. }
  61038. }
  61039. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  61040. /** @hidden */
  61041. export var chromaticAberrationPixelShader: {
  61042. name: string;
  61043. shader: string;
  61044. };
  61045. }
  61046. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  61047. import { Vector2 } from "babylonjs/Maths/math.vector";
  61048. import { Nullable } from "babylonjs/types";
  61049. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61050. import { Camera } from "babylonjs/Cameras/camera";
  61051. import { Engine } from "babylonjs/Engines/engine";
  61052. import "babylonjs/Shaders/chromaticAberration.fragment";
  61053. /**
  61054. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  61055. */
  61056. export class ChromaticAberrationPostProcess extends PostProcess {
  61057. /**
  61058. * The amount of seperation of rgb channels (default: 30)
  61059. */
  61060. aberrationAmount: number;
  61061. /**
  61062. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  61063. */
  61064. radialIntensity: number;
  61065. /**
  61066. * 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))
  61067. */
  61068. direction: Vector2;
  61069. /**
  61070. * 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))
  61071. */
  61072. centerPosition: Vector2;
  61073. /**
  61074. * Creates a new instance ChromaticAberrationPostProcess
  61075. * @param name The name of the effect.
  61076. * @param screenWidth The width of the screen to apply the effect on.
  61077. * @param screenHeight The height of the screen to apply the effect on.
  61078. * @param options The required width/height ratio to downsize to before computing the render pass.
  61079. * @param camera The camera to apply the render pass to.
  61080. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61081. * @param engine The engine which the post process will be applied. (default: current engine)
  61082. * @param reusable If the post process can be reused on the same frame. (default: false)
  61083. * @param textureType Type of textures used when performing the post process. (default: 0)
  61084. * @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)
  61085. */
  61086. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61087. }
  61088. }
  61089. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  61090. /** @hidden */
  61091. export var circleOfConfusionPixelShader: {
  61092. name: string;
  61093. shader: string;
  61094. };
  61095. }
  61096. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  61097. import { Nullable } from "babylonjs/types";
  61098. import { Engine } from "babylonjs/Engines/engine";
  61099. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61100. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61101. import { Camera } from "babylonjs/Cameras/camera";
  61102. import "babylonjs/Shaders/circleOfConfusion.fragment";
  61103. /**
  61104. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  61105. */
  61106. export class CircleOfConfusionPostProcess extends PostProcess {
  61107. /**
  61108. * 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.
  61109. */
  61110. lensSize: number;
  61111. /**
  61112. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61113. */
  61114. fStop: number;
  61115. /**
  61116. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61117. */
  61118. focusDistance: number;
  61119. /**
  61120. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  61121. */
  61122. focalLength: number;
  61123. private _depthTexture;
  61124. /**
  61125. * Creates a new instance CircleOfConfusionPostProcess
  61126. * @param name The name of the effect.
  61127. * @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.
  61128. * @param options The required width/height ratio to downsize to before computing the render pass.
  61129. * @param camera The camera to apply the render pass to.
  61130. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61131. * @param engine The engine which the post process will be applied. (default: current engine)
  61132. * @param reusable If the post process can be reused on the same frame. (default: false)
  61133. * @param textureType Type of textures used when performing the post process. (default: 0)
  61134. * @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)
  61135. */
  61136. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61137. /**
  61138. * 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.
  61139. */
  61140. depthTexture: RenderTargetTexture;
  61141. }
  61142. }
  61143. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  61144. /** @hidden */
  61145. export var colorCorrectionPixelShader: {
  61146. name: string;
  61147. shader: string;
  61148. };
  61149. }
  61150. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  61151. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61152. import { Engine } from "babylonjs/Engines/engine";
  61153. import { Camera } from "babylonjs/Cameras/camera";
  61154. import "babylonjs/Shaders/colorCorrection.fragment";
  61155. /**
  61156. *
  61157. * This post-process allows the modification of rendered colors by using
  61158. * a 'look-up table' (LUT). This effect is also called Color Grading.
  61159. *
  61160. * The object needs to be provided an url to a texture containing the color
  61161. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  61162. * Use an image editing software to tweak the LUT to match your needs.
  61163. *
  61164. * For an example of a color LUT, see here:
  61165. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  61166. * For explanations on color grading, see here:
  61167. * @see http://udn.epicgames.com/Three/ColorGrading.html
  61168. *
  61169. */
  61170. export class ColorCorrectionPostProcess extends PostProcess {
  61171. private _colorTableTexture;
  61172. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61173. }
  61174. }
  61175. declare module "babylonjs/Shaders/convolution.fragment" {
  61176. /** @hidden */
  61177. export var convolutionPixelShader: {
  61178. name: string;
  61179. shader: string;
  61180. };
  61181. }
  61182. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  61183. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61184. import { Nullable } from "babylonjs/types";
  61185. import { Camera } from "babylonjs/Cameras/camera";
  61186. import { Engine } from "babylonjs/Engines/engine";
  61187. import "babylonjs/Shaders/convolution.fragment";
  61188. /**
  61189. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  61190. * input texture to perform effects such as edge detection or sharpening
  61191. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61192. */
  61193. export class ConvolutionPostProcess extends PostProcess {
  61194. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61195. kernel: number[];
  61196. /**
  61197. * Creates a new instance ConvolutionPostProcess
  61198. * @param name The name of the effect.
  61199. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  61200. * @param options The required width/height ratio to downsize to before computing the render pass.
  61201. * @param camera The camera to apply the render pass to.
  61202. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61203. * @param engine The engine which the post process will be applied. (default: current engine)
  61204. * @param reusable If the post process can be reused on the same frame. (default: false)
  61205. * @param textureType Type of textures used when performing the post process. (default: 0)
  61206. */
  61207. constructor(name: string,
  61208. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61209. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61210. /**
  61211. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61212. */
  61213. static EdgeDetect0Kernel: number[];
  61214. /**
  61215. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61216. */
  61217. static EdgeDetect1Kernel: number[];
  61218. /**
  61219. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61220. */
  61221. static EdgeDetect2Kernel: number[];
  61222. /**
  61223. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61224. */
  61225. static SharpenKernel: number[];
  61226. /**
  61227. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61228. */
  61229. static EmbossKernel: number[];
  61230. /**
  61231. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61232. */
  61233. static GaussianKernel: number[];
  61234. }
  61235. }
  61236. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  61237. import { Nullable } from "babylonjs/types";
  61238. import { Vector2 } from "babylonjs/Maths/math.vector";
  61239. import { Camera } from "babylonjs/Cameras/camera";
  61240. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61241. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  61242. import { Engine } from "babylonjs/Engines/engine";
  61243. import { Scene } from "babylonjs/scene";
  61244. /**
  61245. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  61246. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  61247. * based on samples that have a large difference in distance than the center pixel.
  61248. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  61249. */
  61250. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  61251. direction: Vector2;
  61252. /**
  61253. * Creates a new instance CircleOfConfusionPostProcess
  61254. * @param name The name of the effect.
  61255. * @param scene The scene the effect belongs to.
  61256. * @param direction The direction the blur should be applied.
  61257. * @param kernel The size of the kernel used to blur.
  61258. * @param options The required width/height ratio to downsize to before computing the render pass.
  61259. * @param camera The camera to apply the render pass to.
  61260. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  61261. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  61262. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61263. * @param engine The engine which the post process will be applied. (default: current engine)
  61264. * @param reusable If the post process can be reused on the same frame. (default: false)
  61265. * @param textureType Type of textures used when performing the post process. (default: 0)
  61266. * @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)
  61267. */
  61268. 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);
  61269. }
  61270. }
  61271. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  61272. /** @hidden */
  61273. export var depthOfFieldMergePixelShader: {
  61274. name: string;
  61275. shader: string;
  61276. };
  61277. }
  61278. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  61279. import { Nullable } from "babylonjs/types";
  61280. import { Camera } from "babylonjs/Cameras/camera";
  61281. import { Effect } from "babylonjs/Materials/effect";
  61282. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61283. import { Engine } from "babylonjs/Engines/engine";
  61284. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  61285. /**
  61286. * Options to be set when merging outputs from the default pipeline.
  61287. */
  61288. export class DepthOfFieldMergePostProcessOptions {
  61289. /**
  61290. * The original image to merge on top of
  61291. */
  61292. originalFromInput: PostProcess;
  61293. /**
  61294. * Parameters to perform the merge of the depth of field effect
  61295. */
  61296. depthOfField?: {
  61297. circleOfConfusion: PostProcess;
  61298. blurSteps: Array<PostProcess>;
  61299. };
  61300. /**
  61301. * Parameters to perform the merge of bloom effect
  61302. */
  61303. bloom?: {
  61304. blurred: PostProcess;
  61305. weight: number;
  61306. };
  61307. }
  61308. /**
  61309. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61310. */
  61311. export class DepthOfFieldMergePostProcess extends PostProcess {
  61312. private blurSteps;
  61313. /**
  61314. * Creates a new instance of DepthOfFieldMergePostProcess
  61315. * @param name The name of the effect.
  61316. * @param originalFromInput Post process which's input will be used for the merge.
  61317. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  61318. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  61319. * @param options The required width/height ratio to downsize to before computing the render pass.
  61320. * @param camera The camera to apply the render pass to.
  61321. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61322. * @param engine The engine which the post process will be applied. (default: current engine)
  61323. * @param reusable If the post process can be reused on the same frame. (default: false)
  61324. * @param textureType Type of textures used when performing the post process. (default: 0)
  61325. * @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)
  61326. */
  61327. 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);
  61328. /**
  61329. * Updates the effect with the current post process compile time values and recompiles the shader.
  61330. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  61331. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  61332. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  61333. * @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
  61334. * @param onCompiled Called when the shader has been compiled.
  61335. * @param onError Called if there is an error when compiling a shader.
  61336. */
  61337. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  61338. }
  61339. }
  61340. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  61341. import { Nullable } from "babylonjs/types";
  61342. import { Camera } from "babylonjs/Cameras/camera";
  61343. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61344. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61345. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61346. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  61347. import { Scene } from "babylonjs/scene";
  61348. /**
  61349. * Specifies the level of max blur that should be applied when using the depth of field effect
  61350. */
  61351. export enum DepthOfFieldEffectBlurLevel {
  61352. /**
  61353. * Subtle blur
  61354. */
  61355. Low = 0,
  61356. /**
  61357. * Medium blur
  61358. */
  61359. Medium = 1,
  61360. /**
  61361. * Large blur
  61362. */
  61363. High = 2
  61364. }
  61365. /**
  61366. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  61367. */
  61368. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  61369. private _circleOfConfusion;
  61370. /**
  61371. * @hidden Internal, blurs from high to low
  61372. */
  61373. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  61374. private _depthOfFieldBlurY;
  61375. private _dofMerge;
  61376. /**
  61377. * @hidden Internal post processes in depth of field effect
  61378. */
  61379. _effects: Array<PostProcess>;
  61380. /**
  61381. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  61382. */
  61383. focalLength: number;
  61384. /**
  61385. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61386. */
  61387. fStop: number;
  61388. /**
  61389. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61390. */
  61391. focusDistance: number;
  61392. /**
  61393. * 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.
  61394. */
  61395. lensSize: number;
  61396. /**
  61397. * Creates a new instance DepthOfFieldEffect
  61398. * @param scene The scene the effect belongs to.
  61399. * @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.
  61400. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61401. * @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)
  61402. */
  61403. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  61404. /**
  61405. * Get the current class name of the current effet
  61406. * @returns "DepthOfFieldEffect"
  61407. */
  61408. getClassName(): string;
  61409. /**
  61410. * 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.
  61411. */
  61412. depthTexture: RenderTargetTexture;
  61413. /**
  61414. * Disposes each of the internal effects for a given camera.
  61415. * @param camera The camera to dispose the effect on.
  61416. */
  61417. disposeEffects(camera: Camera): void;
  61418. /**
  61419. * @hidden Internal
  61420. */
  61421. _updateEffects(): void;
  61422. /**
  61423. * Internal
  61424. * @returns if all the contained post processes are ready.
  61425. * @hidden
  61426. */
  61427. _isReady(): boolean;
  61428. }
  61429. }
  61430. declare module "babylonjs/Shaders/displayPass.fragment" {
  61431. /** @hidden */
  61432. export var displayPassPixelShader: {
  61433. name: string;
  61434. shader: string;
  61435. };
  61436. }
  61437. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  61438. import { Nullable } from "babylonjs/types";
  61439. import { Camera } from "babylonjs/Cameras/camera";
  61440. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61441. import { Engine } from "babylonjs/Engines/engine";
  61442. import "babylonjs/Shaders/displayPass.fragment";
  61443. /**
  61444. * DisplayPassPostProcess which produces an output the same as it's input
  61445. */
  61446. export class DisplayPassPostProcess extends PostProcess {
  61447. /**
  61448. * Creates the DisplayPassPostProcess
  61449. * @param name The name of the effect.
  61450. * @param options The required width/height ratio to downsize to before computing the render pass.
  61451. * @param camera The camera to apply the render pass to.
  61452. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61453. * @param engine The engine which the post process will be applied. (default: current engine)
  61454. * @param reusable If the post process can be reused on the same frame. (default: false)
  61455. */
  61456. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61457. }
  61458. }
  61459. declare module "babylonjs/Shaders/filter.fragment" {
  61460. /** @hidden */
  61461. export var filterPixelShader: {
  61462. name: string;
  61463. shader: string;
  61464. };
  61465. }
  61466. declare module "babylonjs/PostProcesses/filterPostProcess" {
  61467. import { Nullable } from "babylonjs/types";
  61468. import { Matrix } from "babylonjs/Maths/math.vector";
  61469. import { Camera } from "babylonjs/Cameras/camera";
  61470. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61471. import { Engine } from "babylonjs/Engines/engine";
  61472. import "babylonjs/Shaders/filter.fragment";
  61473. /**
  61474. * Applies a kernel filter to the image
  61475. */
  61476. export class FilterPostProcess extends PostProcess {
  61477. /** The matrix to be applied to the image */
  61478. kernelMatrix: Matrix;
  61479. /**
  61480. *
  61481. * @param name The name of the effect.
  61482. * @param kernelMatrix The matrix to be applied to the image
  61483. * @param options The required width/height ratio to downsize to before computing the render pass.
  61484. * @param camera The camera to apply the render pass to.
  61485. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61486. * @param engine The engine which the post process will be applied. (default: current engine)
  61487. * @param reusable If the post process can be reused on the same frame. (default: false)
  61488. */
  61489. constructor(name: string,
  61490. /** The matrix to be applied to the image */
  61491. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61492. }
  61493. }
  61494. declare module "babylonjs/Shaders/fxaa.fragment" {
  61495. /** @hidden */
  61496. export var fxaaPixelShader: {
  61497. name: string;
  61498. shader: string;
  61499. };
  61500. }
  61501. declare module "babylonjs/Shaders/fxaa.vertex" {
  61502. /** @hidden */
  61503. export var fxaaVertexShader: {
  61504. name: string;
  61505. shader: string;
  61506. };
  61507. }
  61508. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  61509. import { Nullable } from "babylonjs/types";
  61510. import { Camera } from "babylonjs/Cameras/camera";
  61511. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61512. import { Engine } from "babylonjs/Engines/engine";
  61513. import "babylonjs/Shaders/fxaa.fragment";
  61514. import "babylonjs/Shaders/fxaa.vertex";
  61515. /**
  61516. * Fxaa post process
  61517. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  61518. */
  61519. export class FxaaPostProcess extends PostProcess {
  61520. /** @hidden */
  61521. texelWidth: number;
  61522. /** @hidden */
  61523. texelHeight: number;
  61524. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61525. private _getDefines;
  61526. }
  61527. }
  61528. declare module "babylonjs/Shaders/grain.fragment" {
  61529. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61530. /** @hidden */
  61531. export var grainPixelShader: {
  61532. name: string;
  61533. shader: string;
  61534. };
  61535. }
  61536. declare module "babylonjs/PostProcesses/grainPostProcess" {
  61537. import { Nullable } from "babylonjs/types";
  61538. import { Camera } from "babylonjs/Cameras/camera";
  61539. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61540. import { Engine } from "babylonjs/Engines/engine";
  61541. import "babylonjs/Shaders/grain.fragment";
  61542. /**
  61543. * The GrainPostProcess adds noise to the image at mid luminance levels
  61544. */
  61545. export class GrainPostProcess extends PostProcess {
  61546. /**
  61547. * The intensity of the grain added (default: 30)
  61548. */
  61549. intensity: number;
  61550. /**
  61551. * If the grain should be randomized on every frame
  61552. */
  61553. animated: boolean;
  61554. /**
  61555. * Creates a new instance of @see GrainPostProcess
  61556. * @param name The name of the effect.
  61557. * @param options The required width/height ratio to downsize to before computing the render pass.
  61558. * @param camera The camera to apply the render pass to.
  61559. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61560. * @param engine The engine which the post process will be applied. (default: current engine)
  61561. * @param reusable If the post process can be reused on the same frame. (default: false)
  61562. * @param textureType Type of textures used when performing the post process. (default: 0)
  61563. * @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)
  61564. */
  61565. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61566. }
  61567. }
  61568. declare module "babylonjs/Shaders/highlights.fragment" {
  61569. /** @hidden */
  61570. export var highlightsPixelShader: {
  61571. name: string;
  61572. shader: string;
  61573. };
  61574. }
  61575. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  61576. import { Nullable } from "babylonjs/types";
  61577. import { Camera } from "babylonjs/Cameras/camera";
  61578. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61579. import { Engine } from "babylonjs/Engines/engine";
  61580. import "babylonjs/Shaders/highlights.fragment";
  61581. /**
  61582. * Extracts highlights from the image
  61583. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61584. */
  61585. export class HighlightsPostProcess extends PostProcess {
  61586. /**
  61587. * Extracts highlights from the image
  61588. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61589. * @param name The name of the effect.
  61590. * @param options The required width/height ratio to downsize to before computing the render pass.
  61591. * @param camera The camera to apply the render pass to.
  61592. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61593. * @param engine The engine which the post process will be applied. (default: current engine)
  61594. * @param reusable If the post process can be reused on the same frame. (default: false)
  61595. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  61596. */
  61597. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61598. }
  61599. }
  61600. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  61601. /** @hidden */
  61602. export var mrtFragmentDeclaration: {
  61603. name: string;
  61604. shader: string;
  61605. };
  61606. }
  61607. declare module "babylonjs/Shaders/geometry.fragment" {
  61608. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  61609. /** @hidden */
  61610. export var geometryPixelShader: {
  61611. name: string;
  61612. shader: string;
  61613. };
  61614. }
  61615. declare module "babylonjs/Shaders/geometry.vertex" {
  61616. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61617. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61618. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61619. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61620. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61621. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61622. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61623. /** @hidden */
  61624. export var geometryVertexShader: {
  61625. name: string;
  61626. shader: string;
  61627. };
  61628. }
  61629. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  61630. import { Matrix } from "babylonjs/Maths/math.vector";
  61631. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61632. import { Mesh } from "babylonjs/Meshes/mesh";
  61633. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  61634. import { Effect } from "babylonjs/Materials/effect";
  61635. import { Scene } from "babylonjs/scene";
  61636. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61637. import "babylonjs/Shaders/geometry.fragment";
  61638. import "babylonjs/Shaders/geometry.vertex";
  61639. /** @hidden */
  61640. interface ISavedTransformationMatrix {
  61641. world: Matrix;
  61642. viewProjection: Matrix;
  61643. }
  61644. /**
  61645. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  61646. */
  61647. export class GeometryBufferRenderer {
  61648. /**
  61649. * Constant used to retrieve the position texture index in the G-Buffer textures array
  61650. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  61651. */
  61652. static readonly POSITION_TEXTURE_TYPE: number;
  61653. /**
  61654. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  61655. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  61656. */
  61657. static readonly VELOCITY_TEXTURE_TYPE: number;
  61658. /**
  61659. * Dictionary used to store the previous transformation matrices of each rendered mesh
  61660. * in order to compute objects velocities when enableVelocity is set to "true"
  61661. * @hidden
  61662. */
  61663. _previousTransformationMatrices: {
  61664. [index: number]: ISavedTransformationMatrix;
  61665. };
  61666. /**
  61667. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  61668. * in order to compute objects velocities when enableVelocity is set to "true"
  61669. * @hidden
  61670. */
  61671. _previousBonesTransformationMatrices: {
  61672. [index: number]: Float32Array;
  61673. };
  61674. /**
  61675. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  61676. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  61677. */
  61678. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  61679. private _scene;
  61680. private _multiRenderTarget;
  61681. private _ratio;
  61682. private _enablePosition;
  61683. private _enableVelocity;
  61684. private _positionIndex;
  61685. private _velocityIndex;
  61686. protected _effect: Effect;
  61687. protected _cachedDefines: string;
  61688. /**
  61689. * Set the render list (meshes to be rendered) used in the G buffer.
  61690. */
  61691. renderList: Mesh[];
  61692. /**
  61693. * Gets wether or not G buffer are supported by the running hardware.
  61694. * This requires draw buffer supports
  61695. */
  61696. readonly isSupported: boolean;
  61697. /**
  61698. * Returns the index of the given texture type in the G-Buffer textures array
  61699. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  61700. * @returns the index of the given texture type in the G-Buffer textures array
  61701. */
  61702. getTextureIndex(textureType: number): number;
  61703. /**
  61704. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  61705. */
  61706. /**
  61707. * Sets whether or not objects positions are enabled for the G buffer.
  61708. */
  61709. enablePosition: boolean;
  61710. /**
  61711. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  61712. */
  61713. /**
  61714. * Sets wether or not objects velocities are enabled for the G buffer.
  61715. */
  61716. enableVelocity: boolean;
  61717. /**
  61718. * Gets the scene associated with the buffer.
  61719. */
  61720. readonly scene: Scene;
  61721. /**
  61722. * Gets the ratio used by the buffer during its creation.
  61723. * How big is the buffer related to the main canvas.
  61724. */
  61725. readonly ratio: number;
  61726. /** @hidden */
  61727. static _SceneComponentInitialization: (scene: Scene) => void;
  61728. /**
  61729. * Creates a new G Buffer for the scene
  61730. * @param scene The scene the buffer belongs to
  61731. * @param ratio How big is the buffer related to the main canvas.
  61732. */
  61733. constructor(scene: Scene, ratio?: number);
  61734. /**
  61735. * Checks wether everything is ready to render a submesh to the G buffer.
  61736. * @param subMesh the submesh to check readiness for
  61737. * @param useInstances is the mesh drawn using instance or not
  61738. * @returns true if ready otherwise false
  61739. */
  61740. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61741. /**
  61742. * Gets the current underlying G Buffer.
  61743. * @returns the buffer
  61744. */
  61745. getGBuffer(): MultiRenderTarget;
  61746. /**
  61747. * Gets the number of samples used to render the buffer (anti aliasing).
  61748. */
  61749. /**
  61750. * Sets the number of samples used to render the buffer (anti aliasing).
  61751. */
  61752. samples: number;
  61753. /**
  61754. * Disposes the renderer and frees up associated resources.
  61755. */
  61756. dispose(): void;
  61757. protected _createRenderTargets(): void;
  61758. private _copyBonesTransformationMatrices;
  61759. }
  61760. }
  61761. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  61762. import { Nullable } from "babylonjs/types";
  61763. import { Scene } from "babylonjs/scene";
  61764. import { ISceneComponent } from "babylonjs/sceneComponent";
  61765. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  61766. module "babylonjs/scene" {
  61767. interface Scene {
  61768. /** @hidden (Backing field) */
  61769. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61770. /**
  61771. * Gets or Sets the current geometry buffer associated to the scene.
  61772. */
  61773. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61774. /**
  61775. * Enables a GeometryBufferRender and associates it with the scene
  61776. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  61777. * @returns the GeometryBufferRenderer
  61778. */
  61779. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  61780. /**
  61781. * Disables the GeometryBufferRender associated with the scene
  61782. */
  61783. disableGeometryBufferRenderer(): void;
  61784. }
  61785. }
  61786. /**
  61787. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  61788. * in several rendering techniques.
  61789. */
  61790. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  61791. /**
  61792. * The component name helpful to identify the component in the list of scene components.
  61793. */
  61794. readonly name: string;
  61795. /**
  61796. * The scene the component belongs to.
  61797. */
  61798. scene: Scene;
  61799. /**
  61800. * Creates a new instance of the component for the given scene
  61801. * @param scene Defines the scene to register the component in
  61802. */
  61803. constructor(scene: Scene);
  61804. /**
  61805. * Registers the component in a given scene
  61806. */
  61807. register(): void;
  61808. /**
  61809. * Rebuilds the elements related to this component in case of
  61810. * context lost for instance.
  61811. */
  61812. rebuild(): void;
  61813. /**
  61814. * Disposes the component and the associated ressources
  61815. */
  61816. dispose(): void;
  61817. private _gatherRenderTargets;
  61818. }
  61819. }
  61820. declare module "babylonjs/Shaders/motionBlur.fragment" {
  61821. /** @hidden */
  61822. export var motionBlurPixelShader: {
  61823. name: string;
  61824. shader: string;
  61825. };
  61826. }
  61827. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  61828. import { Nullable } from "babylonjs/types";
  61829. import { Camera } from "babylonjs/Cameras/camera";
  61830. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61831. import { Scene } from "babylonjs/scene";
  61832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61833. import "babylonjs/Animations/animatable";
  61834. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  61835. import "babylonjs/Shaders/motionBlur.fragment";
  61836. import { Engine } from "babylonjs/Engines/engine";
  61837. /**
  61838. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  61839. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  61840. * As an example, all you have to do is to create the post-process:
  61841. * var mb = new BABYLON.MotionBlurPostProcess(
  61842. * 'mb', // The name of the effect.
  61843. * scene, // The scene containing the objects to blur according to their velocity.
  61844. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  61845. * camera // The camera to apply the render pass to.
  61846. * );
  61847. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  61848. */
  61849. export class MotionBlurPostProcess extends PostProcess {
  61850. /**
  61851. * Defines how much the image is blurred by the movement. Default value is equal to 1
  61852. */
  61853. motionStrength: number;
  61854. /**
  61855. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  61856. */
  61857. /**
  61858. * Sets the number of iterations to be used for motion blur quality
  61859. */
  61860. motionBlurSamples: number;
  61861. private _motionBlurSamples;
  61862. private _geometryBufferRenderer;
  61863. /**
  61864. * Creates a new instance MotionBlurPostProcess
  61865. * @param name The name of the effect.
  61866. * @param scene The scene containing the objects to blur according to their velocity.
  61867. * @param options The required width/height ratio to downsize to before computing the render pass.
  61868. * @param camera The camera to apply the render pass to.
  61869. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61870. * @param engine The engine which the post process will be applied. (default: current engine)
  61871. * @param reusable If the post process can be reused on the same frame. (default: false)
  61872. * @param textureType Type of textures used when performing the post process. (default: 0)
  61873. * @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)
  61874. */
  61875. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61876. /**
  61877. * Excludes the given skinned mesh from computing bones velocities.
  61878. * 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.
  61879. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  61880. */
  61881. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61882. /**
  61883. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  61884. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  61885. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  61886. */
  61887. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61888. /**
  61889. * Disposes the post process.
  61890. * @param camera The camera to dispose the post process on.
  61891. */
  61892. dispose(camera?: Camera): void;
  61893. }
  61894. }
  61895. declare module "babylonjs/Shaders/refraction.fragment" {
  61896. /** @hidden */
  61897. export var refractionPixelShader: {
  61898. name: string;
  61899. shader: string;
  61900. };
  61901. }
  61902. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  61903. import { Color3 } from "babylonjs/Maths/math.color";
  61904. import { Camera } from "babylonjs/Cameras/camera";
  61905. import { Texture } from "babylonjs/Materials/Textures/texture";
  61906. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61907. import { Engine } from "babylonjs/Engines/engine";
  61908. import "babylonjs/Shaders/refraction.fragment";
  61909. /**
  61910. * Post process which applies a refractin texture
  61911. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61912. */
  61913. export class RefractionPostProcess extends PostProcess {
  61914. /** the base color of the refraction (used to taint the rendering) */
  61915. color: Color3;
  61916. /** simulated refraction depth */
  61917. depth: number;
  61918. /** the coefficient of the base color (0 to remove base color tainting) */
  61919. colorLevel: number;
  61920. private _refTexture;
  61921. private _ownRefractionTexture;
  61922. /**
  61923. * Gets or sets the refraction texture
  61924. * Please note that you are responsible for disposing the texture if you set it manually
  61925. */
  61926. refractionTexture: Texture;
  61927. /**
  61928. * Initializes the RefractionPostProcess
  61929. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61930. * @param name The name of the effect.
  61931. * @param refractionTextureUrl Url of the refraction texture to use
  61932. * @param color the base color of the refraction (used to taint the rendering)
  61933. * @param depth simulated refraction depth
  61934. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  61935. * @param camera The camera to apply the render pass to.
  61936. * @param options The required width/height ratio to downsize to before computing the render pass.
  61937. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61938. * @param engine The engine which the post process will be applied. (default: current engine)
  61939. * @param reusable If the post process can be reused on the same frame. (default: false)
  61940. */
  61941. constructor(name: string, refractionTextureUrl: string,
  61942. /** the base color of the refraction (used to taint the rendering) */
  61943. color: Color3,
  61944. /** simulated refraction depth */
  61945. depth: number,
  61946. /** the coefficient of the base color (0 to remove base color tainting) */
  61947. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61948. /**
  61949. * Disposes of the post process
  61950. * @param camera Camera to dispose post process on
  61951. */
  61952. dispose(camera: Camera): void;
  61953. }
  61954. }
  61955. declare module "babylonjs/Shaders/sharpen.fragment" {
  61956. /** @hidden */
  61957. export var sharpenPixelShader: {
  61958. name: string;
  61959. shader: string;
  61960. };
  61961. }
  61962. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  61963. import { Nullable } from "babylonjs/types";
  61964. import { Camera } from "babylonjs/Cameras/camera";
  61965. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61966. import "babylonjs/Shaders/sharpen.fragment";
  61967. import { Engine } from "babylonjs/Engines/engine";
  61968. /**
  61969. * The SharpenPostProcess applies a sharpen kernel to every pixel
  61970. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61971. */
  61972. export class SharpenPostProcess extends PostProcess {
  61973. /**
  61974. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  61975. */
  61976. colorAmount: number;
  61977. /**
  61978. * How much sharpness should be applied (default: 0.3)
  61979. */
  61980. edgeAmount: number;
  61981. /**
  61982. * Creates a new instance ConvolutionPostProcess
  61983. * @param name The name of the effect.
  61984. * @param options The required width/height ratio to downsize to before computing the render pass.
  61985. * @param camera The camera to apply the render pass to.
  61986. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61987. * @param engine The engine which the post process will be applied. (default: current engine)
  61988. * @param reusable If the post process can be reused on the same frame. (default: false)
  61989. * @param textureType Type of textures used when performing the post process. (default: 0)
  61990. * @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)
  61991. */
  61992. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61993. }
  61994. }
  61995. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  61996. import { Nullable } from "babylonjs/types";
  61997. import { Camera } from "babylonjs/Cameras/camera";
  61998. import { Engine } from "babylonjs/Engines/engine";
  61999. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62000. import { IInspectable } from "babylonjs/Misc/iInspectable";
  62001. /**
  62002. * PostProcessRenderPipeline
  62003. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62004. */
  62005. export class PostProcessRenderPipeline {
  62006. private engine;
  62007. private _renderEffects;
  62008. private _renderEffectsForIsolatedPass;
  62009. /**
  62010. * List of inspectable custom properties (used by the Inspector)
  62011. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  62012. */
  62013. inspectableCustomProperties: IInspectable[];
  62014. /**
  62015. * @hidden
  62016. */
  62017. protected _cameras: Camera[];
  62018. /** @hidden */
  62019. _name: string;
  62020. /**
  62021. * Gets pipeline name
  62022. */
  62023. readonly name: string;
  62024. /**
  62025. * Initializes a PostProcessRenderPipeline
  62026. * @param engine engine to add the pipeline to
  62027. * @param name name of the pipeline
  62028. */
  62029. constructor(engine: Engine, name: string);
  62030. /**
  62031. * Gets the class name
  62032. * @returns "PostProcessRenderPipeline"
  62033. */
  62034. getClassName(): string;
  62035. /**
  62036. * If all the render effects in the pipeline are supported
  62037. */
  62038. readonly isSupported: boolean;
  62039. /**
  62040. * Adds an effect to the pipeline
  62041. * @param renderEffect the effect to add
  62042. */
  62043. addEffect(renderEffect: PostProcessRenderEffect): void;
  62044. /** @hidden */
  62045. _rebuild(): void;
  62046. /** @hidden */
  62047. _enableEffect(renderEffectName: string, cameras: Camera): void;
  62048. /** @hidden */
  62049. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  62050. /** @hidden */
  62051. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62052. /** @hidden */
  62053. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62054. /** @hidden */
  62055. _attachCameras(cameras: Camera, unique: boolean): void;
  62056. /** @hidden */
  62057. _attachCameras(cameras: Camera[], unique: boolean): void;
  62058. /** @hidden */
  62059. _detachCameras(cameras: Camera): void;
  62060. /** @hidden */
  62061. _detachCameras(cameras: Nullable<Camera[]>): void;
  62062. /** @hidden */
  62063. _update(): void;
  62064. /** @hidden */
  62065. _reset(): void;
  62066. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  62067. /**
  62068. * Disposes of the pipeline
  62069. */
  62070. dispose(): void;
  62071. }
  62072. }
  62073. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  62074. import { Camera } from "babylonjs/Cameras/camera";
  62075. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62076. /**
  62077. * PostProcessRenderPipelineManager class
  62078. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62079. */
  62080. export class PostProcessRenderPipelineManager {
  62081. private _renderPipelines;
  62082. /**
  62083. * Initializes a PostProcessRenderPipelineManager
  62084. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62085. */
  62086. constructor();
  62087. /**
  62088. * Gets the list of supported render pipelines
  62089. */
  62090. readonly supportedPipelines: PostProcessRenderPipeline[];
  62091. /**
  62092. * Adds a pipeline to the manager
  62093. * @param renderPipeline The pipeline to add
  62094. */
  62095. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  62096. /**
  62097. * Attaches a camera to the pipeline
  62098. * @param renderPipelineName The name of the pipeline to attach to
  62099. * @param cameras the camera to attach
  62100. * @param unique if the camera can be attached multiple times to the pipeline
  62101. */
  62102. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  62103. /**
  62104. * Detaches a camera from the pipeline
  62105. * @param renderPipelineName The name of the pipeline to detach from
  62106. * @param cameras the camera to detach
  62107. */
  62108. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  62109. /**
  62110. * Enables an effect by name on a pipeline
  62111. * @param renderPipelineName the name of the pipeline to enable the effect in
  62112. * @param renderEffectName the name of the effect to enable
  62113. * @param cameras the cameras that the effect should be enabled on
  62114. */
  62115. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62116. /**
  62117. * Disables an effect by name on a pipeline
  62118. * @param renderPipelineName the name of the pipeline to disable the effect in
  62119. * @param renderEffectName the name of the effect to disable
  62120. * @param cameras the cameras that the effect should be disabled on
  62121. */
  62122. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62123. /**
  62124. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  62125. */
  62126. update(): void;
  62127. /** @hidden */
  62128. _rebuild(): void;
  62129. /**
  62130. * Disposes of the manager and pipelines
  62131. */
  62132. dispose(): void;
  62133. }
  62134. }
  62135. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  62136. import { ISceneComponent } from "babylonjs/sceneComponent";
  62137. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  62138. import { Scene } from "babylonjs/scene";
  62139. module "babylonjs/scene" {
  62140. interface Scene {
  62141. /** @hidden (Backing field) */
  62142. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62143. /**
  62144. * Gets the postprocess render pipeline manager
  62145. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62146. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62147. */
  62148. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62149. }
  62150. }
  62151. /**
  62152. * Defines the Render Pipeline scene component responsible to rendering pipelines
  62153. */
  62154. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  62155. /**
  62156. * The component name helpfull to identify the component in the list of scene components.
  62157. */
  62158. readonly name: string;
  62159. /**
  62160. * The scene the component belongs to.
  62161. */
  62162. scene: Scene;
  62163. /**
  62164. * Creates a new instance of the component for the given scene
  62165. * @param scene Defines the scene to register the component in
  62166. */
  62167. constructor(scene: Scene);
  62168. /**
  62169. * Registers the component in a given scene
  62170. */
  62171. register(): void;
  62172. /**
  62173. * Rebuilds the elements related to this component in case of
  62174. * context lost for instance.
  62175. */
  62176. rebuild(): void;
  62177. /**
  62178. * Disposes the component and the associated ressources
  62179. */
  62180. dispose(): void;
  62181. private _gatherRenderTargets;
  62182. }
  62183. }
  62184. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  62185. import { Nullable } from "babylonjs/types";
  62186. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62187. import { Camera } from "babylonjs/Cameras/camera";
  62188. import { IDisposable } from "babylonjs/scene";
  62189. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  62190. import { Scene } from "babylonjs/scene";
  62191. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  62192. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  62193. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  62194. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  62195. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  62196. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62197. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  62198. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62199. import { Animation } from "babylonjs/Animations/animation";
  62200. /**
  62201. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  62202. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62203. */
  62204. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62205. private _scene;
  62206. private _camerasToBeAttached;
  62207. /**
  62208. * ID of the sharpen post process,
  62209. */
  62210. private readonly SharpenPostProcessId;
  62211. /**
  62212. * @ignore
  62213. * ID of the image processing post process;
  62214. */
  62215. readonly ImageProcessingPostProcessId: string;
  62216. /**
  62217. * @ignore
  62218. * ID of the Fast Approximate Anti-Aliasing post process;
  62219. */
  62220. readonly FxaaPostProcessId: string;
  62221. /**
  62222. * ID of the chromatic aberration post process,
  62223. */
  62224. private readonly ChromaticAberrationPostProcessId;
  62225. /**
  62226. * ID of the grain post process
  62227. */
  62228. private readonly GrainPostProcessId;
  62229. /**
  62230. * Sharpen post process which will apply a sharpen convolution to enhance edges
  62231. */
  62232. sharpen: SharpenPostProcess;
  62233. private _sharpenEffect;
  62234. private bloom;
  62235. /**
  62236. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  62237. */
  62238. depthOfField: DepthOfFieldEffect;
  62239. /**
  62240. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62241. */
  62242. fxaa: FxaaPostProcess;
  62243. /**
  62244. * Image post processing pass used to perform operations such as tone mapping or color grading.
  62245. */
  62246. imageProcessing: ImageProcessingPostProcess;
  62247. /**
  62248. * Chromatic aberration post process which will shift rgb colors in the image
  62249. */
  62250. chromaticAberration: ChromaticAberrationPostProcess;
  62251. private _chromaticAberrationEffect;
  62252. /**
  62253. * Grain post process which add noise to the image
  62254. */
  62255. grain: GrainPostProcess;
  62256. private _grainEffect;
  62257. /**
  62258. * Glow post process which adds a glow to emissive areas of the image
  62259. */
  62260. private _glowLayer;
  62261. /**
  62262. * Animations which can be used to tweak settings over a period of time
  62263. */
  62264. animations: Animation[];
  62265. private _imageProcessingConfigurationObserver;
  62266. private _sharpenEnabled;
  62267. private _bloomEnabled;
  62268. private _depthOfFieldEnabled;
  62269. private _depthOfFieldBlurLevel;
  62270. private _fxaaEnabled;
  62271. private _imageProcessingEnabled;
  62272. private _defaultPipelineTextureType;
  62273. private _bloomScale;
  62274. private _chromaticAberrationEnabled;
  62275. private _grainEnabled;
  62276. private _buildAllowed;
  62277. /**
  62278. * Gets active scene
  62279. */
  62280. readonly scene: Scene;
  62281. /**
  62282. * Enable or disable the sharpen process from the pipeline
  62283. */
  62284. sharpenEnabled: boolean;
  62285. private _resizeObserver;
  62286. private _hardwareScaleLevel;
  62287. private _bloomKernel;
  62288. /**
  62289. * Specifies the size of the bloom blur kernel, relative to the final output size
  62290. */
  62291. bloomKernel: number;
  62292. /**
  62293. * Specifies the weight of the bloom in the final rendering
  62294. */
  62295. private _bloomWeight;
  62296. /**
  62297. * Specifies the luma threshold for the area that will be blurred by the bloom
  62298. */
  62299. private _bloomThreshold;
  62300. private _hdr;
  62301. /**
  62302. * The strength of the bloom.
  62303. */
  62304. bloomWeight: number;
  62305. /**
  62306. * The strength of the bloom.
  62307. */
  62308. bloomThreshold: number;
  62309. /**
  62310. * The scale of the bloom, lower value will provide better performance.
  62311. */
  62312. bloomScale: number;
  62313. /**
  62314. * Enable or disable the bloom from the pipeline
  62315. */
  62316. bloomEnabled: boolean;
  62317. private _rebuildBloom;
  62318. /**
  62319. * If the depth of field is enabled.
  62320. */
  62321. depthOfFieldEnabled: boolean;
  62322. /**
  62323. * Blur level of the depth of field effect. (Higher blur will effect performance)
  62324. */
  62325. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  62326. /**
  62327. * If the anti aliasing is enabled.
  62328. */
  62329. fxaaEnabled: boolean;
  62330. private _samples;
  62331. /**
  62332. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62333. */
  62334. samples: number;
  62335. /**
  62336. * If image processing is enabled.
  62337. */
  62338. imageProcessingEnabled: boolean;
  62339. /**
  62340. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  62341. */
  62342. glowLayerEnabled: boolean;
  62343. /**
  62344. * Gets the glow layer (or null if not defined)
  62345. */
  62346. readonly glowLayer: Nullable<GlowLayer>;
  62347. /**
  62348. * Enable or disable the chromaticAberration process from the pipeline
  62349. */
  62350. chromaticAberrationEnabled: boolean;
  62351. /**
  62352. * Enable or disable the grain process from the pipeline
  62353. */
  62354. grainEnabled: boolean;
  62355. /**
  62356. * @constructor
  62357. * @param name - The rendering pipeline name (default: "")
  62358. * @param hdr - If high dynamic range textures should be used (default: true)
  62359. * @param scene - The scene linked to this pipeline (default: the last created scene)
  62360. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  62361. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  62362. */
  62363. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  62364. /**
  62365. * Get the class name
  62366. * @returns "DefaultRenderingPipeline"
  62367. */
  62368. getClassName(): string;
  62369. /**
  62370. * Force the compilation of the entire pipeline.
  62371. */
  62372. prepare(): void;
  62373. private _hasCleared;
  62374. private _prevPostProcess;
  62375. private _prevPrevPostProcess;
  62376. private _setAutoClearAndTextureSharing;
  62377. private _depthOfFieldSceneObserver;
  62378. private _buildPipeline;
  62379. private _disposePostProcesses;
  62380. /**
  62381. * Adds a camera to the pipeline
  62382. * @param camera the camera to be added
  62383. */
  62384. addCamera(camera: Camera): void;
  62385. /**
  62386. * Removes a camera from the pipeline
  62387. * @param camera the camera to remove
  62388. */
  62389. removeCamera(camera: Camera): void;
  62390. /**
  62391. * Dispose of the pipeline and stop all post processes
  62392. */
  62393. dispose(): void;
  62394. /**
  62395. * Serialize the rendering pipeline (Used when exporting)
  62396. * @returns the serialized object
  62397. */
  62398. serialize(): any;
  62399. /**
  62400. * Parse the serialized pipeline
  62401. * @param source Source pipeline.
  62402. * @param scene The scene to load the pipeline to.
  62403. * @param rootUrl The URL of the serialized pipeline.
  62404. * @returns An instantiated pipeline from the serialized object.
  62405. */
  62406. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  62407. }
  62408. }
  62409. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  62410. /** @hidden */
  62411. export var lensHighlightsPixelShader: {
  62412. name: string;
  62413. shader: string;
  62414. };
  62415. }
  62416. declare module "babylonjs/Shaders/depthOfField.fragment" {
  62417. /** @hidden */
  62418. export var depthOfFieldPixelShader: {
  62419. name: string;
  62420. shader: string;
  62421. };
  62422. }
  62423. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  62424. import { Camera } from "babylonjs/Cameras/camera";
  62425. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62426. import { Scene } from "babylonjs/scene";
  62427. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62428. import "babylonjs/Shaders/chromaticAberration.fragment";
  62429. import "babylonjs/Shaders/lensHighlights.fragment";
  62430. import "babylonjs/Shaders/depthOfField.fragment";
  62431. /**
  62432. * BABYLON.JS Chromatic Aberration GLSL Shader
  62433. * Author: Olivier Guyot
  62434. * Separates very slightly R, G and B colors on the edges of the screen
  62435. * Inspired by Francois Tarlier & Martins Upitis
  62436. */
  62437. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  62438. /**
  62439. * @ignore
  62440. * The chromatic aberration PostProcess id in the pipeline
  62441. */
  62442. LensChromaticAberrationEffect: string;
  62443. /**
  62444. * @ignore
  62445. * The highlights enhancing PostProcess id in the pipeline
  62446. */
  62447. HighlightsEnhancingEffect: string;
  62448. /**
  62449. * @ignore
  62450. * The depth-of-field PostProcess id in the pipeline
  62451. */
  62452. LensDepthOfFieldEffect: string;
  62453. private _scene;
  62454. private _depthTexture;
  62455. private _grainTexture;
  62456. private _chromaticAberrationPostProcess;
  62457. private _highlightsPostProcess;
  62458. private _depthOfFieldPostProcess;
  62459. private _edgeBlur;
  62460. private _grainAmount;
  62461. private _chromaticAberration;
  62462. private _distortion;
  62463. private _highlightsGain;
  62464. private _highlightsThreshold;
  62465. private _dofDistance;
  62466. private _dofAperture;
  62467. private _dofDarken;
  62468. private _dofPentagon;
  62469. private _blurNoise;
  62470. /**
  62471. * @constructor
  62472. *
  62473. * Effect parameters are as follow:
  62474. * {
  62475. * chromatic_aberration: number; // from 0 to x (1 for realism)
  62476. * edge_blur: number; // from 0 to x (1 for realism)
  62477. * distortion: number; // from 0 to x (1 for realism)
  62478. * grain_amount: number; // from 0 to 1
  62479. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  62480. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  62481. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  62482. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  62483. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  62484. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  62485. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  62486. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  62487. * }
  62488. * Note: if an effect parameter is unset, effect is disabled
  62489. *
  62490. * @param name The rendering pipeline name
  62491. * @param parameters - An object containing all parameters (see above)
  62492. * @param scene The scene linked to this pipeline
  62493. * @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)
  62494. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62495. */
  62496. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  62497. /**
  62498. * Get the class name
  62499. * @returns "LensRenderingPipeline"
  62500. */
  62501. getClassName(): string;
  62502. /**
  62503. * Gets associated scene
  62504. */
  62505. readonly scene: Scene;
  62506. /**
  62507. * Gets or sets the edge blur
  62508. */
  62509. edgeBlur: number;
  62510. /**
  62511. * Gets or sets the grain amount
  62512. */
  62513. grainAmount: number;
  62514. /**
  62515. * Gets or sets the chromatic aberration amount
  62516. */
  62517. chromaticAberration: number;
  62518. /**
  62519. * Gets or sets the depth of field aperture
  62520. */
  62521. dofAperture: number;
  62522. /**
  62523. * Gets or sets the edge distortion
  62524. */
  62525. edgeDistortion: number;
  62526. /**
  62527. * Gets or sets the depth of field distortion
  62528. */
  62529. dofDistortion: number;
  62530. /**
  62531. * Gets or sets the darken out of focus amount
  62532. */
  62533. darkenOutOfFocus: number;
  62534. /**
  62535. * Gets or sets a boolean indicating if blur noise is enabled
  62536. */
  62537. blurNoise: boolean;
  62538. /**
  62539. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  62540. */
  62541. pentagonBokeh: boolean;
  62542. /**
  62543. * Gets or sets the highlight grain amount
  62544. */
  62545. highlightsGain: number;
  62546. /**
  62547. * Gets or sets the highlight threshold
  62548. */
  62549. highlightsThreshold: number;
  62550. /**
  62551. * Sets the amount of blur at the edges
  62552. * @param amount blur amount
  62553. */
  62554. setEdgeBlur(amount: number): void;
  62555. /**
  62556. * Sets edge blur to 0
  62557. */
  62558. disableEdgeBlur(): void;
  62559. /**
  62560. * Sets the amout of grain
  62561. * @param amount Amount of grain
  62562. */
  62563. setGrainAmount(amount: number): void;
  62564. /**
  62565. * Set grain amount to 0
  62566. */
  62567. disableGrain(): void;
  62568. /**
  62569. * Sets the chromatic aberration amount
  62570. * @param amount amount of chromatic aberration
  62571. */
  62572. setChromaticAberration(amount: number): void;
  62573. /**
  62574. * Sets chromatic aberration amount to 0
  62575. */
  62576. disableChromaticAberration(): void;
  62577. /**
  62578. * Sets the EdgeDistortion amount
  62579. * @param amount amount of EdgeDistortion
  62580. */
  62581. setEdgeDistortion(amount: number): void;
  62582. /**
  62583. * Sets edge distortion to 0
  62584. */
  62585. disableEdgeDistortion(): void;
  62586. /**
  62587. * Sets the FocusDistance amount
  62588. * @param amount amount of FocusDistance
  62589. */
  62590. setFocusDistance(amount: number): void;
  62591. /**
  62592. * Disables depth of field
  62593. */
  62594. disableDepthOfField(): void;
  62595. /**
  62596. * Sets the Aperture amount
  62597. * @param amount amount of Aperture
  62598. */
  62599. setAperture(amount: number): void;
  62600. /**
  62601. * Sets the DarkenOutOfFocus amount
  62602. * @param amount amount of DarkenOutOfFocus
  62603. */
  62604. setDarkenOutOfFocus(amount: number): void;
  62605. private _pentagonBokehIsEnabled;
  62606. /**
  62607. * Creates a pentagon bokeh effect
  62608. */
  62609. enablePentagonBokeh(): void;
  62610. /**
  62611. * Disables the pentagon bokeh effect
  62612. */
  62613. disablePentagonBokeh(): void;
  62614. /**
  62615. * Enables noise blur
  62616. */
  62617. enableNoiseBlur(): void;
  62618. /**
  62619. * Disables noise blur
  62620. */
  62621. disableNoiseBlur(): void;
  62622. /**
  62623. * Sets the HighlightsGain amount
  62624. * @param amount amount of HighlightsGain
  62625. */
  62626. setHighlightsGain(amount: number): void;
  62627. /**
  62628. * Sets the HighlightsThreshold amount
  62629. * @param amount amount of HighlightsThreshold
  62630. */
  62631. setHighlightsThreshold(amount: number): void;
  62632. /**
  62633. * Disables highlights
  62634. */
  62635. disableHighlights(): void;
  62636. /**
  62637. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  62638. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  62639. */
  62640. dispose(disableDepthRender?: boolean): void;
  62641. private _createChromaticAberrationPostProcess;
  62642. private _createHighlightsPostProcess;
  62643. private _createDepthOfFieldPostProcess;
  62644. private _createGrainTexture;
  62645. }
  62646. }
  62647. declare module "babylonjs/Shaders/ssao2.fragment" {
  62648. /** @hidden */
  62649. export var ssao2PixelShader: {
  62650. name: string;
  62651. shader: string;
  62652. };
  62653. }
  62654. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  62655. /** @hidden */
  62656. export var ssaoCombinePixelShader: {
  62657. name: string;
  62658. shader: string;
  62659. };
  62660. }
  62661. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  62662. import { Camera } from "babylonjs/Cameras/camera";
  62663. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62664. import { Scene } from "babylonjs/scene";
  62665. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62666. import "babylonjs/Shaders/ssao2.fragment";
  62667. import "babylonjs/Shaders/ssaoCombine.fragment";
  62668. /**
  62669. * Render pipeline to produce ssao effect
  62670. */
  62671. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  62672. /**
  62673. * @ignore
  62674. * The PassPostProcess id in the pipeline that contains the original scene color
  62675. */
  62676. SSAOOriginalSceneColorEffect: string;
  62677. /**
  62678. * @ignore
  62679. * The SSAO PostProcess id in the pipeline
  62680. */
  62681. SSAORenderEffect: string;
  62682. /**
  62683. * @ignore
  62684. * The horizontal blur PostProcess id in the pipeline
  62685. */
  62686. SSAOBlurHRenderEffect: string;
  62687. /**
  62688. * @ignore
  62689. * The vertical blur PostProcess id in the pipeline
  62690. */
  62691. SSAOBlurVRenderEffect: string;
  62692. /**
  62693. * @ignore
  62694. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62695. */
  62696. SSAOCombineRenderEffect: string;
  62697. /**
  62698. * The output strength of the SSAO post-process. Default value is 1.0.
  62699. */
  62700. totalStrength: number;
  62701. /**
  62702. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  62703. */
  62704. maxZ: number;
  62705. /**
  62706. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  62707. */
  62708. minZAspect: number;
  62709. private _samples;
  62710. /**
  62711. * Number of samples used for the SSAO calculations. Default value is 8
  62712. */
  62713. samples: number;
  62714. private _textureSamples;
  62715. /**
  62716. * Number of samples to use for antialiasing
  62717. */
  62718. textureSamples: number;
  62719. /**
  62720. * Ratio object used for SSAO ratio and blur ratio
  62721. */
  62722. private _ratio;
  62723. /**
  62724. * Dynamically generated sphere sampler.
  62725. */
  62726. private _sampleSphere;
  62727. /**
  62728. * Blur filter offsets
  62729. */
  62730. private _samplerOffsets;
  62731. private _expensiveBlur;
  62732. /**
  62733. * If bilateral blur should be used
  62734. */
  62735. expensiveBlur: boolean;
  62736. /**
  62737. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  62738. */
  62739. radius: number;
  62740. /**
  62741. * The base color of the SSAO post-process
  62742. * The final result is "base + ssao" between [0, 1]
  62743. */
  62744. base: number;
  62745. /**
  62746. * Support test.
  62747. */
  62748. static readonly IsSupported: boolean;
  62749. private _scene;
  62750. private _depthTexture;
  62751. private _normalTexture;
  62752. private _randomTexture;
  62753. private _originalColorPostProcess;
  62754. private _ssaoPostProcess;
  62755. private _blurHPostProcess;
  62756. private _blurVPostProcess;
  62757. private _ssaoCombinePostProcess;
  62758. private _firstUpdate;
  62759. /**
  62760. * Gets active scene
  62761. */
  62762. readonly scene: Scene;
  62763. /**
  62764. * @constructor
  62765. * @param name The rendering pipeline name
  62766. * @param scene The scene linked to this pipeline
  62767. * @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 }
  62768. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62769. */
  62770. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62771. /**
  62772. * Get the class name
  62773. * @returns "SSAO2RenderingPipeline"
  62774. */
  62775. getClassName(): string;
  62776. /**
  62777. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62778. */
  62779. dispose(disableGeometryBufferRenderer?: boolean): void;
  62780. private _createBlurPostProcess;
  62781. /** @hidden */
  62782. _rebuild(): void;
  62783. private _bits;
  62784. private _radicalInverse_VdC;
  62785. private _hammersley;
  62786. private _hemisphereSample_uniform;
  62787. private _generateHemisphere;
  62788. private _createSSAOPostProcess;
  62789. private _createSSAOCombinePostProcess;
  62790. private _createRandomTexture;
  62791. /**
  62792. * Serialize the rendering pipeline (Used when exporting)
  62793. * @returns the serialized object
  62794. */
  62795. serialize(): any;
  62796. /**
  62797. * Parse the serialized pipeline
  62798. * @param source Source pipeline.
  62799. * @param scene The scene to load the pipeline to.
  62800. * @param rootUrl The URL of the serialized pipeline.
  62801. * @returns An instantiated pipeline from the serialized object.
  62802. */
  62803. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  62804. }
  62805. }
  62806. declare module "babylonjs/Shaders/ssao.fragment" {
  62807. /** @hidden */
  62808. export var ssaoPixelShader: {
  62809. name: string;
  62810. shader: string;
  62811. };
  62812. }
  62813. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  62814. import { Camera } from "babylonjs/Cameras/camera";
  62815. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62816. import { Scene } from "babylonjs/scene";
  62817. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62818. import "babylonjs/Shaders/ssao.fragment";
  62819. import "babylonjs/Shaders/ssaoCombine.fragment";
  62820. /**
  62821. * Render pipeline to produce ssao effect
  62822. */
  62823. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  62824. /**
  62825. * @ignore
  62826. * The PassPostProcess id in the pipeline that contains the original scene color
  62827. */
  62828. SSAOOriginalSceneColorEffect: string;
  62829. /**
  62830. * @ignore
  62831. * The SSAO PostProcess id in the pipeline
  62832. */
  62833. SSAORenderEffect: string;
  62834. /**
  62835. * @ignore
  62836. * The horizontal blur PostProcess id in the pipeline
  62837. */
  62838. SSAOBlurHRenderEffect: string;
  62839. /**
  62840. * @ignore
  62841. * The vertical blur PostProcess id in the pipeline
  62842. */
  62843. SSAOBlurVRenderEffect: string;
  62844. /**
  62845. * @ignore
  62846. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62847. */
  62848. SSAOCombineRenderEffect: string;
  62849. /**
  62850. * The output strength of the SSAO post-process. Default value is 1.0.
  62851. */
  62852. totalStrength: number;
  62853. /**
  62854. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  62855. */
  62856. radius: number;
  62857. /**
  62858. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  62859. * Must not be equal to fallOff and superior to fallOff.
  62860. * Default value is 0.0075
  62861. */
  62862. area: number;
  62863. /**
  62864. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  62865. * Must not be equal to area and inferior to area.
  62866. * Default value is 0.000001
  62867. */
  62868. fallOff: number;
  62869. /**
  62870. * The base color of the SSAO post-process
  62871. * The final result is "base + ssao" between [0, 1]
  62872. */
  62873. base: number;
  62874. private _scene;
  62875. private _depthTexture;
  62876. private _randomTexture;
  62877. private _originalColorPostProcess;
  62878. private _ssaoPostProcess;
  62879. private _blurHPostProcess;
  62880. private _blurVPostProcess;
  62881. private _ssaoCombinePostProcess;
  62882. private _firstUpdate;
  62883. /**
  62884. * Gets active scene
  62885. */
  62886. readonly scene: Scene;
  62887. /**
  62888. * @constructor
  62889. * @param name - The rendering pipeline name
  62890. * @param scene - The scene linked to this pipeline
  62891. * @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 }
  62892. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  62893. */
  62894. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62895. /**
  62896. * Get the class name
  62897. * @returns "SSAORenderingPipeline"
  62898. */
  62899. getClassName(): string;
  62900. /**
  62901. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62902. */
  62903. dispose(disableDepthRender?: boolean): void;
  62904. private _createBlurPostProcess;
  62905. /** @hidden */
  62906. _rebuild(): void;
  62907. private _createSSAOPostProcess;
  62908. private _createSSAOCombinePostProcess;
  62909. private _createRandomTexture;
  62910. }
  62911. }
  62912. declare module "babylonjs/Shaders/standard.fragment" {
  62913. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62914. /** @hidden */
  62915. export var standardPixelShader: {
  62916. name: string;
  62917. shader: string;
  62918. };
  62919. }
  62920. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  62921. import { Nullable } from "babylonjs/types";
  62922. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62923. import { Camera } from "babylonjs/Cameras/camera";
  62924. import { Texture } from "babylonjs/Materials/Textures/texture";
  62925. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62926. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62927. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62928. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  62929. import { IDisposable } from "babylonjs/scene";
  62930. import { SpotLight } from "babylonjs/Lights/spotLight";
  62931. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62932. import { Scene } from "babylonjs/scene";
  62933. import { Animation } from "babylonjs/Animations/animation";
  62934. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62935. import "babylonjs/Shaders/standard.fragment";
  62936. /**
  62937. * Standard rendering pipeline
  62938. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  62939. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  62940. */
  62941. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62942. /**
  62943. * Public members
  62944. */
  62945. /**
  62946. * Post-process which contains the original scene color before the pipeline applies all the effects
  62947. */
  62948. originalPostProcess: Nullable<PostProcess>;
  62949. /**
  62950. * Post-process used to down scale an image x4
  62951. */
  62952. downSampleX4PostProcess: Nullable<PostProcess>;
  62953. /**
  62954. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  62955. */
  62956. brightPassPostProcess: Nullable<PostProcess>;
  62957. /**
  62958. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  62959. */
  62960. blurHPostProcesses: PostProcess[];
  62961. /**
  62962. * Post-process array storing all the vertical blur post-processes used by the pipeline
  62963. */
  62964. blurVPostProcesses: PostProcess[];
  62965. /**
  62966. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  62967. */
  62968. textureAdderPostProcess: Nullable<PostProcess>;
  62969. /**
  62970. * Post-process used to create volumetric lighting effect
  62971. */
  62972. volumetricLightPostProcess: Nullable<PostProcess>;
  62973. /**
  62974. * Post-process used to smooth the previous volumetric light post-process on the X axis
  62975. */
  62976. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  62977. /**
  62978. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  62979. */
  62980. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  62981. /**
  62982. * Post-process used to merge the volumetric light effect and the real scene color
  62983. */
  62984. volumetricLightMergePostProces: Nullable<PostProcess>;
  62985. /**
  62986. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  62987. */
  62988. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  62989. /**
  62990. * Base post-process used to calculate the average luminance of the final image for HDR
  62991. */
  62992. luminancePostProcess: Nullable<PostProcess>;
  62993. /**
  62994. * Post-processes used to create down sample post-processes in order to get
  62995. * the average luminance of the final image for HDR
  62996. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  62997. */
  62998. luminanceDownSamplePostProcesses: PostProcess[];
  62999. /**
  63000. * Post-process used to create a HDR effect (light adaptation)
  63001. */
  63002. hdrPostProcess: Nullable<PostProcess>;
  63003. /**
  63004. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  63005. */
  63006. textureAdderFinalPostProcess: Nullable<PostProcess>;
  63007. /**
  63008. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  63009. */
  63010. lensFlareFinalPostProcess: Nullable<PostProcess>;
  63011. /**
  63012. * Post-process used to merge the final HDR post-process and the real scene color
  63013. */
  63014. hdrFinalPostProcess: Nullable<PostProcess>;
  63015. /**
  63016. * Post-process used to create a lens flare effect
  63017. */
  63018. lensFlarePostProcess: Nullable<PostProcess>;
  63019. /**
  63020. * Post-process that merges the result of the lens flare post-process and the real scene color
  63021. */
  63022. lensFlareComposePostProcess: Nullable<PostProcess>;
  63023. /**
  63024. * Post-process used to create a motion blur effect
  63025. */
  63026. motionBlurPostProcess: Nullable<PostProcess>;
  63027. /**
  63028. * Post-process used to create a depth of field effect
  63029. */
  63030. depthOfFieldPostProcess: Nullable<PostProcess>;
  63031. /**
  63032. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63033. */
  63034. fxaaPostProcess: Nullable<FxaaPostProcess>;
  63035. /**
  63036. * Represents the brightness threshold in order to configure the illuminated surfaces
  63037. */
  63038. brightThreshold: number;
  63039. /**
  63040. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  63041. */
  63042. blurWidth: number;
  63043. /**
  63044. * Sets if the blur for highlighted surfaces must be only horizontal
  63045. */
  63046. horizontalBlur: boolean;
  63047. /**
  63048. * Gets the overall exposure used by the pipeline
  63049. */
  63050. /**
  63051. * Sets the overall exposure used by the pipeline
  63052. */
  63053. exposure: number;
  63054. /**
  63055. * Texture used typically to simulate "dirty" on camera lens
  63056. */
  63057. lensTexture: Nullable<Texture>;
  63058. /**
  63059. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  63060. */
  63061. volumetricLightCoefficient: number;
  63062. /**
  63063. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  63064. */
  63065. volumetricLightPower: number;
  63066. /**
  63067. * Used the set the blur intensity to smooth the volumetric lights
  63068. */
  63069. volumetricLightBlurScale: number;
  63070. /**
  63071. * Light (spot or directional) used to generate the volumetric lights rays
  63072. * The source light must have a shadow generate so the pipeline can get its
  63073. * depth map
  63074. */
  63075. sourceLight: Nullable<SpotLight | DirectionalLight>;
  63076. /**
  63077. * For eye adaptation, represents the minimum luminance the eye can see
  63078. */
  63079. hdrMinimumLuminance: number;
  63080. /**
  63081. * For eye adaptation, represents the decrease luminance speed
  63082. */
  63083. hdrDecreaseRate: number;
  63084. /**
  63085. * For eye adaptation, represents the increase luminance speed
  63086. */
  63087. hdrIncreaseRate: number;
  63088. /**
  63089. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63090. */
  63091. /**
  63092. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63093. */
  63094. hdrAutoExposure: boolean;
  63095. /**
  63096. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  63097. */
  63098. lensColorTexture: Nullable<Texture>;
  63099. /**
  63100. * The overall strengh for the lens flare effect
  63101. */
  63102. lensFlareStrength: number;
  63103. /**
  63104. * Dispersion coefficient for lens flare ghosts
  63105. */
  63106. lensFlareGhostDispersal: number;
  63107. /**
  63108. * Main lens flare halo width
  63109. */
  63110. lensFlareHaloWidth: number;
  63111. /**
  63112. * Based on the lens distortion effect, defines how much the lens flare result
  63113. * is distorted
  63114. */
  63115. lensFlareDistortionStrength: number;
  63116. /**
  63117. * Configures the blur intensity used for for lens flare (halo)
  63118. */
  63119. lensFlareBlurWidth: number;
  63120. /**
  63121. * Lens star texture must be used to simulate rays on the flares and is available
  63122. * in the documentation
  63123. */
  63124. lensStarTexture: Nullable<Texture>;
  63125. /**
  63126. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  63127. * flare effect by taking account of the dirt texture
  63128. */
  63129. lensFlareDirtTexture: Nullable<Texture>;
  63130. /**
  63131. * Represents the focal length for the depth of field effect
  63132. */
  63133. depthOfFieldDistance: number;
  63134. /**
  63135. * Represents the blur intensity for the blurred part of the depth of field effect
  63136. */
  63137. depthOfFieldBlurWidth: number;
  63138. /**
  63139. * Gets how much the image is blurred by the movement while using the motion blur post-process
  63140. */
  63141. /**
  63142. * Sets how much the image is blurred by the movement while using the motion blur post-process
  63143. */
  63144. motionStrength: number;
  63145. /**
  63146. * Gets wether or not the motion blur post-process is object based or screen based.
  63147. */
  63148. /**
  63149. * Sets wether or not the motion blur post-process should be object based or screen based
  63150. */
  63151. objectBasedMotionBlur: boolean;
  63152. /**
  63153. * List of animations for the pipeline (IAnimatable implementation)
  63154. */
  63155. animations: Animation[];
  63156. /**
  63157. * Private members
  63158. */
  63159. private _scene;
  63160. private _currentDepthOfFieldSource;
  63161. private _basePostProcess;
  63162. private _fixedExposure;
  63163. private _currentExposure;
  63164. private _hdrAutoExposure;
  63165. private _hdrCurrentLuminance;
  63166. private _motionStrength;
  63167. private _isObjectBasedMotionBlur;
  63168. private _floatTextureType;
  63169. private _camerasToBeAttached;
  63170. private _ratio;
  63171. private _bloomEnabled;
  63172. private _depthOfFieldEnabled;
  63173. private _vlsEnabled;
  63174. private _lensFlareEnabled;
  63175. private _hdrEnabled;
  63176. private _motionBlurEnabled;
  63177. private _fxaaEnabled;
  63178. private _motionBlurSamples;
  63179. private _volumetricLightStepsCount;
  63180. private _samples;
  63181. /**
  63182. * @ignore
  63183. * Specifies if the bloom pipeline is enabled
  63184. */
  63185. BloomEnabled: boolean;
  63186. /**
  63187. * @ignore
  63188. * Specifies if the depth of field pipeline is enabed
  63189. */
  63190. DepthOfFieldEnabled: boolean;
  63191. /**
  63192. * @ignore
  63193. * Specifies if the lens flare pipeline is enabed
  63194. */
  63195. LensFlareEnabled: boolean;
  63196. /**
  63197. * @ignore
  63198. * Specifies if the HDR pipeline is enabled
  63199. */
  63200. HDREnabled: boolean;
  63201. /**
  63202. * @ignore
  63203. * Specifies if the volumetric lights scattering effect is enabled
  63204. */
  63205. VLSEnabled: boolean;
  63206. /**
  63207. * @ignore
  63208. * Specifies if the motion blur effect is enabled
  63209. */
  63210. MotionBlurEnabled: boolean;
  63211. /**
  63212. * Specifies if anti-aliasing is enabled
  63213. */
  63214. fxaaEnabled: boolean;
  63215. /**
  63216. * Specifies the number of steps used to calculate the volumetric lights
  63217. * Typically in interval [50, 200]
  63218. */
  63219. volumetricLightStepsCount: number;
  63220. /**
  63221. * Specifies the number of samples used for the motion blur effect
  63222. * Typically in interval [16, 64]
  63223. */
  63224. motionBlurSamples: number;
  63225. /**
  63226. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63227. */
  63228. samples: number;
  63229. /**
  63230. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63231. * @constructor
  63232. * @param name The rendering pipeline name
  63233. * @param scene The scene linked to this pipeline
  63234. * @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)
  63235. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  63236. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63237. */
  63238. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  63239. private _buildPipeline;
  63240. private _createDownSampleX4PostProcess;
  63241. private _createBrightPassPostProcess;
  63242. private _createBlurPostProcesses;
  63243. private _createTextureAdderPostProcess;
  63244. private _createVolumetricLightPostProcess;
  63245. private _createLuminancePostProcesses;
  63246. private _createHdrPostProcess;
  63247. private _createLensFlarePostProcess;
  63248. private _createDepthOfFieldPostProcess;
  63249. private _createMotionBlurPostProcess;
  63250. private _getDepthTexture;
  63251. private _disposePostProcesses;
  63252. /**
  63253. * Dispose of the pipeline and stop all post processes
  63254. */
  63255. dispose(): void;
  63256. /**
  63257. * Serialize the rendering pipeline (Used when exporting)
  63258. * @returns the serialized object
  63259. */
  63260. serialize(): any;
  63261. /**
  63262. * Parse the serialized pipeline
  63263. * @param source Source pipeline.
  63264. * @param scene The scene to load the pipeline to.
  63265. * @param rootUrl The URL of the serialized pipeline.
  63266. * @returns An instantiated pipeline from the serialized object.
  63267. */
  63268. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  63269. /**
  63270. * Luminance steps
  63271. */
  63272. static LuminanceSteps: number;
  63273. }
  63274. }
  63275. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  63276. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  63277. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  63278. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  63279. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  63280. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  63281. }
  63282. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  63283. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  63284. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63285. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63286. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63287. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63288. }
  63289. declare module "babylonjs/Shaders/tonemap.fragment" {
  63290. /** @hidden */
  63291. export var tonemapPixelShader: {
  63292. name: string;
  63293. shader: string;
  63294. };
  63295. }
  63296. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  63297. import { Camera } from "babylonjs/Cameras/camera";
  63298. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63299. import "babylonjs/Shaders/tonemap.fragment";
  63300. import { Engine } from "babylonjs/Engines/engine";
  63301. /** Defines operator used for tonemapping */
  63302. export enum TonemappingOperator {
  63303. /** Hable */
  63304. Hable = 0,
  63305. /** Reinhard */
  63306. Reinhard = 1,
  63307. /** HejiDawson */
  63308. HejiDawson = 2,
  63309. /** Photographic */
  63310. Photographic = 3
  63311. }
  63312. /**
  63313. * Defines a post process to apply tone mapping
  63314. */
  63315. export class TonemapPostProcess extends PostProcess {
  63316. private _operator;
  63317. /** Defines the required exposure adjustement */
  63318. exposureAdjustment: number;
  63319. /**
  63320. * Creates a new TonemapPostProcess
  63321. * @param name defines the name of the postprocess
  63322. * @param _operator defines the operator to use
  63323. * @param exposureAdjustment defines the required exposure adjustement
  63324. * @param camera defines the camera to use (can be null)
  63325. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  63326. * @param engine defines the hosting engine (can be ignore if camera is set)
  63327. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63328. */
  63329. constructor(name: string, _operator: TonemappingOperator,
  63330. /** Defines the required exposure adjustement */
  63331. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  63332. }
  63333. }
  63334. declare module "babylonjs/Shaders/depth.vertex" {
  63335. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63336. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63337. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63338. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63339. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63340. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63341. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63342. /** @hidden */
  63343. export var depthVertexShader: {
  63344. name: string;
  63345. shader: string;
  63346. };
  63347. }
  63348. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  63349. /** @hidden */
  63350. export var volumetricLightScatteringPixelShader: {
  63351. name: string;
  63352. shader: string;
  63353. };
  63354. }
  63355. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  63356. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63357. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63358. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63359. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63360. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63361. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63362. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63363. /** @hidden */
  63364. export var volumetricLightScatteringPassVertexShader: {
  63365. name: string;
  63366. shader: string;
  63367. };
  63368. }
  63369. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  63370. /** @hidden */
  63371. export var volumetricLightScatteringPassPixelShader: {
  63372. name: string;
  63373. shader: string;
  63374. };
  63375. }
  63376. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  63377. import { Vector3 } from "babylonjs/Maths/math.vector";
  63378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63379. import { Mesh } from "babylonjs/Meshes/mesh";
  63380. import { Camera } from "babylonjs/Cameras/camera";
  63381. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63382. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63383. import { Scene } from "babylonjs/scene";
  63384. import "babylonjs/Meshes/Builders/planeBuilder";
  63385. import "babylonjs/Shaders/depth.vertex";
  63386. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  63387. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  63388. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  63389. import { Engine } from "babylonjs/Engines/engine";
  63390. /**
  63391. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  63392. */
  63393. export class VolumetricLightScatteringPostProcess extends PostProcess {
  63394. private _volumetricLightScatteringPass;
  63395. private _volumetricLightScatteringRTT;
  63396. private _viewPort;
  63397. private _screenCoordinates;
  63398. private _cachedDefines;
  63399. /**
  63400. * If not undefined, the mesh position is computed from the attached node position
  63401. */
  63402. attachedNode: {
  63403. position: Vector3;
  63404. };
  63405. /**
  63406. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  63407. */
  63408. customMeshPosition: Vector3;
  63409. /**
  63410. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  63411. */
  63412. useCustomMeshPosition: boolean;
  63413. /**
  63414. * If the post-process should inverse the light scattering direction
  63415. */
  63416. invert: boolean;
  63417. /**
  63418. * The internal mesh used by the post-process
  63419. */
  63420. mesh: Mesh;
  63421. /**
  63422. * @hidden
  63423. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  63424. */
  63425. useDiffuseColor: boolean;
  63426. /**
  63427. * Array containing the excluded meshes not rendered in the internal pass
  63428. */
  63429. excludedMeshes: AbstractMesh[];
  63430. /**
  63431. * Controls the overall intensity of the post-process
  63432. */
  63433. exposure: number;
  63434. /**
  63435. * Dissipates each sample's contribution in range [0, 1]
  63436. */
  63437. decay: number;
  63438. /**
  63439. * Controls the overall intensity of each sample
  63440. */
  63441. weight: number;
  63442. /**
  63443. * Controls the density of each sample
  63444. */
  63445. density: number;
  63446. /**
  63447. * @constructor
  63448. * @param name The post-process name
  63449. * @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)
  63450. * @param camera The camera that the post-process will be attached to
  63451. * @param mesh The mesh used to create the light scattering
  63452. * @param samples The post-process quality, default 100
  63453. * @param samplingModeThe post-process filtering mode
  63454. * @param engine The babylon engine
  63455. * @param reusable If the post-process is reusable
  63456. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  63457. */
  63458. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  63459. /**
  63460. * Returns the string "VolumetricLightScatteringPostProcess"
  63461. * @returns "VolumetricLightScatteringPostProcess"
  63462. */
  63463. getClassName(): string;
  63464. private _isReady;
  63465. /**
  63466. * Sets the new light position for light scattering effect
  63467. * @param position The new custom light position
  63468. */
  63469. setCustomMeshPosition(position: Vector3): void;
  63470. /**
  63471. * Returns the light position for light scattering effect
  63472. * @return Vector3 The custom light position
  63473. */
  63474. getCustomMeshPosition(): Vector3;
  63475. /**
  63476. * Disposes the internal assets and detaches the post-process from the camera
  63477. */
  63478. dispose(camera: Camera): void;
  63479. /**
  63480. * Returns the render target texture used by the post-process
  63481. * @return the render target texture used by the post-process
  63482. */
  63483. getPass(): RenderTargetTexture;
  63484. private _meshExcluded;
  63485. private _createPass;
  63486. private _updateMeshScreenCoordinates;
  63487. /**
  63488. * Creates a default mesh for the Volumeric Light Scattering post-process
  63489. * @param name The mesh name
  63490. * @param scene The scene where to create the mesh
  63491. * @return the default mesh
  63492. */
  63493. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  63494. }
  63495. }
  63496. declare module "babylonjs/PostProcesses/index" {
  63497. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  63498. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  63499. export * from "babylonjs/PostProcesses/bloomEffect";
  63500. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  63501. export * from "babylonjs/PostProcesses/blurPostProcess";
  63502. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63503. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  63504. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  63505. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  63506. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  63507. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  63508. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  63509. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  63510. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  63511. export * from "babylonjs/PostProcesses/filterPostProcess";
  63512. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  63513. export * from "babylonjs/PostProcesses/grainPostProcess";
  63514. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  63515. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63516. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  63517. export * from "babylonjs/PostProcesses/passPostProcess";
  63518. export * from "babylonjs/PostProcesses/postProcess";
  63519. export * from "babylonjs/PostProcesses/postProcessManager";
  63520. export * from "babylonjs/PostProcesses/refractionPostProcess";
  63521. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  63522. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  63523. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  63524. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  63525. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  63526. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  63527. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  63528. }
  63529. declare module "babylonjs/Probes/index" {
  63530. export * from "babylonjs/Probes/reflectionProbe";
  63531. }
  63532. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  63533. import { Scene } from "babylonjs/scene";
  63534. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63535. import { SmartArray } from "babylonjs/Misc/smartArray";
  63536. import { ISceneComponent } from "babylonjs/sceneComponent";
  63537. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  63538. import "babylonjs/Meshes/Builders/boxBuilder";
  63539. import "babylonjs/Shaders/color.fragment";
  63540. import "babylonjs/Shaders/color.vertex";
  63541. import { Color3 } from "babylonjs/Maths/math.color";
  63542. module "babylonjs/scene" {
  63543. interface Scene {
  63544. /** @hidden (Backing field) */
  63545. _boundingBoxRenderer: BoundingBoxRenderer;
  63546. /** @hidden (Backing field) */
  63547. _forceShowBoundingBoxes: boolean;
  63548. /**
  63549. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  63550. */
  63551. forceShowBoundingBoxes: boolean;
  63552. /**
  63553. * Gets the bounding box renderer associated with the scene
  63554. * @returns a BoundingBoxRenderer
  63555. */
  63556. getBoundingBoxRenderer(): BoundingBoxRenderer;
  63557. }
  63558. }
  63559. module "babylonjs/Meshes/abstractMesh" {
  63560. interface AbstractMesh {
  63561. /** @hidden (Backing field) */
  63562. _showBoundingBox: boolean;
  63563. /**
  63564. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  63565. */
  63566. showBoundingBox: boolean;
  63567. }
  63568. }
  63569. /**
  63570. * Component responsible of rendering the bounding box of the meshes in a scene.
  63571. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  63572. */
  63573. export class BoundingBoxRenderer implements ISceneComponent {
  63574. /**
  63575. * The component name helpfull to identify the component in the list of scene components.
  63576. */
  63577. readonly name: string;
  63578. /**
  63579. * The scene the component belongs to.
  63580. */
  63581. scene: Scene;
  63582. /**
  63583. * Color of the bounding box lines placed in front of an object
  63584. */
  63585. frontColor: Color3;
  63586. /**
  63587. * Color of the bounding box lines placed behind an object
  63588. */
  63589. backColor: Color3;
  63590. /**
  63591. * Defines if the renderer should show the back lines or not
  63592. */
  63593. showBackLines: boolean;
  63594. /**
  63595. * @hidden
  63596. */
  63597. renderList: SmartArray<BoundingBox>;
  63598. private _colorShader;
  63599. private _vertexBuffers;
  63600. private _indexBuffer;
  63601. private _fillIndexBuffer;
  63602. private _fillIndexData;
  63603. /**
  63604. * Instantiates a new bounding box renderer in a scene.
  63605. * @param scene the scene the renderer renders in
  63606. */
  63607. constructor(scene: Scene);
  63608. /**
  63609. * Registers the component in a given scene
  63610. */
  63611. register(): void;
  63612. private _evaluateSubMesh;
  63613. private _activeMesh;
  63614. private _prepareRessources;
  63615. private _createIndexBuffer;
  63616. /**
  63617. * Rebuilds the elements related to this component in case of
  63618. * context lost for instance.
  63619. */
  63620. rebuild(): void;
  63621. /**
  63622. * @hidden
  63623. */
  63624. reset(): void;
  63625. /**
  63626. * Render the bounding boxes of a specific rendering group
  63627. * @param renderingGroupId defines the rendering group to render
  63628. */
  63629. render(renderingGroupId: number): void;
  63630. /**
  63631. * In case of occlusion queries, we can render the occlusion bounding box through this method
  63632. * @param mesh Define the mesh to render the occlusion bounding box for
  63633. */
  63634. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  63635. /**
  63636. * Dispose and release the resources attached to this renderer.
  63637. */
  63638. dispose(): void;
  63639. }
  63640. }
  63641. declare module "babylonjs/Shaders/depth.fragment" {
  63642. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63643. /** @hidden */
  63644. export var depthPixelShader: {
  63645. name: string;
  63646. shader: string;
  63647. };
  63648. }
  63649. declare module "babylonjs/Rendering/depthRenderer" {
  63650. import { Nullable } from "babylonjs/types";
  63651. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63652. import { Scene } from "babylonjs/scene";
  63653. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63654. import { Camera } from "babylonjs/Cameras/camera";
  63655. import "babylonjs/Shaders/depth.fragment";
  63656. import "babylonjs/Shaders/depth.vertex";
  63657. /**
  63658. * This represents a depth renderer in Babylon.
  63659. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63660. */
  63661. export class DepthRenderer {
  63662. private _scene;
  63663. private _depthMap;
  63664. private _effect;
  63665. private readonly _storeNonLinearDepth;
  63666. private readonly _clearColor;
  63667. /** Get if the depth renderer is using packed depth or not */
  63668. readonly isPacked: boolean;
  63669. private _cachedDefines;
  63670. private _camera;
  63671. /**
  63672. * Specifiess that the depth renderer will only be used within
  63673. * the camera it is created for.
  63674. * This can help forcing its rendering during the camera processing.
  63675. */
  63676. useOnlyInActiveCamera: boolean;
  63677. /** @hidden */
  63678. static _SceneComponentInitialization: (scene: Scene) => void;
  63679. /**
  63680. * Instantiates a depth renderer
  63681. * @param scene The scene the renderer belongs to
  63682. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63683. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63684. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63685. */
  63686. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63687. /**
  63688. * Creates the depth rendering effect and checks if the effect is ready.
  63689. * @param subMesh The submesh to be used to render the depth map of
  63690. * @param useInstances If multiple world instances should be used
  63691. * @returns if the depth renderer is ready to render the depth map
  63692. */
  63693. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63694. /**
  63695. * Gets the texture which the depth map will be written to.
  63696. * @returns The depth map texture
  63697. */
  63698. getDepthMap(): RenderTargetTexture;
  63699. /**
  63700. * Disposes of the depth renderer.
  63701. */
  63702. dispose(): void;
  63703. }
  63704. }
  63705. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  63706. import { Nullable } from "babylonjs/types";
  63707. import { Scene } from "babylonjs/scene";
  63708. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63709. import { Camera } from "babylonjs/Cameras/camera";
  63710. import { ISceneComponent } from "babylonjs/sceneComponent";
  63711. module "babylonjs/scene" {
  63712. interface Scene {
  63713. /** @hidden (Backing field) */
  63714. _depthRenderer: {
  63715. [id: string]: DepthRenderer;
  63716. };
  63717. /**
  63718. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  63719. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  63720. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63721. * @returns the created depth renderer
  63722. */
  63723. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  63724. /**
  63725. * Disables a depth renderer for a given camera
  63726. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  63727. */
  63728. disableDepthRenderer(camera?: Nullable<Camera>): void;
  63729. }
  63730. }
  63731. /**
  63732. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  63733. * in several rendering techniques.
  63734. */
  63735. export class DepthRendererSceneComponent implements ISceneComponent {
  63736. /**
  63737. * The component name helpfull to identify the component in the list of scene components.
  63738. */
  63739. readonly name: string;
  63740. /**
  63741. * The scene the component belongs to.
  63742. */
  63743. scene: Scene;
  63744. /**
  63745. * Creates a new instance of the component for the given scene
  63746. * @param scene Defines the scene to register the component in
  63747. */
  63748. constructor(scene: Scene);
  63749. /**
  63750. * Registers the component in a given scene
  63751. */
  63752. register(): void;
  63753. /**
  63754. * Rebuilds the elements related to this component in case of
  63755. * context lost for instance.
  63756. */
  63757. rebuild(): void;
  63758. /**
  63759. * Disposes the component and the associated ressources
  63760. */
  63761. dispose(): void;
  63762. private _gatherRenderTargets;
  63763. private _gatherActiveCameraRenderTargets;
  63764. }
  63765. }
  63766. declare module "babylonjs/Shaders/outline.fragment" {
  63767. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  63768. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  63769. /** @hidden */
  63770. export var outlinePixelShader: {
  63771. name: string;
  63772. shader: string;
  63773. };
  63774. }
  63775. declare module "babylonjs/Shaders/outline.vertex" {
  63776. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63777. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63778. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63779. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63780. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  63781. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63782. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63783. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63784. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  63785. /** @hidden */
  63786. export var outlineVertexShader: {
  63787. name: string;
  63788. shader: string;
  63789. };
  63790. }
  63791. declare module "babylonjs/Rendering/outlineRenderer" {
  63792. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63793. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  63794. import { Scene } from "babylonjs/scene";
  63795. import { ISceneComponent } from "babylonjs/sceneComponent";
  63796. import "babylonjs/Shaders/outline.fragment";
  63797. import "babylonjs/Shaders/outline.vertex";
  63798. module "babylonjs/scene" {
  63799. interface Scene {
  63800. /** @hidden */
  63801. _outlineRenderer: OutlineRenderer;
  63802. /**
  63803. * Gets the outline renderer associated with the scene
  63804. * @returns a OutlineRenderer
  63805. */
  63806. getOutlineRenderer(): OutlineRenderer;
  63807. }
  63808. }
  63809. module "babylonjs/Meshes/abstractMesh" {
  63810. interface AbstractMesh {
  63811. /** @hidden (Backing field) */
  63812. _renderOutline: boolean;
  63813. /**
  63814. * Gets or sets a boolean indicating if the outline must be rendered as well
  63815. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  63816. */
  63817. renderOutline: boolean;
  63818. /** @hidden (Backing field) */
  63819. _renderOverlay: boolean;
  63820. /**
  63821. * Gets or sets a boolean indicating if the overlay must be rendered as well
  63822. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  63823. */
  63824. renderOverlay: boolean;
  63825. }
  63826. }
  63827. /**
  63828. * This class is responsible to draw bothe outline/overlay of meshes.
  63829. * It should not be used directly but through the available method on mesh.
  63830. */
  63831. export class OutlineRenderer implements ISceneComponent {
  63832. /**
  63833. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  63834. */
  63835. private static _StencilReference;
  63836. /**
  63837. * The name of the component. Each component must have a unique name.
  63838. */
  63839. name: string;
  63840. /**
  63841. * The scene the component belongs to.
  63842. */
  63843. scene: Scene;
  63844. /**
  63845. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  63846. */
  63847. zOffset: number;
  63848. private _engine;
  63849. private _effect;
  63850. private _cachedDefines;
  63851. private _savedDepthWrite;
  63852. /**
  63853. * Instantiates a new outline renderer. (There could be only one per scene).
  63854. * @param scene Defines the scene it belongs to
  63855. */
  63856. constructor(scene: Scene);
  63857. /**
  63858. * Register the component to one instance of a scene.
  63859. */
  63860. register(): void;
  63861. /**
  63862. * Rebuilds the elements related to this component in case of
  63863. * context lost for instance.
  63864. */
  63865. rebuild(): void;
  63866. /**
  63867. * Disposes the component and the associated ressources.
  63868. */
  63869. dispose(): void;
  63870. /**
  63871. * Renders the outline in the canvas.
  63872. * @param subMesh Defines the sumesh to render
  63873. * @param batch Defines the batch of meshes in case of instances
  63874. * @param useOverlay Defines if the rendering is for the overlay or the outline
  63875. */
  63876. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  63877. /**
  63878. * Returns whether or not the outline renderer is ready for a given submesh.
  63879. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  63880. * @param subMesh Defines the submesh to check readyness for
  63881. * @param useInstances Defines wheter wee are trying to render instances or not
  63882. * @returns true if ready otherwise false
  63883. */
  63884. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63885. private _beforeRenderingMesh;
  63886. private _afterRenderingMesh;
  63887. }
  63888. }
  63889. declare module "babylonjs/Rendering/index" {
  63890. export * from "babylonjs/Rendering/boundingBoxRenderer";
  63891. export * from "babylonjs/Rendering/depthRenderer";
  63892. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  63893. export * from "babylonjs/Rendering/edgesRenderer";
  63894. export * from "babylonjs/Rendering/geometryBufferRenderer";
  63895. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  63896. export * from "babylonjs/Rendering/outlineRenderer";
  63897. export * from "babylonjs/Rendering/renderingGroup";
  63898. export * from "babylonjs/Rendering/renderingManager";
  63899. export * from "babylonjs/Rendering/utilityLayerRenderer";
  63900. }
  63901. declare module "babylonjs/Sprites/spritePackedManager" {
  63902. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  63903. import { Scene } from "babylonjs/scene";
  63904. /**
  63905. * Class used to manage multiple sprites of different sizes on the same spritesheet
  63906. * @see http://doc.babylonjs.com/babylon101/sprites
  63907. */
  63908. export class SpritePackedManager extends SpriteManager {
  63909. /** defines the packed manager's name */
  63910. name: string;
  63911. /**
  63912. * Creates a new sprite manager from a packed sprite sheet
  63913. * @param name defines the manager's name
  63914. * @param imgUrl defines the sprite sheet url
  63915. * @param capacity defines the maximum allowed number of sprites
  63916. * @param scene defines the hosting scene
  63917. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  63918. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  63919. * @param samplingMode defines the smapling mode to use with spritesheet
  63920. * @param fromPacked set to true; do not alter
  63921. */
  63922. constructor(
  63923. /** defines the packed manager's name */
  63924. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  63925. }
  63926. }
  63927. declare module "babylonjs/Sprites/index" {
  63928. export * from "babylonjs/Sprites/sprite";
  63929. export * from "babylonjs/Sprites/spriteManager";
  63930. export * from "babylonjs/Sprites/spritePackedManager";
  63931. export * from "babylonjs/Sprites/spriteSceneComponent";
  63932. }
  63933. declare module "babylonjs/Misc/assetsManager" {
  63934. import { Scene } from "babylonjs/scene";
  63935. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63936. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  63937. import { Skeleton } from "babylonjs/Bones/skeleton";
  63938. import { Observable } from "babylonjs/Misc/observable";
  63939. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63940. import { Texture } from "babylonjs/Materials/Textures/texture";
  63941. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  63942. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  63943. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  63944. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  63945. /**
  63946. * Defines the list of states available for a task inside a AssetsManager
  63947. */
  63948. export enum AssetTaskState {
  63949. /**
  63950. * Initialization
  63951. */
  63952. INIT = 0,
  63953. /**
  63954. * Running
  63955. */
  63956. RUNNING = 1,
  63957. /**
  63958. * Done
  63959. */
  63960. DONE = 2,
  63961. /**
  63962. * Error
  63963. */
  63964. ERROR = 3
  63965. }
  63966. /**
  63967. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  63968. */
  63969. export abstract class AbstractAssetTask {
  63970. /**
  63971. * Task name
  63972. */ name: string;
  63973. /**
  63974. * Callback called when the task is successful
  63975. */
  63976. onSuccess: (task: any) => void;
  63977. /**
  63978. * Callback called when the task is not successful
  63979. */
  63980. onError: (task: any, message?: string, exception?: any) => void;
  63981. /**
  63982. * Creates a new AssetsManager
  63983. * @param name defines the name of the task
  63984. */
  63985. constructor(
  63986. /**
  63987. * Task name
  63988. */ name: string);
  63989. private _isCompleted;
  63990. private _taskState;
  63991. private _errorObject;
  63992. /**
  63993. * Get if the task is completed
  63994. */
  63995. readonly isCompleted: boolean;
  63996. /**
  63997. * Gets the current state of the task
  63998. */
  63999. readonly taskState: AssetTaskState;
  64000. /**
  64001. * Gets the current error object (if task is in error)
  64002. */
  64003. readonly errorObject: {
  64004. message?: string;
  64005. exception?: any;
  64006. };
  64007. /**
  64008. * Internal only
  64009. * @hidden
  64010. */
  64011. _setErrorObject(message?: string, exception?: any): void;
  64012. /**
  64013. * Execute the current task
  64014. * @param scene defines the scene where you want your assets to be loaded
  64015. * @param onSuccess is a callback called when the task is successfully executed
  64016. * @param onError is a callback called if an error occurs
  64017. */
  64018. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64019. /**
  64020. * Execute the current task
  64021. * @param scene defines the scene where you want your assets to be loaded
  64022. * @param onSuccess is a callback called when the task is successfully executed
  64023. * @param onError is a callback called if an error occurs
  64024. */
  64025. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64026. /**
  64027. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  64028. * This can be used with failed tasks that have the reason for failure fixed.
  64029. */
  64030. reset(): void;
  64031. private onErrorCallback;
  64032. private onDoneCallback;
  64033. }
  64034. /**
  64035. * Define the interface used by progress events raised during assets loading
  64036. */
  64037. export interface IAssetsProgressEvent {
  64038. /**
  64039. * Defines the number of remaining tasks to process
  64040. */
  64041. remainingCount: number;
  64042. /**
  64043. * Defines the total number of tasks
  64044. */
  64045. totalCount: number;
  64046. /**
  64047. * Defines the task that was just processed
  64048. */
  64049. task: AbstractAssetTask;
  64050. }
  64051. /**
  64052. * Class used to share progress information about assets loading
  64053. */
  64054. export class AssetsProgressEvent implements IAssetsProgressEvent {
  64055. /**
  64056. * Defines the number of remaining tasks to process
  64057. */
  64058. remainingCount: number;
  64059. /**
  64060. * Defines the total number of tasks
  64061. */
  64062. totalCount: number;
  64063. /**
  64064. * Defines the task that was just processed
  64065. */
  64066. task: AbstractAssetTask;
  64067. /**
  64068. * Creates a AssetsProgressEvent
  64069. * @param remainingCount defines the number of remaining tasks to process
  64070. * @param totalCount defines the total number of tasks
  64071. * @param task defines the task that was just processed
  64072. */
  64073. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  64074. }
  64075. /**
  64076. * Define a task used by AssetsManager to load meshes
  64077. */
  64078. export class MeshAssetTask extends AbstractAssetTask {
  64079. /**
  64080. * Defines the name of the task
  64081. */
  64082. name: string;
  64083. /**
  64084. * Defines the list of mesh's names you want to load
  64085. */
  64086. meshesNames: any;
  64087. /**
  64088. * Defines the root url to use as a base to load your meshes and associated resources
  64089. */
  64090. rootUrl: string;
  64091. /**
  64092. * Defines the filename of the scene to load from
  64093. */
  64094. sceneFilename: string;
  64095. /**
  64096. * Gets the list of loaded meshes
  64097. */
  64098. loadedMeshes: Array<AbstractMesh>;
  64099. /**
  64100. * Gets the list of loaded particle systems
  64101. */
  64102. loadedParticleSystems: Array<IParticleSystem>;
  64103. /**
  64104. * Gets the list of loaded skeletons
  64105. */
  64106. loadedSkeletons: Array<Skeleton>;
  64107. /**
  64108. * Gets the list of loaded animation groups
  64109. */
  64110. loadedAnimationGroups: Array<AnimationGroup>;
  64111. /**
  64112. * Callback called when the task is successful
  64113. */
  64114. onSuccess: (task: MeshAssetTask) => void;
  64115. /**
  64116. * Callback called when the task is successful
  64117. */
  64118. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  64119. /**
  64120. * Creates a new MeshAssetTask
  64121. * @param name defines the name of the task
  64122. * @param meshesNames defines the list of mesh's names you want to load
  64123. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  64124. * @param sceneFilename defines the filename of the scene to load from
  64125. */
  64126. constructor(
  64127. /**
  64128. * Defines the name of the task
  64129. */
  64130. name: string,
  64131. /**
  64132. * Defines the list of mesh's names you want to load
  64133. */
  64134. meshesNames: any,
  64135. /**
  64136. * Defines the root url to use as a base to load your meshes and associated resources
  64137. */
  64138. rootUrl: string,
  64139. /**
  64140. * Defines the filename of the scene to load from
  64141. */
  64142. sceneFilename: string);
  64143. /**
  64144. * Execute the current task
  64145. * @param scene defines the scene where you want your assets to be loaded
  64146. * @param onSuccess is a callback called when the task is successfully executed
  64147. * @param onError is a callback called if an error occurs
  64148. */
  64149. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64150. }
  64151. /**
  64152. * Define a task used by AssetsManager to load text content
  64153. */
  64154. export class TextFileAssetTask extends AbstractAssetTask {
  64155. /**
  64156. * Defines the name of the task
  64157. */
  64158. name: string;
  64159. /**
  64160. * Defines the location of the file to load
  64161. */
  64162. url: string;
  64163. /**
  64164. * Gets the loaded text string
  64165. */
  64166. text: string;
  64167. /**
  64168. * Callback called when the task is successful
  64169. */
  64170. onSuccess: (task: TextFileAssetTask) => void;
  64171. /**
  64172. * Callback called when the task is successful
  64173. */
  64174. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  64175. /**
  64176. * Creates a new TextFileAssetTask object
  64177. * @param name defines the name of the task
  64178. * @param url defines the location of the file to load
  64179. */
  64180. constructor(
  64181. /**
  64182. * Defines the name of the task
  64183. */
  64184. name: string,
  64185. /**
  64186. * Defines the location of the file to load
  64187. */
  64188. url: string);
  64189. /**
  64190. * Execute the current task
  64191. * @param scene defines the scene where you want your assets to be loaded
  64192. * @param onSuccess is a callback called when the task is successfully executed
  64193. * @param onError is a callback called if an error occurs
  64194. */
  64195. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64196. }
  64197. /**
  64198. * Define a task used by AssetsManager to load binary data
  64199. */
  64200. export class BinaryFileAssetTask extends AbstractAssetTask {
  64201. /**
  64202. * Defines the name of the task
  64203. */
  64204. name: string;
  64205. /**
  64206. * Defines the location of the file to load
  64207. */
  64208. url: string;
  64209. /**
  64210. * Gets the lodaded data (as an array buffer)
  64211. */
  64212. data: ArrayBuffer;
  64213. /**
  64214. * Callback called when the task is successful
  64215. */
  64216. onSuccess: (task: BinaryFileAssetTask) => void;
  64217. /**
  64218. * Callback called when the task is successful
  64219. */
  64220. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  64221. /**
  64222. * Creates a new BinaryFileAssetTask object
  64223. * @param name defines the name of the new task
  64224. * @param url defines the location of the file to load
  64225. */
  64226. constructor(
  64227. /**
  64228. * Defines the name of the task
  64229. */
  64230. name: string,
  64231. /**
  64232. * Defines the location of the file to load
  64233. */
  64234. url: string);
  64235. /**
  64236. * Execute the current task
  64237. * @param scene defines the scene where you want your assets to be loaded
  64238. * @param onSuccess is a callback called when the task is successfully executed
  64239. * @param onError is a callback called if an error occurs
  64240. */
  64241. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64242. }
  64243. /**
  64244. * Define a task used by AssetsManager to load images
  64245. */
  64246. export class ImageAssetTask extends AbstractAssetTask {
  64247. /**
  64248. * Defines the name of the task
  64249. */
  64250. name: string;
  64251. /**
  64252. * Defines the location of the image to load
  64253. */
  64254. url: string;
  64255. /**
  64256. * Gets the loaded images
  64257. */
  64258. image: HTMLImageElement;
  64259. /**
  64260. * Callback called when the task is successful
  64261. */
  64262. onSuccess: (task: ImageAssetTask) => void;
  64263. /**
  64264. * Callback called when the task is successful
  64265. */
  64266. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  64267. /**
  64268. * Creates a new ImageAssetTask
  64269. * @param name defines the name of the task
  64270. * @param url defines the location of the image to load
  64271. */
  64272. constructor(
  64273. /**
  64274. * Defines the name of the task
  64275. */
  64276. name: string,
  64277. /**
  64278. * Defines the location of the image to load
  64279. */
  64280. url: string);
  64281. /**
  64282. * Execute the current task
  64283. * @param scene defines the scene where you want your assets to be loaded
  64284. * @param onSuccess is a callback called when the task is successfully executed
  64285. * @param onError is a callback called if an error occurs
  64286. */
  64287. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64288. }
  64289. /**
  64290. * Defines the interface used by texture loading tasks
  64291. */
  64292. export interface ITextureAssetTask<TEX extends BaseTexture> {
  64293. /**
  64294. * Gets the loaded texture
  64295. */
  64296. texture: TEX;
  64297. }
  64298. /**
  64299. * Define a task used by AssetsManager to load 2D textures
  64300. */
  64301. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  64302. /**
  64303. * Defines the name of the task
  64304. */
  64305. name: string;
  64306. /**
  64307. * Defines the location of the file to load
  64308. */
  64309. url: string;
  64310. /**
  64311. * Defines if mipmap should not be generated (default is false)
  64312. */
  64313. noMipmap?: boolean | undefined;
  64314. /**
  64315. * Defines if texture must be inverted on Y axis (default is false)
  64316. */
  64317. invertY?: boolean | undefined;
  64318. /**
  64319. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64320. */
  64321. samplingMode: number;
  64322. /**
  64323. * Gets the loaded texture
  64324. */
  64325. texture: Texture;
  64326. /**
  64327. * Callback called when the task is successful
  64328. */
  64329. onSuccess: (task: TextureAssetTask) => void;
  64330. /**
  64331. * Callback called when the task is successful
  64332. */
  64333. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  64334. /**
  64335. * Creates a new TextureAssetTask object
  64336. * @param name defines the name of the task
  64337. * @param url defines the location of the file to load
  64338. * @param noMipmap defines if mipmap should not be generated (default is false)
  64339. * @param invertY defines if texture must be inverted on Y axis (default is false)
  64340. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64341. */
  64342. constructor(
  64343. /**
  64344. * Defines the name of the task
  64345. */
  64346. name: string,
  64347. /**
  64348. * Defines the location of the file to load
  64349. */
  64350. url: string,
  64351. /**
  64352. * Defines if mipmap should not be generated (default is false)
  64353. */
  64354. noMipmap?: boolean | undefined,
  64355. /**
  64356. * Defines if texture must be inverted on Y axis (default is false)
  64357. */
  64358. invertY?: boolean | undefined,
  64359. /**
  64360. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64361. */
  64362. samplingMode?: number);
  64363. /**
  64364. * Execute the current task
  64365. * @param scene defines the scene where you want your assets to be loaded
  64366. * @param onSuccess is a callback called when the task is successfully executed
  64367. * @param onError is a callback called if an error occurs
  64368. */
  64369. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64370. }
  64371. /**
  64372. * Define a task used by AssetsManager to load cube textures
  64373. */
  64374. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  64375. /**
  64376. * Defines the name of the task
  64377. */
  64378. name: string;
  64379. /**
  64380. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64381. */
  64382. url: string;
  64383. /**
  64384. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64385. */
  64386. extensions?: string[] | undefined;
  64387. /**
  64388. * Defines if mipmaps should not be generated (default is false)
  64389. */
  64390. noMipmap?: boolean | undefined;
  64391. /**
  64392. * Defines the explicit list of files (undefined by default)
  64393. */
  64394. files?: string[] | undefined;
  64395. /**
  64396. * Gets the loaded texture
  64397. */
  64398. texture: CubeTexture;
  64399. /**
  64400. * Callback called when the task is successful
  64401. */
  64402. onSuccess: (task: CubeTextureAssetTask) => void;
  64403. /**
  64404. * Callback called when the task is successful
  64405. */
  64406. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  64407. /**
  64408. * Creates a new CubeTextureAssetTask
  64409. * @param name defines the name of the task
  64410. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64411. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64412. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64413. * @param files defines the explicit list of files (undefined by default)
  64414. */
  64415. constructor(
  64416. /**
  64417. * Defines the name of the task
  64418. */
  64419. name: string,
  64420. /**
  64421. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64422. */
  64423. url: string,
  64424. /**
  64425. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64426. */
  64427. extensions?: string[] | undefined,
  64428. /**
  64429. * Defines if mipmaps should not be generated (default is false)
  64430. */
  64431. noMipmap?: boolean | undefined,
  64432. /**
  64433. * Defines the explicit list of files (undefined by default)
  64434. */
  64435. files?: string[] | undefined);
  64436. /**
  64437. * Execute the current task
  64438. * @param scene defines the scene where you want your assets to be loaded
  64439. * @param onSuccess is a callback called when the task is successfully executed
  64440. * @param onError is a callback called if an error occurs
  64441. */
  64442. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64443. }
  64444. /**
  64445. * Define a task used by AssetsManager to load HDR cube textures
  64446. */
  64447. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  64448. /**
  64449. * Defines the name of the task
  64450. */
  64451. name: string;
  64452. /**
  64453. * Defines the location of the file to load
  64454. */
  64455. url: string;
  64456. /**
  64457. * Defines the desired size (the more it increases the longer the generation will be)
  64458. */
  64459. size: number;
  64460. /**
  64461. * Defines if mipmaps should not be generated (default is false)
  64462. */
  64463. noMipmap: boolean;
  64464. /**
  64465. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64466. */
  64467. generateHarmonics: boolean;
  64468. /**
  64469. * 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)
  64470. */
  64471. gammaSpace: boolean;
  64472. /**
  64473. * Internal Use Only
  64474. */
  64475. reserved: boolean;
  64476. /**
  64477. * Gets the loaded texture
  64478. */
  64479. texture: HDRCubeTexture;
  64480. /**
  64481. * Callback called when the task is successful
  64482. */
  64483. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  64484. /**
  64485. * Callback called when the task is successful
  64486. */
  64487. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  64488. /**
  64489. * Creates a new HDRCubeTextureAssetTask object
  64490. * @param name defines the name of the task
  64491. * @param url defines the location of the file to load
  64492. * @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.
  64493. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64494. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64495. * @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)
  64496. * @param reserved Internal use only
  64497. */
  64498. constructor(
  64499. /**
  64500. * Defines the name of the task
  64501. */
  64502. name: string,
  64503. /**
  64504. * Defines the location of the file to load
  64505. */
  64506. url: string,
  64507. /**
  64508. * Defines the desired size (the more it increases the longer the generation will be)
  64509. */
  64510. size: number,
  64511. /**
  64512. * Defines if mipmaps should not be generated (default is false)
  64513. */
  64514. noMipmap?: boolean,
  64515. /**
  64516. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64517. */
  64518. generateHarmonics?: boolean,
  64519. /**
  64520. * 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)
  64521. */
  64522. gammaSpace?: boolean,
  64523. /**
  64524. * Internal Use Only
  64525. */
  64526. reserved?: boolean);
  64527. /**
  64528. * Execute the current task
  64529. * @param scene defines the scene where you want your assets to be loaded
  64530. * @param onSuccess is a callback called when the task is successfully executed
  64531. * @param onError is a callback called if an error occurs
  64532. */
  64533. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64534. }
  64535. /**
  64536. * Define a task used by AssetsManager to load Equirectangular cube textures
  64537. */
  64538. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  64539. /**
  64540. * Defines the name of the task
  64541. */
  64542. name: string;
  64543. /**
  64544. * Defines the location of the file to load
  64545. */
  64546. url: string;
  64547. /**
  64548. * Defines the desired size (the more it increases the longer the generation will be)
  64549. */
  64550. size: number;
  64551. /**
  64552. * Defines if mipmaps should not be generated (default is false)
  64553. */
  64554. noMipmap: boolean;
  64555. /**
  64556. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64557. * but the standard material would require them in Gamma space) (default is true)
  64558. */
  64559. gammaSpace: boolean;
  64560. /**
  64561. * Gets the loaded texture
  64562. */
  64563. texture: EquiRectangularCubeTexture;
  64564. /**
  64565. * Callback called when the task is successful
  64566. */
  64567. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  64568. /**
  64569. * Callback called when the task is successful
  64570. */
  64571. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  64572. /**
  64573. * Creates a new EquiRectangularCubeTextureAssetTask object
  64574. * @param name defines the name of the task
  64575. * @param url defines the location of the file to load
  64576. * @param size defines the desired size (the more it increases the longer the generation will be)
  64577. * If the size is omitted this implies you are using a preprocessed cubemap.
  64578. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64579. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  64580. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  64581. * (default is true)
  64582. */
  64583. constructor(
  64584. /**
  64585. * Defines the name of the task
  64586. */
  64587. name: string,
  64588. /**
  64589. * Defines the location of the file to load
  64590. */
  64591. url: string,
  64592. /**
  64593. * Defines the desired size (the more it increases the longer the generation will be)
  64594. */
  64595. size: number,
  64596. /**
  64597. * Defines if mipmaps should not be generated (default is false)
  64598. */
  64599. noMipmap?: boolean,
  64600. /**
  64601. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64602. * but the standard material would require them in Gamma space) (default is true)
  64603. */
  64604. gammaSpace?: boolean);
  64605. /**
  64606. * Execute the current task
  64607. * @param scene defines the scene where you want your assets to be loaded
  64608. * @param onSuccess is a callback called when the task is successfully executed
  64609. * @param onError is a callback called if an error occurs
  64610. */
  64611. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64612. }
  64613. /**
  64614. * This class can be used to easily import assets into a scene
  64615. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  64616. */
  64617. export class AssetsManager {
  64618. private _scene;
  64619. private _isLoading;
  64620. protected _tasks: AbstractAssetTask[];
  64621. protected _waitingTasksCount: number;
  64622. protected _totalTasksCount: number;
  64623. /**
  64624. * Callback called when all tasks are processed
  64625. */
  64626. onFinish: (tasks: AbstractAssetTask[]) => void;
  64627. /**
  64628. * Callback called when a task is successful
  64629. */
  64630. onTaskSuccess: (task: AbstractAssetTask) => void;
  64631. /**
  64632. * Callback called when a task had an error
  64633. */
  64634. onTaskError: (task: AbstractAssetTask) => void;
  64635. /**
  64636. * Callback called when a task is done (whatever the result is)
  64637. */
  64638. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  64639. /**
  64640. * Observable called when all tasks are processed
  64641. */
  64642. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  64643. /**
  64644. * Observable called when a task had an error
  64645. */
  64646. onTaskErrorObservable: Observable<AbstractAssetTask>;
  64647. /**
  64648. * Observable called when all tasks were executed
  64649. */
  64650. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  64651. /**
  64652. * Observable called when a task is done (whatever the result is)
  64653. */
  64654. onProgressObservable: Observable<IAssetsProgressEvent>;
  64655. /**
  64656. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  64657. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  64658. */
  64659. useDefaultLoadingScreen: boolean;
  64660. /**
  64661. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  64662. * when all assets have been downloaded.
  64663. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  64664. */
  64665. autoHideLoadingUI: boolean;
  64666. /**
  64667. * Creates a new AssetsManager
  64668. * @param scene defines the scene to work on
  64669. */
  64670. constructor(scene: Scene);
  64671. /**
  64672. * Add a MeshAssetTask to the list of active tasks
  64673. * @param taskName defines the name of the new task
  64674. * @param meshesNames defines the name of meshes to load
  64675. * @param rootUrl defines the root url to use to locate files
  64676. * @param sceneFilename defines the filename of the scene file
  64677. * @returns a new MeshAssetTask object
  64678. */
  64679. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  64680. /**
  64681. * Add a TextFileAssetTask to the list of active tasks
  64682. * @param taskName defines the name of the new task
  64683. * @param url defines the url of the file to load
  64684. * @returns a new TextFileAssetTask object
  64685. */
  64686. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  64687. /**
  64688. * Add a BinaryFileAssetTask to the list of active tasks
  64689. * @param taskName defines the name of the new task
  64690. * @param url defines the url of the file to load
  64691. * @returns a new BinaryFileAssetTask object
  64692. */
  64693. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  64694. /**
  64695. * Add a ImageAssetTask to the list of active tasks
  64696. * @param taskName defines the name of the new task
  64697. * @param url defines the url of the file to load
  64698. * @returns a new ImageAssetTask object
  64699. */
  64700. addImageTask(taskName: string, url: string): ImageAssetTask;
  64701. /**
  64702. * Add a TextureAssetTask to the list of active tasks
  64703. * @param taskName defines the name of the new task
  64704. * @param url defines the url of the file to load
  64705. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64706. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  64707. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64708. * @returns a new TextureAssetTask object
  64709. */
  64710. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  64711. /**
  64712. * Add a CubeTextureAssetTask to the list of active tasks
  64713. * @param taskName defines the name of the new task
  64714. * @param url defines the url of the file to load
  64715. * @param extensions defines the extension to use to load the cube map (can be null)
  64716. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64717. * @param files defines the list of files to load (can be null)
  64718. * @returns a new CubeTextureAssetTask object
  64719. */
  64720. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  64721. /**
  64722. *
  64723. * Add a HDRCubeTextureAssetTask to the list of active tasks
  64724. * @param taskName defines the name of the new task
  64725. * @param url defines the url of the file to load
  64726. * @param size defines the size you want for the cubemap (can be null)
  64727. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64728. * @param generateHarmonics defines if you want to automatically generate (true by default)
  64729. * @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)
  64730. * @param reserved Internal use only
  64731. * @returns a new HDRCubeTextureAssetTask object
  64732. */
  64733. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  64734. /**
  64735. *
  64736. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  64737. * @param taskName defines the name of the new task
  64738. * @param url defines the url of the file to load
  64739. * @param size defines the size you want for the cubemap (can be null)
  64740. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64741. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64742. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64743. * @returns a new EquiRectangularCubeTextureAssetTask object
  64744. */
  64745. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  64746. /**
  64747. * Remove a task from the assets manager.
  64748. * @param task the task to remove
  64749. */
  64750. removeTask(task: AbstractAssetTask): void;
  64751. private _decreaseWaitingTasksCount;
  64752. private _runTask;
  64753. /**
  64754. * Reset the AssetsManager and remove all tasks
  64755. * @return the current instance of the AssetsManager
  64756. */
  64757. reset(): AssetsManager;
  64758. /**
  64759. * Start the loading process
  64760. * @return the current instance of the AssetsManager
  64761. */
  64762. load(): AssetsManager;
  64763. /**
  64764. * Start the loading process as an async operation
  64765. * @return a promise returning the list of failed tasks
  64766. */
  64767. loadAsync(): Promise<void>;
  64768. }
  64769. }
  64770. declare module "babylonjs/Misc/deferred" {
  64771. /**
  64772. * Wrapper class for promise with external resolve and reject.
  64773. */
  64774. export class Deferred<T> {
  64775. /**
  64776. * The promise associated with this deferred object.
  64777. */
  64778. readonly promise: Promise<T>;
  64779. private _resolve;
  64780. private _reject;
  64781. /**
  64782. * The resolve method of the promise associated with this deferred object.
  64783. */
  64784. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  64785. /**
  64786. * The reject method of the promise associated with this deferred object.
  64787. */
  64788. readonly reject: (reason?: any) => void;
  64789. /**
  64790. * Constructor for this deferred object.
  64791. */
  64792. constructor();
  64793. }
  64794. }
  64795. declare module "babylonjs/Misc/meshExploder" {
  64796. import { Mesh } from "babylonjs/Meshes/mesh";
  64797. /**
  64798. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  64799. */
  64800. export class MeshExploder {
  64801. private _centerMesh;
  64802. private _meshes;
  64803. private _meshesOrigins;
  64804. private _toCenterVectors;
  64805. private _scaledDirection;
  64806. private _newPosition;
  64807. private _centerPosition;
  64808. /**
  64809. * Explodes meshes from a center mesh.
  64810. * @param meshes The meshes to explode.
  64811. * @param centerMesh The mesh to be center of explosion.
  64812. */
  64813. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  64814. private _setCenterMesh;
  64815. /**
  64816. * Get class name
  64817. * @returns "MeshExploder"
  64818. */
  64819. getClassName(): string;
  64820. /**
  64821. * "Exploded meshes"
  64822. * @returns Array of meshes with the centerMesh at index 0.
  64823. */
  64824. getMeshes(): Array<Mesh>;
  64825. /**
  64826. * Explodes meshes giving a specific direction
  64827. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  64828. */
  64829. explode(direction?: number): void;
  64830. }
  64831. }
  64832. declare module "babylonjs/Misc/filesInput" {
  64833. import { Engine } from "babylonjs/Engines/engine";
  64834. import { Scene } from "babylonjs/scene";
  64835. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  64836. /**
  64837. * Class used to help managing file picking and drag'n'drop
  64838. */
  64839. export class FilesInput {
  64840. /**
  64841. * List of files ready to be loaded
  64842. */
  64843. static readonly FilesToLoad: {
  64844. [key: string]: File;
  64845. };
  64846. /**
  64847. * Callback called when a file is processed
  64848. */
  64849. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  64850. private _engine;
  64851. private _currentScene;
  64852. private _sceneLoadedCallback;
  64853. private _progressCallback;
  64854. private _additionalRenderLoopLogicCallback;
  64855. private _textureLoadingCallback;
  64856. private _startingProcessingFilesCallback;
  64857. private _onReloadCallback;
  64858. private _errorCallback;
  64859. private _elementToMonitor;
  64860. private _sceneFileToLoad;
  64861. private _filesToLoad;
  64862. /**
  64863. * Creates a new FilesInput
  64864. * @param engine defines the rendering engine
  64865. * @param scene defines the hosting scene
  64866. * @param sceneLoadedCallback callback called when scene is loaded
  64867. * @param progressCallback callback called to track progress
  64868. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  64869. * @param textureLoadingCallback callback called when a texture is loading
  64870. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  64871. * @param onReloadCallback callback called when a reload is requested
  64872. * @param errorCallback callback call if an error occurs
  64873. */
  64874. 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);
  64875. private _dragEnterHandler;
  64876. private _dragOverHandler;
  64877. private _dropHandler;
  64878. /**
  64879. * Calls this function to listen to drag'n'drop events on a specific DOM element
  64880. * @param elementToMonitor defines the DOM element to track
  64881. */
  64882. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  64883. /**
  64884. * Release all associated resources
  64885. */
  64886. dispose(): void;
  64887. private renderFunction;
  64888. private drag;
  64889. private drop;
  64890. private _traverseFolder;
  64891. private _processFiles;
  64892. /**
  64893. * Load files from a drop event
  64894. * @param event defines the drop event to use as source
  64895. */
  64896. loadFiles(event: any): void;
  64897. private _processReload;
  64898. /**
  64899. * Reload the current scene from the loaded files
  64900. */
  64901. reload(): void;
  64902. }
  64903. }
  64904. declare module "babylonjs/Misc/HighDynamicRange/index" {
  64905. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  64906. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  64907. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  64908. }
  64909. declare module "babylonjs/Misc/sceneOptimizer" {
  64910. import { Scene, IDisposable } from "babylonjs/scene";
  64911. import { Observable } from "babylonjs/Misc/observable";
  64912. /**
  64913. * Defines the root class used to create scene optimization to use with SceneOptimizer
  64914. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64915. */
  64916. export class SceneOptimization {
  64917. /**
  64918. * Defines the priority of this optimization (0 by default which means first in the list)
  64919. */
  64920. priority: number;
  64921. /**
  64922. * Gets a string describing the action executed by the current optimization
  64923. * @returns description string
  64924. */
  64925. getDescription(): string;
  64926. /**
  64927. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64928. * @param scene defines the current scene where to apply this optimization
  64929. * @param optimizer defines the current optimizer
  64930. * @returns true if everything that can be done was applied
  64931. */
  64932. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64933. /**
  64934. * Creates the SceneOptimization object
  64935. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64936. * @param desc defines the description associated with the optimization
  64937. */
  64938. constructor(
  64939. /**
  64940. * Defines the priority of this optimization (0 by default which means first in the list)
  64941. */
  64942. priority?: number);
  64943. }
  64944. /**
  64945. * Defines an optimization used to reduce the size of render target textures
  64946. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64947. */
  64948. export class TextureOptimization extends SceneOptimization {
  64949. /**
  64950. * Defines the priority of this optimization (0 by default which means first in the list)
  64951. */
  64952. priority: number;
  64953. /**
  64954. * 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
  64955. */
  64956. maximumSize: number;
  64957. /**
  64958. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64959. */
  64960. step: number;
  64961. /**
  64962. * Gets a string describing the action executed by the current optimization
  64963. * @returns description string
  64964. */
  64965. getDescription(): string;
  64966. /**
  64967. * Creates the TextureOptimization object
  64968. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64969. * @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
  64970. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64971. */
  64972. constructor(
  64973. /**
  64974. * Defines the priority of this optimization (0 by default which means first in the list)
  64975. */
  64976. priority?: number,
  64977. /**
  64978. * 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
  64979. */
  64980. maximumSize?: number,
  64981. /**
  64982. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64983. */
  64984. step?: number);
  64985. /**
  64986. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64987. * @param scene defines the current scene where to apply this optimization
  64988. * @param optimizer defines the current optimizer
  64989. * @returns true if everything that can be done was applied
  64990. */
  64991. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64992. }
  64993. /**
  64994. * Defines an optimization used to increase or decrease the rendering resolution
  64995. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64996. */
  64997. export class HardwareScalingOptimization extends SceneOptimization {
  64998. /**
  64999. * Defines the priority of this optimization (0 by default which means first in the list)
  65000. */
  65001. priority: number;
  65002. /**
  65003. * Defines the maximum scale to use (2 by default)
  65004. */
  65005. maximumScale: number;
  65006. /**
  65007. * Defines the step to use between two passes (0.5 by default)
  65008. */
  65009. step: number;
  65010. private _currentScale;
  65011. private _directionOffset;
  65012. /**
  65013. * Gets a string describing the action executed by the current optimization
  65014. * @return description string
  65015. */
  65016. getDescription(): string;
  65017. /**
  65018. * Creates the HardwareScalingOptimization object
  65019. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65020. * @param maximumScale defines the maximum scale to use (2 by default)
  65021. * @param step defines the step to use between two passes (0.5 by default)
  65022. */
  65023. constructor(
  65024. /**
  65025. * Defines the priority of this optimization (0 by default which means first in the list)
  65026. */
  65027. priority?: number,
  65028. /**
  65029. * Defines the maximum scale to use (2 by default)
  65030. */
  65031. maximumScale?: number,
  65032. /**
  65033. * Defines the step to use between two passes (0.5 by default)
  65034. */
  65035. step?: number);
  65036. /**
  65037. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65038. * @param scene defines the current scene where to apply this optimization
  65039. * @param optimizer defines the current optimizer
  65040. * @returns true if everything that can be done was applied
  65041. */
  65042. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65043. }
  65044. /**
  65045. * Defines an optimization used to remove shadows
  65046. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65047. */
  65048. export class ShadowsOptimization extends SceneOptimization {
  65049. /**
  65050. * Gets a string describing the action executed by the current optimization
  65051. * @return description string
  65052. */
  65053. getDescription(): string;
  65054. /**
  65055. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65056. * @param scene defines the current scene where to apply this optimization
  65057. * @param optimizer defines the current optimizer
  65058. * @returns true if everything that can be done was applied
  65059. */
  65060. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65061. }
  65062. /**
  65063. * Defines an optimization used to turn post-processes off
  65064. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65065. */
  65066. export class PostProcessesOptimization extends SceneOptimization {
  65067. /**
  65068. * Gets a string describing the action executed by the current optimization
  65069. * @return description string
  65070. */
  65071. getDescription(): string;
  65072. /**
  65073. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65074. * @param scene defines the current scene where to apply this optimization
  65075. * @param optimizer defines the current optimizer
  65076. * @returns true if everything that can be done was applied
  65077. */
  65078. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65079. }
  65080. /**
  65081. * Defines an optimization used to turn lens flares off
  65082. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65083. */
  65084. export class LensFlaresOptimization extends SceneOptimization {
  65085. /**
  65086. * Gets a string describing the action executed by the current optimization
  65087. * @return description string
  65088. */
  65089. getDescription(): string;
  65090. /**
  65091. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65092. * @param scene defines the current scene where to apply this optimization
  65093. * @param optimizer defines the current optimizer
  65094. * @returns true if everything that can be done was applied
  65095. */
  65096. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65097. }
  65098. /**
  65099. * Defines an optimization based on user defined callback.
  65100. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65101. */
  65102. export class CustomOptimization extends SceneOptimization {
  65103. /**
  65104. * Callback called to apply the custom optimization.
  65105. */
  65106. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  65107. /**
  65108. * Callback called to get custom description
  65109. */
  65110. onGetDescription: () => string;
  65111. /**
  65112. * Gets a string describing the action executed by the current optimization
  65113. * @returns description string
  65114. */
  65115. getDescription(): string;
  65116. /**
  65117. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65118. * @param scene defines the current scene where to apply this optimization
  65119. * @param optimizer defines the current optimizer
  65120. * @returns true if everything that can be done was applied
  65121. */
  65122. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65123. }
  65124. /**
  65125. * Defines an optimization used to turn particles off
  65126. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65127. */
  65128. export class ParticlesOptimization extends SceneOptimization {
  65129. /**
  65130. * Gets a string describing the action executed by the current optimization
  65131. * @return description string
  65132. */
  65133. getDescription(): string;
  65134. /**
  65135. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65136. * @param scene defines the current scene where to apply this optimization
  65137. * @param optimizer defines the current optimizer
  65138. * @returns true if everything that can be done was applied
  65139. */
  65140. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65141. }
  65142. /**
  65143. * Defines an optimization used to turn render targets off
  65144. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65145. */
  65146. export class RenderTargetsOptimization extends SceneOptimization {
  65147. /**
  65148. * Gets a string describing the action executed by the current optimization
  65149. * @return description string
  65150. */
  65151. getDescription(): string;
  65152. /**
  65153. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65154. * @param scene defines the current scene where to apply this optimization
  65155. * @param optimizer defines the current optimizer
  65156. * @returns true if everything that can be done was applied
  65157. */
  65158. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65159. }
  65160. /**
  65161. * Defines an optimization used to merge meshes with compatible materials
  65162. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65163. */
  65164. export class MergeMeshesOptimization extends SceneOptimization {
  65165. private static _UpdateSelectionTree;
  65166. /**
  65167. * Gets or sets a boolean which defines if optimization octree has to be updated
  65168. */
  65169. /**
  65170. * Gets or sets a boolean which defines if optimization octree has to be updated
  65171. */
  65172. static UpdateSelectionTree: boolean;
  65173. /**
  65174. * Gets a string describing the action executed by the current optimization
  65175. * @return description string
  65176. */
  65177. getDescription(): string;
  65178. private _canBeMerged;
  65179. /**
  65180. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65181. * @param scene defines the current scene where to apply this optimization
  65182. * @param optimizer defines the current optimizer
  65183. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  65184. * @returns true if everything that can be done was applied
  65185. */
  65186. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  65187. }
  65188. /**
  65189. * Defines a list of options used by SceneOptimizer
  65190. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65191. */
  65192. export class SceneOptimizerOptions {
  65193. /**
  65194. * Defines the target frame rate to reach (60 by default)
  65195. */
  65196. targetFrameRate: number;
  65197. /**
  65198. * Defines the interval between two checkes (2000ms by default)
  65199. */
  65200. trackerDuration: number;
  65201. /**
  65202. * Gets the list of optimizations to apply
  65203. */
  65204. optimizations: SceneOptimization[];
  65205. /**
  65206. * Creates a new list of options used by SceneOptimizer
  65207. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  65208. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  65209. */
  65210. constructor(
  65211. /**
  65212. * Defines the target frame rate to reach (60 by default)
  65213. */
  65214. targetFrameRate?: number,
  65215. /**
  65216. * Defines the interval between two checkes (2000ms by default)
  65217. */
  65218. trackerDuration?: number);
  65219. /**
  65220. * Add a new optimization
  65221. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  65222. * @returns the current SceneOptimizerOptions
  65223. */
  65224. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  65225. /**
  65226. * Add a new custom optimization
  65227. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  65228. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  65229. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65230. * @returns the current SceneOptimizerOptions
  65231. */
  65232. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  65233. /**
  65234. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  65235. * @param targetFrameRate defines the target frame rate (60 by default)
  65236. * @returns a SceneOptimizerOptions object
  65237. */
  65238. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65239. /**
  65240. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  65241. * @param targetFrameRate defines the target frame rate (60 by default)
  65242. * @returns a SceneOptimizerOptions object
  65243. */
  65244. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65245. /**
  65246. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  65247. * @param targetFrameRate defines the target frame rate (60 by default)
  65248. * @returns a SceneOptimizerOptions object
  65249. */
  65250. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65251. }
  65252. /**
  65253. * Class used to run optimizations in order to reach a target frame rate
  65254. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65255. */
  65256. export class SceneOptimizer implements IDisposable {
  65257. private _isRunning;
  65258. private _options;
  65259. private _scene;
  65260. private _currentPriorityLevel;
  65261. private _targetFrameRate;
  65262. private _trackerDuration;
  65263. private _currentFrameRate;
  65264. private _sceneDisposeObserver;
  65265. private _improvementMode;
  65266. /**
  65267. * Defines an observable called when the optimizer reaches the target frame rate
  65268. */
  65269. onSuccessObservable: Observable<SceneOptimizer>;
  65270. /**
  65271. * Defines an observable called when the optimizer enables an optimization
  65272. */
  65273. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  65274. /**
  65275. * Defines an observable called when the optimizer is not able to reach the target frame rate
  65276. */
  65277. onFailureObservable: Observable<SceneOptimizer>;
  65278. /**
  65279. * Gets a boolean indicating if the optimizer is in improvement mode
  65280. */
  65281. readonly isInImprovementMode: boolean;
  65282. /**
  65283. * Gets the current priority level (0 at start)
  65284. */
  65285. readonly currentPriorityLevel: number;
  65286. /**
  65287. * Gets the current frame rate checked by the SceneOptimizer
  65288. */
  65289. readonly currentFrameRate: number;
  65290. /**
  65291. * Gets or sets the current target frame rate (60 by default)
  65292. */
  65293. /**
  65294. * Gets or sets the current target frame rate (60 by default)
  65295. */
  65296. targetFrameRate: number;
  65297. /**
  65298. * Gets or sets the current interval between two checks (every 2000ms by default)
  65299. */
  65300. /**
  65301. * Gets or sets the current interval between two checks (every 2000ms by default)
  65302. */
  65303. trackerDuration: number;
  65304. /**
  65305. * Gets the list of active optimizations
  65306. */
  65307. readonly optimizations: SceneOptimization[];
  65308. /**
  65309. * Creates a new SceneOptimizer
  65310. * @param scene defines the scene to work on
  65311. * @param options defines the options to use with the SceneOptimizer
  65312. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  65313. * @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)
  65314. */
  65315. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  65316. /**
  65317. * Stops the current optimizer
  65318. */
  65319. stop(): void;
  65320. /**
  65321. * Reset the optimizer to initial step (current priority level = 0)
  65322. */
  65323. reset(): void;
  65324. /**
  65325. * Start the optimizer. By default it will try to reach a specific framerate
  65326. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  65327. */
  65328. start(): void;
  65329. private _checkCurrentState;
  65330. /**
  65331. * Release all resources
  65332. */
  65333. dispose(): void;
  65334. /**
  65335. * Helper function to create a SceneOptimizer with one single line of code
  65336. * @param scene defines the scene to work on
  65337. * @param options defines the options to use with the SceneOptimizer
  65338. * @param onSuccess defines a callback to call on success
  65339. * @param onFailure defines a callback to call on failure
  65340. * @returns the new SceneOptimizer object
  65341. */
  65342. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  65343. }
  65344. }
  65345. declare module "babylonjs/Misc/sceneSerializer" {
  65346. import { Scene } from "babylonjs/scene";
  65347. /**
  65348. * Class used to serialize a scene into a string
  65349. */
  65350. export class SceneSerializer {
  65351. /**
  65352. * Clear cache used by a previous serialization
  65353. */
  65354. static ClearCache(): void;
  65355. /**
  65356. * Serialize a scene into a JSON compatible object
  65357. * @param scene defines the scene to serialize
  65358. * @returns a JSON compatible object
  65359. */
  65360. static Serialize(scene: Scene): any;
  65361. /**
  65362. * Serialize a mesh into a JSON compatible object
  65363. * @param toSerialize defines the mesh to serialize
  65364. * @param withParents defines if parents must be serialized as well
  65365. * @param withChildren defines if children must be serialized as well
  65366. * @returns a JSON compatible object
  65367. */
  65368. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  65369. }
  65370. }
  65371. declare module "babylonjs/Misc/textureTools" {
  65372. import { Texture } from "babylonjs/Materials/Textures/texture";
  65373. /**
  65374. * Class used to host texture specific utilities
  65375. */
  65376. export class TextureTools {
  65377. /**
  65378. * Uses the GPU to create a copy texture rescaled at a given size
  65379. * @param texture Texture to copy from
  65380. * @param width defines the desired width
  65381. * @param height defines the desired height
  65382. * @param useBilinearMode defines if bilinear mode has to be used
  65383. * @return the generated texture
  65384. */
  65385. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  65386. }
  65387. }
  65388. declare module "babylonjs/Misc/videoRecorder" {
  65389. import { Nullable } from "babylonjs/types";
  65390. import { Engine } from "babylonjs/Engines/engine";
  65391. /**
  65392. * This represents the different options available for the video capture.
  65393. */
  65394. export interface VideoRecorderOptions {
  65395. /** Defines the mime type of the video. */
  65396. mimeType: string;
  65397. /** Defines the FPS the video should be recorded at. */
  65398. fps: number;
  65399. /** Defines the chunk size for the recording data. */
  65400. recordChunckSize: number;
  65401. /** The audio tracks to attach to the recording. */
  65402. audioTracks?: MediaStreamTrack[];
  65403. }
  65404. /**
  65405. * This can help with recording videos from BabylonJS.
  65406. * This is based on the available WebRTC functionalities of the browser.
  65407. *
  65408. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  65409. */
  65410. export class VideoRecorder {
  65411. private static readonly _defaultOptions;
  65412. /**
  65413. * Returns whether or not the VideoRecorder is available in your browser.
  65414. * @param engine Defines the Babylon Engine.
  65415. * @returns true if supported otherwise false.
  65416. */
  65417. static IsSupported(engine: Engine): boolean;
  65418. private readonly _options;
  65419. private _canvas;
  65420. private _mediaRecorder;
  65421. private _recordedChunks;
  65422. private _fileName;
  65423. private _resolve;
  65424. private _reject;
  65425. /**
  65426. * True when a recording is already in progress.
  65427. */
  65428. readonly isRecording: boolean;
  65429. /**
  65430. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  65431. * @param engine Defines the BabylonJS Engine you wish to record.
  65432. * @param options Defines options that can be used to customize the capture.
  65433. */
  65434. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  65435. /**
  65436. * Stops the current recording before the default capture timeout passed in the startRecording function.
  65437. */
  65438. stopRecording(): void;
  65439. /**
  65440. * Starts recording the canvas for a max duration specified in parameters.
  65441. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  65442. * If null no automatic download will start and you can rely on the promise to get the data back.
  65443. * @param maxDuration Defines the maximum recording time in seconds.
  65444. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  65445. * @return A promise callback at the end of the recording with the video data in Blob.
  65446. */
  65447. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  65448. /**
  65449. * Releases internal resources used during the recording.
  65450. */
  65451. dispose(): void;
  65452. private _handleDataAvailable;
  65453. private _handleError;
  65454. private _handleStop;
  65455. }
  65456. }
  65457. declare module "babylonjs/Misc/screenshotTools" {
  65458. import { Camera } from "babylonjs/Cameras/camera";
  65459. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  65460. import { Engine } from "babylonjs/Engines/engine";
  65461. /**
  65462. * Class containing a set of static utilities functions for screenshots
  65463. */
  65464. export class ScreenshotTools {
  65465. /**
  65466. * Captures a screenshot of the current rendering
  65467. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65468. * @param engine defines the rendering engine
  65469. * @param camera defines the source camera
  65470. * @param size This parameter can be set to a single number or to an object with the
  65471. * following (optional) properties: precision, width, height. If a single number is passed,
  65472. * it will be used for both width and height. If an object is passed, the screenshot size
  65473. * will be derived from the parameters. The precision property is a multiplier allowing
  65474. * rendering at a higher or lower resolution
  65475. * @param successCallback defines the callback receives a single parameter which contains the
  65476. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65477. * src parameter of an <img> to display it
  65478. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65479. * Check your browser for supported MIME types
  65480. */
  65481. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  65482. /**
  65483. * Captures a screenshot of the current rendering
  65484. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65485. * @param engine defines the rendering engine
  65486. * @param camera defines the source camera
  65487. * @param size This parameter can be set to a single number or to an object with the
  65488. * following (optional) properties: precision, width, height. If a single number is passed,
  65489. * it will be used for both width and height. If an object is passed, the screenshot size
  65490. * will be derived from the parameters. The precision property is a multiplier allowing
  65491. * rendering at a higher or lower resolution
  65492. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65493. * Check your browser for supported MIME types
  65494. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65495. * to the src parameter of an <img> to display it
  65496. */
  65497. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  65498. /**
  65499. * Generates an image screenshot from the specified camera.
  65500. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65501. * @param engine The engine to use for rendering
  65502. * @param camera The camera to use for rendering
  65503. * @param size This parameter can be set to a single number or to an object with the
  65504. * following (optional) properties: precision, width, height. If a single number is passed,
  65505. * it will be used for both width and height. If an object is passed, the screenshot size
  65506. * will be derived from the parameters. The precision property is a multiplier allowing
  65507. * rendering at a higher or lower resolution
  65508. * @param successCallback The callback receives a single parameter which contains the
  65509. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65510. * src parameter of an <img> to display it
  65511. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65512. * Check your browser for supported MIME types
  65513. * @param samples Texture samples (default: 1)
  65514. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65515. * @param fileName A name for for the downloaded file.
  65516. */
  65517. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  65518. /**
  65519. * Generates an image screenshot from the specified camera.
  65520. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65521. * @param engine The engine to use for rendering
  65522. * @param camera The camera to use for rendering
  65523. * @param size This parameter can be set to a single number or to an object with the
  65524. * following (optional) properties: precision, width, height. If a single number is passed,
  65525. * it will be used for both width and height. If an object is passed, the screenshot size
  65526. * will be derived from the parameters. The precision property is a multiplier allowing
  65527. * rendering at a higher or lower resolution
  65528. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65529. * Check your browser for supported MIME types
  65530. * @param samples Texture samples (default: 1)
  65531. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65532. * @param fileName A name for for the downloaded file.
  65533. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65534. * to the src parameter of an <img> to display it
  65535. */
  65536. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  65537. /**
  65538. * Gets height and width for screenshot size
  65539. * @private
  65540. */
  65541. private static _getScreenshotSize;
  65542. }
  65543. }
  65544. declare module "babylonjs/Misc/index" {
  65545. export * from "babylonjs/Misc/andOrNotEvaluator";
  65546. export * from "babylonjs/Misc/assetsManager";
  65547. export * from "babylonjs/Misc/dds";
  65548. export * from "babylonjs/Misc/decorators";
  65549. export * from "babylonjs/Misc/deferred";
  65550. export * from "babylonjs/Misc/environmentTextureTools";
  65551. export * from "babylonjs/Misc/meshExploder";
  65552. export * from "babylonjs/Misc/filesInput";
  65553. export * from "babylonjs/Misc/HighDynamicRange/index";
  65554. export * from "babylonjs/Misc/khronosTextureContainer";
  65555. export * from "babylonjs/Misc/observable";
  65556. export * from "babylonjs/Misc/performanceMonitor";
  65557. export * from "babylonjs/Misc/promise";
  65558. export * from "babylonjs/Misc/sceneOptimizer";
  65559. export * from "babylonjs/Misc/sceneSerializer";
  65560. export * from "babylonjs/Misc/smartArray";
  65561. export * from "babylonjs/Misc/stringDictionary";
  65562. export * from "babylonjs/Misc/tags";
  65563. export * from "babylonjs/Misc/textureTools";
  65564. export * from "babylonjs/Misc/tga";
  65565. export * from "babylonjs/Misc/tools";
  65566. export * from "babylonjs/Misc/videoRecorder";
  65567. export * from "babylonjs/Misc/virtualJoystick";
  65568. export * from "babylonjs/Misc/workerPool";
  65569. export * from "babylonjs/Misc/logger";
  65570. export * from "babylonjs/Misc/typeStore";
  65571. export * from "babylonjs/Misc/filesInputStore";
  65572. export * from "babylonjs/Misc/deepCopier";
  65573. export * from "babylonjs/Misc/pivotTools";
  65574. export * from "babylonjs/Misc/precisionDate";
  65575. export * from "babylonjs/Misc/screenshotTools";
  65576. export * from "babylonjs/Misc/typeStore";
  65577. export * from "babylonjs/Misc/webRequest";
  65578. export * from "babylonjs/Misc/iInspectable";
  65579. export * from "babylonjs/Misc/brdfTextureTools";
  65580. export * from "babylonjs/Misc/rgbdTextureTools";
  65581. export * from "babylonjs/Misc/gradients";
  65582. export * from "babylonjs/Misc/perfCounter";
  65583. export * from "babylonjs/Misc/fileRequest";
  65584. export * from "babylonjs/Misc/customAnimationFrameRequester";
  65585. export * from "babylonjs/Misc/retryStrategy";
  65586. export * from "babylonjs/Misc/loadFileError";
  65587. }
  65588. declare module "babylonjs/index" {
  65589. export * from "babylonjs/abstractScene";
  65590. export * from "babylonjs/Actions/index";
  65591. export * from "babylonjs/Animations/index";
  65592. export * from "babylonjs/assetContainer";
  65593. export * from "babylonjs/Audio/index";
  65594. export * from "babylonjs/Behaviors/index";
  65595. export * from "babylonjs/Bones/index";
  65596. export * from "babylonjs/Cameras/index";
  65597. export * from "babylonjs/Collisions/index";
  65598. export * from "babylonjs/Culling/index";
  65599. export * from "babylonjs/Debug/index";
  65600. export * from "babylonjs/Engines/index";
  65601. export * from "babylonjs/Events/index";
  65602. export * from "babylonjs/Gamepads/index";
  65603. export * from "babylonjs/Gizmos/index";
  65604. export * from "babylonjs/Helpers/index";
  65605. export * from "babylonjs/Instrumentation/index";
  65606. export * from "babylonjs/Layers/index";
  65607. export * from "babylonjs/LensFlares/index";
  65608. export * from "babylonjs/Lights/index";
  65609. export * from "babylonjs/Loading/index";
  65610. export * from "babylonjs/Materials/index";
  65611. export * from "babylonjs/Maths/index";
  65612. export * from "babylonjs/Meshes/index";
  65613. export * from "babylonjs/Morph/index";
  65614. export * from "babylonjs/Navigation/index";
  65615. export * from "babylonjs/node";
  65616. export * from "babylonjs/Offline/index";
  65617. export * from "babylonjs/Particles/index";
  65618. export * from "babylonjs/Physics/index";
  65619. export * from "babylonjs/PostProcesses/index";
  65620. export * from "babylonjs/Probes/index";
  65621. export * from "babylonjs/Rendering/index";
  65622. export * from "babylonjs/scene";
  65623. export * from "babylonjs/sceneComponent";
  65624. export * from "babylonjs/Sprites/index";
  65625. export * from "babylonjs/States/index";
  65626. export * from "babylonjs/Misc/index";
  65627. export * from "babylonjs/types";
  65628. }
  65629. declare module "babylonjs/Animations/pathCursor" {
  65630. import { Vector3 } from "babylonjs/Maths/math.vector";
  65631. import { Path2 } from "babylonjs/Maths/math.path";
  65632. /**
  65633. * A cursor which tracks a point on a path
  65634. */
  65635. export class PathCursor {
  65636. private path;
  65637. /**
  65638. * Stores path cursor callbacks for when an onchange event is triggered
  65639. */
  65640. private _onchange;
  65641. /**
  65642. * The value of the path cursor
  65643. */
  65644. value: number;
  65645. /**
  65646. * The animation array of the path cursor
  65647. */
  65648. animations: Animation[];
  65649. /**
  65650. * Initializes the path cursor
  65651. * @param path The path to track
  65652. */
  65653. constructor(path: Path2);
  65654. /**
  65655. * Gets the cursor point on the path
  65656. * @returns A point on the path cursor at the cursor location
  65657. */
  65658. getPoint(): Vector3;
  65659. /**
  65660. * Moves the cursor ahead by the step amount
  65661. * @param step The amount to move the cursor forward
  65662. * @returns This path cursor
  65663. */
  65664. moveAhead(step?: number): PathCursor;
  65665. /**
  65666. * Moves the cursor behind by the step amount
  65667. * @param step The amount to move the cursor back
  65668. * @returns This path cursor
  65669. */
  65670. moveBack(step?: number): PathCursor;
  65671. /**
  65672. * Moves the cursor by the step amount
  65673. * If the step amount is greater than one, an exception is thrown
  65674. * @param step The amount to move the cursor
  65675. * @returns This path cursor
  65676. */
  65677. move(step: number): PathCursor;
  65678. /**
  65679. * Ensures that the value is limited between zero and one
  65680. * @returns This path cursor
  65681. */
  65682. private ensureLimits;
  65683. /**
  65684. * Runs onchange callbacks on change (used by the animation engine)
  65685. * @returns This path cursor
  65686. */
  65687. private raiseOnChange;
  65688. /**
  65689. * Executes a function on change
  65690. * @param f A path cursor onchange callback
  65691. * @returns This path cursor
  65692. */
  65693. onchange(f: (cursor: PathCursor) => void): PathCursor;
  65694. }
  65695. }
  65696. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  65697. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  65698. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  65699. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  65700. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  65701. }
  65702. declare module "babylonjs/Engines/Processors/Expressions/index" {
  65703. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  65704. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  65705. }
  65706. declare module "babylonjs/Engines/Processors/index" {
  65707. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  65708. export * from "babylonjs/Engines/Processors/Expressions/index";
  65709. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  65710. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  65711. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  65712. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  65713. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  65714. export * from "babylonjs/Engines/Processors/shaderProcessor";
  65715. }
  65716. declare module "babylonjs/Legacy/legacy" {
  65717. import * as Babylon from "babylonjs/index";
  65718. export * from "babylonjs/index";
  65719. }
  65720. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  65721. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65722. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65723. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65724. /**
  65725. * Block used to get the value of the first parameter raised to the power of the second
  65726. */
  65727. export class PowBlock extends NodeMaterialBlock {
  65728. /**
  65729. * Creates a new PowBlock
  65730. * @param name defines the block name
  65731. */
  65732. constructor(name: string);
  65733. /**
  65734. * Gets the current class name
  65735. * @returns the class name
  65736. */
  65737. getClassName(): string;
  65738. /**
  65739. * Gets the value operand input component
  65740. */
  65741. readonly value: NodeMaterialConnectionPoint;
  65742. /**
  65743. * Gets the power operand input component
  65744. */
  65745. readonly power: NodeMaterialConnectionPoint;
  65746. /**
  65747. * Gets the output component
  65748. */
  65749. readonly output: NodeMaterialConnectionPoint;
  65750. protected _buildBlock(state: NodeMaterialBuildState): this;
  65751. }
  65752. }
  65753. declare module "babylonjs/Shaders/blur.fragment" {
  65754. /** @hidden */
  65755. export var blurPixelShader: {
  65756. name: string;
  65757. shader: string;
  65758. };
  65759. }
  65760. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  65761. /** @hidden */
  65762. export var pointCloudVertexDeclaration: {
  65763. name: string;
  65764. shader: string;
  65765. };
  65766. }
  65767. declare module "babylonjs" {
  65768. export * from "babylonjs/Legacy/legacy";
  65769. }
  65770. declare module BABYLON {
  65771. /** Alias type for value that can be null */
  65772. export type Nullable<T> = T | null;
  65773. /**
  65774. * Alias type for number that are floats
  65775. * @ignorenaming
  65776. */
  65777. export type float = number;
  65778. /**
  65779. * Alias type for number that are doubles.
  65780. * @ignorenaming
  65781. */
  65782. export type double = number;
  65783. /**
  65784. * Alias type for number that are integer
  65785. * @ignorenaming
  65786. */
  65787. export type int = number;
  65788. /** Alias type for number array or Float32Array */
  65789. export type FloatArray = number[] | Float32Array;
  65790. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  65791. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  65792. /**
  65793. * Alias for types that can be used by a Buffer or VertexBuffer.
  65794. */
  65795. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  65796. /**
  65797. * Alias type for primitive types
  65798. * @ignorenaming
  65799. */
  65800. type Primitive = undefined | null | boolean | string | number | Function;
  65801. /**
  65802. * Type modifier to make all the properties of an object Readonly
  65803. */
  65804. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  65805. /**
  65806. * Type modifier to make all the properties of an object Readonly recursively
  65807. */
  65808. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  65809. /** @hidden */
  65810. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  65811. }
  65812. /** @hidden */
  65813. /** @hidden */
  65814. type DeepImmutableObject<T> = {
  65815. readonly [K in keyof T]: DeepImmutable<T[K]>;
  65816. };
  65817. }
  65818. declare module BABYLON {
  65819. /**
  65820. * A class serves as a medium between the observable and its observers
  65821. */
  65822. export class EventState {
  65823. /**
  65824. * Create a new EventState
  65825. * @param mask defines the mask associated with this state
  65826. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  65827. * @param target defines the original target of the state
  65828. * @param currentTarget defines the current target of the state
  65829. */
  65830. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  65831. /**
  65832. * Initialize the current event state
  65833. * @param mask defines the mask associated with this state
  65834. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  65835. * @param target defines the original target of the state
  65836. * @param currentTarget defines the current target of the state
  65837. * @returns the current event state
  65838. */
  65839. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  65840. /**
  65841. * An Observer can set this property to true to prevent subsequent observers of being notified
  65842. */
  65843. skipNextObservers: boolean;
  65844. /**
  65845. * Get the mask value that were used to trigger the event corresponding to this EventState object
  65846. */
  65847. mask: number;
  65848. /**
  65849. * The object that originally notified the event
  65850. */
  65851. target?: any;
  65852. /**
  65853. * The current object in the bubbling phase
  65854. */
  65855. currentTarget?: any;
  65856. /**
  65857. * This will be populated with the return value of the last function that was executed.
  65858. * If it is the first function in the callback chain it will be the event data.
  65859. */
  65860. lastReturnValue?: any;
  65861. }
  65862. /**
  65863. * Represent an Observer registered to a given Observable object.
  65864. */
  65865. export class Observer<T> {
  65866. /**
  65867. * Defines the callback to call when the observer is notified
  65868. */
  65869. callback: (eventData: T, eventState: EventState) => void;
  65870. /**
  65871. * Defines the mask of the observer (used to filter notifications)
  65872. */
  65873. mask: number;
  65874. /**
  65875. * Defines the current scope used to restore the JS context
  65876. */
  65877. scope: any;
  65878. /** @hidden */
  65879. _willBeUnregistered: boolean;
  65880. /**
  65881. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  65882. */
  65883. unregisterOnNextCall: boolean;
  65884. /**
  65885. * Creates a new observer
  65886. * @param callback defines the callback to call when the observer is notified
  65887. * @param mask defines the mask of the observer (used to filter notifications)
  65888. * @param scope defines the current scope used to restore the JS context
  65889. */
  65890. constructor(
  65891. /**
  65892. * Defines the callback to call when the observer is notified
  65893. */
  65894. callback: (eventData: T, eventState: EventState) => void,
  65895. /**
  65896. * Defines the mask of the observer (used to filter notifications)
  65897. */
  65898. mask: number,
  65899. /**
  65900. * Defines the current scope used to restore the JS context
  65901. */
  65902. scope?: any);
  65903. }
  65904. /**
  65905. * Represent a list of observers registered to multiple Observables object.
  65906. */
  65907. export class MultiObserver<T> {
  65908. private _observers;
  65909. private _observables;
  65910. /**
  65911. * Release associated resources
  65912. */
  65913. dispose(): void;
  65914. /**
  65915. * Raise a callback when one of the observable will notify
  65916. * @param observables defines a list of observables to watch
  65917. * @param callback defines the callback to call on notification
  65918. * @param mask defines the mask used to filter notifications
  65919. * @param scope defines the current scope used to restore the JS context
  65920. * @returns the new MultiObserver
  65921. */
  65922. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  65923. }
  65924. /**
  65925. * The Observable class is a simple implementation of the Observable pattern.
  65926. *
  65927. * 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.
  65928. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  65929. * 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).
  65930. * 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.
  65931. */
  65932. export class Observable<T> {
  65933. private _observers;
  65934. private _eventState;
  65935. private _onObserverAdded;
  65936. /**
  65937. * Gets the list of observers
  65938. */
  65939. readonly observers: Array<Observer<T>>;
  65940. /**
  65941. * Creates a new observable
  65942. * @param onObserverAdded defines a callback to call when a new observer is added
  65943. */
  65944. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  65945. /**
  65946. * Create a new Observer with the specified callback
  65947. * @param callback the callback that will be executed for that Observer
  65948. * @param mask the mask used to filter observers
  65949. * @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.
  65950. * @param scope optional scope for the callback to be called from
  65951. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  65952. * @returns the new observer created for the callback
  65953. */
  65954. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  65955. /**
  65956. * Create a new Observer with the specified callback and unregisters after the next notification
  65957. * @param callback the callback that will be executed for that Observer
  65958. * @returns the new observer created for the callback
  65959. */
  65960. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  65961. /**
  65962. * Remove an Observer from the Observable object
  65963. * @param observer the instance of the Observer to remove
  65964. * @returns false if it doesn't belong to this Observable
  65965. */
  65966. remove(observer: Nullable<Observer<T>>): boolean;
  65967. /**
  65968. * Remove a callback from the Observable object
  65969. * @param callback the callback to remove
  65970. * @param scope optional scope. If used only the callbacks with this scope will be removed
  65971. * @returns false if it doesn't belong to this Observable
  65972. */
  65973. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  65974. private _deferUnregister;
  65975. private _remove;
  65976. /**
  65977. * Moves the observable to the top of the observer list making it get called first when notified
  65978. * @param observer the observer to move
  65979. */
  65980. makeObserverTopPriority(observer: Observer<T>): void;
  65981. /**
  65982. * Moves the observable to the bottom of the observer list making it get called last when notified
  65983. * @param observer the observer to move
  65984. */
  65985. makeObserverBottomPriority(observer: Observer<T>): void;
  65986. /**
  65987. * Notify all Observers by calling their respective callback with the given data
  65988. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  65989. * @param eventData defines the data to send to all observers
  65990. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  65991. * @param target defines the original target of the state
  65992. * @param currentTarget defines the current target of the state
  65993. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  65994. */
  65995. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  65996. /**
  65997. * Calling this will execute each callback, expecting it to be a promise or return a value.
  65998. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  65999. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  66000. * and it is crucial that all callbacks will be executed.
  66001. * The order of the callbacks is kept, callbacks are not executed parallel.
  66002. *
  66003. * @param eventData The data to be sent to each callback
  66004. * @param mask is used to filter observers defaults to -1
  66005. * @param target defines the callback target (see EventState)
  66006. * @param currentTarget defines he current object in the bubbling phase
  66007. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  66008. */
  66009. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  66010. /**
  66011. * Notify a specific observer
  66012. * @param observer defines the observer to notify
  66013. * @param eventData defines the data to be sent to each callback
  66014. * @param mask is used to filter observers defaults to -1
  66015. */
  66016. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  66017. /**
  66018. * Gets a boolean indicating if the observable has at least one observer
  66019. * @returns true is the Observable has at least one Observer registered
  66020. */
  66021. hasObservers(): boolean;
  66022. /**
  66023. * Clear the list of observers
  66024. */
  66025. clear(): void;
  66026. /**
  66027. * Clone the current observable
  66028. * @returns a new observable
  66029. */
  66030. clone(): Observable<T>;
  66031. /**
  66032. * Does this observable handles observer registered with a given mask
  66033. * @param mask defines the mask to be tested
  66034. * @return whether or not one observer registered with the given mask is handeled
  66035. **/
  66036. hasSpecificMask(mask?: number): boolean;
  66037. }
  66038. }
  66039. declare module BABYLON {
  66040. /**
  66041. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  66042. * Babylon.js
  66043. */
  66044. export class DomManagement {
  66045. /**
  66046. * Checks if the window object exists
  66047. * @returns true if the window object exists
  66048. */
  66049. static IsWindowObjectExist(): boolean;
  66050. /**
  66051. * Checks if the navigator object exists
  66052. * @returns true if the navigator object exists
  66053. */
  66054. static IsNavigatorAvailable(): boolean;
  66055. /**
  66056. * Extracts text content from a DOM element hierarchy
  66057. * @param element defines the root element
  66058. * @returns a string
  66059. */
  66060. static GetDOMTextContent(element: HTMLElement): string;
  66061. }
  66062. }
  66063. declare module BABYLON {
  66064. /**
  66065. * Logger used througouht the application to allow configuration of
  66066. * the log level required for the messages.
  66067. */
  66068. export class Logger {
  66069. /**
  66070. * No log
  66071. */
  66072. static readonly NoneLogLevel: number;
  66073. /**
  66074. * Only message logs
  66075. */
  66076. static readonly MessageLogLevel: number;
  66077. /**
  66078. * Only warning logs
  66079. */
  66080. static readonly WarningLogLevel: number;
  66081. /**
  66082. * Only error logs
  66083. */
  66084. static readonly ErrorLogLevel: number;
  66085. /**
  66086. * All logs
  66087. */
  66088. static readonly AllLogLevel: number;
  66089. private static _LogCache;
  66090. /**
  66091. * Gets a value indicating the number of loading errors
  66092. * @ignorenaming
  66093. */
  66094. static errorsCount: number;
  66095. /**
  66096. * Callback called when a new log is added
  66097. */
  66098. static OnNewCacheEntry: (entry: string) => void;
  66099. private static _AddLogEntry;
  66100. private static _FormatMessage;
  66101. private static _LogDisabled;
  66102. private static _LogEnabled;
  66103. private static _WarnDisabled;
  66104. private static _WarnEnabled;
  66105. private static _ErrorDisabled;
  66106. private static _ErrorEnabled;
  66107. /**
  66108. * Log a message to the console
  66109. */
  66110. static Log: (message: string) => void;
  66111. /**
  66112. * Write a warning message to the console
  66113. */
  66114. static Warn: (message: string) => void;
  66115. /**
  66116. * Write an error message to the console
  66117. */
  66118. static Error: (message: string) => void;
  66119. /**
  66120. * Gets current log cache (list of logs)
  66121. */
  66122. static readonly LogCache: string;
  66123. /**
  66124. * Clears the log cache
  66125. */
  66126. static ClearLogCache(): void;
  66127. /**
  66128. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  66129. */
  66130. static LogLevels: number;
  66131. }
  66132. }
  66133. declare module BABYLON {
  66134. /** @hidden */
  66135. export class _TypeStore {
  66136. /** @hidden */
  66137. static RegisteredTypes: {
  66138. [key: string]: Object;
  66139. };
  66140. /** @hidden */
  66141. static GetClass(fqdn: string): any;
  66142. }
  66143. }
  66144. declare module BABYLON {
  66145. /**
  66146. * Class containing a set of static utilities functions for deep copy.
  66147. */
  66148. export class DeepCopier {
  66149. /**
  66150. * Tries to copy an object by duplicating every property
  66151. * @param source defines the source object
  66152. * @param destination defines the target object
  66153. * @param doNotCopyList defines a list of properties to avoid
  66154. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  66155. */
  66156. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  66157. }
  66158. }
  66159. declare module BABYLON {
  66160. /**
  66161. * Class containing a set of static utilities functions for precision date
  66162. */
  66163. export class PrecisionDate {
  66164. /**
  66165. * Gets either window.performance.now() if supported or Date.now() else
  66166. */
  66167. static readonly Now: number;
  66168. }
  66169. }
  66170. declare module BABYLON {
  66171. /** @hidden */
  66172. export class _DevTools {
  66173. static WarnImport(name: string): string;
  66174. }
  66175. }
  66176. declare module BABYLON {
  66177. /**
  66178. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  66179. */
  66180. export class WebRequest {
  66181. private _xhr;
  66182. /**
  66183. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  66184. * i.e. when loading files, where the server/service expects an Authorization header
  66185. */
  66186. static CustomRequestHeaders: {
  66187. [key: string]: string;
  66188. };
  66189. /**
  66190. * Add callback functions in this array to update all the requests before they get sent to the network
  66191. */
  66192. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  66193. private _injectCustomRequestHeaders;
  66194. /**
  66195. * Gets or sets a function to be called when loading progress changes
  66196. */
  66197. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  66198. /**
  66199. * Returns client's state
  66200. */
  66201. readonly readyState: number;
  66202. /**
  66203. * Returns client's status
  66204. */
  66205. readonly status: number;
  66206. /**
  66207. * Returns client's status as a text
  66208. */
  66209. readonly statusText: string;
  66210. /**
  66211. * Returns client's response
  66212. */
  66213. readonly response: any;
  66214. /**
  66215. * Returns client's response url
  66216. */
  66217. readonly responseURL: string;
  66218. /**
  66219. * Returns client's response as text
  66220. */
  66221. readonly responseText: string;
  66222. /**
  66223. * Gets or sets the expected response type
  66224. */
  66225. responseType: XMLHttpRequestResponseType;
  66226. /** @hidden */
  66227. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  66228. /** @hidden */
  66229. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  66230. /**
  66231. * Cancels any network activity
  66232. */
  66233. abort(): void;
  66234. /**
  66235. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  66236. * @param body defines an optional request body
  66237. */
  66238. send(body?: Document | BodyInit | null): void;
  66239. /**
  66240. * Sets the request method, request URL
  66241. * @param method defines the method to use (GET, POST, etc..)
  66242. * @param url defines the url to connect with
  66243. */
  66244. open(method: string, url: string): void;
  66245. }
  66246. }
  66247. declare module BABYLON {
  66248. /**
  66249. * File request interface
  66250. */
  66251. export interface IFileRequest {
  66252. /**
  66253. * Raised when the request is complete (success or error).
  66254. */
  66255. onCompleteObservable: Observable<IFileRequest>;
  66256. /**
  66257. * Aborts the request for a file.
  66258. */
  66259. abort: () => void;
  66260. }
  66261. }
  66262. declare module BABYLON {
  66263. /**
  66264. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  66265. */
  66266. export class PerformanceMonitor {
  66267. private _enabled;
  66268. private _rollingFrameTime;
  66269. private _lastFrameTimeMs;
  66270. /**
  66271. * constructor
  66272. * @param frameSampleSize The number of samples required to saturate the sliding window
  66273. */
  66274. constructor(frameSampleSize?: number);
  66275. /**
  66276. * Samples current frame
  66277. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  66278. */
  66279. sampleFrame(timeMs?: number): void;
  66280. /**
  66281. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  66282. */
  66283. readonly averageFrameTime: number;
  66284. /**
  66285. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  66286. */
  66287. readonly averageFrameTimeVariance: number;
  66288. /**
  66289. * Returns the frame time of the most recent frame
  66290. */
  66291. readonly instantaneousFrameTime: number;
  66292. /**
  66293. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  66294. */
  66295. readonly averageFPS: number;
  66296. /**
  66297. * Returns the average framerate in frames per second using the most recent frame time
  66298. */
  66299. readonly instantaneousFPS: number;
  66300. /**
  66301. * Returns true if enough samples have been taken to completely fill the sliding window
  66302. */
  66303. readonly isSaturated: boolean;
  66304. /**
  66305. * Enables contributions to the sliding window sample set
  66306. */
  66307. enable(): void;
  66308. /**
  66309. * Disables contributions to the sliding window sample set
  66310. * Samples will not be interpolated over the disabled period
  66311. */
  66312. disable(): void;
  66313. /**
  66314. * Returns true if sampling is enabled
  66315. */
  66316. readonly isEnabled: boolean;
  66317. /**
  66318. * Resets performance monitor
  66319. */
  66320. reset(): void;
  66321. }
  66322. /**
  66323. * RollingAverage
  66324. *
  66325. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  66326. */
  66327. export class RollingAverage {
  66328. /**
  66329. * Current average
  66330. */
  66331. average: number;
  66332. /**
  66333. * Current variance
  66334. */
  66335. variance: number;
  66336. protected _samples: Array<number>;
  66337. protected _sampleCount: number;
  66338. protected _pos: number;
  66339. protected _m2: number;
  66340. /**
  66341. * constructor
  66342. * @param length The number of samples required to saturate the sliding window
  66343. */
  66344. constructor(length: number);
  66345. /**
  66346. * Adds a sample to the sample set
  66347. * @param v The sample value
  66348. */
  66349. add(v: number): void;
  66350. /**
  66351. * Returns previously added values or null if outside of history or outside the sliding window domain
  66352. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  66353. * @return Value previously recorded with add() or null if outside of range
  66354. */
  66355. history(i: number): number;
  66356. /**
  66357. * Returns true if enough samples have been taken to completely fill the sliding window
  66358. * @return true if sample-set saturated
  66359. */
  66360. isSaturated(): boolean;
  66361. /**
  66362. * Resets the rolling average (equivalent to 0 samples taken so far)
  66363. */
  66364. reset(): void;
  66365. /**
  66366. * Wraps a value around the sample range boundaries
  66367. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  66368. * @return Wrapped position in sample range
  66369. */
  66370. protected _wrapPosition(i: number): number;
  66371. }
  66372. }
  66373. declare module BABYLON {
  66374. /**
  66375. * This class implement a typical dictionary using a string as key and the generic type T as value.
  66376. * The underlying implementation relies on an associative array to ensure the best performances.
  66377. * The value can be anything including 'null' but except 'undefined'
  66378. */
  66379. export class StringDictionary<T> {
  66380. /**
  66381. * This will clear this dictionary and copy the content from the 'source' one.
  66382. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  66383. * @param source the dictionary to take the content from and copy to this dictionary
  66384. */
  66385. copyFrom(source: StringDictionary<T>): void;
  66386. /**
  66387. * Get a value based from its key
  66388. * @param key the given key to get the matching value from
  66389. * @return the value if found, otherwise undefined is returned
  66390. */
  66391. get(key: string): T | undefined;
  66392. /**
  66393. * Get a value from its key or add it if it doesn't exist.
  66394. * This method will ensure you that a given key/data will be present in the dictionary.
  66395. * @param key the given key to get the matching value from
  66396. * @param factory the factory that will create the value if the key is not present in the dictionary.
  66397. * The factory will only be invoked if there's no data for the given key.
  66398. * @return the value corresponding to the key.
  66399. */
  66400. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  66401. /**
  66402. * Get a value from its key if present in the dictionary otherwise add it
  66403. * @param key the key to get the value from
  66404. * @param val if there's no such key/value pair in the dictionary add it with this value
  66405. * @return the value corresponding to the key
  66406. */
  66407. getOrAdd(key: string, val: T): T;
  66408. /**
  66409. * Check if there's a given key in the dictionary
  66410. * @param key the key to check for
  66411. * @return true if the key is present, false otherwise
  66412. */
  66413. contains(key: string): boolean;
  66414. /**
  66415. * Add a new key and its corresponding value
  66416. * @param key the key to add
  66417. * @param value the value corresponding to the key
  66418. * @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
  66419. */
  66420. add(key: string, value: T): boolean;
  66421. /**
  66422. * Update a specific value associated to a key
  66423. * @param key defines the key to use
  66424. * @param value defines the value to store
  66425. * @returns true if the value was updated (or false if the key was not found)
  66426. */
  66427. set(key: string, value: T): boolean;
  66428. /**
  66429. * Get the element of the given key and remove it from the dictionary
  66430. * @param key defines the key to search
  66431. * @returns the value associated with the key or null if not found
  66432. */
  66433. getAndRemove(key: string): Nullable<T>;
  66434. /**
  66435. * Remove a key/value from the dictionary.
  66436. * @param key the key to remove
  66437. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  66438. */
  66439. remove(key: string): boolean;
  66440. /**
  66441. * Clear the whole content of the dictionary
  66442. */
  66443. clear(): void;
  66444. /**
  66445. * Gets the current count
  66446. */
  66447. readonly count: number;
  66448. /**
  66449. * Execute a callback on each key/val of the dictionary.
  66450. * Note that you can remove any element in this dictionary in the callback implementation
  66451. * @param callback the callback to execute on a given key/value pair
  66452. */
  66453. forEach(callback: (key: string, val: T) => void): void;
  66454. /**
  66455. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  66456. * If the callback returns null or undefined the method will iterate to the next key/value pair
  66457. * Note that you can remove any element in this dictionary in the callback implementation
  66458. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  66459. * @returns the first item
  66460. */
  66461. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  66462. private _count;
  66463. private _data;
  66464. }
  66465. }
  66466. declare module BABYLON {
  66467. /**
  66468. * Class used to store gfx data (like WebGLBuffer)
  66469. */
  66470. export class DataBuffer {
  66471. /**
  66472. * Gets or sets the number of objects referencing this buffer
  66473. */
  66474. references: number;
  66475. /** Gets or sets the size of the underlying buffer */
  66476. capacity: number;
  66477. /**
  66478. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  66479. */
  66480. is32Bits: boolean;
  66481. /**
  66482. * Gets the underlying buffer
  66483. */
  66484. readonly underlyingResource: any;
  66485. }
  66486. }
  66487. declare module BABYLON {
  66488. /**
  66489. * Class used to store data that will be store in GPU memory
  66490. */
  66491. export class Buffer {
  66492. private _engine;
  66493. private _buffer;
  66494. /** @hidden */
  66495. _data: Nullable<DataArray>;
  66496. private _updatable;
  66497. private _instanced;
  66498. /**
  66499. * Gets the byte stride.
  66500. */
  66501. readonly byteStride: number;
  66502. /**
  66503. * Constructor
  66504. * @param engine the engine
  66505. * @param data the data to use for this buffer
  66506. * @param updatable whether the data is updatable
  66507. * @param stride the stride (optional)
  66508. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  66509. * @param instanced whether the buffer is instanced (optional)
  66510. * @param useBytes set to true if the stride in in bytes (optional)
  66511. */
  66512. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  66513. /**
  66514. * Create a new VertexBuffer based on the current buffer
  66515. * @param kind defines the vertex buffer kind (position, normal, etc.)
  66516. * @param offset defines offset in the buffer (0 by default)
  66517. * @param size defines the size in floats of attributes (position is 3 for instance)
  66518. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  66519. * @param instanced defines if the vertex buffer contains indexed data
  66520. * @param useBytes defines if the offset and stride are in bytes
  66521. * @returns the new vertex buffer
  66522. */
  66523. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  66524. /**
  66525. * Gets a boolean indicating if the Buffer is updatable?
  66526. * @returns true if the buffer is updatable
  66527. */
  66528. isUpdatable(): boolean;
  66529. /**
  66530. * Gets current buffer's data
  66531. * @returns a DataArray or null
  66532. */
  66533. getData(): Nullable<DataArray>;
  66534. /**
  66535. * Gets underlying native buffer
  66536. * @returns underlying native buffer
  66537. */
  66538. getBuffer(): Nullable<DataBuffer>;
  66539. /**
  66540. * Gets the stride in float32 units (i.e. byte stride / 4).
  66541. * May not be an integer if the byte stride is not divisible by 4.
  66542. * DEPRECATED. Use byteStride instead.
  66543. * @returns the stride in float32 units
  66544. */
  66545. getStrideSize(): number;
  66546. /**
  66547. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  66548. * @param data defines the data to store
  66549. */
  66550. create(data?: Nullable<DataArray>): void;
  66551. /** @hidden */
  66552. _rebuild(): void;
  66553. /**
  66554. * Update current buffer data
  66555. * @param data defines the data to store
  66556. */
  66557. update(data: DataArray): void;
  66558. /**
  66559. * Updates the data directly.
  66560. * @param data the new data
  66561. * @param offset the new offset
  66562. * @param vertexCount the vertex count (optional)
  66563. * @param useBytes set to true if the offset is in bytes
  66564. */
  66565. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  66566. /**
  66567. * Release all resources
  66568. */
  66569. dispose(): void;
  66570. }
  66571. /**
  66572. * Specialized buffer used to store vertex data
  66573. */
  66574. export class VertexBuffer {
  66575. /** @hidden */
  66576. _buffer: Buffer;
  66577. private _kind;
  66578. private _size;
  66579. private _ownsBuffer;
  66580. private _instanced;
  66581. private _instanceDivisor;
  66582. /**
  66583. * The byte type.
  66584. */
  66585. static readonly BYTE: number;
  66586. /**
  66587. * The unsigned byte type.
  66588. */
  66589. static readonly UNSIGNED_BYTE: number;
  66590. /**
  66591. * The short type.
  66592. */
  66593. static readonly SHORT: number;
  66594. /**
  66595. * The unsigned short type.
  66596. */
  66597. static readonly UNSIGNED_SHORT: number;
  66598. /**
  66599. * The integer type.
  66600. */
  66601. static readonly INT: number;
  66602. /**
  66603. * The unsigned integer type.
  66604. */
  66605. static readonly UNSIGNED_INT: number;
  66606. /**
  66607. * The float type.
  66608. */
  66609. static readonly FLOAT: number;
  66610. /**
  66611. * Gets or sets the instance divisor when in instanced mode
  66612. */
  66613. instanceDivisor: number;
  66614. /**
  66615. * Gets the byte stride.
  66616. */
  66617. readonly byteStride: number;
  66618. /**
  66619. * Gets the byte offset.
  66620. */
  66621. readonly byteOffset: number;
  66622. /**
  66623. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  66624. */
  66625. readonly normalized: boolean;
  66626. /**
  66627. * Gets the data type of each component in the array.
  66628. */
  66629. readonly type: number;
  66630. /**
  66631. * Constructor
  66632. * @param engine the engine
  66633. * @param data the data to use for this vertex buffer
  66634. * @param kind the vertex buffer kind
  66635. * @param updatable whether the data is updatable
  66636. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  66637. * @param stride the stride (optional)
  66638. * @param instanced whether the buffer is instanced (optional)
  66639. * @param offset the offset of the data (optional)
  66640. * @param size the number of components (optional)
  66641. * @param type the type of the component (optional)
  66642. * @param normalized whether the data contains normalized data (optional)
  66643. * @param useBytes set to true if stride and offset are in bytes (optional)
  66644. */
  66645. 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);
  66646. /** @hidden */
  66647. _rebuild(): void;
  66648. /**
  66649. * Returns the kind of the VertexBuffer (string)
  66650. * @returns a string
  66651. */
  66652. getKind(): string;
  66653. /**
  66654. * Gets a boolean indicating if the VertexBuffer is updatable?
  66655. * @returns true if the buffer is updatable
  66656. */
  66657. isUpdatable(): boolean;
  66658. /**
  66659. * Gets current buffer's data
  66660. * @returns a DataArray or null
  66661. */
  66662. getData(): Nullable<DataArray>;
  66663. /**
  66664. * Gets underlying native buffer
  66665. * @returns underlying native buffer
  66666. */
  66667. getBuffer(): Nullable<DataBuffer>;
  66668. /**
  66669. * Gets the stride in float32 units (i.e. byte stride / 4).
  66670. * May not be an integer if the byte stride is not divisible by 4.
  66671. * DEPRECATED. Use byteStride instead.
  66672. * @returns the stride in float32 units
  66673. */
  66674. getStrideSize(): number;
  66675. /**
  66676. * Returns the offset as a multiple of the type byte length.
  66677. * DEPRECATED. Use byteOffset instead.
  66678. * @returns the offset in bytes
  66679. */
  66680. getOffset(): number;
  66681. /**
  66682. * Returns the number of components per vertex attribute (integer)
  66683. * @returns the size in float
  66684. */
  66685. getSize(): number;
  66686. /**
  66687. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  66688. * @returns true if this buffer is instanced
  66689. */
  66690. getIsInstanced(): boolean;
  66691. /**
  66692. * Returns the instancing divisor, zero for non-instanced (integer).
  66693. * @returns a number
  66694. */
  66695. getInstanceDivisor(): number;
  66696. /**
  66697. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  66698. * @param data defines the data to store
  66699. */
  66700. create(data?: DataArray): void;
  66701. /**
  66702. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  66703. * This function will create a new buffer if the current one is not updatable
  66704. * @param data defines the data to store
  66705. */
  66706. update(data: DataArray): void;
  66707. /**
  66708. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  66709. * Returns the directly updated WebGLBuffer.
  66710. * @param data the new data
  66711. * @param offset the new offset
  66712. * @param useBytes set to true if the offset is in bytes
  66713. */
  66714. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  66715. /**
  66716. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  66717. */
  66718. dispose(): void;
  66719. /**
  66720. * Enumerates each value of this vertex buffer as numbers.
  66721. * @param count the number of values to enumerate
  66722. * @param callback the callback function called for each value
  66723. */
  66724. forEach(count: number, callback: (value: number, index: number) => void): void;
  66725. /**
  66726. * Positions
  66727. */
  66728. static readonly PositionKind: string;
  66729. /**
  66730. * Normals
  66731. */
  66732. static readonly NormalKind: string;
  66733. /**
  66734. * Tangents
  66735. */
  66736. static readonly TangentKind: string;
  66737. /**
  66738. * Texture coordinates
  66739. */
  66740. static readonly UVKind: string;
  66741. /**
  66742. * Texture coordinates 2
  66743. */
  66744. static readonly UV2Kind: string;
  66745. /**
  66746. * Texture coordinates 3
  66747. */
  66748. static readonly UV3Kind: string;
  66749. /**
  66750. * Texture coordinates 4
  66751. */
  66752. static readonly UV4Kind: string;
  66753. /**
  66754. * Texture coordinates 5
  66755. */
  66756. static readonly UV5Kind: string;
  66757. /**
  66758. * Texture coordinates 6
  66759. */
  66760. static readonly UV6Kind: string;
  66761. /**
  66762. * Colors
  66763. */
  66764. static readonly ColorKind: string;
  66765. /**
  66766. * Matrix indices (for bones)
  66767. */
  66768. static readonly MatricesIndicesKind: string;
  66769. /**
  66770. * Matrix weights (for bones)
  66771. */
  66772. static readonly MatricesWeightsKind: string;
  66773. /**
  66774. * Additional matrix indices (for bones)
  66775. */
  66776. static readonly MatricesIndicesExtraKind: string;
  66777. /**
  66778. * Additional matrix weights (for bones)
  66779. */
  66780. static readonly MatricesWeightsExtraKind: string;
  66781. /**
  66782. * Deduces the stride given a kind.
  66783. * @param kind The kind string to deduce
  66784. * @returns The deduced stride
  66785. */
  66786. static DeduceStride(kind: string): number;
  66787. /**
  66788. * Gets the byte length of the given type.
  66789. * @param type the type
  66790. * @returns the number of bytes
  66791. */
  66792. static GetTypeByteLength(type: number): number;
  66793. /**
  66794. * Enumerates each value of the given parameters as numbers.
  66795. * @param data the data to enumerate
  66796. * @param byteOffset the byte offset of the data
  66797. * @param byteStride the byte stride of the data
  66798. * @param componentCount the number of components per element
  66799. * @param componentType the type of the component
  66800. * @param count the number of values to enumerate
  66801. * @param normalized whether the data is normalized
  66802. * @param callback the callback function called for each value
  66803. */
  66804. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  66805. private static _GetFloatValue;
  66806. }
  66807. }
  66808. declare module BABYLON {
  66809. /**
  66810. * Scalar computation library
  66811. */
  66812. export class Scalar {
  66813. /**
  66814. * Two pi constants convenient for computation.
  66815. */
  66816. static TwoPi: number;
  66817. /**
  66818. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66819. * @param a number
  66820. * @param b number
  66821. * @param epsilon (default = 1.401298E-45)
  66822. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66823. */
  66824. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  66825. /**
  66826. * Returns a string : the upper case translation of the number i to hexadecimal.
  66827. * @param i number
  66828. * @returns the upper case translation of the number i to hexadecimal.
  66829. */
  66830. static ToHex(i: number): string;
  66831. /**
  66832. * Returns -1 if value is negative and +1 is value is positive.
  66833. * @param value the value
  66834. * @returns the value itself if it's equal to zero.
  66835. */
  66836. static Sign(value: number): number;
  66837. /**
  66838. * Returns the value itself if it's between min and max.
  66839. * Returns min if the value is lower than min.
  66840. * Returns max if the value is greater than max.
  66841. * @param value the value to clmap
  66842. * @param min the min value to clamp to (default: 0)
  66843. * @param max the max value to clamp to (default: 1)
  66844. * @returns the clamped value
  66845. */
  66846. static Clamp(value: number, min?: number, max?: number): number;
  66847. /**
  66848. * the log2 of value.
  66849. * @param value the value to compute log2 of
  66850. * @returns the log2 of value.
  66851. */
  66852. static Log2(value: number): number;
  66853. /**
  66854. * Loops the value, so that it is never larger than length and never smaller than 0.
  66855. *
  66856. * This is similar to the modulo operator but it works with floating point numbers.
  66857. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  66858. * With t = 5 and length = 2.5, the result would be 0.0.
  66859. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  66860. * @param value the value
  66861. * @param length the length
  66862. * @returns the looped value
  66863. */
  66864. static Repeat(value: number, length: number): number;
  66865. /**
  66866. * Normalize the value between 0.0 and 1.0 using min and max values
  66867. * @param value value to normalize
  66868. * @param min max to normalize between
  66869. * @param max min to normalize between
  66870. * @returns the normalized value
  66871. */
  66872. static Normalize(value: number, min: number, max: number): number;
  66873. /**
  66874. * Denormalize the value from 0.0 and 1.0 using min and max values
  66875. * @param normalized value to denormalize
  66876. * @param min max to denormalize between
  66877. * @param max min to denormalize between
  66878. * @returns the denormalized value
  66879. */
  66880. static Denormalize(normalized: number, min: number, max: number): number;
  66881. /**
  66882. * Calculates the shortest difference between two given angles given in degrees.
  66883. * @param current current angle in degrees
  66884. * @param target target angle in degrees
  66885. * @returns the delta
  66886. */
  66887. static DeltaAngle(current: number, target: number): number;
  66888. /**
  66889. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  66890. * @param tx value
  66891. * @param length length
  66892. * @returns The returned value will move back and forth between 0 and length
  66893. */
  66894. static PingPong(tx: number, length: number): number;
  66895. /**
  66896. * Interpolates between min and max with smoothing at the limits.
  66897. *
  66898. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  66899. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  66900. * @param from from
  66901. * @param to to
  66902. * @param tx value
  66903. * @returns the smooth stepped value
  66904. */
  66905. static SmoothStep(from: number, to: number, tx: number): number;
  66906. /**
  66907. * Moves a value current towards target.
  66908. *
  66909. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  66910. * Negative values of maxDelta pushes the value away from target.
  66911. * @param current current value
  66912. * @param target target value
  66913. * @param maxDelta max distance to move
  66914. * @returns resulting value
  66915. */
  66916. static MoveTowards(current: number, target: number, maxDelta: number): number;
  66917. /**
  66918. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66919. *
  66920. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  66921. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  66922. * @param current current value
  66923. * @param target target value
  66924. * @param maxDelta max distance to move
  66925. * @returns resulting angle
  66926. */
  66927. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  66928. /**
  66929. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  66930. * @param start start value
  66931. * @param end target value
  66932. * @param amount amount to lerp between
  66933. * @returns the lerped value
  66934. */
  66935. static Lerp(start: number, end: number, amount: number): number;
  66936. /**
  66937. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66938. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  66939. * @param start start value
  66940. * @param end target value
  66941. * @param amount amount to lerp between
  66942. * @returns the lerped value
  66943. */
  66944. static LerpAngle(start: number, end: number, amount: number): number;
  66945. /**
  66946. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  66947. * @param a start value
  66948. * @param b target value
  66949. * @param value value between a and b
  66950. * @returns the inverseLerp value
  66951. */
  66952. static InverseLerp(a: number, b: number, value: number): number;
  66953. /**
  66954. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  66955. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  66956. * @param value1 spline value
  66957. * @param tangent1 spline value
  66958. * @param value2 spline value
  66959. * @param tangent2 spline value
  66960. * @param amount input value
  66961. * @returns hermite result
  66962. */
  66963. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  66964. /**
  66965. * Returns a random float number between and min and max values
  66966. * @param min min value of random
  66967. * @param max max value of random
  66968. * @returns random value
  66969. */
  66970. static RandomRange(min: number, max: number): number;
  66971. /**
  66972. * This function returns percentage of a number in a given range.
  66973. *
  66974. * RangeToPercent(40,20,60) will return 0.5 (50%)
  66975. * RangeToPercent(34,0,100) will return 0.34 (34%)
  66976. * @param number to convert to percentage
  66977. * @param min min range
  66978. * @param max max range
  66979. * @returns the percentage
  66980. */
  66981. static RangeToPercent(number: number, min: number, max: number): number;
  66982. /**
  66983. * This function returns number that corresponds to the percentage in a given range.
  66984. *
  66985. * PercentToRange(0.34,0,100) will return 34.
  66986. * @param percent to convert to number
  66987. * @param min min range
  66988. * @param max max range
  66989. * @returns the number
  66990. */
  66991. static PercentToRange(percent: number, min: number, max: number): number;
  66992. /**
  66993. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  66994. * @param angle The angle to normalize in radian.
  66995. * @return The converted angle.
  66996. */
  66997. static NormalizeRadians(angle: number): number;
  66998. }
  66999. }
  67000. declare module BABYLON {
  67001. /**
  67002. * Constant used to convert a value to gamma space
  67003. * @ignorenaming
  67004. */
  67005. export const ToGammaSpace: number;
  67006. /**
  67007. * Constant used to convert a value to linear space
  67008. * @ignorenaming
  67009. */
  67010. export const ToLinearSpace = 2.2;
  67011. /**
  67012. * Constant used to define the minimal number value in Babylon.js
  67013. * @ignorenaming
  67014. */
  67015. let Epsilon: number;
  67016. }
  67017. declare module BABYLON {
  67018. /**
  67019. * Class used to represent a viewport on screen
  67020. */
  67021. export class Viewport {
  67022. /** viewport left coordinate */
  67023. x: number;
  67024. /** viewport top coordinate */
  67025. y: number;
  67026. /**viewport width */
  67027. width: number;
  67028. /** viewport height */
  67029. height: number;
  67030. /**
  67031. * Creates a Viewport object located at (x, y) and sized (width, height)
  67032. * @param x defines viewport left coordinate
  67033. * @param y defines viewport top coordinate
  67034. * @param width defines the viewport width
  67035. * @param height defines the viewport height
  67036. */
  67037. constructor(
  67038. /** viewport left coordinate */
  67039. x: number,
  67040. /** viewport top coordinate */
  67041. y: number,
  67042. /**viewport width */
  67043. width: number,
  67044. /** viewport height */
  67045. height: number);
  67046. /**
  67047. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  67048. * @param renderWidth defines the rendering width
  67049. * @param renderHeight defines the rendering height
  67050. * @returns a new Viewport
  67051. */
  67052. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  67053. /**
  67054. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  67055. * @param renderWidth defines the rendering width
  67056. * @param renderHeight defines the rendering height
  67057. * @param ref defines the target viewport
  67058. * @returns the current viewport
  67059. */
  67060. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  67061. /**
  67062. * Returns a new Viewport copied from the current one
  67063. * @returns a new Viewport
  67064. */
  67065. clone(): Viewport;
  67066. }
  67067. }
  67068. declare module BABYLON {
  67069. /**
  67070. * Class containing a set of static utilities functions for arrays.
  67071. */
  67072. export class ArrayTools {
  67073. /**
  67074. * Returns an array of the given size filled with element built from the given constructor and the paramters
  67075. * @param size the number of element to construct and put in the array
  67076. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  67077. * @returns a new array filled with new objects
  67078. */
  67079. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  67080. }
  67081. }
  67082. declare module BABYLON {
  67083. /**
  67084. * @hidden
  67085. */
  67086. export interface IColor4Like {
  67087. r: float;
  67088. g: float;
  67089. b: float;
  67090. a: float;
  67091. }
  67092. /**
  67093. * @hidden
  67094. */
  67095. export interface IColor3Like {
  67096. r: float;
  67097. g: float;
  67098. b: float;
  67099. }
  67100. /**
  67101. * @hidden
  67102. */
  67103. export interface IVector4Like {
  67104. x: float;
  67105. y: float;
  67106. z: float;
  67107. w: float;
  67108. }
  67109. /**
  67110. * @hidden
  67111. */
  67112. export interface IVector3Like {
  67113. x: float;
  67114. y: float;
  67115. z: float;
  67116. }
  67117. /**
  67118. * @hidden
  67119. */
  67120. export interface IVector2Like {
  67121. x: float;
  67122. y: float;
  67123. }
  67124. /**
  67125. * @hidden
  67126. */
  67127. export interface IMatrixLike {
  67128. toArray(): DeepImmutable<Float32Array>;
  67129. updateFlag: int;
  67130. }
  67131. /**
  67132. * @hidden
  67133. */
  67134. export interface IViewportLike {
  67135. x: float;
  67136. y: float;
  67137. width: float;
  67138. height: float;
  67139. }
  67140. /**
  67141. * @hidden
  67142. */
  67143. export interface IPlaneLike {
  67144. normal: IVector3Like;
  67145. d: float;
  67146. normalize(): void;
  67147. }
  67148. }
  67149. declare module BABYLON {
  67150. /**
  67151. * Class representing a vector containing 2 coordinates
  67152. */
  67153. export class Vector2 {
  67154. /** defines the first coordinate */
  67155. x: number;
  67156. /** defines the second coordinate */
  67157. y: number;
  67158. /**
  67159. * Creates a new Vector2 from the given x and y coordinates
  67160. * @param x defines the first coordinate
  67161. * @param y defines the second coordinate
  67162. */
  67163. constructor(
  67164. /** defines the first coordinate */
  67165. x?: number,
  67166. /** defines the second coordinate */
  67167. y?: number);
  67168. /**
  67169. * Gets a string with the Vector2 coordinates
  67170. * @returns a string with the Vector2 coordinates
  67171. */
  67172. toString(): string;
  67173. /**
  67174. * Gets class name
  67175. * @returns the string "Vector2"
  67176. */
  67177. getClassName(): string;
  67178. /**
  67179. * Gets current vector hash code
  67180. * @returns the Vector2 hash code as a number
  67181. */
  67182. getHashCode(): number;
  67183. /**
  67184. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  67185. * @param array defines the source array
  67186. * @param index defines the offset in source array
  67187. * @returns the current Vector2
  67188. */
  67189. toArray(array: FloatArray, index?: number): Vector2;
  67190. /**
  67191. * Copy the current vector to an array
  67192. * @returns a new array with 2 elements: the Vector2 coordinates.
  67193. */
  67194. asArray(): number[];
  67195. /**
  67196. * Sets the Vector2 coordinates with the given Vector2 coordinates
  67197. * @param source defines the source Vector2
  67198. * @returns the current updated Vector2
  67199. */
  67200. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  67201. /**
  67202. * Sets the Vector2 coordinates with the given floats
  67203. * @param x defines the first coordinate
  67204. * @param y defines the second coordinate
  67205. * @returns the current updated Vector2
  67206. */
  67207. copyFromFloats(x: number, y: number): Vector2;
  67208. /**
  67209. * Sets the Vector2 coordinates with the given floats
  67210. * @param x defines the first coordinate
  67211. * @param y defines the second coordinate
  67212. * @returns the current updated Vector2
  67213. */
  67214. set(x: number, y: number): Vector2;
  67215. /**
  67216. * Add another vector with the current one
  67217. * @param otherVector defines the other vector
  67218. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  67219. */
  67220. add(otherVector: DeepImmutable<Vector2>): Vector2;
  67221. /**
  67222. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  67223. * @param otherVector defines the other vector
  67224. * @param result defines the target vector
  67225. * @returns the unmodified current Vector2
  67226. */
  67227. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67228. /**
  67229. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  67230. * @param otherVector defines the other vector
  67231. * @returns the current updated Vector2
  67232. */
  67233. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67234. /**
  67235. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  67236. * @param otherVector defines the other vector
  67237. * @returns a new Vector2
  67238. */
  67239. addVector3(otherVector: Vector3): Vector2;
  67240. /**
  67241. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  67242. * @param otherVector defines the other vector
  67243. * @returns a new Vector2
  67244. */
  67245. subtract(otherVector: Vector2): Vector2;
  67246. /**
  67247. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  67248. * @param otherVector defines the other vector
  67249. * @param result defines the target vector
  67250. * @returns the unmodified current Vector2
  67251. */
  67252. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67253. /**
  67254. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  67255. * @param otherVector defines the other vector
  67256. * @returns the current updated Vector2
  67257. */
  67258. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67259. /**
  67260. * Multiplies in place the current Vector2 coordinates by the given ones
  67261. * @param otherVector defines the other vector
  67262. * @returns the current updated Vector2
  67263. */
  67264. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67265. /**
  67266. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  67267. * @param otherVector defines the other vector
  67268. * @returns a new Vector2
  67269. */
  67270. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  67271. /**
  67272. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  67273. * @param otherVector defines the other vector
  67274. * @param result defines the target vector
  67275. * @returns the unmodified current Vector2
  67276. */
  67277. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67278. /**
  67279. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  67280. * @param x defines the first coordinate
  67281. * @param y defines the second coordinate
  67282. * @returns a new Vector2
  67283. */
  67284. multiplyByFloats(x: number, y: number): Vector2;
  67285. /**
  67286. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  67287. * @param otherVector defines the other vector
  67288. * @returns a new Vector2
  67289. */
  67290. divide(otherVector: Vector2): Vector2;
  67291. /**
  67292. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  67293. * @param otherVector defines the other vector
  67294. * @param result defines the target vector
  67295. * @returns the unmodified current Vector2
  67296. */
  67297. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67298. /**
  67299. * Divides the current Vector2 coordinates by the given ones
  67300. * @param otherVector defines the other vector
  67301. * @returns the current updated Vector2
  67302. */
  67303. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67304. /**
  67305. * Gets a new Vector2 with current Vector2 negated coordinates
  67306. * @returns a new Vector2
  67307. */
  67308. negate(): Vector2;
  67309. /**
  67310. * Multiply the Vector2 coordinates by scale
  67311. * @param scale defines the scaling factor
  67312. * @returns the current updated Vector2
  67313. */
  67314. scaleInPlace(scale: number): Vector2;
  67315. /**
  67316. * Returns a new Vector2 scaled by "scale" from the current Vector2
  67317. * @param scale defines the scaling factor
  67318. * @returns a new Vector2
  67319. */
  67320. scale(scale: number): Vector2;
  67321. /**
  67322. * Scale the current Vector2 values by a factor to a given Vector2
  67323. * @param scale defines the scale factor
  67324. * @param result defines the Vector2 object where to store the result
  67325. * @returns the unmodified current Vector2
  67326. */
  67327. scaleToRef(scale: number, result: Vector2): Vector2;
  67328. /**
  67329. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  67330. * @param scale defines the scale factor
  67331. * @param result defines the Vector2 object where to store the result
  67332. * @returns the unmodified current Vector2
  67333. */
  67334. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  67335. /**
  67336. * Gets a boolean if two vectors are equals
  67337. * @param otherVector defines the other vector
  67338. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  67339. */
  67340. equals(otherVector: DeepImmutable<Vector2>): boolean;
  67341. /**
  67342. * Gets a boolean if two vectors are equals (using an epsilon value)
  67343. * @param otherVector defines the other vector
  67344. * @param epsilon defines the minimal distance to consider equality
  67345. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  67346. */
  67347. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  67348. /**
  67349. * Gets a new Vector2 from current Vector2 floored values
  67350. * @returns a new Vector2
  67351. */
  67352. floor(): Vector2;
  67353. /**
  67354. * Gets a new Vector2 from current Vector2 floored values
  67355. * @returns a new Vector2
  67356. */
  67357. fract(): Vector2;
  67358. /**
  67359. * Gets the length of the vector
  67360. * @returns the vector length (float)
  67361. */
  67362. length(): number;
  67363. /**
  67364. * Gets the vector squared length
  67365. * @returns the vector squared length (float)
  67366. */
  67367. lengthSquared(): number;
  67368. /**
  67369. * Normalize the vector
  67370. * @returns the current updated Vector2
  67371. */
  67372. normalize(): Vector2;
  67373. /**
  67374. * Gets a new Vector2 copied from the Vector2
  67375. * @returns a new Vector2
  67376. */
  67377. clone(): Vector2;
  67378. /**
  67379. * Gets a new Vector2(0, 0)
  67380. * @returns a new Vector2
  67381. */
  67382. static Zero(): Vector2;
  67383. /**
  67384. * Gets a new Vector2(1, 1)
  67385. * @returns a new Vector2
  67386. */
  67387. static One(): Vector2;
  67388. /**
  67389. * Gets a new Vector2 set from the given index element of the given array
  67390. * @param array defines the data source
  67391. * @param offset defines the offset in the data source
  67392. * @returns a new Vector2
  67393. */
  67394. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  67395. /**
  67396. * Sets "result" from the given index element of the given array
  67397. * @param array defines the data source
  67398. * @param offset defines the offset in the data source
  67399. * @param result defines the target vector
  67400. */
  67401. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  67402. /**
  67403. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  67404. * @param value1 defines 1st point of control
  67405. * @param value2 defines 2nd point of control
  67406. * @param value3 defines 3rd point of control
  67407. * @param value4 defines 4th point of control
  67408. * @param amount defines the interpolation factor
  67409. * @returns a new Vector2
  67410. */
  67411. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  67412. /**
  67413. * 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".
  67414. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  67415. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  67416. * @param value defines the value to clamp
  67417. * @param min defines the lower limit
  67418. * @param max defines the upper limit
  67419. * @returns a new Vector2
  67420. */
  67421. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  67422. /**
  67423. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  67424. * @param value1 defines the 1st control point
  67425. * @param tangent1 defines the outgoing tangent
  67426. * @param value2 defines the 2nd control point
  67427. * @param tangent2 defines the incoming tangent
  67428. * @param amount defines the interpolation factor
  67429. * @returns a new Vector2
  67430. */
  67431. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  67432. /**
  67433. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  67434. * @param start defines the start vector
  67435. * @param end defines the end vector
  67436. * @param amount defines the interpolation factor
  67437. * @returns a new Vector2
  67438. */
  67439. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  67440. /**
  67441. * Gets the dot product of the vector "left" and the vector "right"
  67442. * @param left defines first vector
  67443. * @param right defines second vector
  67444. * @returns the dot product (float)
  67445. */
  67446. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  67447. /**
  67448. * Returns a new Vector2 equal to the normalized given vector
  67449. * @param vector defines the vector to normalize
  67450. * @returns a new Vector2
  67451. */
  67452. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  67453. /**
  67454. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  67455. * @param left defines 1st vector
  67456. * @param right defines 2nd vector
  67457. * @returns a new Vector2
  67458. */
  67459. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67460. /**
  67461. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  67462. * @param left defines 1st vector
  67463. * @param right defines 2nd vector
  67464. * @returns a new Vector2
  67465. */
  67466. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67467. /**
  67468. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  67469. * @param vector defines the vector to transform
  67470. * @param transformation defines the matrix to apply
  67471. * @returns a new Vector2
  67472. */
  67473. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  67474. /**
  67475. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  67476. * @param vector defines the vector to transform
  67477. * @param transformation defines the matrix to apply
  67478. * @param result defines the target vector
  67479. */
  67480. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  67481. /**
  67482. * Determines if a given vector is included in a triangle
  67483. * @param p defines the vector to test
  67484. * @param p0 defines 1st triangle point
  67485. * @param p1 defines 2nd triangle point
  67486. * @param p2 defines 3rd triangle point
  67487. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  67488. */
  67489. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  67490. /**
  67491. * Gets the distance between the vectors "value1" and "value2"
  67492. * @param value1 defines first vector
  67493. * @param value2 defines second vector
  67494. * @returns the distance between vectors
  67495. */
  67496. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67497. /**
  67498. * Returns the squared distance between the vectors "value1" and "value2"
  67499. * @param value1 defines first vector
  67500. * @param value2 defines second vector
  67501. * @returns the squared distance between vectors
  67502. */
  67503. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67504. /**
  67505. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  67506. * @param value1 defines first vector
  67507. * @param value2 defines second vector
  67508. * @returns a new Vector2
  67509. */
  67510. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  67511. /**
  67512. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  67513. * @param p defines the middle point
  67514. * @param segA defines one point of the segment
  67515. * @param segB defines the other point of the segment
  67516. * @returns the shortest distance
  67517. */
  67518. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  67519. }
  67520. /**
  67521. * Classed used to store (x,y,z) vector representation
  67522. * A Vector3 is the main object used in 3D geometry
  67523. * It can represent etiher the coordinates of a point the space, either a direction
  67524. * Reminder: js uses a left handed forward facing system
  67525. */
  67526. export class Vector3 {
  67527. /**
  67528. * Defines the first coordinates (on X axis)
  67529. */
  67530. x: number;
  67531. /**
  67532. * Defines the second coordinates (on Y axis)
  67533. */
  67534. y: number;
  67535. /**
  67536. * Defines the third coordinates (on Z axis)
  67537. */
  67538. z: number;
  67539. private static _UpReadOnly;
  67540. private static _ZeroReadOnly;
  67541. /**
  67542. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  67543. * @param x defines the first coordinates (on X axis)
  67544. * @param y defines the second coordinates (on Y axis)
  67545. * @param z defines the third coordinates (on Z axis)
  67546. */
  67547. constructor(
  67548. /**
  67549. * Defines the first coordinates (on X axis)
  67550. */
  67551. x?: number,
  67552. /**
  67553. * Defines the second coordinates (on Y axis)
  67554. */
  67555. y?: number,
  67556. /**
  67557. * Defines the third coordinates (on Z axis)
  67558. */
  67559. z?: number);
  67560. /**
  67561. * Creates a string representation of the Vector3
  67562. * @returns a string with the Vector3 coordinates.
  67563. */
  67564. toString(): string;
  67565. /**
  67566. * Gets the class name
  67567. * @returns the string "Vector3"
  67568. */
  67569. getClassName(): string;
  67570. /**
  67571. * Creates the Vector3 hash code
  67572. * @returns a number which tends to be unique between Vector3 instances
  67573. */
  67574. getHashCode(): number;
  67575. /**
  67576. * Creates an array containing three elements : the coordinates of the Vector3
  67577. * @returns a new array of numbers
  67578. */
  67579. asArray(): number[];
  67580. /**
  67581. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  67582. * @param array defines the destination array
  67583. * @param index defines the offset in the destination array
  67584. * @returns the current Vector3
  67585. */
  67586. toArray(array: FloatArray, index?: number): Vector3;
  67587. /**
  67588. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  67589. * @returns a new Quaternion object, computed from the Vector3 coordinates
  67590. */
  67591. toQuaternion(): Quaternion;
  67592. /**
  67593. * Adds the given vector to the current Vector3
  67594. * @param otherVector defines the second operand
  67595. * @returns the current updated Vector3
  67596. */
  67597. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67598. /**
  67599. * Adds the given coordinates to the current Vector3
  67600. * @param x defines the x coordinate of the operand
  67601. * @param y defines the y coordinate of the operand
  67602. * @param z defines the z coordinate of the operand
  67603. * @returns the current updated Vector3
  67604. */
  67605. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67606. /**
  67607. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  67608. * @param otherVector defines the second operand
  67609. * @returns the resulting Vector3
  67610. */
  67611. add(otherVector: DeepImmutable<Vector3>): Vector3;
  67612. /**
  67613. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  67614. * @param otherVector defines the second operand
  67615. * @param result defines the Vector3 object where to store the result
  67616. * @returns the current Vector3
  67617. */
  67618. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67619. /**
  67620. * Subtract the given vector from the current Vector3
  67621. * @param otherVector defines the second operand
  67622. * @returns the current updated Vector3
  67623. */
  67624. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67625. /**
  67626. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  67627. * @param otherVector defines the second operand
  67628. * @returns the resulting Vector3
  67629. */
  67630. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  67631. /**
  67632. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  67633. * @param otherVector defines the second operand
  67634. * @param result defines the Vector3 object where to store the result
  67635. * @returns the current Vector3
  67636. */
  67637. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67638. /**
  67639. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  67640. * @param x defines the x coordinate of the operand
  67641. * @param y defines the y coordinate of the operand
  67642. * @param z defines the z coordinate of the operand
  67643. * @returns the resulting Vector3
  67644. */
  67645. subtractFromFloats(x: number, y: number, z: number): Vector3;
  67646. /**
  67647. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  67648. * @param x defines the x coordinate of the operand
  67649. * @param y defines the y coordinate of the operand
  67650. * @param z defines the z coordinate of the operand
  67651. * @param result defines the Vector3 object where to store the result
  67652. * @returns the current Vector3
  67653. */
  67654. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  67655. /**
  67656. * Gets a new Vector3 set with the current Vector3 negated coordinates
  67657. * @returns a new Vector3
  67658. */
  67659. negate(): Vector3;
  67660. /**
  67661. * Multiplies the Vector3 coordinates by the float "scale"
  67662. * @param scale defines the multiplier factor
  67663. * @returns the current updated Vector3
  67664. */
  67665. scaleInPlace(scale: number): Vector3;
  67666. /**
  67667. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  67668. * @param scale defines the multiplier factor
  67669. * @returns a new Vector3
  67670. */
  67671. scale(scale: number): Vector3;
  67672. /**
  67673. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  67674. * @param scale defines the multiplier factor
  67675. * @param result defines the Vector3 object where to store the result
  67676. * @returns the current Vector3
  67677. */
  67678. scaleToRef(scale: number, result: Vector3): Vector3;
  67679. /**
  67680. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  67681. * @param scale defines the scale factor
  67682. * @param result defines the Vector3 object where to store the result
  67683. * @returns the unmodified current Vector3
  67684. */
  67685. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  67686. /**
  67687. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  67688. * @param otherVector defines the second operand
  67689. * @returns true if both vectors are equals
  67690. */
  67691. equals(otherVector: DeepImmutable<Vector3>): boolean;
  67692. /**
  67693. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  67694. * @param otherVector defines the second operand
  67695. * @param epsilon defines the minimal distance to define values as equals
  67696. * @returns true if both vectors are distant less than epsilon
  67697. */
  67698. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  67699. /**
  67700. * Returns true if the current Vector3 coordinates equals the given floats
  67701. * @param x defines the x coordinate of the operand
  67702. * @param y defines the y coordinate of the operand
  67703. * @param z defines the z coordinate of the operand
  67704. * @returns true if both vectors are equals
  67705. */
  67706. equalsToFloats(x: number, y: number, z: number): boolean;
  67707. /**
  67708. * Multiplies the current Vector3 coordinates by the given ones
  67709. * @param otherVector defines the second operand
  67710. * @returns the current updated Vector3
  67711. */
  67712. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67713. /**
  67714. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  67715. * @param otherVector defines the second operand
  67716. * @returns the new Vector3
  67717. */
  67718. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  67719. /**
  67720. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  67721. * @param otherVector defines the second operand
  67722. * @param result defines the Vector3 object where to store the result
  67723. * @returns the current Vector3
  67724. */
  67725. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67726. /**
  67727. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  67728. * @param x defines the x coordinate of the operand
  67729. * @param y defines the y coordinate of the operand
  67730. * @param z defines the z coordinate of the operand
  67731. * @returns the new Vector3
  67732. */
  67733. multiplyByFloats(x: number, y: number, z: number): Vector3;
  67734. /**
  67735. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  67736. * @param otherVector defines the second operand
  67737. * @returns the new Vector3
  67738. */
  67739. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  67740. /**
  67741. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  67742. * @param otherVector defines the second operand
  67743. * @param result defines the Vector3 object where to store the result
  67744. * @returns the current Vector3
  67745. */
  67746. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67747. /**
  67748. * Divides the current Vector3 coordinates by the given ones.
  67749. * @param otherVector defines the second operand
  67750. * @returns the current updated Vector3
  67751. */
  67752. divideInPlace(otherVector: Vector3): Vector3;
  67753. /**
  67754. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  67755. * @param other defines the second operand
  67756. * @returns the current updated Vector3
  67757. */
  67758. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67759. /**
  67760. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  67761. * @param other defines the second operand
  67762. * @returns the current updated Vector3
  67763. */
  67764. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67765. /**
  67766. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  67767. * @param x defines the x coordinate of the operand
  67768. * @param y defines the y coordinate of the operand
  67769. * @param z defines the z coordinate of the operand
  67770. * @returns the current updated Vector3
  67771. */
  67772. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67773. /**
  67774. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  67775. * @param x defines the x coordinate of the operand
  67776. * @param y defines the y coordinate of the operand
  67777. * @param z defines the z coordinate of the operand
  67778. * @returns the current updated Vector3
  67779. */
  67780. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67781. /**
  67782. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  67783. * Check if is non uniform within a certain amount of decimal places to account for this
  67784. * @param epsilon the amount the values can differ
  67785. * @returns if the the vector is non uniform to a certain number of decimal places
  67786. */
  67787. isNonUniformWithinEpsilon(epsilon: number): boolean;
  67788. /**
  67789. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  67790. */
  67791. readonly isNonUniform: boolean;
  67792. /**
  67793. * Gets a new Vector3 from current Vector3 floored values
  67794. * @returns a new Vector3
  67795. */
  67796. floor(): Vector3;
  67797. /**
  67798. * Gets a new Vector3 from current Vector3 floored values
  67799. * @returns a new Vector3
  67800. */
  67801. fract(): Vector3;
  67802. /**
  67803. * Gets the length of the Vector3
  67804. * @returns the length of the Vector3
  67805. */
  67806. length(): number;
  67807. /**
  67808. * Gets the squared length of the Vector3
  67809. * @returns squared length of the Vector3
  67810. */
  67811. lengthSquared(): number;
  67812. /**
  67813. * Normalize the current Vector3.
  67814. * Please note that this is an in place operation.
  67815. * @returns the current updated Vector3
  67816. */
  67817. normalize(): Vector3;
  67818. /**
  67819. * Reorders the x y z properties of the vector in place
  67820. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  67821. * @returns the current updated vector
  67822. */
  67823. reorderInPlace(order: string): this;
  67824. /**
  67825. * Rotates the vector around 0,0,0 by a quaternion
  67826. * @param quaternion the rotation quaternion
  67827. * @param result vector to store the result
  67828. * @returns the resulting vector
  67829. */
  67830. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  67831. /**
  67832. * Rotates a vector around a given point
  67833. * @param quaternion the rotation quaternion
  67834. * @param point the point to rotate around
  67835. * @param result vector to store the result
  67836. * @returns the resulting vector
  67837. */
  67838. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  67839. /**
  67840. * Normalize the current Vector3 with the given input length.
  67841. * Please note that this is an in place operation.
  67842. * @param len the length of the vector
  67843. * @returns the current updated Vector3
  67844. */
  67845. normalizeFromLength(len: number): Vector3;
  67846. /**
  67847. * Normalize the current Vector3 to a new vector
  67848. * @returns the new Vector3
  67849. */
  67850. normalizeToNew(): Vector3;
  67851. /**
  67852. * Normalize the current Vector3 to the reference
  67853. * @param reference define the Vector3 to update
  67854. * @returns the updated Vector3
  67855. */
  67856. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  67857. /**
  67858. * Creates a new Vector3 copied from the current Vector3
  67859. * @returns the new Vector3
  67860. */
  67861. clone(): Vector3;
  67862. /**
  67863. * Copies the given vector coordinates to the current Vector3 ones
  67864. * @param source defines the source Vector3
  67865. * @returns the current updated Vector3
  67866. */
  67867. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  67868. /**
  67869. * Copies the given floats to the current Vector3 coordinates
  67870. * @param x defines the x coordinate of the operand
  67871. * @param y defines the y coordinate of the operand
  67872. * @param z defines the z coordinate of the operand
  67873. * @returns the current updated Vector3
  67874. */
  67875. copyFromFloats(x: number, y: number, z: number): Vector3;
  67876. /**
  67877. * Copies the given floats to the current Vector3 coordinates
  67878. * @param x defines the x coordinate of the operand
  67879. * @param y defines the y coordinate of the operand
  67880. * @param z defines the z coordinate of the operand
  67881. * @returns the current updated Vector3
  67882. */
  67883. set(x: number, y: number, z: number): Vector3;
  67884. /**
  67885. * Copies the given float to the current Vector3 coordinates
  67886. * @param v defines the x, y and z coordinates of the operand
  67887. * @returns the current updated Vector3
  67888. */
  67889. setAll(v: number): Vector3;
  67890. /**
  67891. * Get the clip factor between two vectors
  67892. * @param vector0 defines the first operand
  67893. * @param vector1 defines the second operand
  67894. * @param axis defines the axis to use
  67895. * @param size defines the size along the axis
  67896. * @returns the clip factor
  67897. */
  67898. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  67899. /**
  67900. * Get angle between two vectors
  67901. * @param vector0 angle between vector0 and vector1
  67902. * @param vector1 angle between vector0 and vector1
  67903. * @param normal direction of the normal
  67904. * @return the angle between vector0 and vector1
  67905. */
  67906. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  67907. /**
  67908. * Returns a new Vector3 set from the index "offset" of the given array
  67909. * @param array defines the source array
  67910. * @param offset defines the offset in the source array
  67911. * @returns the new Vector3
  67912. */
  67913. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  67914. /**
  67915. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  67916. * This function is deprecated. Use FromArray instead
  67917. * @param array defines the source array
  67918. * @param offset defines the offset in the source array
  67919. * @returns the new Vector3
  67920. */
  67921. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  67922. /**
  67923. * Sets the given vector "result" with the element values from the index "offset" of the given array
  67924. * @param array defines the source array
  67925. * @param offset defines the offset in the source array
  67926. * @param result defines the Vector3 where to store the result
  67927. */
  67928. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  67929. /**
  67930. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  67931. * This function is deprecated. Use FromArrayToRef instead.
  67932. * @param array defines the source array
  67933. * @param offset defines the offset in the source array
  67934. * @param result defines the Vector3 where to store the result
  67935. */
  67936. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  67937. /**
  67938. * Sets the given vector "result" with the given floats.
  67939. * @param x defines the x coordinate of the source
  67940. * @param y defines the y coordinate of the source
  67941. * @param z defines the z coordinate of the source
  67942. * @param result defines the Vector3 where to store the result
  67943. */
  67944. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  67945. /**
  67946. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  67947. * @returns a new empty Vector3
  67948. */
  67949. static Zero(): Vector3;
  67950. /**
  67951. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  67952. * @returns a new unit Vector3
  67953. */
  67954. static One(): Vector3;
  67955. /**
  67956. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  67957. * @returns a new up Vector3
  67958. */
  67959. static Up(): Vector3;
  67960. /**
  67961. * Gets a up Vector3 that must not be updated
  67962. */
  67963. static readonly UpReadOnly: DeepImmutable<Vector3>;
  67964. /**
  67965. * Gets a zero Vector3 that must not be updated
  67966. */
  67967. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  67968. /**
  67969. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  67970. * @returns a new down Vector3
  67971. */
  67972. static Down(): Vector3;
  67973. /**
  67974. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  67975. * @returns a new forward Vector3
  67976. */
  67977. static Forward(): Vector3;
  67978. /**
  67979. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  67980. * @returns a new forward Vector3
  67981. */
  67982. static Backward(): Vector3;
  67983. /**
  67984. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  67985. * @returns a new right Vector3
  67986. */
  67987. static Right(): Vector3;
  67988. /**
  67989. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  67990. * @returns a new left Vector3
  67991. */
  67992. static Left(): Vector3;
  67993. /**
  67994. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  67995. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  67996. * @param vector defines the Vector3 to transform
  67997. * @param transformation defines the transformation matrix
  67998. * @returns the transformed Vector3
  67999. */
  68000. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68001. /**
  68002. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  68003. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68004. * @param vector defines the Vector3 to transform
  68005. * @param transformation defines the transformation matrix
  68006. * @param result defines the Vector3 where to store the result
  68007. */
  68008. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68009. /**
  68010. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  68011. * This method computes tranformed coordinates only, not transformed direction vectors
  68012. * @param x define the x coordinate of the source vector
  68013. * @param y define the y coordinate of the source vector
  68014. * @param z define the z coordinate of the source vector
  68015. * @param transformation defines the transformation matrix
  68016. * @param result defines the Vector3 where to store the result
  68017. */
  68018. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68019. /**
  68020. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  68021. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68022. * @param vector defines the Vector3 to transform
  68023. * @param transformation defines the transformation matrix
  68024. * @returns the new Vector3
  68025. */
  68026. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68027. /**
  68028. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  68029. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68030. * @param vector defines the Vector3 to transform
  68031. * @param transformation defines the transformation matrix
  68032. * @param result defines the Vector3 where to store the result
  68033. */
  68034. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68035. /**
  68036. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  68037. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68038. * @param x define the x coordinate of the source vector
  68039. * @param y define the y coordinate of the source vector
  68040. * @param z define the z coordinate of the source vector
  68041. * @param transformation defines the transformation matrix
  68042. * @param result defines the Vector3 where to store the result
  68043. */
  68044. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68045. /**
  68046. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  68047. * @param value1 defines the first control point
  68048. * @param value2 defines the second control point
  68049. * @param value3 defines the third control point
  68050. * @param value4 defines the fourth control point
  68051. * @param amount defines the amount on the spline to use
  68052. * @returns the new Vector3
  68053. */
  68054. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  68055. /**
  68056. * 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"
  68057. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68058. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68059. * @param value defines the current value
  68060. * @param min defines the lower range value
  68061. * @param max defines the upper range value
  68062. * @returns the new Vector3
  68063. */
  68064. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  68065. /**
  68066. * 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"
  68067. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68068. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68069. * @param value defines the current value
  68070. * @param min defines the lower range value
  68071. * @param max defines the upper range value
  68072. * @param result defines the Vector3 where to store the result
  68073. */
  68074. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  68075. /**
  68076. * Checks if a given vector is inside a specific range
  68077. * @param v defines the vector to test
  68078. * @param min defines the minimum range
  68079. * @param max defines the maximum range
  68080. */
  68081. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  68082. /**
  68083. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  68084. * @param value1 defines the first control point
  68085. * @param tangent1 defines the first tangent vector
  68086. * @param value2 defines the second control point
  68087. * @param tangent2 defines the second tangent vector
  68088. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  68089. * @returns the new Vector3
  68090. */
  68091. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  68092. /**
  68093. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  68094. * @param start defines the start value
  68095. * @param end defines the end value
  68096. * @param amount max defines amount between both (between 0 and 1)
  68097. * @returns the new Vector3
  68098. */
  68099. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  68100. /**
  68101. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  68102. * @param start defines the start value
  68103. * @param end defines the end value
  68104. * @param amount max defines amount between both (between 0 and 1)
  68105. * @param result defines the Vector3 where to store the result
  68106. */
  68107. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  68108. /**
  68109. * Returns the dot product (float) between the vectors "left" and "right"
  68110. * @param left defines the left operand
  68111. * @param right defines the right operand
  68112. * @returns the dot product
  68113. */
  68114. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  68115. /**
  68116. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  68117. * The cross product is then orthogonal to both "left" and "right"
  68118. * @param left defines the left operand
  68119. * @param right defines the right operand
  68120. * @returns the cross product
  68121. */
  68122. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68123. /**
  68124. * Sets the given vector "result" with the cross product of "left" and "right"
  68125. * The cross product is then orthogonal to both "left" and "right"
  68126. * @param left defines the left operand
  68127. * @param right defines the right operand
  68128. * @param result defines the Vector3 where to store the result
  68129. */
  68130. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  68131. /**
  68132. * Returns a new Vector3 as the normalization of the given vector
  68133. * @param vector defines the Vector3 to normalize
  68134. * @returns the new Vector3
  68135. */
  68136. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  68137. /**
  68138. * Sets the given vector "result" with the normalization of the given first vector
  68139. * @param vector defines the Vector3 to normalize
  68140. * @param result defines the Vector3 where to store the result
  68141. */
  68142. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  68143. /**
  68144. * Project a Vector3 onto screen space
  68145. * @param vector defines the Vector3 to project
  68146. * @param world defines the world matrix to use
  68147. * @param transform defines the transform (view x projection) matrix to use
  68148. * @param viewport defines the screen viewport to use
  68149. * @returns the new Vector3
  68150. */
  68151. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  68152. /** @hidden */
  68153. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  68154. /**
  68155. * Unproject from screen space to object space
  68156. * @param source defines the screen space Vector3 to use
  68157. * @param viewportWidth defines the current width of the viewport
  68158. * @param viewportHeight defines the current height of the viewport
  68159. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68160. * @param transform defines the transform (view x projection) matrix to use
  68161. * @returns the new Vector3
  68162. */
  68163. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  68164. /**
  68165. * Unproject from screen space to object space
  68166. * @param source defines the screen space Vector3 to use
  68167. * @param viewportWidth defines the current width of the viewport
  68168. * @param viewportHeight defines the current height of the viewport
  68169. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68170. * @param view defines the view matrix to use
  68171. * @param projection defines the projection matrix to use
  68172. * @returns the new Vector3
  68173. */
  68174. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  68175. /**
  68176. * Unproject from screen space to object space
  68177. * @param source defines the screen space Vector3 to use
  68178. * @param viewportWidth defines the current width of the viewport
  68179. * @param viewportHeight defines the current height of the viewport
  68180. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68181. * @param view defines the view matrix to use
  68182. * @param projection defines the projection matrix to use
  68183. * @param result defines the Vector3 where to store the result
  68184. */
  68185. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68186. /**
  68187. * Unproject from screen space to object space
  68188. * @param sourceX defines the screen space x coordinate to use
  68189. * @param sourceY defines the screen space y coordinate to use
  68190. * @param sourceZ defines the screen space z coordinate to use
  68191. * @param viewportWidth defines the current width of the viewport
  68192. * @param viewportHeight defines the current height of the viewport
  68193. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68194. * @param view defines the view matrix to use
  68195. * @param projection defines the projection matrix to use
  68196. * @param result defines the Vector3 where to store the result
  68197. */
  68198. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68199. /**
  68200. * Gets the minimal coordinate values between two Vector3
  68201. * @param left defines the first operand
  68202. * @param right defines the second operand
  68203. * @returns the new Vector3
  68204. */
  68205. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68206. /**
  68207. * Gets the maximal coordinate values between two Vector3
  68208. * @param left defines the first operand
  68209. * @param right defines the second operand
  68210. * @returns the new Vector3
  68211. */
  68212. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68213. /**
  68214. * Returns the distance between the vectors "value1" and "value2"
  68215. * @param value1 defines the first operand
  68216. * @param value2 defines the second operand
  68217. * @returns the distance
  68218. */
  68219. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68220. /**
  68221. * Returns the squared distance between the vectors "value1" and "value2"
  68222. * @param value1 defines the first operand
  68223. * @param value2 defines the second operand
  68224. * @returns the squared distance
  68225. */
  68226. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68227. /**
  68228. * Returns a new Vector3 located at the center between "value1" and "value2"
  68229. * @param value1 defines the first operand
  68230. * @param value2 defines the second operand
  68231. * @returns the new Vector3
  68232. */
  68233. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  68234. /**
  68235. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  68236. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  68237. * to something in order to rotate it from its local system to the given target system
  68238. * Note: axis1, axis2 and axis3 are normalized during this operation
  68239. * @param axis1 defines the first axis
  68240. * @param axis2 defines the second axis
  68241. * @param axis3 defines the third axis
  68242. * @returns a new Vector3
  68243. */
  68244. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  68245. /**
  68246. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  68247. * @param axis1 defines the first axis
  68248. * @param axis2 defines the second axis
  68249. * @param axis3 defines the third axis
  68250. * @param ref defines the Vector3 where to store the result
  68251. */
  68252. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  68253. }
  68254. /**
  68255. * Vector4 class created for EulerAngle class conversion to Quaternion
  68256. */
  68257. export class Vector4 {
  68258. /** x value of the vector */
  68259. x: number;
  68260. /** y value of the vector */
  68261. y: number;
  68262. /** z value of the vector */
  68263. z: number;
  68264. /** w value of the vector */
  68265. w: number;
  68266. /**
  68267. * Creates a Vector4 object from the given floats.
  68268. * @param x x value of the vector
  68269. * @param y y value of the vector
  68270. * @param z z value of the vector
  68271. * @param w w value of the vector
  68272. */
  68273. constructor(
  68274. /** x value of the vector */
  68275. x: number,
  68276. /** y value of the vector */
  68277. y: number,
  68278. /** z value of the vector */
  68279. z: number,
  68280. /** w value of the vector */
  68281. w: number);
  68282. /**
  68283. * Returns the string with the Vector4 coordinates.
  68284. * @returns a string containing all the vector values
  68285. */
  68286. toString(): string;
  68287. /**
  68288. * Returns the string "Vector4".
  68289. * @returns "Vector4"
  68290. */
  68291. getClassName(): string;
  68292. /**
  68293. * Returns the Vector4 hash code.
  68294. * @returns a unique hash code
  68295. */
  68296. getHashCode(): number;
  68297. /**
  68298. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  68299. * @returns the resulting array
  68300. */
  68301. asArray(): number[];
  68302. /**
  68303. * Populates the given array from the given index with the Vector4 coordinates.
  68304. * @param array array to populate
  68305. * @param index index of the array to start at (default: 0)
  68306. * @returns the Vector4.
  68307. */
  68308. toArray(array: FloatArray, index?: number): Vector4;
  68309. /**
  68310. * Adds the given vector to the current Vector4.
  68311. * @param otherVector the vector to add
  68312. * @returns the updated Vector4.
  68313. */
  68314. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68315. /**
  68316. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  68317. * @param otherVector the vector to add
  68318. * @returns the resulting vector
  68319. */
  68320. add(otherVector: DeepImmutable<Vector4>): Vector4;
  68321. /**
  68322. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  68323. * @param otherVector the vector to add
  68324. * @param result the vector to store the result
  68325. * @returns the current Vector4.
  68326. */
  68327. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68328. /**
  68329. * Subtract in place the given vector from the current Vector4.
  68330. * @param otherVector the vector to subtract
  68331. * @returns the updated Vector4.
  68332. */
  68333. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68334. /**
  68335. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  68336. * @param otherVector the vector to add
  68337. * @returns the new vector with the result
  68338. */
  68339. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  68340. /**
  68341. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  68342. * @param otherVector the vector to subtract
  68343. * @param result the vector to store the result
  68344. * @returns the current Vector4.
  68345. */
  68346. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68347. /**
  68348. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68349. */
  68350. /**
  68351. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68352. * @param x value to subtract
  68353. * @param y value to subtract
  68354. * @param z value to subtract
  68355. * @param w value to subtract
  68356. * @returns new vector containing the result
  68357. */
  68358. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68359. /**
  68360. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68361. * @param x value to subtract
  68362. * @param y value to subtract
  68363. * @param z value to subtract
  68364. * @param w value to subtract
  68365. * @param result the vector to store the result in
  68366. * @returns the current Vector4.
  68367. */
  68368. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  68369. /**
  68370. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  68371. * @returns a new vector with the negated values
  68372. */
  68373. negate(): Vector4;
  68374. /**
  68375. * Multiplies the current Vector4 coordinates by scale (float).
  68376. * @param scale the number to scale with
  68377. * @returns the updated Vector4.
  68378. */
  68379. scaleInPlace(scale: number): Vector4;
  68380. /**
  68381. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  68382. * @param scale the number to scale with
  68383. * @returns a new vector with the result
  68384. */
  68385. scale(scale: number): Vector4;
  68386. /**
  68387. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  68388. * @param scale the number to scale with
  68389. * @param result a vector to store the result in
  68390. * @returns the current Vector4.
  68391. */
  68392. scaleToRef(scale: number, result: Vector4): Vector4;
  68393. /**
  68394. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  68395. * @param scale defines the scale factor
  68396. * @param result defines the Vector4 object where to store the result
  68397. * @returns the unmodified current Vector4
  68398. */
  68399. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  68400. /**
  68401. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  68402. * @param otherVector the vector to compare against
  68403. * @returns true if they are equal
  68404. */
  68405. equals(otherVector: DeepImmutable<Vector4>): boolean;
  68406. /**
  68407. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  68408. * @param otherVector vector to compare against
  68409. * @param epsilon (Default: very small number)
  68410. * @returns true if they are equal
  68411. */
  68412. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  68413. /**
  68414. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  68415. * @param x x value to compare against
  68416. * @param y y value to compare against
  68417. * @param z z value to compare against
  68418. * @param w w value to compare against
  68419. * @returns true if equal
  68420. */
  68421. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  68422. /**
  68423. * Multiplies in place the current Vector4 by the given one.
  68424. * @param otherVector vector to multiple with
  68425. * @returns the updated Vector4.
  68426. */
  68427. multiplyInPlace(otherVector: Vector4): Vector4;
  68428. /**
  68429. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  68430. * @param otherVector vector to multiple with
  68431. * @returns resulting new vector
  68432. */
  68433. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  68434. /**
  68435. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  68436. * @param otherVector vector to multiple with
  68437. * @param result vector to store the result
  68438. * @returns the current Vector4.
  68439. */
  68440. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68441. /**
  68442. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  68443. * @param x x value multiply with
  68444. * @param y y value multiply with
  68445. * @param z z value multiply with
  68446. * @param w w value multiply with
  68447. * @returns resulting new vector
  68448. */
  68449. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  68450. /**
  68451. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  68452. * @param otherVector vector to devide with
  68453. * @returns resulting new vector
  68454. */
  68455. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  68456. /**
  68457. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  68458. * @param otherVector vector to devide with
  68459. * @param result vector to store the result
  68460. * @returns the current Vector4.
  68461. */
  68462. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68463. /**
  68464. * Divides the current Vector3 coordinates by the given ones.
  68465. * @param otherVector vector to devide with
  68466. * @returns the updated Vector3.
  68467. */
  68468. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68469. /**
  68470. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  68471. * @param other defines the second operand
  68472. * @returns the current updated Vector4
  68473. */
  68474. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68475. /**
  68476. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  68477. * @param other defines the second operand
  68478. * @returns the current updated Vector4
  68479. */
  68480. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68481. /**
  68482. * Gets a new Vector4 from current Vector4 floored values
  68483. * @returns a new Vector4
  68484. */
  68485. floor(): Vector4;
  68486. /**
  68487. * Gets a new Vector4 from current Vector3 floored values
  68488. * @returns a new Vector4
  68489. */
  68490. fract(): Vector4;
  68491. /**
  68492. * Returns the Vector4 length (float).
  68493. * @returns the length
  68494. */
  68495. length(): number;
  68496. /**
  68497. * Returns the Vector4 squared length (float).
  68498. * @returns the length squared
  68499. */
  68500. lengthSquared(): number;
  68501. /**
  68502. * Normalizes in place the Vector4.
  68503. * @returns the updated Vector4.
  68504. */
  68505. normalize(): Vector4;
  68506. /**
  68507. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  68508. * @returns this converted to a new vector3
  68509. */
  68510. toVector3(): Vector3;
  68511. /**
  68512. * Returns a new Vector4 copied from the current one.
  68513. * @returns the new cloned vector
  68514. */
  68515. clone(): Vector4;
  68516. /**
  68517. * Updates the current Vector4 with the given one coordinates.
  68518. * @param source the source vector to copy from
  68519. * @returns the updated Vector4.
  68520. */
  68521. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  68522. /**
  68523. * Updates the current Vector4 coordinates with the given floats.
  68524. * @param x float to copy from
  68525. * @param y float to copy from
  68526. * @param z float to copy from
  68527. * @param w float to copy from
  68528. * @returns the updated Vector4.
  68529. */
  68530. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68531. /**
  68532. * Updates the current Vector4 coordinates with the given floats.
  68533. * @param x float to set from
  68534. * @param y float to set from
  68535. * @param z float to set from
  68536. * @param w float to set from
  68537. * @returns the updated Vector4.
  68538. */
  68539. set(x: number, y: number, z: number, w: number): Vector4;
  68540. /**
  68541. * Copies the given float to the current Vector3 coordinates
  68542. * @param v defines the x, y, z and w coordinates of the operand
  68543. * @returns the current updated Vector3
  68544. */
  68545. setAll(v: number): Vector4;
  68546. /**
  68547. * Returns a new Vector4 set from the starting index of the given array.
  68548. * @param array the array to pull values from
  68549. * @param offset the offset into the array to start at
  68550. * @returns the new vector
  68551. */
  68552. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  68553. /**
  68554. * Updates the given vector "result" from the starting index of the given array.
  68555. * @param array the array to pull values from
  68556. * @param offset the offset into the array to start at
  68557. * @param result the vector to store the result in
  68558. */
  68559. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  68560. /**
  68561. * Updates the given vector "result" from the starting index of the given Float32Array.
  68562. * @param array the array to pull values from
  68563. * @param offset the offset into the array to start at
  68564. * @param result the vector to store the result in
  68565. */
  68566. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  68567. /**
  68568. * Updates the given vector "result" coordinates from the given floats.
  68569. * @param x float to set from
  68570. * @param y float to set from
  68571. * @param z float to set from
  68572. * @param w float to set from
  68573. * @param result the vector to the floats in
  68574. */
  68575. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  68576. /**
  68577. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  68578. * @returns the new vector
  68579. */
  68580. static Zero(): Vector4;
  68581. /**
  68582. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  68583. * @returns the new vector
  68584. */
  68585. static One(): Vector4;
  68586. /**
  68587. * Returns a new normalized Vector4 from the given one.
  68588. * @param vector the vector to normalize
  68589. * @returns the vector
  68590. */
  68591. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  68592. /**
  68593. * Updates the given vector "result" from the normalization of the given one.
  68594. * @param vector the vector to normalize
  68595. * @param result the vector to store the result in
  68596. */
  68597. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  68598. /**
  68599. * Returns a vector with the minimum values from the left and right vectors
  68600. * @param left left vector to minimize
  68601. * @param right right vector to minimize
  68602. * @returns a new vector with the minimum of the left and right vector values
  68603. */
  68604. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68605. /**
  68606. * Returns a vector with the maximum values from the left and right vectors
  68607. * @param left left vector to maximize
  68608. * @param right right vector to maximize
  68609. * @returns a new vector with the maximum of the left and right vector values
  68610. */
  68611. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68612. /**
  68613. * Returns the distance (float) between the vectors "value1" and "value2".
  68614. * @param value1 value to calulate the distance between
  68615. * @param value2 value to calulate the distance between
  68616. * @return the distance between the two vectors
  68617. */
  68618. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68619. /**
  68620. * Returns the squared distance (float) between the vectors "value1" and "value2".
  68621. * @param value1 value to calulate the distance between
  68622. * @param value2 value to calulate the distance between
  68623. * @return the distance between the two vectors squared
  68624. */
  68625. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68626. /**
  68627. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  68628. * @param value1 value to calulate the center between
  68629. * @param value2 value to calulate the center between
  68630. * @return the center between the two vectors
  68631. */
  68632. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  68633. /**
  68634. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  68635. * This methods computes transformed normalized direction vectors only.
  68636. * @param vector the vector to transform
  68637. * @param transformation the transformation matrix to apply
  68638. * @returns the new vector
  68639. */
  68640. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  68641. /**
  68642. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  68643. * This methods computes transformed normalized direction vectors only.
  68644. * @param vector the vector to transform
  68645. * @param transformation the transformation matrix to apply
  68646. * @param result the vector to store the result in
  68647. */
  68648. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68649. /**
  68650. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  68651. * This methods computes transformed normalized direction vectors only.
  68652. * @param x value to transform
  68653. * @param y value to transform
  68654. * @param z value to transform
  68655. * @param w value to transform
  68656. * @param transformation the transformation matrix to apply
  68657. * @param result the vector to store the results in
  68658. */
  68659. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68660. /**
  68661. * Creates a new Vector4 from a Vector3
  68662. * @param source defines the source data
  68663. * @param w defines the 4th component (default is 0)
  68664. * @returns a new Vector4
  68665. */
  68666. static FromVector3(source: Vector3, w?: number): Vector4;
  68667. }
  68668. /**
  68669. * Class used to store quaternion data
  68670. * @see https://en.wikipedia.org/wiki/Quaternion
  68671. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  68672. */
  68673. export class Quaternion {
  68674. /** defines the first component (0 by default) */
  68675. x: number;
  68676. /** defines the second component (0 by default) */
  68677. y: number;
  68678. /** defines the third component (0 by default) */
  68679. z: number;
  68680. /** defines the fourth component (1.0 by default) */
  68681. w: number;
  68682. /**
  68683. * Creates a new Quaternion from the given floats
  68684. * @param x defines the first component (0 by default)
  68685. * @param y defines the second component (0 by default)
  68686. * @param z defines the third component (0 by default)
  68687. * @param w defines the fourth component (1.0 by default)
  68688. */
  68689. constructor(
  68690. /** defines the first component (0 by default) */
  68691. x?: number,
  68692. /** defines the second component (0 by default) */
  68693. y?: number,
  68694. /** defines the third component (0 by default) */
  68695. z?: number,
  68696. /** defines the fourth component (1.0 by default) */
  68697. w?: number);
  68698. /**
  68699. * Gets a string representation for the current quaternion
  68700. * @returns a string with the Quaternion coordinates
  68701. */
  68702. toString(): string;
  68703. /**
  68704. * Gets the class name of the quaternion
  68705. * @returns the string "Quaternion"
  68706. */
  68707. getClassName(): string;
  68708. /**
  68709. * Gets a hash code for this quaternion
  68710. * @returns the quaternion hash code
  68711. */
  68712. getHashCode(): number;
  68713. /**
  68714. * Copy the quaternion to an array
  68715. * @returns a new array populated with 4 elements from the quaternion coordinates
  68716. */
  68717. asArray(): number[];
  68718. /**
  68719. * Check if two quaternions are equals
  68720. * @param otherQuaternion defines the second operand
  68721. * @return true if the current quaternion and the given one coordinates are strictly equals
  68722. */
  68723. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  68724. /**
  68725. * Clone the current quaternion
  68726. * @returns a new quaternion copied from the current one
  68727. */
  68728. clone(): Quaternion;
  68729. /**
  68730. * Copy a quaternion to the current one
  68731. * @param other defines the other quaternion
  68732. * @returns the updated current quaternion
  68733. */
  68734. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  68735. /**
  68736. * Updates the current quaternion with the given float coordinates
  68737. * @param x defines the x coordinate
  68738. * @param y defines the y coordinate
  68739. * @param z defines the z coordinate
  68740. * @param w defines the w coordinate
  68741. * @returns the updated current quaternion
  68742. */
  68743. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  68744. /**
  68745. * Updates the current quaternion from the given float coordinates
  68746. * @param x defines the x coordinate
  68747. * @param y defines the y coordinate
  68748. * @param z defines the z coordinate
  68749. * @param w defines the w coordinate
  68750. * @returns the updated current quaternion
  68751. */
  68752. set(x: number, y: number, z: number, w: number): Quaternion;
  68753. /**
  68754. * Adds two quaternions
  68755. * @param other defines the second operand
  68756. * @returns a new quaternion as the addition result of the given one and the current quaternion
  68757. */
  68758. add(other: DeepImmutable<Quaternion>): Quaternion;
  68759. /**
  68760. * Add a quaternion to the current one
  68761. * @param other defines the quaternion to add
  68762. * @returns the current quaternion
  68763. */
  68764. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  68765. /**
  68766. * Subtract two quaternions
  68767. * @param other defines the second operand
  68768. * @returns a new quaternion as the subtraction result of the given one from the current one
  68769. */
  68770. subtract(other: Quaternion): Quaternion;
  68771. /**
  68772. * Multiplies the current quaternion by a scale factor
  68773. * @param value defines the scale factor
  68774. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  68775. */
  68776. scale(value: number): Quaternion;
  68777. /**
  68778. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  68779. * @param scale defines the scale factor
  68780. * @param result defines the Quaternion object where to store the result
  68781. * @returns the unmodified current quaternion
  68782. */
  68783. scaleToRef(scale: number, result: Quaternion): Quaternion;
  68784. /**
  68785. * Multiplies in place the current quaternion by a scale factor
  68786. * @param value defines the scale factor
  68787. * @returns the current modified quaternion
  68788. */
  68789. scaleInPlace(value: number): Quaternion;
  68790. /**
  68791. * Scale the current quaternion values by a factor and add the result to a given quaternion
  68792. * @param scale defines the scale factor
  68793. * @param result defines the Quaternion object where to store the result
  68794. * @returns the unmodified current quaternion
  68795. */
  68796. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  68797. /**
  68798. * Multiplies two quaternions
  68799. * @param q1 defines the second operand
  68800. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  68801. */
  68802. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  68803. /**
  68804. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  68805. * @param q1 defines the second operand
  68806. * @param result defines the target quaternion
  68807. * @returns the current quaternion
  68808. */
  68809. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  68810. /**
  68811. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  68812. * @param q1 defines the second operand
  68813. * @returns the currentupdated quaternion
  68814. */
  68815. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  68816. /**
  68817. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  68818. * @param ref defines the target quaternion
  68819. * @returns the current quaternion
  68820. */
  68821. conjugateToRef(ref: Quaternion): Quaternion;
  68822. /**
  68823. * Conjugates in place (1-q) the current quaternion
  68824. * @returns the current updated quaternion
  68825. */
  68826. conjugateInPlace(): Quaternion;
  68827. /**
  68828. * Conjugates in place (1-q) the current quaternion
  68829. * @returns a new quaternion
  68830. */
  68831. conjugate(): Quaternion;
  68832. /**
  68833. * Gets length of current quaternion
  68834. * @returns the quaternion length (float)
  68835. */
  68836. length(): number;
  68837. /**
  68838. * Normalize in place the current quaternion
  68839. * @returns the current updated quaternion
  68840. */
  68841. normalize(): Quaternion;
  68842. /**
  68843. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  68844. * @param order is a reserved parameter and is ignore for now
  68845. * @returns a new Vector3 containing the Euler angles
  68846. */
  68847. toEulerAngles(order?: string): Vector3;
  68848. /**
  68849. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  68850. * @param result defines the vector which will be filled with the Euler angles
  68851. * @param order is a reserved parameter and is ignore for now
  68852. * @returns the current unchanged quaternion
  68853. */
  68854. toEulerAnglesToRef(result: Vector3): Quaternion;
  68855. /**
  68856. * Updates the given rotation matrix with the current quaternion values
  68857. * @param result defines the target matrix
  68858. * @returns the current unchanged quaternion
  68859. */
  68860. toRotationMatrix(result: Matrix): Quaternion;
  68861. /**
  68862. * Updates the current quaternion from the given rotation matrix values
  68863. * @param matrix defines the source matrix
  68864. * @returns the current updated quaternion
  68865. */
  68866. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68867. /**
  68868. * Creates a new quaternion from a rotation matrix
  68869. * @param matrix defines the source matrix
  68870. * @returns a new quaternion created from the given rotation matrix values
  68871. */
  68872. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68873. /**
  68874. * Updates the given quaternion with the given rotation matrix values
  68875. * @param matrix defines the source matrix
  68876. * @param result defines the target quaternion
  68877. */
  68878. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  68879. /**
  68880. * Returns the dot product (float) between the quaternions "left" and "right"
  68881. * @param left defines the left operand
  68882. * @param right defines the right operand
  68883. * @returns the dot product
  68884. */
  68885. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  68886. /**
  68887. * Checks if the two quaternions are close to each other
  68888. * @param quat0 defines the first quaternion to check
  68889. * @param quat1 defines the second quaternion to check
  68890. * @returns true if the two quaternions are close to each other
  68891. */
  68892. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  68893. /**
  68894. * Creates an empty quaternion
  68895. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  68896. */
  68897. static Zero(): Quaternion;
  68898. /**
  68899. * Inverse a given quaternion
  68900. * @param q defines the source quaternion
  68901. * @returns a new quaternion as the inverted current quaternion
  68902. */
  68903. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  68904. /**
  68905. * Inverse a given quaternion
  68906. * @param q defines the source quaternion
  68907. * @param result the quaternion the result will be stored in
  68908. * @returns the result quaternion
  68909. */
  68910. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  68911. /**
  68912. * Creates an identity quaternion
  68913. * @returns the identity quaternion
  68914. */
  68915. static Identity(): Quaternion;
  68916. /**
  68917. * Gets a boolean indicating if the given quaternion is identity
  68918. * @param quaternion defines the quaternion to check
  68919. * @returns true if the quaternion is identity
  68920. */
  68921. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  68922. /**
  68923. * Creates a quaternion from a rotation around an axis
  68924. * @param axis defines the axis to use
  68925. * @param angle defines the angle to use
  68926. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  68927. */
  68928. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  68929. /**
  68930. * Creates a rotation around an axis and stores it into the given quaternion
  68931. * @param axis defines the axis to use
  68932. * @param angle defines the angle to use
  68933. * @param result defines the target quaternion
  68934. * @returns the target quaternion
  68935. */
  68936. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  68937. /**
  68938. * Creates a new quaternion from data stored into an array
  68939. * @param array defines the data source
  68940. * @param offset defines the offset in the source array where the data starts
  68941. * @returns a new quaternion
  68942. */
  68943. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  68944. /**
  68945. * Create a quaternion from Euler rotation angles
  68946. * @param x Pitch
  68947. * @param y Yaw
  68948. * @param z Roll
  68949. * @returns the new Quaternion
  68950. */
  68951. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  68952. /**
  68953. * Updates a quaternion from Euler rotation angles
  68954. * @param x Pitch
  68955. * @param y Yaw
  68956. * @param z Roll
  68957. * @param result the quaternion to store the result
  68958. * @returns the updated quaternion
  68959. */
  68960. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  68961. /**
  68962. * Create a quaternion from Euler rotation vector
  68963. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  68964. * @returns the new Quaternion
  68965. */
  68966. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  68967. /**
  68968. * Updates a quaternion from Euler rotation vector
  68969. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  68970. * @param result the quaternion to store the result
  68971. * @returns the updated quaternion
  68972. */
  68973. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  68974. /**
  68975. * Creates a new quaternion from the given Euler float angles (y, x, z)
  68976. * @param yaw defines the rotation around Y axis
  68977. * @param pitch defines the rotation around X axis
  68978. * @param roll defines the rotation around Z axis
  68979. * @returns the new quaternion
  68980. */
  68981. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  68982. /**
  68983. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  68984. * @param yaw defines the rotation around Y axis
  68985. * @param pitch defines the rotation around X axis
  68986. * @param roll defines the rotation around Z axis
  68987. * @param result defines the target quaternion
  68988. */
  68989. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  68990. /**
  68991. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  68992. * @param alpha defines the rotation around first axis
  68993. * @param beta defines the rotation around second axis
  68994. * @param gamma defines the rotation around third axis
  68995. * @returns the new quaternion
  68996. */
  68997. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  68998. /**
  68999. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  69000. * @param alpha defines the rotation around first axis
  69001. * @param beta defines the rotation around second axis
  69002. * @param gamma defines the rotation around third axis
  69003. * @param result defines the target quaternion
  69004. */
  69005. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  69006. /**
  69007. * 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)
  69008. * @param axis1 defines the first axis
  69009. * @param axis2 defines the second axis
  69010. * @param axis3 defines the third axis
  69011. * @returns the new quaternion
  69012. */
  69013. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  69014. /**
  69015. * 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
  69016. * @param axis1 defines the first axis
  69017. * @param axis2 defines the second axis
  69018. * @param axis3 defines the third axis
  69019. * @param ref defines the target quaternion
  69020. */
  69021. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  69022. /**
  69023. * Interpolates between two quaternions
  69024. * @param left defines first quaternion
  69025. * @param right defines second quaternion
  69026. * @param amount defines the gradient to use
  69027. * @returns the new interpolated quaternion
  69028. */
  69029. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69030. /**
  69031. * Interpolates between two quaternions and stores it into a target quaternion
  69032. * @param left defines first quaternion
  69033. * @param right defines second quaternion
  69034. * @param amount defines the gradient to use
  69035. * @param result defines the target quaternion
  69036. */
  69037. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  69038. /**
  69039. * Interpolate between two quaternions using Hermite interpolation
  69040. * @param value1 defines first quaternion
  69041. * @param tangent1 defines the incoming tangent
  69042. * @param value2 defines second quaternion
  69043. * @param tangent2 defines the outgoing tangent
  69044. * @param amount defines the target quaternion
  69045. * @returns the new interpolated quaternion
  69046. */
  69047. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69048. }
  69049. /**
  69050. * Class used to store matrix data (4x4)
  69051. */
  69052. export class Matrix {
  69053. private static _updateFlagSeed;
  69054. private static _identityReadOnly;
  69055. private _isIdentity;
  69056. private _isIdentityDirty;
  69057. private _isIdentity3x2;
  69058. private _isIdentity3x2Dirty;
  69059. /**
  69060. * Gets the update flag of the matrix which is an unique number for the matrix.
  69061. * It will be incremented every time the matrix data change.
  69062. * You can use it to speed the comparison between two versions of the same matrix.
  69063. */
  69064. updateFlag: number;
  69065. private readonly _m;
  69066. /**
  69067. * Gets the internal data of the matrix
  69068. */
  69069. readonly m: DeepImmutable<Float32Array>;
  69070. /** @hidden */
  69071. _markAsUpdated(): void;
  69072. /** @hidden */
  69073. private _updateIdentityStatus;
  69074. /**
  69075. * Creates an empty matrix (filled with zeros)
  69076. */
  69077. constructor();
  69078. /**
  69079. * Check if the current matrix is identity
  69080. * @returns true is the matrix is the identity matrix
  69081. */
  69082. isIdentity(): boolean;
  69083. /**
  69084. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  69085. * @returns true is the matrix is the identity matrix
  69086. */
  69087. isIdentityAs3x2(): boolean;
  69088. /**
  69089. * Gets the determinant of the matrix
  69090. * @returns the matrix determinant
  69091. */
  69092. determinant(): number;
  69093. /**
  69094. * Returns the matrix as a Float32Array
  69095. * @returns the matrix underlying array
  69096. */
  69097. toArray(): DeepImmutable<Float32Array>;
  69098. /**
  69099. * Returns the matrix as a Float32Array
  69100. * @returns the matrix underlying array.
  69101. */
  69102. asArray(): DeepImmutable<Float32Array>;
  69103. /**
  69104. * Inverts the current matrix in place
  69105. * @returns the current inverted matrix
  69106. */
  69107. invert(): Matrix;
  69108. /**
  69109. * Sets all the matrix elements to zero
  69110. * @returns the current matrix
  69111. */
  69112. reset(): Matrix;
  69113. /**
  69114. * Adds the current matrix with a second one
  69115. * @param other defines the matrix to add
  69116. * @returns a new matrix as the addition of the current matrix and the given one
  69117. */
  69118. add(other: DeepImmutable<Matrix>): Matrix;
  69119. /**
  69120. * Sets the given matrix "result" to the addition of the current matrix and the given one
  69121. * @param other defines the matrix to add
  69122. * @param result defines the target matrix
  69123. * @returns the current matrix
  69124. */
  69125. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69126. /**
  69127. * Adds in place the given matrix to the current matrix
  69128. * @param other defines the second operand
  69129. * @returns the current updated matrix
  69130. */
  69131. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  69132. /**
  69133. * Sets the given matrix to the current inverted Matrix
  69134. * @param other defines the target matrix
  69135. * @returns the unmodified current matrix
  69136. */
  69137. invertToRef(other: Matrix): Matrix;
  69138. /**
  69139. * add a value at the specified position in the current Matrix
  69140. * @param index the index of the value within the matrix. between 0 and 15.
  69141. * @param value the value to be added
  69142. * @returns the current updated matrix
  69143. */
  69144. addAtIndex(index: number, value: number): Matrix;
  69145. /**
  69146. * mutiply the specified position in the current Matrix by a value
  69147. * @param index the index of the value within the matrix. between 0 and 15.
  69148. * @param value the value to be added
  69149. * @returns the current updated matrix
  69150. */
  69151. multiplyAtIndex(index: number, value: number): Matrix;
  69152. /**
  69153. * Inserts the translation vector (using 3 floats) in the current matrix
  69154. * @param x defines the 1st component of the translation
  69155. * @param y defines the 2nd component of the translation
  69156. * @param z defines the 3rd component of the translation
  69157. * @returns the current updated matrix
  69158. */
  69159. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69160. /**
  69161. * Adds the translation vector (using 3 floats) in the current matrix
  69162. * @param x defines the 1st component of the translation
  69163. * @param y defines the 2nd component of the translation
  69164. * @param z defines the 3rd component of the translation
  69165. * @returns the current updated matrix
  69166. */
  69167. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69168. /**
  69169. * Inserts the translation vector in the current matrix
  69170. * @param vector3 defines the translation to insert
  69171. * @returns the current updated matrix
  69172. */
  69173. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  69174. /**
  69175. * Gets the translation value of the current matrix
  69176. * @returns a new Vector3 as the extracted translation from the matrix
  69177. */
  69178. getTranslation(): Vector3;
  69179. /**
  69180. * Fill a Vector3 with the extracted translation from the matrix
  69181. * @param result defines the Vector3 where to store the translation
  69182. * @returns the current matrix
  69183. */
  69184. getTranslationToRef(result: Vector3): Matrix;
  69185. /**
  69186. * Remove rotation and scaling part from the matrix
  69187. * @returns the updated matrix
  69188. */
  69189. removeRotationAndScaling(): Matrix;
  69190. /**
  69191. * Multiply two matrices
  69192. * @param other defines the second operand
  69193. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  69194. */
  69195. multiply(other: DeepImmutable<Matrix>): Matrix;
  69196. /**
  69197. * Copy the current matrix from the given one
  69198. * @param other defines the source matrix
  69199. * @returns the current updated matrix
  69200. */
  69201. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  69202. /**
  69203. * Populates the given array from the starting index with the current matrix values
  69204. * @param array defines the target array
  69205. * @param offset defines the offset in the target array where to start storing values
  69206. * @returns the current matrix
  69207. */
  69208. copyToArray(array: Float32Array, offset?: number): Matrix;
  69209. /**
  69210. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  69211. * @param other defines the second operand
  69212. * @param result defines the matrix where to store the multiplication
  69213. * @returns the current matrix
  69214. */
  69215. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69216. /**
  69217. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  69218. * @param other defines the second operand
  69219. * @param result defines the array where to store the multiplication
  69220. * @param offset defines the offset in the target array where to start storing values
  69221. * @returns the current matrix
  69222. */
  69223. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  69224. /**
  69225. * Check equality between this matrix and a second one
  69226. * @param value defines the second matrix to compare
  69227. * @returns true is the current matrix and the given one values are strictly equal
  69228. */
  69229. equals(value: DeepImmutable<Matrix>): boolean;
  69230. /**
  69231. * Clone the current matrix
  69232. * @returns a new matrix from the current matrix
  69233. */
  69234. clone(): Matrix;
  69235. /**
  69236. * Returns the name of the current matrix class
  69237. * @returns the string "Matrix"
  69238. */
  69239. getClassName(): string;
  69240. /**
  69241. * Gets the hash code of the current matrix
  69242. * @returns the hash code
  69243. */
  69244. getHashCode(): number;
  69245. /**
  69246. * Decomposes the current Matrix into a translation, rotation and scaling components
  69247. * @param scale defines the scale vector3 given as a reference to update
  69248. * @param rotation defines the rotation quaternion given as a reference to update
  69249. * @param translation defines the translation vector3 given as a reference to update
  69250. * @returns true if operation was successful
  69251. */
  69252. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  69253. /**
  69254. * Gets specific row of the matrix
  69255. * @param index defines the number of the row to get
  69256. * @returns the index-th row of the current matrix as a new Vector4
  69257. */
  69258. getRow(index: number): Nullable<Vector4>;
  69259. /**
  69260. * Sets the index-th row of the current matrix to the vector4 values
  69261. * @param index defines the number of the row to set
  69262. * @param row defines the target vector4
  69263. * @returns the updated current matrix
  69264. */
  69265. setRow(index: number, row: Vector4): Matrix;
  69266. /**
  69267. * Compute the transpose of the matrix
  69268. * @returns the new transposed matrix
  69269. */
  69270. transpose(): Matrix;
  69271. /**
  69272. * Compute the transpose of the matrix and store it in a given matrix
  69273. * @param result defines the target matrix
  69274. * @returns the current matrix
  69275. */
  69276. transposeToRef(result: Matrix): Matrix;
  69277. /**
  69278. * Sets the index-th row of the current matrix with the given 4 x float values
  69279. * @param index defines the row index
  69280. * @param x defines the x component to set
  69281. * @param y defines the y component to set
  69282. * @param z defines the z component to set
  69283. * @param w defines the w component to set
  69284. * @returns the updated current matrix
  69285. */
  69286. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  69287. /**
  69288. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  69289. * @param scale defines the scale factor
  69290. * @returns a new matrix
  69291. */
  69292. scale(scale: number): Matrix;
  69293. /**
  69294. * Scale the current matrix values by a factor to a given result matrix
  69295. * @param scale defines the scale factor
  69296. * @param result defines the matrix to store the result
  69297. * @returns the current matrix
  69298. */
  69299. scaleToRef(scale: number, result: Matrix): Matrix;
  69300. /**
  69301. * Scale the current matrix values by a factor and add the result to a given matrix
  69302. * @param scale defines the scale factor
  69303. * @param result defines the Matrix to store the result
  69304. * @returns the current matrix
  69305. */
  69306. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  69307. /**
  69308. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  69309. * @param ref matrix to store the result
  69310. */
  69311. toNormalMatrix(ref: Matrix): void;
  69312. /**
  69313. * Gets only rotation part of the current matrix
  69314. * @returns a new matrix sets to the extracted rotation matrix from the current one
  69315. */
  69316. getRotationMatrix(): Matrix;
  69317. /**
  69318. * Extracts the rotation matrix from the current one and sets it as the given "result"
  69319. * @param result defines the target matrix to store data to
  69320. * @returns the current matrix
  69321. */
  69322. getRotationMatrixToRef(result: Matrix): Matrix;
  69323. /**
  69324. * Toggles model matrix from being right handed to left handed in place and vice versa
  69325. */
  69326. toggleModelMatrixHandInPlace(): void;
  69327. /**
  69328. * Toggles projection matrix from being right handed to left handed in place and vice versa
  69329. */
  69330. toggleProjectionMatrixHandInPlace(): void;
  69331. /**
  69332. * Creates a matrix from an array
  69333. * @param array defines the source array
  69334. * @param offset defines an offset in the source array
  69335. * @returns a new Matrix set from the starting index of the given array
  69336. */
  69337. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  69338. /**
  69339. * Copy the content of an array into a given matrix
  69340. * @param array defines the source array
  69341. * @param offset defines an offset in the source array
  69342. * @param result defines the target matrix
  69343. */
  69344. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  69345. /**
  69346. * Stores an array into a matrix after having multiplied each component by a given factor
  69347. * @param array defines the source array
  69348. * @param offset defines the offset in the source array
  69349. * @param scale defines the scaling factor
  69350. * @param result defines the target matrix
  69351. */
  69352. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  69353. /**
  69354. * Gets an identity matrix that must not be updated
  69355. */
  69356. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  69357. /**
  69358. * Stores a list of values (16) inside a given matrix
  69359. * @param initialM11 defines 1st value of 1st row
  69360. * @param initialM12 defines 2nd value of 1st row
  69361. * @param initialM13 defines 3rd value of 1st row
  69362. * @param initialM14 defines 4th value of 1st row
  69363. * @param initialM21 defines 1st value of 2nd row
  69364. * @param initialM22 defines 2nd value of 2nd row
  69365. * @param initialM23 defines 3rd value of 2nd row
  69366. * @param initialM24 defines 4th value of 2nd row
  69367. * @param initialM31 defines 1st value of 3rd row
  69368. * @param initialM32 defines 2nd value of 3rd row
  69369. * @param initialM33 defines 3rd value of 3rd row
  69370. * @param initialM34 defines 4th value of 3rd row
  69371. * @param initialM41 defines 1st value of 4th row
  69372. * @param initialM42 defines 2nd value of 4th row
  69373. * @param initialM43 defines 3rd value of 4th row
  69374. * @param initialM44 defines 4th value of 4th row
  69375. * @param result defines the target matrix
  69376. */
  69377. 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;
  69378. /**
  69379. * Creates new matrix from a list of values (16)
  69380. * @param initialM11 defines 1st value of 1st row
  69381. * @param initialM12 defines 2nd value of 1st row
  69382. * @param initialM13 defines 3rd value of 1st row
  69383. * @param initialM14 defines 4th value of 1st row
  69384. * @param initialM21 defines 1st value of 2nd row
  69385. * @param initialM22 defines 2nd value of 2nd row
  69386. * @param initialM23 defines 3rd value of 2nd row
  69387. * @param initialM24 defines 4th value of 2nd row
  69388. * @param initialM31 defines 1st value of 3rd row
  69389. * @param initialM32 defines 2nd value of 3rd row
  69390. * @param initialM33 defines 3rd value of 3rd row
  69391. * @param initialM34 defines 4th value of 3rd row
  69392. * @param initialM41 defines 1st value of 4th row
  69393. * @param initialM42 defines 2nd value of 4th row
  69394. * @param initialM43 defines 3rd value of 4th row
  69395. * @param initialM44 defines 4th value of 4th row
  69396. * @returns the new matrix
  69397. */
  69398. 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;
  69399. /**
  69400. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69401. * @param scale defines the scale vector3
  69402. * @param rotation defines the rotation quaternion
  69403. * @param translation defines the translation vector3
  69404. * @returns a new matrix
  69405. */
  69406. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  69407. /**
  69408. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69409. * @param scale defines the scale vector3
  69410. * @param rotation defines the rotation quaternion
  69411. * @param translation defines the translation vector3
  69412. * @param result defines the target matrix
  69413. */
  69414. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  69415. /**
  69416. * Creates a new identity matrix
  69417. * @returns a new identity matrix
  69418. */
  69419. static Identity(): Matrix;
  69420. /**
  69421. * Creates a new identity matrix and stores the result in a given matrix
  69422. * @param result defines the target matrix
  69423. */
  69424. static IdentityToRef(result: Matrix): void;
  69425. /**
  69426. * Creates a new zero matrix
  69427. * @returns a new zero matrix
  69428. */
  69429. static Zero(): Matrix;
  69430. /**
  69431. * Creates a new rotation matrix for "angle" radians around the X axis
  69432. * @param angle defines the angle (in radians) to use
  69433. * @return the new matrix
  69434. */
  69435. static RotationX(angle: number): Matrix;
  69436. /**
  69437. * Creates a new matrix as the invert of a given matrix
  69438. * @param source defines the source matrix
  69439. * @returns the new matrix
  69440. */
  69441. static Invert(source: DeepImmutable<Matrix>): Matrix;
  69442. /**
  69443. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  69444. * @param angle defines the angle (in radians) to use
  69445. * @param result defines the target matrix
  69446. */
  69447. static RotationXToRef(angle: number, result: Matrix): void;
  69448. /**
  69449. * Creates a new rotation matrix for "angle" radians around the Y axis
  69450. * @param angle defines the angle (in radians) to use
  69451. * @return the new matrix
  69452. */
  69453. static RotationY(angle: number): Matrix;
  69454. /**
  69455. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  69456. * @param angle defines the angle (in radians) to use
  69457. * @param result defines the target matrix
  69458. */
  69459. static RotationYToRef(angle: number, result: Matrix): void;
  69460. /**
  69461. * Creates a new rotation matrix for "angle" radians around the Z axis
  69462. * @param angle defines the angle (in radians) to use
  69463. * @return the new matrix
  69464. */
  69465. static RotationZ(angle: number): Matrix;
  69466. /**
  69467. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  69468. * @param angle defines the angle (in radians) to use
  69469. * @param result defines the target matrix
  69470. */
  69471. static RotationZToRef(angle: number, result: Matrix): void;
  69472. /**
  69473. * Creates a new rotation matrix for "angle" radians around the given axis
  69474. * @param axis defines the axis to use
  69475. * @param angle defines the angle (in radians) to use
  69476. * @return the new matrix
  69477. */
  69478. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  69479. /**
  69480. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  69481. * @param axis defines the axis to use
  69482. * @param angle defines the angle (in radians) to use
  69483. * @param result defines the target matrix
  69484. */
  69485. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  69486. /**
  69487. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  69488. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  69489. * @param from defines the vector to align
  69490. * @param to defines the vector to align to
  69491. * @param result defines the target matrix
  69492. */
  69493. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  69494. /**
  69495. * Creates a rotation matrix
  69496. * @param yaw defines the yaw angle in radians (Y axis)
  69497. * @param pitch defines the pitch angle in radians (X axis)
  69498. * @param roll defines the roll angle in radians (X axis)
  69499. * @returns the new rotation matrix
  69500. */
  69501. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  69502. /**
  69503. * Creates a rotation matrix and stores it in a given matrix
  69504. * @param yaw defines the yaw angle in radians (Y axis)
  69505. * @param pitch defines the pitch angle in radians (X axis)
  69506. * @param roll defines the roll angle in radians (X axis)
  69507. * @param result defines the target matrix
  69508. */
  69509. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  69510. /**
  69511. * Creates a scaling matrix
  69512. * @param x defines the scale factor on X axis
  69513. * @param y defines the scale factor on Y axis
  69514. * @param z defines the scale factor on Z axis
  69515. * @returns the new matrix
  69516. */
  69517. static Scaling(x: number, y: number, z: number): Matrix;
  69518. /**
  69519. * Creates a scaling matrix and stores it in a given matrix
  69520. * @param x defines the scale factor on X axis
  69521. * @param y defines the scale factor on Y axis
  69522. * @param z defines the scale factor on Z axis
  69523. * @param result defines the target matrix
  69524. */
  69525. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  69526. /**
  69527. * Creates a translation matrix
  69528. * @param x defines the translation on X axis
  69529. * @param y defines the translation on Y axis
  69530. * @param z defines the translationon Z axis
  69531. * @returns the new matrix
  69532. */
  69533. static Translation(x: number, y: number, z: number): Matrix;
  69534. /**
  69535. * Creates a translation matrix and stores it in a given matrix
  69536. * @param x defines the translation on X axis
  69537. * @param y defines the translation on Y axis
  69538. * @param z defines the translationon Z axis
  69539. * @param result defines the target matrix
  69540. */
  69541. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  69542. /**
  69543. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69544. * @param startValue defines the start value
  69545. * @param endValue defines the end value
  69546. * @param gradient defines the gradient factor
  69547. * @returns the new matrix
  69548. */
  69549. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69550. /**
  69551. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69552. * @param startValue defines the start value
  69553. * @param endValue defines the end value
  69554. * @param gradient defines the gradient factor
  69555. * @param result defines the Matrix object where to store data
  69556. */
  69557. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69558. /**
  69559. * Builds a new matrix whose values are computed by:
  69560. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69561. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69562. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69563. * @param startValue defines the first matrix
  69564. * @param endValue defines the second matrix
  69565. * @param gradient defines the gradient between the two matrices
  69566. * @returns the new matrix
  69567. */
  69568. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69569. /**
  69570. * Update a matrix to values which are computed by:
  69571. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69572. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69573. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69574. * @param startValue defines the first matrix
  69575. * @param endValue defines the second matrix
  69576. * @param gradient defines the gradient between the two matrices
  69577. * @param result defines the target matrix
  69578. */
  69579. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69580. /**
  69581. * 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"
  69582. * This function works in left handed mode
  69583. * @param eye defines the final position of the entity
  69584. * @param target defines where the entity should look at
  69585. * @param up defines the up vector for the entity
  69586. * @returns the new matrix
  69587. */
  69588. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69589. /**
  69590. * 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".
  69591. * This function works in left handed mode
  69592. * @param eye defines the final position of the entity
  69593. * @param target defines where the entity should look at
  69594. * @param up defines the up vector for the entity
  69595. * @param result defines the target matrix
  69596. */
  69597. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69598. /**
  69599. * 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"
  69600. * This function works in right handed mode
  69601. * @param eye defines the final position of the entity
  69602. * @param target defines where the entity should look at
  69603. * @param up defines the up vector for the entity
  69604. * @returns the new matrix
  69605. */
  69606. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69607. /**
  69608. * 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".
  69609. * This function works in right handed mode
  69610. * @param eye defines the final position of the entity
  69611. * @param target defines where the entity should look at
  69612. * @param up defines the up vector for the entity
  69613. * @param result defines the target matrix
  69614. */
  69615. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69616. /**
  69617. * Create a left-handed orthographic projection matrix
  69618. * @param width defines the viewport width
  69619. * @param height defines the viewport height
  69620. * @param znear defines the near clip plane
  69621. * @param zfar defines the far clip plane
  69622. * @returns a new matrix as a left-handed orthographic projection matrix
  69623. */
  69624. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69625. /**
  69626. * Store a left-handed orthographic projection to a given matrix
  69627. * @param width defines the viewport width
  69628. * @param height defines the viewport height
  69629. * @param znear defines the near clip plane
  69630. * @param zfar defines the far clip plane
  69631. * @param result defines the target matrix
  69632. */
  69633. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  69634. /**
  69635. * Create a left-handed orthographic projection matrix
  69636. * @param left defines the viewport left coordinate
  69637. * @param right defines the viewport right coordinate
  69638. * @param bottom defines the viewport bottom coordinate
  69639. * @param top defines the viewport top coordinate
  69640. * @param znear defines the near clip plane
  69641. * @param zfar defines the far clip plane
  69642. * @returns a new matrix as a left-handed orthographic projection matrix
  69643. */
  69644. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69645. /**
  69646. * Stores a left-handed orthographic projection into a given matrix
  69647. * @param left defines the viewport left coordinate
  69648. * @param right defines the viewport right coordinate
  69649. * @param bottom defines the viewport bottom coordinate
  69650. * @param top defines the viewport top coordinate
  69651. * @param znear defines the near clip plane
  69652. * @param zfar defines the far clip plane
  69653. * @param result defines the target matrix
  69654. */
  69655. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69656. /**
  69657. * Creates a right-handed orthographic projection matrix
  69658. * @param left defines the viewport left coordinate
  69659. * @param right defines the viewport right coordinate
  69660. * @param bottom defines the viewport bottom coordinate
  69661. * @param top defines the viewport top coordinate
  69662. * @param znear defines the near clip plane
  69663. * @param zfar defines the far clip plane
  69664. * @returns a new matrix as a right-handed orthographic projection matrix
  69665. */
  69666. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69667. /**
  69668. * Stores a right-handed orthographic projection into a given matrix
  69669. * @param left defines the viewport left coordinate
  69670. * @param right defines the viewport right coordinate
  69671. * @param bottom defines the viewport bottom coordinate
  69672. * @param top defines the viewport top coordinate
  69673. * @param znear defines the near clip plane
  69674. * @param zfar defines the far clip plane
  69675. * @param result defines the target matrix
  69676. */
  69677. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69678. /**
  69679. * Creates a left-handed perspective projection matrix
  69680. * @param width defines the viewport width
  69681. * @param height defines the viewport height
  69682. * @param znear defines the near clip plane
  69683. * @param zfar defines the far clip plane
  69684. * @returns a new matrix as a left-handed perspective projection matrix
  69685. */
  69686. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69687. /**
  69688. * Creates a left-handed perspective projection matrix
  69689. * @param fov defines the horizontal field of view
  69690. * @param aspect defines the aspect ratio
  69691. * @param znear defines the near clip plane
  69692. * @param zfar defines the far clip plane
  69693. * @returns a new matrix as a left-handed perspective projection matrix
  69694. */
  69695. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69696. /**
  69697. * Stores a left-handed perspective projection into a given matrix
  69698. * @param fov defines the horizontal field of view
  69699. * @param aspect defines the aspect ratio
  69700. * @param znear defines the near clip plane
  69701. * @param zfar defines the far clip plane
  69702. * @param result defines the target matrix
  69703. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69704. */
  69705. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69706. /**
  69707. * Creates a right-handed perspective projection matrix
  69708. * @param fov defines the horizontal field of view
  69709. * @param aspect defines the aspect ratio
  69710. * @param znear defines the near clip plane
  69711. * @param zfar defines the far clip plane
  69712. * @returns a new matrix as a right-handed perspective projection matrix
  69713. */
  69714. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69715. /**
  69716. * Stores a right-handed perspective projection into a given matrix
  69717. * @param fov defines the horizontal field of view
  69718. * @param aspect defines the aspect ratio
  69719. * @param znear defines the near clip plane
  69720. * @param zfar defines the far clip plane
  69721. * @param result defines the target matrix
  69722. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69723. */
  69724. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69725. /**
  69726. * Stores a perspective projection for WebVR info a given matrix
  69727. * @param fov defines the field of view
  69728. * @param znear defines the near clip plane
  69729. * @param zfar defines the far clip plane
  69730. * @param result defines the target matrix
  69731. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  69732. */
  69733. static PerspectiveFovWebVRToRef(fov: {
  69734. upDegrees: number;
  69735. downDegrees: number;
  69736. leftDegrees: number;
  69737. rightDegrees: number;
  69738. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  69739. /**
  69740. * Computes a complete transformation matrix
  69741. * @param viewport defines the viewport to use
  69742. * @param world defines the world matrix
  69743. * @param view defines the view matrix
  69744. * @param projection defines the projection matrix
  69745. * @param zmin defines the near clip plane
  69746. * @param zmax defines the far clip plane
  69747. * @returns the transformation matrix
  69748. */
  69749. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  69750. /**
  69751. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  69752. * @param matrix defines the matrix to use
  69753. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  69754. */
  69755. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  69756. /**
  69757. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  69758. * @param matrix defines the matrix to use
  69759. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  69760. */
  69761. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  69762. /**
  69763. * Compute the transpose of a given matrix
  69764. * @param matrix defines the matrix to transpose
  69765. * @returns the new matrix
  69766. */
  69767. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  69768. /**
  69769. * Compute the transpose of a matrix and store it in a target matrix
  69770. * @param matrix defines the matrix to transpose
  69771. * @param result defines the target matrix
  69772. */
  69773. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  69774. /**
  69775. * Computes a reflection matrix from a plane
  69776. * @param plane defines the reflection plane
  69777. * @returns a new matrix
  69778. */
  69779. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  69780. /**
  69781. * Computes a reflection matrix from a plane
  69782. * @param plane defines the reflection plane
  69783. * @param result defines the target matrix
  69784. */
  69785. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  69786. /**
  69787. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  69788. * @param xaxis defines the value of the 1st axis
  69789. * @param yaxis defines the value of the 2nd axis
  69790. * @param zaxis defines the value of the 3rd axis
  69791. * @param result defines the target matrix
  69792. */
  69793. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  69794. /**
  69795. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  69796. * @param quat defines the quaternion to use
  69797. * @param result defines the target matrix
  69798. */
  69799. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  69800. }
  69801. /**
  69802. * @hidden
  69803. */
  69804. export class TmpVectors {
  69805. static Vector2: Vector2[];
  69806. static Vector3: Vector3[];
  69807. static Vector4: Vector4[];
  69808. static Quaternion: Quaternion[];
  69809. static Matrix: Matrix[];
  69810. }
  69811. }
  69812. declare module BABYLON {
  69813. /** Defines the cross module used constants to avoid circular dependncies */
  69814. export class Constants {
  69815. /** Defines that alpha blending is disabled */
  69816. static readonly ALPHA_DISABLE: number;
  69817. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  69818. static readonly ALPHA_ADD: number;
  69819. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  69820. static readonly ALPHA_COMBINE: number;
  69821. /** Defines that alpha blending to DEST - SRC * DEST */
  69822. static readonly ALPHA_SUBTRACT: number;
  69823. /** Defines that alpha blending to SRC * DEST */
  69824. static readonly ALPHA_MULTIPLY: number;
  69825. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  69826. static readonly ALPHA_MAXIMIZED: number;
  69827. /** Defines that alpha blending to SRC + DEST */
  69828. static readonly ALPHA_ONEONE: number;
  69829. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  69830. static readonly ALPHA_PREMULTIPLIED: number;
  69831. /**
  69832. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  69833. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  69834. */
  69835. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  69836. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  69837. static readonly ALPHA_INTERPOLATE: number;
  69838. /**
  69839. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  69840. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  69841. */
  69842. static readonly ALPHA_SCREENMODE: number;
  69843. /** Defines that the ressource is not delayed*/
  69844. static readonly DELAYLOADSTATE_NONE: number;
  69845. /** Defines that the ressource was successfully delay loaded */
  69846. static readonly DELAYLOADSTATE_LOADED: number;
  69847. /** Defines that the ressource is currently delay loading */
  69848. static readonly DELAYLOADSTATE_LOADING: number;
  69849. /** Defines that the ressource is delayed and has not started loading */
  69850. static readonly DELAYLOADSTATE_NOTLOADED: number;
  69851. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  69852. static readonly NEVER: number;
  69853. /** 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 */
  69854. static readonly ALWAYS: number;
  69855. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  69856. static readonly LESS: number;
  69857. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  69858. static readonly EQUAL: number;
  69859. /** 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 */
  69860. static readonly LEQUAL: number;
  69861. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  69862. static readonly GREATER: number;
  69863. /** 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 */
  69864. static readonly GEQUAL: number;
  69865. /** 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 */
  69866. static readonly NOTEQUAL: number;
  69867. /** Passed to stencilOperation to specify that stencil value must be kept */
  69868. static readonly KEEP: number;
  69869. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69870. static readonly REPLACE: number;
  69871. /** Passed to stencilOperation to specify that stencil value must be incremented */
  69872. static readonly INCR: number;
  69873. /** Passed to stencilOperation to specify that stencil value must be decremented */
  69874. static readonly DECR: number;
  69875. /** Passed to stencilOperation to specify that stencil value must be inverted */
  69876. static readonly INVERT: number;
  69877. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  69878. static readonly INCR_WRAP: number;
  69879. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  69880. static readonly DECR_WRAP: number;
  69881. /** Texture is not repeating outside of 0..1 UVs */
  69882. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  69883. /** Texture is repeating outside of 0..1 UVs */
  69884. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  69885. /** Texture is repeating and mirrored */
  69886. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  69887. /** ALPHA */
  69888. static readonly TEXTUREFORMAT_ALPHA: number;
  69889. /** LUMINANCE */
  69890. static readonly TEXTUREFORMAT_LUMINANCE: number;
  69891. /** LUMINANCE_ALPHA */
  69892. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  69893. /** RGB */
  69894. static readonly TEXTUREFORMAT_RGB: number;
  69895. /** RGBA */
  69896. static readonly TEXTUREFORMAT_RGBA: number;
  69897. /** RED */
  69898. static readonly TEXTUREFORMAT_RED: number;
  69899. /** RED (2nd reference) */
  69900. static readonly TEXTUREFORMAT_R: number;
  69901. /** RG */
  69902. static readonly TEXTUREFORMAT_RG: number;
  69903. /** RED_INTEGER */
  69904. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  69905. /** RED_INTEGER (2nd reference) */
  69906. static readonly TEXTUREFORMAT_R_INTEGER: number;
  69907. /** RG_INTEGER */
  69908. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  69909. /** RGB_INTEGER */
  69910. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  69911. /** RGBA_INTEGER */
  69912. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  69913. /** UNSIGNED_BYTE */
  69914. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  69915. /** UNSIGNED_BYTE (2nd reference) */
  69916. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  69917. /** FLOAT */
  69918. static readonly TEXTURETYPE_FLOAT: number;
  69919. /** HALF_FLOAT */
  69920. static readonly TEXTURETYPE_HALF_FLOAT: number;
  69921. /** BYTE */
  69922. static readonly TEXTURETYPE_BYTE: number;
  69923. /** SHORT */
  69924. static readonly TEXTURETYPE_SHORT: number;
  69925. /** UNSIGNED_SHORT */
  69926. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  69927. /** INT */
  69928. static readonly TEXTURETYPE_INT: number;
  69929. /** UNSIGNED_INT */
  69930. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  69931. /** UNSIGNED_SHORT_4_4_4_4 */
  69932. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  69933. /** UNSIGNED_SHORT_5_5_5_1 */
  69934. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  69935. /** UNSIGNED_SHORT_5_6_5 */
  69936. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  69937. /** UNSIGNED_INT_2_10_10_10_REV */
  69938. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  69939. /** UNSIGNED_INT_24_8 */
  69940. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  69941. /** UNSIGNED_INT_10F_11F_11F_REV */
  69942. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  69943. /** UNSIGNED_INT_5_9_9_9_REV */
  69944. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  69945. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  69946. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69947. /** nearest is mag = nearest and min = nearest and mip = linear */
  69948. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  69949. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69950. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  69951. /** Trilinear is mag = linear and min = linear and mip = linear */
  69952. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  69953. /** nearest is mag = nearest and min = nearest and mip = linear */
  69954. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  69955. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69956. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  69957. /** Trilinear is mag = linear and min = linear and mip = linear */
  69958. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  69959. /** mag = nearest and min = nearest and mip = nearest */
  69960. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  69961. /** mag = nearest and min = linear and mip = nearest */
  69962. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  69963. /** mag = nearest and min = linear and mip = linear */
  69964. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  69965. /** mag = nearest and min = linear and mip = none */
  69966. static readonly TEXTURE_NEAREST_LINEAR: number;
  69967. /** mag = nearest and min = nearest and mip = none */
  69968. static readonly TEXTURE_NEAREST_NEAREST: number;
  69969. /** mag = linear and min = nearest and mip = nearest */
  69970. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  69971. /** mag = linear and min = nearest and mip = linear */
  69972. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  69973. /** mag = linear and min = linear and mip = none */
  69974. static readonly TEXTURE_LINEAR_LINEAR: number;
  69975. /** mag = linear and min = nearest and mip = none */
  69976. static readonly TEXTURE_LINEAR_NEAREST: number;
  69977. /** Explicit coordinates mode */
  69978. static readonly TEXTURE_EXPLICIT_MODE: number;
  69979. /** Spherical coordinates mode */
  69980. static readonly TEXTURE_SPHERICAL_MODE: number;
  69981. /** Planar coordinates mode */
  69982. static readonly TEXTURE_PLANAR_MODE: number;
  69983. /** Cubic coordinates mode */
  69984. static readonly TEXTURE_CUBIC_MODE: number;
  69985. /** Projection coordinates mode */
  69986. static readonly TEXTURE_PROJECTION_MODE: number;
  69987. /** Skybox coordinates mode */
  69988. static readonly TEXTURE_SKYBOX_MODE: number;
  69989. /** Inverse Cubic coordinates mode */
  69990. static readonly TEXTURE_INVCUBIC_MODE: number;
  69991. /** Equirectangular coordinates mode */
  69992. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  69993. /** Equirectangular Fixed coordinates mode */
  69994. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  69995. /** Equirectangular Fixed Mirrored coordinates mode */
  69996. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  69997. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  69998. static readonly SCALEMODE_FLOOR: number;
  69999. /** Defines that texture rescaling will look for the nearest power of 2 size */
  70000. static readonly SCALEMODE_NEAREST: number;
  70001. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  70002. static readonly SCALEMODE_CEILING: number;
  70003. /**
  70004. * The dirty texture flag value
  70005. */
  70006. static readonly MATERIAL_TextureDirtyFlag: number;
  70007. /**
  70008. * The dirty light flag value
  70009. */
  70010. static readonly MATERIAL_LightDirtyFlag: number;
  70011. /**
  70012. * The dirty fresnel flag value
  70013. */
  70014. static readonly MATERIAL_FresnelDirtyFlag: number;
  70015. /**
  70016. * The dirty attribute flag value
  70017. */
  70018. static readonly MATERIAL_AttributesDirtyFlag: number;
  70019. /**
  70020. * The dirty misc flag value
  70021. */
  70022. static readonly MATERIAL_MiscDirtyFlag: number;
  70023. /**
  70024. * The all dirty flag value
  70025. */
  70026. static readonly MATERIAL_AllDirtyFlag: number;
  70027. /**
  70028. * Returns the triangle fill mode
  70029. */
  70030. static readonly MATERIAL_TriangleFillMode: number;
  70031. /**
  70032. * Returns the wireframe mode
  70033. */
  70034. static readonly MATERIAL_WireFrameFillMode: number;
  70035. /**
  70036. * Returns the point fill mode
  70037. */
  70038. static readonly MATERIAL_PointFillMode: number;
  70039. /**
  70040. * Returns the point list draw mode
  70041. */
  70042. static readonly MATERIAL_PointListDrawMode: number;
  70043. /**
  70044. * Returns the line list draw mode
  70045. */
  70046. static readonly MATERIAL_LineListDrawMode: number;
  70047. /**
  70048. * Returns the line loop draw mode
  70049. */
  70050. static readonly MATERIAL_LineLoopDrawMode: number;
  70051. /**
  70052. * Returns the line strip draw mode
  70053. */
  70054. static readonly MATERIAL_LineStripDrawMode: number;
  70055. /**
  70056. * Returns the triangle strip draw mode
  70057. */
  70058. static readonly MATERIAL_TriangleStripDrawMode: number;
  70059. /**
  70060. * Returns the triangle fan draw mode
  70061. */
  70062. static readonly MATERIAL_TriangleFanDrawMode: number;
  70063. /**
  70064. * Stores the clock-wise side orientation
  70065. */
  70066. static readonly MATERIAL_ClockWiseSideOrientation: number;
  70067. /**
  70068. * Stores the counter clock-wise side orientation
  70069. */
  70070. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  70071. /**
  70072. * Nothing
  70073. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70074. */
  70075. static readonly ACTION_NothingTrigger: number;
  70076. /**
  70077. * On pick
  70078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70079. */
  70080. static readonly ACTION_OnPickTrigger: number;
  70081. /**
  70082. * On left pick
  70083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70084. */
  70085. static readonly ACTION_OnLeftPickTrigger: number;
  70086. /**
  70087. * On right pick
  70088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70089. */
  70090. static readonly ACTION_OnRightPickTrigger: number;
  70091. /**
  70092. * On center pick
  70093. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70094. */
  70095. static readonly ACTION_OnCenterPickTrigger: number;
  70096. /**
  70097. * On pick down
  70098. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70099. */
  70100. static readonly ACTION_OnPickDownTrigger: number;
  70101. /**
  70102. * On double pick
  70103. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70104. */
  70105. static readonly ACTION_OnDoublePickTrigger: number;
  70106. /**
  70107. * On pick up
  70108. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70109. */
  70110. static readonly ACTION_OnPickUpTrigger: number;
  70111. /**
  70112. * On pick out.
  70113. * This trigger will only be raised if you also declared a OnPickDown
  70114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70115. */
  70116. static readonly ACTION_OnPickOutTrigger: number;
  70117. /**
  70118. * On long press
  70119. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70120. */
  70121. static readonly ACTION_OnLongPressTrigger: number;
  70122. /**
  70123. * On pointer over
  70124. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70125. */
  70126. static readonly ACTION_OnPointerOverTrigger: number;
  70127. /**
  70128. * On pointer out
  70129. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70130. */
  70131. static readonly ACTION_OnPointerOutTrigger: number;
  70132. /**
  70133. * On every frame
  70134. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70135. */
  70136. static readonly ACTION_OnEveryFrameTrigger: number;
  70137. /**
  70138. * On intersection enter
  70139. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70140. */
  70141. static readonly ACTION_OnIntersectionEnterTrigger: number;
  70142. /**
  70143. * On intersection exit
  70144. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70145. */
  70146. static readonly ACTION_OnIntersectionExitTrigger: number;
  70147. /**
  70148. * On key down
  70149. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70150. */
  70151. static readonly ACTION_OnKeyDownTrigger: number;
  70152. /**
  70153. * On key up
  70154. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70155. */
  70156. static readonly ACTION_OnKeyUpTrigger: number;
  70157. /**
  70158. * Billboard mode will only apply to Y axis
  70159. */
  70160. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  70161. /**
  70162. * Billboard mode will apply to all axes
  70163. */
  70164. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  70165. /**
  70166. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  70167. */
  70168. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  70169. /**
  70170. * Gets or sets base Assets URL
  70171. */
  70172. static PARTICLES_BaseAssetsUrl: string;
  70173. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  70174. * Test order :
  70175. * Is the bounding sphere outside the frustum ?
  70176. * If not, are the bounding box vertices outside the frustum ?
  70177. * It not, then the cullable object is in the frustum.
  70178. */
  70179. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  70180. /** Culling strategy : Bounding Sphere Only.
  70181. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  70182. * It's also less accurate than the standard because some not visible objects can still be selected.
  70183. * Test : is the bounding sphere outside the frustum ?
  70184. * If not, then the cullable object is in the frustum.
  70185. */
  70186. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  70187. /** Culling strategy : Optimistic Inclusion.
  70188. * This in an inclusion test first, then the standard exclusion test.
  70189. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  70190. * 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.
  70191. * Anyway, it's as accurate as the standard strategy.
  70192. * Test :
  70193. * Is the cullable object bounding sphere center in the frustum ?
  70194. * If not, apply the default culling strategy.
  70195. */
  70196. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  70197. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  70198. * This in an inclusion test first, then the bounding sphere only exclusion test.
  70199. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  70200. * 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.
  70201. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  70202. * Test :
  70203. * Is the cullable object bounding sphere center in the frustum ?
  70204. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  70205. */
  70206. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  70207. /**
  70208. * No logging while loading
  70209. */
  70210. static readonly SCENELOADER_NO_LOGGING: number;
  70211. /**
  70212. * Minimal logging while loading
  70213. */
  70214. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  70215. /**
  70216. * Summary logging while loading
  70217. */
  70218. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  70219. /**
  70220. * Detailled logging while loading
  70221. */
  70222. static readonly SCENELOADER_DETAILED_LOGGING: number;
  70223. }
  70224. }
  70225. declare module BABYLON {
  70226. /**
  70227. * Class used to store and describe the pipeline context associated with an effect
  70228. */
  70229. export interface IPipelineContext {
  70230. /**
  70231. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  70232. */
  70233. isAsync: boolean;
  70234. /**
  70235. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  70236. */
  70237. isReady: boolean;
  70238. /** @hidden */
  70239. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  70240. }
  70241. }
  70242. declare module BABYLON {
  70243. /** @hidden */
  70244. export interface IShaderProcessor {
  70245. attributeProcessor?: (attribute: string) => string;
  70246. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  70247. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  70248. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  70249. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  70250. lineProcessor?: (line: string, isFragment: boolean) => string;
  70251. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70252. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70253. }
  70254. }
  70255. declare module BABYLON {
  70256. /** @hidden */
  70257. export interface ProcessingOptions {
  70258. defines: string[];
  70259. indexParameters: any;
  70260. isFragment: boolean;
  70261. shouldUseHighPrecisionShader: boolean;
  70262. supportsUniformBuffers: boolean;
  70263. shadersRepository: string;
  70264. includesShadersStore: {
  70265. [key: string]: string;
  70266. };
  70267. processor?: IShaderProcessor;
  70268. version: string;
  70269. platformName: string;
  70270. lookForClosingBracketForUniformBuffer?: boolean;
  70271. }
  70272. }
  70273. declare module BABYLON {
  70274. /**
  70275. * Helper to manipulate strings
  70276. */
  70277. export class StringTools {
  70278. /**
  70279. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  70280. * @param str Source string
  70281. * @param suffix Suffix to search for in the source string
  70282. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70283. */
  70284. static EndsWith(str: string, suffix: string): boolean;
  70285. /**
  70286. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  70287. * @param str Source string
  70288. * @param suffix Suffix to search for in the source string
  70289. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70290. */
  70291. static StartsWith(str: string, suffix: string): boolean;
  70292. }
  70293. }
  70294. declare module BABYLON {
  70295. /** @hidden */
  70296. export class ShaderCodeNode {
  70297. line: string;
  70298. children: ShaderCodeNode[];
  70299. additionalDefineKey?: string;
  70300. additionalDefineValue?: string;
  70301. isValid(preprocessors: {
  70302. [key: string]: string;
  70303. }): boolean;
  70304. process(preprocessors: {
  70305. [key: string]: string;
  70306. }, options: ProcessingOptions): string;
  70307. }
  70308. }
  70309. declare module BABYLON {
  70310. /** @hidden */
  70311. export class ShaderCodeCursor {
  70312. private _lines;
  70313. lineIndex: number;
  70314. readonly currentLine: string;
  70315. readonly canRead: boolean;
  70316. lines: string[];
  70317. }
  70318. }
  70319. declare module BABYLON {
  70320. /** @hidden */
  70321. export class ShaderCodeConditionNode extends ShaderCodeNode {
  70322. process(preprocessors: {
  70323. [key: string]: string;
  70324. }, options: ProcessingOptions): string;
  70325. }
  70326. }
  70327. declare module BABYLON {
  70328. /** @hidden */
  70329. export class ShaderDefineExpression {
  70330. isTrue(preprocessors: {
  70331. [key: string]: string;
  70332. }): boolean;
  70333. }
  70334. }
  70335. declare module BABYLON {
  70336. /** @hidden */
  70337. export class ShaderCodeTestNode extends ShaderCodeNode {
  70338. testExpression: ShaderDefineExpression;
  70339. isValid(preprocessors: {
  70340. [key: string]: string;
  70341. }): boolean;
  70342. }
  70343. }
  70344. declare module BABYLON {
  70345. /** @hidden */
  70346. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  70347. define: string;
  70348. not: boolean;
  70349. constructor(define: string, not?: boolean);
  70350. isTrue(preprocessors: {
  70351. [key: string]: string;
  70352. }): boolean;
  70353. }
  70354. }
  70355. declare module BABYLON {
  70356. /** @hidden */
  70357. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  70358. leftOperand: ShaderDefineExpression;
  70359. rightOperand: ShaderDefineExpression;
  70360. isTrue(preprocessors: {
  70361. [key: string]: string;
  70362. }): boolean;
  70363. }
  70364. }
  70365. declare module BABYLON {
  70366. /** @hidden */
  70367. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  70368. leftOperand: ShaderDefineExpression;
  70369. rightOperand: ShaderDefineExpression;
  70370. isTrue(preprocessors: {
  70371. [key: string]: string;
  70372. }): boolean;
  70373. }
  70374. }
  70375. declare module BABYLON {
  70376. /** @hidden */
  70377. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  70378. define: string;
  70379. operand: string;
  70380. testValue: string;
  70381. constructor(define: string, operand: string, testValue: string);
  70382. isTrue(preprocessors: {
  70383. [key: string]: string;
  70384. }): boolean;
  70385. }
  70386. }
  70387. declare module BABYLON {
  70388. /**
  70389. * @ignore
  70390. * Application error to support additional information when loading a file
  70391. */
  70392. export class LoadFileError extends Error {
  70393. /** defines the optional web request */
  70394. request?: WebRequest | undefined;
  70395. private static _setPrototypeOf;
  70396. /**
  70397. * Creates a new LoadFileError
  70398. * @param message defines the message of the error
  70399. * @param request defines the optional web request
  70400. */
  70401. constructor(message: string,
  70402. /** defines the optional web request */
  70403. request?: WebRequest | undefined);
  70404. }
  70405. }
  70406. declare module BABYLON {
  70407. /**
  70408. * Class used to enable access to offline support
  70409. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70410. */
  70411. export interface IOfflineProvider {
  70412. /**
  70413. * Gets a boolean indicating if scene must be saved in the database
  70414. */
  70415. enableSceneOffline: boolean;
  70416. /**
  70417. * Gets a boolean indicating if textures must be saved in the database
  70418. */
  70419. enableTexturesOffline: boolean;
  70420. /**
  70421. * Open the offline support and make it available
  70422. * @param successCallback defines the callback to call on success
  70423. * @param errorCallback defines the callback to call on error
  70424. */
  70425. open(successCallback: () => void, errorCallback: () => void): void;
  70426. /**
  70427. * Loads an image from the offline support
  70428. * @param url defines the url to load from
  70429. * @param image defines the target DOM image
  70430. */
  70431. loadImage(url: string, image: HTMLImageElement): void;
  70432. /**
  70433. * Loads a file from offline support
  70434. * @param url defines the URL to load from
  70435. * @param sceneLoaded defines a callback to call on success
  70436. * @param progressCallBack defines a callback to call when progress changed
  70437. * @param errorCallback defines a callback to call on error
  70438. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70439. */
  70440. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70441. }
  70442. }
  70443. declare module BABYLON {
  70444. /**
  70445. * Class used to help managing file picking and drag'n'drop
  70446. * File Storage
  70447. */
  70448. export class FilesInputStore {
  70449. /**
  70450. * List of files ready to be loaded
  70451. */
  70452. static FilesToLoad: {
  70453. [key: string]: File;
  70454. };
  70455. }
  70456. }
  70457. declare module BABYLON {
  70458. /**
  70459. * Class used to define a retry strategy when error happens while loading assets
  70460. */
  70461. export class RetryStrategy {
  70462. /**
  70463. * Function used to defines an exponential back off strategy
  70464. * @param maxRetries defines the maximum number of retries (3 by default)
  70465. * @param baseInterval defines the interval between retries
  70466. * @returns the strategy function to use
  70467. */
  70468. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  70469. }
  70470. }
  70471. declare module BABYLON {
  70472. /**
  70473. * @hidden
  70474. */
  70475. export class FileTools {
  70476. /**
  70477. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  70478. */
  70479. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  70480. /**
  70481. * Gets or sets the base URL to use to load assets
  70482. */
  70483. static BaseUrl: string;
  70484. /**
  70485. * Default behaviour for cors in the application.
  70486. * It can be a string if the expected behavior is identical in the entire app.
  70487. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  70488. */
  70489. static CorsBehavior: string | ((url: string | string[]) => string);
  70490. /**
  70491. * Gets or sets a function used to pre-process url before using them to load assets
  70492. */
  70493. static PreprocessUrl: (url: string) => string;
  70494. /**
  70495. * Removes unwanted characters from an url
  70496. * @param url defines the url to clean
  70497. * @returns the cleaned url
  70498. */
  70499. private static _CleanUrl;
  70500. /**
  70501. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  70502. * @param url define the url we are trying
  70503. * @param element define the dom element where to configure the cors policy
  70504. */
  70505. static SetCorsBehavior(url: string | string[], element: {
  70506. crossOrigin: string | null;
  70507. }): void;
  70508. /**
  70509. * Loads an image as an HTMLImageElement.
  70510. * @param input url string, ArrayBuffer, or Blob to load
  70511. * @param onLoad callback called when the image successfully loads
  70512. * @param onError callback called when the image fails to load
  70513. * @param offlineProvider offline provider for caching
  70514. * @returns the HTMLImageElement of the loaded image
  70515. */
  70516. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  70517. /**
  70518. * Loads a file
  70519. * @param fileToLoad defines the file to load
  70520. * @param callback defines the callback to call when data is loaded
  70521. * @param progressCallBack defines the callback to call during loading process
  70522. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  70523. * @returns a file request object
  70524. */
  70525. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  70526. /**
  70527. * Loads a file
  70528. * @param url url string, ArrayBuffer, or Blob to load
  70529. * @param onSuccess callback called when the file successfully loads
  70530. * @param onProgress callback called while file is loading (if the server supports this mode)
  70531. * @param offlineProvider defines the offline provider for caching
  70532. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  70533. * @param onError callback called when the file fails to load
  70534. * @returns a file request object
  70535. */
  70536. 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;
  70537. /**
  70538. * Checks if the loaded document was accessed via `file:`-Protocol.
  70539. * @returns boolean
  70540. */
  70541. static IsFileURL(): boolean;
  70542. }
  70543. }
  70544. declare module BABYLON {
  70545. /** @hidden */
  70546. export class ShaderProcessor {
  70547. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  70548. private static _ProcessPrecision;
  70549. private static _ExtractOperation;
  70550. private static _BuildSubExpression;
  70551. private static _BuildExpression;
  70552. private static _MoveCursorWithinIf;
  70553. private static _MoveCursor;
  70554. private static _EvaluatePreProcessors;
  70555. private static _PreparePreProcessors;
  70556. private static _ProcessShaderConversion;
  70557. private static _ProcessIncludes;
  70558. }
  70559. }
  70560. declare module BABYLON {
  70561. /**
  70562. * Class used to hold a RBG color
  70563. */
  70564. export class Color3 {
  70565. /**
  70566. * Defines the red component (between 0 and 1, default is 0)
  70567. */
  70568. r: number;
  70569. /**
  70570. * Defines the green component (between 0 and 1, default is 0)
  70571. */
  70572. g: number;
  70573. /**
  70574. * Defines the blue component (between 0 and 1, default is 0)
  70575. */
  70576. b: number;
  70577. /**
  70578. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  70579. * @param r defines the red component (between 0 and 1, default is 0)
  70580. * @param g defines the green component (between 0 and 1, default is 0)
  70581. * @param b defines the blue component (between 0 and 1, default is 0)
  70582. */
  70583. constructor(
  70584. /**
  70585. * Defines the red component (between 0 and 1, default is 0)
  70586. */
  70587. r?: number,
  70588. /**
  70589. * Defines the green component (between 0 and 1, default is 0)
  70590. */
  70591. g?: number,
  70592. /**
  70593. * Defines the blue component (between 0 and 1, default is 0)
  70594. */
  70595. b?: number);
  70596. /**
  70597. * Creates a string with the Color3 current values
  70598. * @returns the string representation of the Color3 object
  70599. */
  70600. toString(): string;
  70601. /**
  70602. * Returns the string "Color3"
  70603. * @returns "Color3"
  70604. */
  70605. getClassName(): string;
  70606. /**
  70607. * Compute the Color3 hash code
  70608. * @returns an unique number that can be used to hash Color3 objects
  70609. */
  70610. getHashCode(): number;
  70611. /**
  70612. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  70613. * @param array defines the array where to store the r,g,b components
  70614. * @param index defines an optional index in the target array to define where to start storing values
  70615. * @returns the current Color3 object
  70616. */
  70617. toArray(array: FloatArray, index?: number): Color3;
  70618. /**
  70619. * Returns a new Color4 object from the current Color3 and the given alpha
  70620. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  70621. * @returns a new Color4 object
  70622. */
  70623. toColor4(alpha?: number): Color4;
  70624. /**
  70625. * Returns a new array populated with 3 numeric elements : red, green and blue values
  70626. * @returns the new array
  70627. */
  70628. asArray(): number[];
  70629. /**
  70630. * Returns the luminance value
  70631. * @returns a float value
  70632. */
  70633. toLuminance(): number;
  70634. /**
  70635. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  70636. * @param otherColor defines the second operand
  70637. * @returns the new Color3 object
  70638. */
  70639. multiply(otherColor: DeepImmutable<Color3>): Color3;
  70640. /**
  70641. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  70642. * @param otherColor defines the second operand
  70643. * @param result defines the Color3 object where to store the result
  70644. * @returns the current Color3
  70645. */
  70646. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70647. /**
  70648. * Determines equality between Color3 objects
  70649. * @param otherColor defines the second operand
  70650. * @returns true if the rgb values are equal to the given ones
  70651. */
  70652. equals(otherColor: DeepImmutable<Color3>): boolean;
  70653. /**
  70654. * Determines equality between the current Color3 object and a set of r,b,g values
  70655. * @param r defines the red component to check
  70656. * @param g defines the green component to check
  70657. * @param b defines the blue component to check
  70658. * @returns true if the rgb values are equal to the given ones
  70659. */
  70660. equalsFloats(r: number, g: number, b: number): boolean;
  70661. /**
  70662. * Multiplies in place each rgb value by scale
  70663. * @param scale defines the scaling factor
  70664. * @returns the updated Color3
  70665. */
  70666. scale(scale: number): Color3;
  70667. /**
  70668. * Multiplies the rgb values by scale and stores the result into "result"
  70669. * @param scale defines the scaling factor
  70670. * @param result defines the Color3 object where to store the result
  70671. * @returns the unmodified current Color3
  70672. */
  70673. scaleToRef(scale: number, result: Color3): Color3;
  70674. /**
  70675. * Scale the current Color3 values by a factor and add the result to a given Color3
  70676. * @param scale defines the scale factor
  70677. * @param result defines color to store the result into
  70678. * @returns the unmodified current Color3
  70679. */
  70680. scaleAndAddToRef(scale: number, result: Color3): Color3;
  70681. /**
  70682. * Clamps the rgb values by the min and max values and stores the result into "result"
  70683. * @param min defines minimum clamping value (default is 0)
  70684. * @param max defines maximum clamping value (default is 1)
  70685. * @param result defines color to store the result into
  70686. * @returns the original Color3
  70687. */
  70688. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  70689. /**
  70690. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  70691. * @param otherColor defines the second operand
  70692. * @returns the new Color3
  70693. */
  70694. add(otherColor: DeepImmutable<Color3>): Color3;
  70695. /**
  70696. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  70697. * @param otherColor defines the second operand
  70698. * @param result defines Color3 object to store the result into
  70699. * @returns the unmodified current Color3
  70700. */
  70701. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70702. /**
  70703. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  70704. * @param otherColor defines the second operand
  70705. * @returns the new Color3
  70706. */
  70707. subtract(otherColor: DeepImmutable<Color3>): Color3;
  70708. /**
  70709. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  70710. * @param otherColor defines the second operand
  70711. * @param result defines Color3 object to store the result into
  70712. * @returns the unmodified current Color3
  70713. */
  70714. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70715. /**
  70716. * Copy the current object
  70717. * @returns a new Color3 copied the current one
  70718. */
  70719. clone(): Color3;
  70720. /**
  70721. * Copies the rgb values from the source in the current Color3
  70722. * @param source defines the source Color3 object
  70723. * @returns the updated Color3 object
  70724. */
  70725. copyFrom(source: DeepImmutable<Color3>): Color3;
  70726. /**
  70727. * Updates the Color3 rgb values from the given floats
  70728. * @param r defines the red component to read from
  70729. * @param g defines the green component to read from
  70730. * @param b defines the blue component to read from
  70731. * @returns the current Color3 object
  70732. */
  70733. copyFromFloats(r: number, g: number, b: number): Color3;
  70734. /**
  70735. * Updates the Color3 rgb values from the given floats
  70736. * @param r defines the red component to read from
  70737. * @param g defines the green component to read from
  70738. * @param b defines the blue component to read from
  70739. * @returns the current Color3 object
  70740. */
  70741. set(r: number, g: number, b: number): Color3;
  70742. /**
  70743. * Compute the Color3 hexadecimal code as a string
  70744. * @returns a string containing the hexadecimal representation of the Color3 object
  70745. */
  70746. toHexString(): string;
  70747. /**
  70748. * Computes a new Color3 converted from the current one to linear space
  70749. * @returns a new Color3 object
  70750. */
  70751. toLinearSpace(): Color3;
  70752. /**
  70753. * Converts current color in rgb space to HSV values
  70754. * @returns a new color3 representing the HSV values
  70755. */
  70756. toHSV(): Color3;
  70757. /**
  70758. * Converts current color in rgb space to HSV values
  70759. * @param result defines the Color3 where to store the HSV values
  70760. */
  70761. toHSVToRef(result: Color3): void;
  70762. /**
  70763. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  70764. * @param convertedColor defines the Color3 object where to store the linear space version
  70765. * @returns the unmodified Color3
  70766. */
  70767. toLinearSpaceToRef(convertedColor: Color3): Color3;
  70768. /**
  70769. * Computes a new Color3 converted from the current one to gamma space
  70770. * @returns a new Color3 object
  70771. */
  70772. toGammaSpace(): Color3;
  70773. /**
  70774. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  70775. * @param convertedColor defines the Color3 object where to store the gamma space version
  70776. * @returns the unmodified Color3
  70777. */
  70778. toGammaSpaceToRef(convertedColor: Color3): Color3;
  70779. private static _BlackReadOnly;
  70780. /**
  70781. * Convert Hue, saturation and value to a Color3 (RGB)
  70782. * @param hue defines the hue
  70783. * @param saturation defines the saturation
  70784. * @param value defines the value
  70785. * @param result defines the Color3 where to store the RGB values
  70786. */
  70787. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  70788. /**
  70789. * Creates a new Color3 from the string containing valid hexadecimal values
  70790. * @param hex defines a string containing valid hexadecimal values
  70791. * @returns a new Color3 object
  70792. */
  70793. static FromHexString(hex: string): Color3;
  70794. /**
  70795. * Creates a new Color3 from the starting index of the given array
  70796. * @param array defines the source array
  70797. * @param offset defines an offset in the source array
  70798. * @returns a new Color3 object
  70799. */
  70800. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  70801. /**
  70802. * Creates a new Color3 from integer values (< 256)
  70803. * @param r defines the red component to read from (value between 0 and 255)
  70804. * @param g defines the green component to read from (value between 0 and 255)
  70805. * @param b defines the blue component to read from (value between 0 and 255)
  70806. * @returns a new Color3 object
  70807. */
  70808. static FromInts(r: number, g: number, b: number): Color3;
  70809. /**
  70810. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70811. * @param start defines the start Color3 value
  70812. * @param end defines the end Color3 value
  70813. * @param amount defines the gradient value between start and end
  70814. * @returns a new Color3 object
  70815. */
  70816. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  70817. /**
  70818. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70819. * @param left defines the start value
  70820. * @param right defines the end value
  70821. * @param amount defines the gradient factor
  70822. * @param result defines the Color3 object where to store the result
  70823. */
  70824. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  70825. /**
  70826. * Returns a Color3 value containing a red color
  70827. * @returns a new Color3 object
  70828. */
  70829. static Red(): Color3;
  70830. /**
  70831. * Returns a Color3 value containing a green color
  70832. * @returns a new Color3 object
  70833. */
  70834. static Green(): Color3;
  70835. /**
  70836. * Returns a Color3 value containing a blue color
  70837. * @returns a new Color3 object
  70838. */
  70839. static Blue(): Color3;
  70840. /**
  70841. * Returns a Color3 value containing a black color
  70842. * @returns a new Color3 object
  70843. */
  70844. static Black(): Color3;
  70845. /**
  70846. * Gets a Color3 value containing a black color that must not be updated
  70847. */
  70848. static readonly BlackReadOnly: DeepImmutable<Color3>;
  70849. /**
  70850. * Returns a Color3 value containing a white color
  70851. * @returns a new Color3 object
  70852. */
  70853. static White(): Color3;
  70854. /**
  70855. * Returns a Color3 value containing a purple color
  70856. * @returns a new Color3 object
  70857. */
  70858. static Purple(): Color3;
  70859. /**
  70860. * Returns a Color3 value containing a magenta color
  70861. * @returns a new Color3 object
  70862. */
  70863. static Magenta(): Color3;
  70864. /**
  70865. * Returns a Color3 value containing a yellow color
  70866. * @returns a new Color3 object
  70867. */
  70868. static Yellow(): Color3;
  70869. /**
  70870. * Returns a Color3 value containing a gray color
  70871. * @returns a new Color3 object
  70872. */
  70873. static Gray(): Color3;
  70874. /**
  70875. * Returns a Color3 value containing a teal color
  70876. * @returns a new Color3 object
  70877. */
  70878. static Teal(): Color3;
  70879. /**
  70880. * Returns a Color3 value containing a random color
  70881. * @returns a new Color3 object
  70882. */
  70883. static Random(): Color3;
  70884. }
  70885. /**
  70886. * Class used to hold a RBGA color
  70887. */
  70888. export class Color4 {
  70889. /**
  70890. * Defines the red component (between 0 and 1, default is 0)
  70891. */
  70892. r: number;
  70893. /**
  70894. * Defines the green component (between 0 and 1, default is 0)
  70895. */
  70896. g: number;
  70897. /**
  70898. * Defines the blue component (between 0 and 1, default is 0)
  70899. */
  70900. b: number;
  70901. /**
  70902. * Defines the alpha component (between 0 and 1, default is 1)
  70903. */
  70904. a: number;
  70905. /**
  70906. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  70907. * @param r defines the red component (between 0 and 1, default is 0)
  70908. * @param g defines the green component (between 0 and 1, default is 0)
  70909. * @param b defines the blue component (between 0 and 1, default is 0)
  70910. * @param a defines the alpha component (between 0 and 1, default is 1)
  70911. */
  70912. constructor(
  70913. /**
  70914. * Defines the red component (between 0 and 1, default is 0)
  70915. */
  70916. r?: number,
  70917. /**
  70918. * Defines the green component (between 0 and 1, default is 0)
  70919. */
  70920. g?: number,
  70921. /**
  70922. * Defines the blue component (between 0 and 1, default is 0)
  70923. */
  70924. b?: number,
  70925. /**
  70926. * Defines the alpha component (between 0 and 1, default is 1)
  70927. */
  70928. a?: number);
  70929. /**
  70930. * Adds in place the given Color4 values to the current Color4 object
  70931. * @param right defines the second operand
  70932. * @returns the current updated Color4 object
  70933. */
  70934. addInPlace(right: DeepImmutable<Color4>): Color4;
  70935. /**
  70936. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  70937. * @returns the new array
  70938. */
  70939. asArray(): number[];
  70940. /**
  70941. * Stores from the starting index in the given array the Color4 successive values
  70942. * @param array defines the array where to store the r,g,b components
  70943. * @param index defines an optional index in the target array to define where to start storing values
  70944. * @returns the current Color4 object
  70945. */
  70946. toArray(array: number[], index?: number): Color4;
  70947. /**
  70948. * Determines equality between Color4 objects
  70949. * @param otherColor defines the second operand
  70950. * @returns true if the rgba values are equal to the given ones
  70951. */
  70952. equals(otherColor: DeepImmutable<Color4>): boolean;
  70953. /**
  70954. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  70955. * @param right defines the second operand
  70956. * @returns a new Color4 object
  70957. */
  70958. add(right: DeepImmutable<Color4>): Color4;
  70959. /**
  70960. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  70961. * @param right defines the second operand
  70962. * @returns a new Color4 object
  70963. */
  70964. subtract(right: DeepImmutable<Color4>): Color4;
  70965. /**
  70966. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  70967. * @param right defines the second operand
  70968. * @param result defines the Color4 object where to store the result
  70969. * @returns the current Color4 object
  70970. */
  70971. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  70972. /**
  70973. * Creates a new Color4 with the current Color4 values multiplied by scale
  70974. * @param scale defines the scaling factor to apply
  70975. * @returns a new Color4 object
  70976. */
  70977. scale(scale: number): Color4;
  70978. /**
  70979. * Multiplies the current Color4 values by scale and stores the result in "result"
  70980. * @param scale defines the scaling factor to apply
  70981. * @param result defines the Color4 object where to store the result
  70982. * @returns the current unmodified Color4
  70983. */
  70984. scaleToRef(scale: number, result: Color4): Color4;
  70985. /**
  70986. * Scale the current Color4 values by a factor and add the result to a given Color4
  70987. * @param scale defines the scale factor
  70988. * @param result defines the Color4 object where to store the result
  70989. * @returns the unmodified current Color4
  70990. */
  70991. scaleAndAddToRef(scale: number, result: Color4): Color4;
  70992. /**
  70993. * Clamps the rgb values by the min and max values and stores the result into "result"
  70994. * @param min defines minimum clamping value (default is 0)
  70995. * @param max defines maximum clamping value (default is 1)
  70996. * @param result defines color to store the result into.
  70997. * @returns the cuurent Color4
  70998. */
  70999. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  71000. /**
  71001. * Multipy an Color4 value by another and return a new Color4 object
  71002. * @param color defines the Color4 value to multiply by
  71003. * @returns a new Color4 object
  71004. */
  71005. multiply(color: Color4): Color4;
  71006. /**
  71007. * Multipy a Color4 value by another and push the result in a reference value
  71008. * @param color defines the Color4 value to multiply by
  71009. * @param result defines the Color4 to fill the result in
  71010. * @returns the result Color4
  71011. */
  71012. multiplyToRef(color: Color4, result: Color4): Color4;
  71013. /**
  71014. * Creates a string with the Color4 current values
  71015. * @returns the string representation of the Color4 object
  71016. */
  71017. toString(): string;
  71018. /**
  71019. * Returns the string "Color4"
  71020. * @returns "Color4"
  71021. */
  71022. getClassName(): string;
  71023. /**
  71024. * Compute the Color4 hash code
  71025. * @returns an unique number that can be used to hash Color4 objects
  71026. */
  71027. getHashCode(): number;
  71028. /**
  71029. * Creates a new Color4 copied from the current one
  71030. * @returns a new Color4 object
  71031. */
  71032. clone(): Color4;
  71033. /**
  71034. * Copies the given Color4 values into the current one
  71035. * @param source defines the source Color4 object
  71036. * @returns the current updated Color4 object
  71037. */
  71038. copyFrom(source: Color4): Color4;
  71039. /**
  71040. * Copies the given float values into the current one
  71041. * @param r defines the red component to read from
  71042. * @param g defines the green component to read from
  71043. * @param b defines the blue component to read from
  71044. * @param a defines the alpha component to read from
  71045. * @returns the current updated Color4 object
  71046. */
  71047. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  71048. /**
  71049. * Copies the given float values into the current one
  71050. * @param r defines the red component to read from
  71051. * @param g defines the green component to read from
  71052. * @param b defines the blue component to read from
  71053. * @param a defines the alpha component to read from
  71054. * @returns the current updated Color4 object
  71055. */
  71056. set(r: number, g: number, b: number, a: number): Color4;
  71057. /**
  71058. * Compute the Color4 hexadecimal code as a string
  71059. * @returns a string containing the hexadecimal representation of the Color4 object
  71060. */
  71061. toHexString(): string;
  71062. /**
  71063. * Computes a new Color4 converted from the current one to linear space
  71064. * @returns a new Color4 object
  71065. */
  71066. toLinearSpace(): Color4;
  71067. /**
  71068. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  71069. * @param convertedColor defines the Color4 object where to store the linear space version
  71070. * @returns the unmodified Color4
  71071. */
  71072. toLinearSpaceToRef(convertedColor: Color4): Color4;
  71073. /**
  71074. * Computes a new Color4 converted from the current one to gamma space
  71075. * @returns a new Color4 object
  71076. */
  71077. toGammaSpace(): Color4;
  71078. /**
  71079. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  71080. * @param convertedColor defines the Color4 object where to store the gamma space version
  71081. * @returns the unmodified Color4
  71082. */
  71083. toGammaSpaceToRef(convertedColor: Color4): Color4;
  71084. /**
  71085. * Creates a new Color4 from the string containing valid hexadecimal values
  71086. * @param hex defines a string containing valid hexadecimal values
  71087. * @returns a new Color4 object
  71088. */
  71089. static FromHexString(hex: string): Color4;
  71090. /**
  71091. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  71092. * @param left defines the start value
  71093. * @param right defines the end value
  71094. * @param amount defines the gradient factor
  71095. * @returns a new Color4 object
  71096. */
  71097. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  71098. /**
  71099. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  71100. * @param left defines the start value
  71101. * @param right defines the end value
  71102. * @param amount defines the gradient factor
  71103. * @param result defines the Color4 object where to store data
  71104. */
  71105. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  71106. /**
  71107. * Creates a new Color4 from a Color3 and an alpha value
  71108. * @param color3 defines the source Color3 to read from
  71109. * @param alpha defines the alpha component (1.0 by default)
  71110. * @returns a new Color4 object
  71111. */
  71112. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  71113. /**
  71114. * Creates a new Color4 from the starting index element of the given array
  71115. * @param array defines the source array to read from
  71116. * @param offset defines the offset in the source array
  71117. * @returns a new Color4 object
  71118. */
  71119. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  71120. /**
  71121. * Creates a new Color3 from integer values (< 256)
  71122. * @param r defines the red component to read from (value between 0 and 255)
  71123. * @param g defines the green component to read from (value between 0 and 255)
  71124. * @param b defines the blue component to read from (value between 0 and 255)
  71125. * @param a defines the alpha component to read from (value between 0 and 255)
  71126. * @returns a new Color3 object
  71127. */
  71128. static FromInts(r: number, g: number, b: number, a: number): Color4;
  71129. /**
  71130. * Check the content of a given array and convert it to an array containing RGBA data
  71131. * If the original array was already containing count * 4 values then it is returned directly
  71132. * @param colors defines the array to check
  71133. * @param count defines the number of RGBA data to expect
  71134. * @returns an array containing count * 4 values (RGBA)
  71135. */
  71136. static CheckColors4(colors: number[], count: number): number[];
  71137. }
  71138. /**
  71139. * @hidden
  71140. */
  71141. export class TmpColors {
  71142. static Color3: Color3[];
  71143. static Color4: Color4[];
  71144. }
  71145. }
  71146. declare module BABYLON {
  71147. /**
  71148. * Class representing spherical harmonics coefficients to the 3rd degree
  71149. */
  71150. export class SphericalHarmonics {
  71151. /**
  71152. * Defines whether or not the harmonics have been prescaled for rendering.
  71153. */
  71154. preScaled: boolean;
  71155. /**
  71156. * The l0,0 coefficients of the spherical harmonics
  71157. */
  71158. l00: Vector3;
  71159. /**
  71160. * The l1,-1 coefficients of the spherical harmonics
  71161. */
  71162. l1_1: Vector3;
  71163. /**
  71164. * The l1,0 coefficients of the spherical harmonics
  71165. */
  71166. l10: Vector3;
  71167. /**
  71168. * The l1,1 coefficients of the spherical harmonics
  71169. */
  71170. l11: Vector3;
  71171. /**
  71172. * The l2,-2 coefficients of the spherical harmonics
  71173. */
  71174. l2_2: Vector3;
  71175. /**
  71176. * The l2,-1 coefficients of the spherical harmonics
  71177. */
  71178. l2_1: Vector3;
  71179. /**
  71180. * The l2,0 coefficients of the spherical harmonics
  71181. */
  71182. l20: Vector3;
  71183. /**
  71184. * The l2,1 coefficients of the spherical harmonics
  71185. */
  71186. l21: Vector3;
  71187. /**
  71188. * The l2,2 coefficients of the spherical harmonics
  71189. */
  71190. l22: Vector3;
  71191. /**
  71192. * Adds a light to the spherical harmonics
  71193. * @param direction the direction of the light
  71194. * @param color the color of the light
  71195. * @param deltaSolidAngle the delta solid angle of the light
  71196. */
  71197. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  71198. /**
  71199. * Scales the spherical harmonics by the given amount
  71200. * @param scale the amount to scale
  71201. */
  71202. scaleInPlace(scale: number): void;
  71203. /**
  71204. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  71205. *
  71206. * ```
  71207. * E_lm = A_l * L_lm
  71208. * ```
  71209. *
  71210. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  71211. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  71212. * the scaling factors are given in equation 9.
  71213. */
  71214. convertIncidentRadianceToIrradiance(): void;
  71215. /**
  71216. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  71217. *
  71218. * ```
  71219. * L = (1/pi) * E * rho
  71220. * ```
  71221. *
  71222. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  71223. */
  71224. convertIrradianceToLambertianRadiance(): void;
  71225. /**
  71226. * Integrates the reconstruction coefficients directly in to the SH preventing further
  71227. * required operations at run time.
  71228. *
  71229. * This is simply done by scaling back the SH with Ylm constants parameter.
  71230. * The trigonometric part being applied by the shader at run time.
  71231. */
  71232. preScaleForRendering(): void;
  71233. /**
  71234. * Constructs a spherical harmonics from an array.
  71235. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  71236. * @returns the spherical harmonics
  71237. */
  71238. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  71239. /**
  71240. * Gets the spherical harmonics from polynomial
  71241. * @param polynomial the spherical polynomial
  71242. * @returns the spherical harmonics
  71243. */
  71244. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  71245. }
  71246. /**
  71247. * Class representing spherical polynomial coefficients to the 3rd degree
  71248. */
  71249. export class SphericalPolynomial {
  71250. private _harmonics;
  71251. /**
  71252. * The spherical harmonics used to create the polynomials.
  71253. */
  71254. readonly preScaledHarmonics: SphericalHarmonics;
  71255. /**
  71256. * The x coefficients of the spherical polynomial
  71257. */
  71258. x: Vector3;
  71259. /**
  71260. * The y coefficients of the spherical polynomial
  71261. */
  71262. y: Vector3;
  71263. /**
  71264. * The z coefficients of the spherical polynomial
  71265. */
  71266. z: Vector3;
  71267. /**
  71268. * The xx coefficients of the spherical polynomial
  71269. */
  71270. xx: Vector3;
  71271. /**
  71272. * The yy coefficients of the spherical polynomial
  71273. */
  71274. yy: Vector3;
  71275. /**
  71276. * The zz coefficients of the spherical polynomial
  71277. */
  71278. zz: Vector3;
  71279. /**
  71280. * The xy coefficients of the spherical polynomial
  71281. */
  71282. xy: Vector3;
  71283. /**
  71284. * The yz coefficients of the spherical polynomial
  71285. */
  71286. yz: Vector3;
  71287. /**
  71288. * The zx coefficients of the spherical polynomial
  71289. */
  71290. zx: Vector3;
  71291. /**
  71292. * Adds an ambient color to the spherical polynomial
  71293. * @param color the color to add
  71294. */
  71295. addAmbient(color: Color3): void;
  71296. /**
  71297. * Scales the spherical polynomial by the given amount
  71298. * @param scale the amount to scale
  71299. */
  71300. scaleInPlace(scale: number): void;
  71301. /**
  71302. * Gets the spherical polynomial from harmonics
  71303. * @param harmonics the spherical harmonics
  71304. * @returns the spherical polynomial
  71305. */
  71306. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  71307. /**
  71308. * Constructs a spherical polynomial from an array.
  71309. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  71310. * @returns the spherical polynomial
  71311. */
  71312. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  71313. }
  71314. }
  71315. declare module BABYLON {
  71316. /**
  71317. * Define options used to create a render target texture
  71318. */
  71319. export class RenderTargetCreationOptions {
  71320. /**
  71321. * Specifies is mipmaps must be generated
  71322. */
  71323. generateMipMaps?: boolean;
  71324. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  71325. generateDepthBuffer?: boolean;
  71326. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  71327. generateStencilBuffer?: boolean;
  71328. /** Defines texture type (int by default) */
  71329. type?: number;
  71330. /** Defines sampling mode (trilinear by default) */
  71331. samplingMode?: number;
  71332. /** Defines format (RGBA by default) */
  71333. format?: number;
  71334. }
  71335. }
  71336. declare module BABYLON {
  71337. /**
  71338. * @hidden
  71339. **/
  71340. export class _AlphaState {
  71341. private _isAlphaBlendDirty;
  71342. private _isBlendFunctionParametersDirty;
  71343. private _isBlendEquationParametersDirty;
  71344. private _isBlendConstantsDirty;
  71345. private _alphaBlend;
  71346. private _blendFunctionParameters;
  71347. private _blendEquationParameters;
  71348. private _blendConstants;
  71349. /**
  71350. * Initializes the state.
  71351. */
  71352. constructor();
  71353. readonly isDirty: boolean;
  71354. alphaBlend: boolean;
  71355. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  71356. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  71357. setAlphaEquationParameters(rgb: number, alpha: number): void;
  71358. reset(): void;
  71359. apply(gl: WebGLRenderingContext): void;
  71360. }
  71361. }
  71362. declare module BABYLON {
  71363. /**
  71364. * @hidden
  71365. **/
  71366. export class _DepthCullingState {
  71367. private _isDepthTestDirty;
  71368. private _isDepthMaskDirty;
  71369. private _isDepthFuncDirty;
  71370. private _isCullFaceDirty;
  71371. private _isCullDirty;
  71372. private _isZOffsetDirty;
  71373. private _isFrontFaceDirty;
  71374. private _depthTest;
  71375. private _depthMask;
  71376. private _depthFunc;
  71377. private _cull;
  71378. private _cullFace;
  71379. private _zOffset;
  71380. private _frontFace;
  71381. /**
  71382. * Initializes the state.
  71383. */
  71384. constructor();
  71385. readonly isDirty: boolean;
  71386. zOffset: number;
  71387. cullFace: Nullable<number>;
  71388. cull: Nullable<boolean>;
  71389. depthFunc: Nullable<number>;
  71390. depthMask: boolean;
  71391. depthTest: boolean;
  71392. frontFace: Nullable<number>;
  71393. reset(): void;
  71394. apply(gl: WebGLRenderingContext): void;
  71395. }
  71396. }
  71397. declare module BABYLON {
  71398. /**
  71399. * @hidden
  71400. **/
  71401. export class _StencilState {
  71402. /** 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 */
  71403. static readonly ALWAYS: number;
  71404. /** Passed to stencilOperation to specify that stencil value must be kept */
  71405. static readonly KEEP: number;
  71406. /** Passed to stencilOperation to specify that stencil value must be replaced */
  71407. static readonly REPLACE: number;
  71408. private _isStencilTestDirty;
  71409. private _isStencilMaskDirty;
  71410. private _isStencilFuncDirty;
  71411. private _isStencilOpDirty;
  71412. private _stencilTest;
  71413. private _stencilMask;
  71414. private _stencilFunc;
  71415. private _stencilFuncRef;
  71416. private _stencilFuncMask;
  71417. private _stencilOpStencilFail;
  71418. private _stencilOpDepthFail;
  71419. private _stencilOpStencilDepthPass;
  71420. readonly isDirty: boolean;
  71421. stencilFunc: number;
  71422. stencilFuncRef: number;
  71423. stencilFuncMask: number;
  71424. stencilOpStencilFail: number;
  71425. stencilOpDepthFail: number;
  71426. stencilOpStencilDepthPass: number;
  71427. stencilMask: number;
  71428. stencilTest: boolean;
  71429. constructor();
  71430. reset(): void;
  71431. apply(gl: WebGLRenderingContext): void;
  71432. }
  71433. }
  71434. declare module BABYLON {
  71435. /**
  71436. * @hidden
  71437. **/
  71438. export class _TimeToken {
  71439. _startTimeQuery: Nullable<WebGLQuery>;
  71440. _endTimeQuery: Nullable<WebGLQuery>;
  71441. _timeElapsedQuery: Nullable<WebGLQuery>;
  71442. _timeElapsedQueryEnded: boolean;
  71443. }
  71444. }
  71445. declare module BABYLON {
  71446. /**
  71447. * Class used to evalaute queries containing `and` and `or` operators
  71448. */
  71449. export class AndOrNotEvaluator {
  71450. /**
  71451. * Evaluate a query
  71452. * @param query defines the query to evaluate
  71453. * @param evaluateCallback defines the callback used to filter result
  71454. * @returns true if the query matches
  71455. */
  71456. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  71457. private static _HandleParenthesisContent;
  71458. private static _SimplifyNegation;
  71459. }
  71460. }
  71461. declare module BABYLON {
  71462. /**
  71463. * Class used to store custom tags
  71464. */
  71465. export class Tags {
  71466. /**
  71467. * Adds support for tags on the given object
  71468. * @param obj defines the object to use
  71469. */
  71470. static EnableFor(obj: any): void;
  71471. /**
  71472. * Removes tags support
  71473. * @param obj defines the object to use
  71474. */
  71475. static DisableFor(obj: any): void;
  71476. /**
  71477. * Gets a boolean indicating if the given object has tags
  71478. * @param obj defines the object to use
  71479. * @returns a boolean
  71480. */
  71481. static HasTags(obj: any): boolean;
  71482. /**
  71483. * Gets the tags available on a given object
  71484. * @param obj defines the object to use
  71485. * @param asString defines if the tags must be returned as a string instead of an array of strings
  71486. * @returns the tags
  71487. */
  71488. static GetTags(obj: any, asString?: boolean): any;
  71489. /**
  71490. * Adds tags to an object
  71491. * @param obj defines the object to use
  71492. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  71493. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  71494. */
  71495. static AddTagsTo(obj: any, tagsString: string): void;
  71496. /**
  71497. * @hidden
  71498. */
  71499. static _AddTagTo(obj: any, tag: string): void;
  71500. /**
  71501. * Removes specific tags from a specific object
  71502. * @param obj defines the object to use
  71503. * @param tagsString defines the tags to remove
  71504. */
  71505. static RemoveTagsFrom(obj: any, tagsString: string): void;
  71506. /**
  71507. * @hidden
  71508. */
  71509. static _RemoveTagFrom(obj: any, tag: string): void;
  71510. /**
  71511. * Defines if tags hosted on an object match a given query
  71512. * @param obj defines the object to use
  71513. * @param tagsQuery defines the tag query
  71514. * @returns a boolean
  71515. */
  71516. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  71517. }
  71518. }
  71519. declare module BABYLON {
  71520. /**
  71521. * Defines potential orientation for back face culling
  71522. */
  71523. export enum Orientation {
  71524. /**
  71525. * Clockwise
  71526. */
  71527. CW = 0,
  71528. /** Counter clockwise */
  71529. CCW = 1
  71530. }
  71531. /** Class used to represent a Bezier curve */
  71532. export class BezierCurve {
  71533. /**
  71534. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  71535. * @param t defines the time
  71536. * @param x1 defines the left coordinate on X axis
  71537. * @param y1 defines the left coordinate on Y axis
  71538. * @param x2 defines the right coordinate on X axis
  71539. * @param y2 defines the right coordinate on Y axis
  71540. * @returns the interpolated value
  71541. */
  71542. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  71543. }
  71544. /**
  71545. * Defines angle representation
  71546. */
  71547. export class Angle {
  71548. private _radians;
  71549. /**
  71550. * Creates an Angle object of "radians" radians (float).
  71551. * @param radians the angle in radians
  71552. */
  71553. constructor(radians: number);
  71554. /**
  71555. * Get value in degrees
  71556. * @returns the Angle value in degrees (float)
  71557. */
  71558. degrees(): number;
  71559. /**
  71560. * Get value in radians
  71561. * @returns the Angle value in radians (float)
  71562. */
  71563. radians(): number;
  71564. /**
  71565. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  71566. * @param a defines first vector
  71567. * @param b defines second vector
  71568. * @returns a new Angle
  71569. */
  71570. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  71571. /**
  71572. * Gets a new Angle object from the given float in radians
  71573. * @param radians defines the angle value in radians
  71574. * @returns a new Angle
  71575. */
  71576. static FromRadians(radians: number): Angle;
  71577. /**
  71578. * Gets a new Angle object from the given float in degrees
  71579. * @param degrees defines the angle value in degrees
  71580. * @returns a new Angle
  71581. */
  71582. static FromDegrees(degrees: number): Angle;
  71583. }
  71584. /**
  71585. * This represents an arc in a 2d space.
  71586. */
  71587. export class Arc2 {
  71588. /** Defines the start point of the arc */
  71589. startPoint: Vector2;
  71590. /** Defines the mid point of the arc */
  71591. midPoint: Vector2;
  71592. /** Defines the end point of the arc */
  71593. endPoint: Vector2;
  71594. /**
  71595. * Defines the center point of the arc.
  71596. */
  71597. centerPoint: Vector2;
  71598. /**
  71599. * Defines the radius of the arc.
  71600. */
  71601. radius: number;
  71602. /**
  71603. * Defines the angle of the arc (from mid point to end point).
  71604. */
  71605. angle: Angle;
  71606. /**
  71607. * Defines the start angle of the arc (from start point to middle point).
  71608. */
  71609. startAngle: Angle;
  71610. /**
  71611. * Defines the orientation of the arc (clock wise/counter clock wise).
  71612. */
  71613. orientation: Orientation;
  71614. /**
  71615. * Creates an Arc object from the three given points : start, middle and end.
  71616. * @param startPoint Defines the start point of the arc
  71617. * @param midPoint Defines the midlle point of the arc
  71618. * @param endPoint Defines the end point of the arc
  71619. */
  71620. constructor(
  71621. /** Defines the start point of the arc */
  71622. startPoint: Vector2,
  71623. /** Defines the mid point of the arc */
  71624. midPoint: Vector2,
  71625. /** Defines the end point of the arc */
  71626. endPoint: Vector2);
  71627. }
  71628. /**
  71629. * Represents a 2D path made up of multiple 2D points
  71630. */
  71631. export class Path2 {
  71632. private _points;
  71633. private _length;
  71634. /**
  71635. * If the path start and end point are the same
  71636. */
  71637. closed: boolean;
  71638. /**
  71639. * Creates a Path2 object from the starting 2D coordinates x and y.
  71640. * @param x the starting points x value
  71641. * @param y the starting points y value
  71642. */
  71643. constructor(x: number, y: number);
  71644. /**
  71645. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  71646. * @param x the added points x value
  71647. * @param y the added points y value
  71648. * @returns the updated Path2.
  71649. */
  71650. addLineTo(x: number, y: number): Path2;
  71651. /**
  71652. * 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.
  71653. * @param midX middle point x value
  71654. * @param midY middle point y value
  71655. * @param endX end point x value
  71656. * @param endY end point y value
  71657. * @param numberOfSegments (default: 36)
  71658. * @returns the updated Path2.
  71659. */
  71660. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  71661. /**
  71662. * Closes the Path2.
  71663. * @returns the Path2.
  71664. */
  71665. close(): Path2;
  71666. /**
  71667. * Gets the sum of the distance between each sequential point in the path
  71668. * @returns the Path2 total length (float).
  71669. */
  71670. length(): number;
  71671. /**
  71672. * Gets the points which construct the path
  71673. * @returns the Path2 internal array of points.
  71674. */
  71675. getPoints(): Vector2[];
  71676. /**
  71677. * Retreives the point at the distance aways from the starting point
  71678. * @param normalizedLengthPosition the length along the path to retreive the point from
  71679. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  71680. */
  71681. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  71682. /**
  71683. * Creates a new path starting from an x and y position
  71684. * @param x starting x value
  71685. * @param y starting y value
  71686. * @returns a new Path2 starting at the coordinates (x, y).
  71687. */
  71688. static StartingAt(x: number, y: number): Path2;
  71689. }
  71690. /**
  71691. * Represents a 3D path made up of multiple 3D points
  71692. */
  71693. export class Path3D {
  71694. /**
  71695. * an array of Vector3, the curve axis of the Path3D
  71696. */
  71697. path: Vector3[];
  71698. private _curve;
  71699. private _distances;
  71700. private _tangents;
  71701. private _normals;
  71702. private _binormals;
  71703. private _raw;
  71704. /**
  71705. * new Path3D(path, normal, raw)
  71706. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  71707. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  71708. * @param path an array of Vector3, the curve axis of the Path3D
  71709. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  71710. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  71711. */
  71712. constructor(
  71713. /**
  71714. * an array of Vector3, the curve axis of the Path3D
  71715. */
  71716. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  71717. /**
  71718. * Returns the Path3D array of successive Vector3 designing its curve.
  71719. * @returns the Path3D array of successive Vector3 designing its curve.
  71720. */
  71721. getCurve(): Vector3[];
  71722. /**
  71723. * Returns an array populated with tangent vectors on each Path3D curve point.
  71724. * @returns an array populated with tangent vectors on each Path3D curve point.
  71725. */
  71726. getTangents(): Vector3[];
  71727. /**
  71728. * Returns an array populated with normal vectors on each Path3D curve point.
  71729. * @returns an array populated with normal vectors on each Path3D curve point.
  71730. */
  71731. getNormals(): Vector3[];
  71732. /**
  71733. * Returns an array populated with binormal vectors on each Path3D curve point.
  71734. * @returns an array populated with binormal vectors on each Path3D curve point.
  71735. */
  71736. getBinormals(): Vector3[];
  71737. /**
  71738. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  71739. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  71740. */
  71741. getDistances(): number[];
  71742. /**
  71743. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  71744. * @param path path which all values are copied into the curves points
  71745. * @param firstNormal which should be projected onto the curve
  71746. * @returns the same object updated.
  71747. */
  71748. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  71749. private _compute;
  71750. private _getFirstNonNullVector;
  71751. private _getLastNonNullVector;
  71752. private _normalVector;
  71753. }
  71754. /**
  71755. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71756. * A Curve3 is designed from a series of successive Vector3.
  71757. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  71758. */
  71759. export class Curve3 {
  71760. private _points;
  71761. private _length;
  71762. /**
  71763. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  71764. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  71765. * @param v1 (Vector3) the control point
  71766. * @param v2 (Vector3) the end point of the Quadratic Bezier
  71767. * @param nbPoints (integer) the wanted number of points in the curve
  71768. * @returns the created Curve3
  71769. */
  71770. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71771. /**
  71772. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  71773. * @param v0 (Vector3) the origin point of the Cubic Bezier
  71774. * @param v1 (Vector3) the first control point
  71775. * @param v2 (Vector3) the second control point
  71776. * @param v3 (Vector3) the end point of the Cubic Bezier
  71777. * @param nbPoints (integer) the wanted number of points in the curve
  71778. * @returns the created Curve3
  71779. */
  71780. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71781. /**
  71782. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  71783. * @param p1 (Vector3) the origin point of the Hermite Spline
  71784. * @param t1 (Vector3) the tangent vector at the origin point
  71785. * @param p2 (Vector3) the end point of the Hermite Spline
  71786. * @param t2 (Vector3) the tangent vector at the end point
  71787. * @param nbPoints (integer) the wanted number of points in the curve
  71788. * @returns the created Curve3
  71789. */
  71790. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71791. /**
  71792. * Returns a Curve3 object along a CatmullRom Spline curve :
  71793. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  71794. * @param nbPoints (integer) the wanted number of points between each curve control points
  71795. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  71796. * @returns the created Curve3
  71797. */
  71798. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  71799. /**
  71800. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71801. * A Curve3 is designed from a series of successive Vector3.
  71802. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  71803. * @param points points which make up the curve
  71804. */
  71805. constructor(points: Vector3[]);
  71806. /**
  71807. * @returns the Curve3 stored array of successive Vector3
  71808. */
  71809. getPoints(): Vector3[];
  71810. /**
  71811. * @returns the computed length (float) of the curve.
  71812. */
  71813. length(): number;
  71814. /**
  71815. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  71816. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  71817. * curveA and curveB keep unchanged.
  71818. * @param curve the curve to continue from this curve
  71819. * @returns the newly constructed curve
  71820. */
  71821. continue(curve: DeepImmutable<Curve3>): Curve3;
  71822. private _computeLength;
  71823. }
  71824. }
  71825. declare module BABYLON {
  71826. /**
  71827. * This represents the main contract an easing function should follow.
  71828. * Easing functions are used throughout the animation system.
  71829. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71830. */
  71831. export interface IEasingFunction {
  71832. /**
  71833. * Given an input gradient between 0 and 1, this returns the corrseponding value
  71834. * of the easing function.
  71835. * The link below provides some of the most common examples of easing functions.
  71836. * @see https://easings.net/
  71837. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71838. * @returns the corresponding value on the curve defined by the easing function
  71839. */
  71840. ease(gradient: number): number;
  71841. }
  71842. /**
  71843. * Base class used for every default easing function.
  71844. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71845. */
  71846. export class EasingFunction implements IEasingFunction {
  71847. /**
  71848. * Interpolation follows the mathematical formula associated with the easing function.
  71849. */
  71850. static readonly EASINGMODE_EASEIN: number;
  71851. /**
  71852. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  71853. */
  71854. static readonly EASINGMODE_EASEOUT: number;
  71855. /**
  71856. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  71857. */
  71858. static readonly EASINGMODE_EASEINOUT: number;
  71859. private _easingMode;
  71860. /**
  71861. * Sets the easing mode of the current function.
  71862. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  71863. */
  71864. setEasingMode(easingMode: number): void;
  71865. /**
  71866. * Gets the current easing mode.
  71867. * @returns the easing mode
  71868. */
  71869. getEasingMode(): number;
  71870. /**
  71871. * @hidden
  71872. */
  71873. easeInCore(gradient: number): number;
  71874. /**
  71875. * Given an input gradient between 0 and 1, this returns the corresponding value
  71876. * of the easing function.
  71877. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71878. * @returns the corresponding value on the curve defined by the easing function
  71879. */
  71880. ease(gradient: number): number;
  71881. }
  71882. /**
  71883. * Easing function with a circle shape (see link below).
  71884. * @see https://easings.net/#easeInCirc
  71885. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71886. */
  71887. export class CircleEase extends EasingFunction implements IEasingFunction {
  71888. /** @hidden */
  71889. easeInCore(gradient: number): number;
  71890. }
  71891. /**
  71892. * Easing function with a ease back shape (see link below).
  71893. * @see https://easings.net/#easeInBack
  71894. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71895. */
  71896. export class BackEase extends EasingFunction implements IEasingFunction {
  71897. /** Defines the amplitude of the function */
  71898. amplitude: number;
  71899. /**
  71900. * Instantiates a back ease easing
  71901. * @see https://easings.net/#easeInBack
  71902. * @param amplitude Defines the amplitude of the function
  71903. */
  71904. constructor(
  71905. /** Defines the amplitude of the function */
  71906. amplitude?: number);
  71907. /** @hidden */
  71908. easeInCore(gradient: number): number;
  71909. }
  71910. /**
  71911. * Easing function with a bouncing shape (see link below).
  71912. * @see https://easings.net/#easeInBounce
  71913. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71914. */
  71915. export class BounceEase extends EasingFunction implements IEasingFunction {
  71916. /** Defines the number of bounces */
  71917. bounces: number;
  71918. /** Defines the amplitude of the bounce */
  71919. bounciness: number;
  71920. /**
  71921. * Instantiates a bounce easing
  71922. * @see https://easings.net/#easeInBounce
  71923. * @param bounces Defines the number of bounces
  71924. * @param bounciness Defines the amplitude of the bounce
  71925. */
  71926. constructor(
  71927. /** Defines the number of bounces */
  71928. bounces?: number,
  71929. /** Defines the amplitude of the bounce */
  71930. bounciness?: number);
  71931. /** @hidden */
  71932. easeInCore(gradient: number): number;
  71933. }
  71934. /**
  71935. * Easing function with a power of 3 shape (see link below).
  71936. * @see https://easings.net/#easeInCubic
  71937. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71938. */
  71939. export class CubicEase extends EasingFunction implements IEasingFunction {
  71940. /** @hidden */
  71941. easeInCore(gradient: number): number;
  71942. }
  71943. /**
  71944. * Easing function with an elastic shape (see link below).
  71945. * @see https://easings.net/#easeInElastic
  71946. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71947. */
  71948. export class ElasticEase extends EasingFunction implements IEasingFunction {
  71949. /** Defines the number of oscillations*/
  71950. oscillations: number;
  71951. /** Defines the amplitude of the oscillations*/
  71952. springiness: number;
  71953. /**
  71954. * Instantiates an elastic easing function
  71955. * @see https://easings.net/#easeInElastic
  71956. * @param oscillations Defines the number of oscillations
  71957. * @param springiness Defines the amplitude of the oscillations
  71958. */
  71959. constructor(
  71960. /** Defines the number of oscillations*/
  71961. oscillations?: number,
  71962. /** Defines the amplitude of the oscillations*/
  71963. springiness?: number);
  71964. /** @hidden */
  71965. easeInCore(gradient: number): number;
  71966. }
  71967. /**
  71968. * Easing function with an exponential shape (see link below).
  71969. * @see https://easings.net/#easeInExpo
  71970. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71971. */
  71972. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  71973. /** Defines the exponent of the function */
  71974. exponent: number;
  71975. /**
  71976. * Instantiates an exponential easing function
  71977. * @see https://easings.net/#easeInExpo
  71978. * @param exponent Defines the exponent of the function
  71979. */
  71980. constructor(
  71981. /** Defines the exponent of the function */
  71982. exponent?: number);
  71983. /** @hidden */
  71984. easeInCore(gradient: number): number;
  71985. }
  71986. /**
  71987. * Easing function with a power shape (see link below).
  71988. * @see https://easings.net/#easeInQuad
  71989. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71990. */
  71991. export class PowerEase extends EasingFunction implements IEasingFunction {
  71992. /** Defines the power of the function */
  71993. power: number;
  71994. /**
  71995. * Instantiates an power base easing function
  71996. * @see https://easings.net/#easeInQuad
  71997. * @param power Defines the power of the function
  71998. */
  71999. constructor(
  72000. /** Defines the power of the function */
  72001. power?: number);
  72002. /** @hidden */
  72003. easeInCore(gradient: number): number;
  72004. }
  72005. /**
  72006. * Easing function with a power of 2 shape (see link below).
  72007. * @see https://easings.net/#easeInQuad
  72008. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72009. */
  72010. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  72011. /** @hidden */
  72012. easeInCore(gradient: number): number;
  72013. }
  72014. /**
  72015. * Easing function with a power of 4 shape (see link below).
  72016. * @see https://easings.net/#easeInQuart
  72017. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72018. */
  72019. export class QuarticEase extends EasingFunction implements IEasingFunction {
  72020. /** @hidden */
  72021. easeInCore(gradient: number): number;
  72022. }
  72023. /**
  72024. * Easing function with a power of 5 shape (see link below).
  72025. * @see https://easings.net/#easeInQuint
  72026. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72027. */
  72028. export class QuinticEase extends EasingFunction implements IEasingFunction {
  72029. /** @hidden */
  72030. easeInCore(gradient: number): number;
  72031. }
  72032. /**
  72033. * Easing function with a sin shape (see link below).
  72034. * @see https://easings.net/#easeInSine
  72035. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72036. */
  72037. export class SineEase extends EasingFunction implements IEasingFunction {
  72038. /** @hidden */
  72039. easeInCore(gradient: number): number;
  72040. }
  72041. /**
  72042. * Easing function with a bezier shape (see link below).
  72043. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72044. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72045. */
  72046. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  72047. /** Defines the x component of the start tangent in the bezier curve */
  72048. x1: number;
  72049. /** Defines the y component of the start tangent in the bezier curve */
  72050. y1: number;
  72051. /** Defines the x component of the end tangent in the bezier curve */
  72052. x2: number;
  72053. /** Defines the y component of the end tangent in the bezier curve */
  72054. y2: number;
  72055. /**
  72056. * Instantiates a bezier function
  72057. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72058. * @param x1 Defines the x component of the start tangent in the bezier curve
  72059. * @param y1 Defines the y component of the start tangent in the bezier curve
  72060. * @param x2 Defines the x component of the end tangent in the bezier curve
  72061. * @param y2 Defines the y component of the end tangent in the bezier curve
  72062. */
  72063. constructor(
  72064. /** Defines the x component of the start tangent in the bezier curve */
  72065. x1?: number,
  72066. /** Defines the y component of the start tangent in the bezier curve */
  72067. y1?: number,
  72068. /** Defines the x component of the end tangent in the bezier curve */
  72069. x2?: number,
  72070. /** Defines the y component of the end tangent in the bezier curve */
  72071. y2?: number);
  72072. /** @hidden */
  72073. easeInCore(gradient: number): number;
  72074. }
  72075. }
  72076. declare module BABYLON {
  72077. /**
  72078. * Defines an interface which represents an animation key frame
  72079. */
  72080. export interface IAnimationKey {
  72081. /**
  72082. * Frame of the key frame
  72083. */
  72084. frame: number;
  72085. /**
  72086. * Value at the specifies key frame
  72087. */
  72088. value: any;
  72089. /**
  72090. * The input tangent for the cubic hermite spline
  72091. */
  72092. inTangent?: any;
  72093. /**
  72094. * The output tangent for the cubic hermite spline
  72095. */
  72096. outTangent?: any;
  72097. /**
  72098. * The animation interpolation type
  72099. */
  72100. interpolation?: AnimationKeyInterpolation;
  72101. }
  72102. /**
  72103. * Enum for the animation key frame interpolation type
  72104. */
  72105. export enum AnimationKeyInterpolation {
  72106. /**
  72107. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  72108. */
  72109. STEP = 1
  72110. }
  72111. }
  72112. declare module BABYLON {
  72113. /**
  72114. * Represents the range of an animation
  72115. */
  72116. export class AnimationRange {
  72117. /**The name of the animation range**/
  72118. name: string;
  72119. /**The starting frame of the animation */
  72120. from: number;
  72121. /**The ending frame of the animation*/
  72122. to: number;
  72123. /**
  72124. * Initializes the range of an animation
  72125. * @param name The name of the animation range
  72126. * @param from The starting frame of the animation
  72127. * @param to The ending frame of the animation
  72128. */
  72129. constructor(
  72130. /**The name of the animation range**/
  72131. name: string,
  72132. /**The starting frame of the animation */
  72133. from: number,
  72134. /**The ending frame of the animation*/
  72135. to: number);
  72136. /**
  72137. * Makes a copy of the animation range
  72138. * @returns A copy of the animation range
  72139. */
  72140. clone(): AnimationRange;
  72141. }
  72142. }
  72143. declare module BABYLON {
  72144. /**
  72145. * Composed of a frame, and an action function
  72146. */
  72147. export class AnimationEvent {
  72148. /** The frame for which the event is triggered **/
  72149. frame: number;
  72150. /** The event to perform when triggered **/
  72151. action: (currentFrame: number) => void;
  72152. /** Specifies if the event should be triggered only once**/
  72153. onlyOnce?: boolean | undefined;
  72154. /**
  72155. * Specifies if the animation event is done
  72156. */
  72157. isDone: boolean;
  72158. /**
  72159. * Initializes the animation event
  72160. * @param frame The frame for which the event is triggered
  72161. * @param action The event to perform when triggered
  72162. * @param onlyOnce Specifies if the event should be triggered only once
  72163. */
  72164. constructor(
  72165. /** The frame for which the event is triggered **/
  72166. frame: number,
  72167. /** The event to perform when triggered **/
  72168. action: (currentFrame: number) => void,
  72169. /** Specifies if the event should be triggered only once**/
  72170. onlyOnce?: boolean | undefined);
  72171. /** @hidden */
  72172. _clone(): AnimationEvent;
  72173. }
  72174. }
  72175. declare module BABYLON {
  72176. /**
  72177. * Interface used to define a behavior
  72178. */
  72179. export interface Behavior<T> {
  72180. /** gets or sets behavior's name */
  72181. name: string;
  72182. /**
  72183. * Function called when the behavior needs to be initialized (after attaching it to a target)
  72184. */
  72185. init(): void;
  72186. /**
  72187. * Called when the behavior is attached to a target
  72188. * @param target defines the target where the behavior is attached to
  72189. */
  72190. attach(target: T): void;
  72191. /**
  72192. * Called when the behavior is detached from its target
  72193. */
  72194. detach(): void;
  72195. }
  72196. /**
  72197. * Interface implemented by classes supporting behaviors
  72198. */
  72199. export interface IBehaviorAware<T> {
  72200. /**
  72201. * Attach a behavior
  72202. * @param behavior defines the behavior to attach
  72203. * @returns the current host
  72204. */
  72205. addBehavior(behavior: Behavior<T>): T;
  72206. /**
  72207. * Remove a behavior from the current object
  72208. * @param behavior defines the behavior to detach
  72209. * @returns the current host
  72210. */
  72211. removeBehavior(behavior: Behavior<T>): T;
  72212. /**
  72213. * Gets a behavior using its name to search
  72214. * @param name defines the name to search
  72215. * @returns the behavior or null if not found
  72216. */
  72217. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  72218. }
  72219. }
  72220. declare module BABYLON {
  72221. /**
  72222. * Defines an array and its length.
  72223. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  72224. */
  72225. export interface ISmartArrayLike<T> {
  72226. /**
  72227. * The data of the array.
  72228. */
  72229. data: Array<T>;
  72230. /**
  72231. * The active length of the array.
  72232. */
  72233. length: number;
  72234. }
  72235. /**
  72236. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72237. */
  72238. export class SmartArray<T> implements ISmartArrayLike<T> {
  72239. /**
  72240. * The full set of data from the array.
  72241. */
  72242. data: Array<T>;
  72243. /**
  72244. * The active length of the array.
  72245. */
  72246. length: number;
  72247. protected _id: number;
  72248. /**
  72249. * Instantiates a Smart Array.
  72250. * @param capacity defines the default capacity of the array.
  72251. */
  72252. constructor(capacity: number);
  72253. /**
  72254. * Pushes a value at the end of the active data.
  72255. * @param value defines the object to push in the array.
  72256. */
  72257. push(value: T): void;
  72258. /**
  72259. * Iterates over the active data and apply the lambda to them.
  72260. * @param func defines the action to apply on each value.
  72261. */
  72262. forEach(func: (content: T) => void): void;
  72263. /**
  72264. * Sorts the full sets of data.
  72265. * @param compareFn defines the comparison function to apply.
  72266. */
  72267. sort(compareFn: (a: T, b: T) => number): void;
  72268. /**
  72269. * Resets the active data to an empty array.
  72270. */
  72271. reset(): void;
  72272. /**
  72273. * Releases all the data from the array as well as the array.
  72274. */
  72275. dispose(): void;
  72276. /**
  72277. * Concats the active data with a given array.
  72278. * @param array defines the data to concatenate with.
  72279. */
  72280. concat(array: any): void;
  72281. /**
  72282. * Returns the position of a value in the active data.
  72283. * @param value defines the value to find the index for
  72284. * @returns the index if found in the active data otherwise -1
  72285. */
  72286. indexOf(value: T): number;
  72287. /**
  72288. * Returns whether an element is part of the active data.
  72289. * @param value defines the value to look for
  72290. * @returns true if found in the active data otherwise false
  72291. */
  72292. contains(value: T): boolean;
  72293. private static _GlobalId;
  72294. }
  72295. /**
  72296. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72297. * The data in this array can only be present once
  72298. */
  72299. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  72300. private _duplicateId;
  72301. /**
  72302. * Pushes a value at the end of the active data.
  72303. * THIS DOES NOT PREVENT DUPPLICATE DATA
  72304. * @param value defines the object to push in the array.
  72305. */
  72306. push(value: T): void;
  72307. /**
  72308. * Pushes a value at the end of the active data.
  72309. * If the data is already present, it won t be added again
  72310. * @param value defines the object to push in the array.
  72311. * @returns true if added false if it was already present
  72312. */
  72313. pushNoDuplicate(value: T): boolean;
  72314. /**
  72315. * Resets the active data to an empty array.
  72316. */
  72317. reset(): void;
  72318. /**
  72319. * Concats the active data with a given array.
  72320. * This ensures no dupplicate will be present in the result.
  72321. * @param array defines the data to concatenate with.
  72322. */
  72323. concatWithNoDuplicate(array: any): void;
  72324. }
  72325. }
  72326. declare module BABYLON {
  72327. /**
  72328. * @ignore
  72329. * This is a list of all the different input types that are available in the application.
  72330. * Fo instance: ArcRotateCameraGamepadInput...
  72331. */
  72332. export var CameraInputTypes: {};
  72333. /**
  72334. * This is the contract to implement in order to create a new input class.
  72335. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  72336. */
  72337. export interface ICameraInput<TCamera extends Camera> {
  72338. /**
  72339. * Defines the camera the input is attached to.
  72340. */
  72341. camera: Nullable<TCamera>;
  72342. /**
  72343. * Gets the class name of the current intput.
  72344. * @returns the class name
  72345. */
  72346. getClassName(): string;
  72347. /**
  72348. * Get the friendly name associated with the input class.
  72349. * @returns the input friendly name
  72350. */
  72351. getSimpleName(): string;
  72352. /**
  72353. * Attach the input controls to a specific dom element to get the input from.
  72354. * @param element Defines the element the controls should be listened from
  72355. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72356. */
  72357. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72358. /**
  72359. * Detach the current controls from the specified dom element.
  72360. * @param element Defines the element to stop listening the inputs from
  72361. */
  72362. detachControl(element: Nullable<HTMLElement>): void;
  72363. /**
  72364. * Update the current camera state depending on the inputs that have been used this frame.
  72365. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72366. */
  72367. checkInputs?: () => void;
  72368. }
  72369. /**
  72370. * Represents a map of input types to input instance or input index to input instance.
  72371. */
  72372. export interface CameraInputsMap<TCamera extends Camera> {
  72373. /**
  72374. * Accessor to the input by input type.
  72375. */
  72376. [name: string]: ICameraInput<TCamera>;
  72377. /**
  72378. * Accessor to the input by input index.
  72379. */
  72380. [idx: number]: ICameraInput<TCamera>;
  72381. }
  72382. /**
  72383. * This represents the input manager used within a camera.
  72384. * It helps dealing with all the different kind of input attached to a camera.
  72385. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72386. */
  72387. export class CameraInputsManager<TCamera extends Camera> {
  72388. /**
  72389. * Defines the list of inputs attahed to the camera.
  72390. */
  72391. attached: CameraInputsMap<TCamera>;
  72392. /**
  72393. * Defines the dom element the camera is collecting inputs from.
  72394. * This is null if the controls have not been attached.
  72395. */
  72396. attachedElement: Nullable<HTMLElement>;
  72397. /**
  72398. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72399. */
  72400. noPreventDefault: boolean;
  72401. /**
  72402. * Defined the camera the input manager belongs to.
  72403. */
  72404. camera: TCamera;
  72405. /**
  72406. * Update the current camera state depending on the inputs that have been used this frame.
  72407. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72408. */
  72409. checkInputs: () => void;
  72410. /**
  72411. * Instantiate a new Camera Input Manager.
  72412. * @param camera Defines the camera the input manager blongs to
  72413. */
  72414. constructor(camera: TCamera);
  72415. /**
  72416. * Add an input method to a camera
  72417. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72418. * @param input camera input method
  72419. */
  72420. add(input: ICameraInput<TCamera>): void;
  72421. /**
  72422. * Remove a specific input method from a camera
  72423. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  72424. * @param inputToRemove camera input method
  72425. */
  72426. remove(inputToRemove: ICameraInput<TCamera>): void;
  72427. /**
  72428. * Remove a specific input type from a camera
  72429. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  72430. * @param inputType the type of the input to remove
  72431. */
  72432. removeByType(inputType: string): void;
  72433. private _addCheckInputs;
  72434. /**
  72435. * Attach the input controls to the currently attached dom element to listen the events from.
  72436. * @param input Defines the input to attach
  72437. */
  72438. attachInput(input: ICameraInput<TCamera>): void;
  72439. /**
  72440. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  72441. * @param element Defines the dom element to collect the events from
  72442. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72443. */
  72444. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  72445. /**
  72446. * Detach the current manager inputs controls from a specific dom element.
  72447. * @param element Defines the dom element to collect the events from
  72448. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  72449. */
  72450. detachElement(element: HTMLElement, disconnect?: boolean): void;
  72451. /**
  72452. * Rebuild the dynamic inputCheck function from the current list of
  72453. * defined inputs in the manager.
  72454. */
  72455. rebuildInputCheck(): void;
  72456. /**
  72457. * Remove all attached input methods from a camera
  72458. */
  72459. clear(): void;
  72460. /**
  72461. * Serialize the current input manager attached to a camera.
  72462. * This ensures than once parsed,
  72463. * the input associated to the camera will be identical to the current ones
  72464. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  72465. */
  72466. serialize(serializedCamera: any): void;
  72467. /**
  72468. * Parses an input manager serialized JSON to restore the previous list of inputs
  72469. * and states associated to a camera.
  72470. * @param parsedCamera Defines the JSON to parse
  72471. */
  72472. parse(parsedCamera: any): void;
  72473. }
  72474. }
  72475. declare module BABYLON {
  72476. /**
  72477. * @hidden
  72478. */
  72479. export class IntersectionInfo {
  72480. bu: Nullable<number>;
  72481. bv: Nullable<number>;
  72482. distance: number;
  72483. faceId: number;
  72484. subMeshId: number;
  72485. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  72486. }
  72487. }
  72488. declare module BABYLON {
  72489. /**
  72490. * Represens a plane by the equation ax + by + cz + d = 0
  72491. */
  72492. export class Plane {
  72493. private static _TmpMatrix;
  72494. /**
  72495. * Normal of the plane (a,b,c)
  72496. */
  72497. normal: Vector3;
  72498. /**
  72499. * d component of the plane
  72500. */
  72501. d: number;
  72502. /**
  72503. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  72504. * @param a a component of the plane
  72505. * @param b b component of the plane
  72506. * @param c c component of the plane
  72507. * @param d d component of the plane
  72508. */
  72509. constructor(a: number, b: number, c: number, d: number);
  72510. /**
  72511. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  72512. */
  72513. asArray(): number[];
  72514. /**
  72515. * @returns a new plane copied from the current Plane.
  72516. */
  72517. clone(): Plane;
  72518. /**
  72519. * @returns the string "Plane".
  72520. */
  72521. getClassName(): string;
  72522. /**
  72523. * @returns the Plane hash code.
  72524. */
  72525. getHashCode(): number;
  72526. /**
  72527. * Normalize the current Plane in place.
  72528. * @returns the updated Plane.
  72529. */
  72530. normalize(): Plane;
  72531. /**
  72532. * Applies a transformation the plane and returns the result
  72533. * @param transformation the transformation matrix to be applied to the plane
  72534. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  72535. */
  72536. transform(transformation: DeepImmutable<Matrix>): Plane;
  72537. /**
  72538. * Calcualtte the dot product between the point and the plane normal
  72539. * @param point point to calculate the dot product with
  72540. * @returns the dot product (float) of the point coordinates and the plane normal.
  72541. */
  72542. dotCoordinate(point: DeepImmutable<Vector3>): number;
  72543. /**
  72544. * Updates the current Plane from the plane defined by the three given points.
  72545. * @param point1 one of the points used to contruct the plane
  72546. * @param point2 one of the points used to contruct the plane
  72547. * @param point3 one of the points used to contruct the plane
  72548. * @returns the updated Plane.
  72549. */
  72550. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  72551. /**
  72552. * Checks if the plane is facing a given direction
  72553. * @param direction the direction to check if the plane is facing
  72554. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  72555. * @returns True is the vector "direction" is the same side than the plane normal.
  72556. */
  72557. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  72558. /**
  72559. * Calculates the distance to a point
  72560. * @param point point to calculate distance to
  72561. * @returns the signed distance (float) from the given point to the Plane.
  72562. */
  72563. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  72564. /**
  72565. * Creates a plane from an array
  72566. * @param array the array to create a plane from
  72567. * @returns a new Plane from the given array.
  72568. */
  72569. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  72570. /**
  72571. * Creates a plane from three points
  72572. * @param point1 point used to create the plane
  72573. * @param point2 point used to create the plane
  72574. * @param point3 point used to create the plane
  72575. * @returns a new Plane defined by the three given points.
  72576. */
  72577. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  72578. /**
  72579. * Creates a plane from an origin point and a normal
  72580. * @param origin origin of the plane to be constructed
  72581. * @param normal normal of the plane to be constructed
  72582. * @returns a new Plane the normal vector to this plane at the given origin point.
  72583. * Note : the vector "normal" is updated because normalized.
  72584. */
  72585. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  72586. /**
  72587. * Calculates the distance from a plane and a point
  72588. * @param origin origin of the plane to be constructed
  72589. * @param normal normal of the plane to be constructed
  72590. * @param point point to calculate distance to
  72591. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  72592. */
  72593. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  72594. }
  72595. }
  72596. declare module BABYLON {
  72597. /**
  72598. * Class used to store bounding sphere information
  72599. */
  72600. export class BoundingSphere {
  72601. /**
  72602. * Gets the center of the bounding sphere in local space
  72603. */
  72604. readonly center: Vector3;
  72605. /**
  72606. * Radius of the bounding sphere in local space
  72607. */
  72608. radius: number;
  72609. /**
  72610. * Gets the center of the bounding sphere in world space
  72611. */
  72612. readonly centerWorld: Vector3;
  72613. /**
  72614. * Radius of the bounding sphere in world space
  72615. */
  72616. radiusWorld: number;
  72617. /**
  72618. * Gets the minimum vector in local space
  72619. */
  72620. readonly minimum: Vector3;
  72621. /**
  72622. * Gets the maximum vector in local space
  72623. */
  72624. readonly maximum: Vector3;
  72625. private _worldMatrix;
  72626. private static readonly TmpVector3;
  72627. /**
  72628. * Creates a new bounding sphere
  72629. * @param min defines the minimum vector (in local space)
  72630. * @param max defines the maximum vector (in local space)
  72631. * @param worldMatrix defines the new world matrix
  72632. */
  72633. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72634. /**
  72635. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  72636. * @param min defines the new minimum vector (in local space)
  72637. * @param max defines the new maximum vector (in local space)
  72638. * @param worldMatrix defines the new world matrix
  72639. */
  72640. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72641. /**
  72642. * Scale the current bounding sphere by applying a scale factor
  72643. * @param factor defines the scale factor to apply
  72644. * @returns the current bounding box
  72645. */
  72646. scale(factor: number): BoundingSphere;
  72647. /**
  72648. * Gets the world matrix of the bounding box
  72649. * @returns a matrix
  72650. */
  72651. getWorldMatrix(): DeepImmutable<Matrix>;
  72652. /** @hidden */
  72653. _update(worldMatrix: DeepImmutable<Matrix>): void;
  72654. /**
  72655. * Tests if the bounding sphere is intersecting the frustum planes
  72656. * @param frustumPlanes defines the frustum planes to test
  72657. * @returns true if there is an intersection
  72658. */
  72659. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72660. /**
  72661. * Tests if the bounding sphere center is in between the frustum planes.
  72662. * Used for optimistic fast inclusion.
  72663. * @param frustumPlanes defines the frustum planes to test
  72664. * @returns true if the sphere center is in between the frustum planes
  72665. */
  72666. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72667. /**
  72668. * Tests if a point is inside the bounding sphere
  72669. * @param point defines the point to test
  72670. * @returns true if the point is inside the bounding sphere
  72671. */
  72672. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72673. /**
  72674. * Checks if two sphere intersct
  72675. * @param sphere0 sphere 0
  72676. * @param sphere1 sphere 1
  72677. * @returns true if the speres intersect
  72678. */
  72679. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  72680. }
  72681. }
  72682. declare module BABYLON {
  72683. /**
  72684. * Class used to store bounding box information
  72685. */
  72686. export class BoundingBox implements ICullable {
  72687. /**
  72688. * Gets the 8 vectors representing the bounding box in local space
  72689. */
  72690. readonly vectors: Vector3[];
  72691. /**
  72692. * Gets the center of the bounding box in local space
  72693. */
  72694. readonly center: Vector3;
  72695. /**
  72696. * Gets the center of the bounding box in world space
  72697. */
  72698. readonly centerWorld: Vector3;
  72699. /**
  72700. * Gets the extend size in local space
  72701. */
  72702. readonly extendSize: Vector3;
  72703. /**
  72704. * Gets the extend size in world space
  72705. */
  72706. readonly extendSizeWorld: Vector3;
  72707. /**
  72708. * Gets the OBB (object bounding box) directions
  72709. */
  72710. readonly directions: Vector3[];
  72711. /**
  72712. * Gets the 8 vectors representing the bounding box in world space
  72713. */
  72714. readonly vectorsWorld: Vector3[];
  72715. /**
  72716. * Gets the minimum vector in world space
  72717. */
  72718. readonly minimumWorld: Vector3;
  72719. /**
  72720. * Gets the maximum vector in world space
  72721. */
  72722. readonly maximumWorld: Vector3;
  72723. /**
  72724. * Gets the minimum vector in local space
  72725. */
  72726. readonly minimum: Vector3;
  72727. /**
  72728. * Gets the maximum vector in local space
  72729. */
  72730. readonly maximum: Vector3;
  72731. private _worldMatrix;
  72732. private static readonly TmpVector3;
  72733. /**
  72734. * @hidden
  72735. */
  72736. _tag: number;
  72737. /**
  72738. * Creates a new bounding box
  72739. * @param min defines the minimum vector (in local space)
  72740. * @param max defines the maximum vector (in local space)
  72741. * @param worldMatrix defines the new world matrix
  72742. */
  72743. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72744. /**
  72745. * Recreates the entire bounding box from scratch as if we call the constructor in place
  72746. * @param min defines the new minimum vector (in local space)
  72747. * @param max defines the new maximum vector (in local space)
  72748. * @param worldMatrix defines the new world matrix
  72749. */
  72750. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72751. /**
  72752. * Scale the current bounding box by applying a scale factor
  72753. * @param factor defines the scale factor to apply
  72754. * @returns the current bounding box
  72755. */
  72756. scale(factor: number): BoundingBox;
  72757. /**
  72758. * Gets the world matrix of the bounding box
  72759. * @returns a matrix
  72760. */
  72761. getWorldMatrix(): DeepImmutable<Matrix>;
  72762. /** @hidden */
  72763. _update(world: DeepImmutable<Matrix>): void;
  72764. /**
  72765. * Tests if the bounding box is intersecting the frustum planes
  72766. * @param frustumPlanes defines the frustum planes to test
  72767. * @returns true if there is an intersection
  72768. */
  72769. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72770. /**
  72771. * Tests if the bounding box is entirely inside the frustum planes
  72772. * @param frustumPlanes defines the frustum planes to test
  72773. * @returns true if there is an inclusion
  72774. */
  72775. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72776. /**
  72777. * Tests if a point is inside the bounding box
  72778. * @param point defines the point to test
  72779. * @returns true if the point is inside the bounding box
  72780. */
  72781. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72782. /**
  72783. * Tests if the bounding box intersects with a bounding sphere
  72784. * @param sphere defines the sphere to test
  72785. * @returns true if there is an intersection
  72786. */
  72787. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  72788. /**
  72789. * Tests if the bounding box intersects with a box defined by a min and max vectors
  72790. * @param min defines the min vector to use
  72791. * @param max defines the max vector to use
  72792. * @returns true if there is an intersection
  72793. */
  72794. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  72795. /**
  72796. * Tests if two bounding boxes are intersections
  72797. * @param box0 defines the first box to test
  72798. * @param box1 defines the second box to test
  72799. * @returns true if there is an intersection
  72800. */
  72801. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  72802. /**
  72803. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  72804. * @param minPoint defines the minimum vector of the bounding box
  72805. * @param maxPoint defines the maximum vector of the bounding box
  72806. * @param sphereCenter defines the sphere center
  72807. * @param sphereRadius defines the sphere radius
  72808. * @returns true if there is an intersection
  72809. */
  72810. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  72811. /**
  72812. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  72813. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  72814. * @param frustumPlanes defines the frustum planes to test
  72815. * @return true if there is an inclusion
  72816. */
  72817. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72818. /**
  72819. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  72820. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  72821. * @param frustumPlanes defines the frustum planes to test
  72822. * @return true if there is an intersection
  72823. */
  72824. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72825. }
  72826. }
  72827. declare module BABYLON {
  72828. /** @hidden */
  72829. export class Collider {
  72830. /** Define if a collision was found */
  72831. collisionFound: boolean;
  72832. /**
  72833. * Define last intersection point in local space
  72834. */
  72835. intersectionPoint: Vector3;
  72836. /**
  72837. * Define last collided mesh
  72838. */
  72839. collidedMesh: Nullable<AbstractMesh>;
  72840. private _collisionPoint;
  72841. private _planeIntersectionPoint;
  72842. private _tempVector;
  72843. private _tempVector2;
  72844. private _tempVector3;
  72845. private _tempVector4;
  72846. private _edge;
  72847. private _baseToVertex;
  72848. private _destinationPoint;
  72849. private _slidePlaneNormal;
  72850. private _displacementVector;
  72851. /** @hidden */
  72852. _radius: Vector3;
  72853. /** @hidden */
  72854. _retry: number;
  72855. private _velocity;
  72856. private _basePoint;
  72857. private _epsilon;
  72858. /** @hidden */
  72859. _velocityWorldLength: number;
  72860. /** @hidden */
  72861. _basePointWorld: Vector3;
  72862. private _velocityWorld;
  72863. private _normalizedVelocity;
  72864. /** @hidden */
  72865. _initialVelocity: Vector3;
  72866. /** @hidden */
  72867. _initialPosition: Vector3;
  72868. private _nearestDistance;
  72869. private _collisionMask;
  72870. collisionMask: number;
  72871. /**
  72872. * Gets the plane normal used to compute the sliding response (in local space)
  72873. */
  72874. readonly slidePlaneNormal: Vector3;
  72875. /** @hidden */
  72876. _initialize(source: Vector3, dir: Vector3, e: number): void;
  72877. /** @hidden */
  72878. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  72879. /** @hidden */
  72880. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  72881. /** @hidden */
  72882. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  72883. /** @hidden */
  72884. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  72885. /** @hidden */
  72886. _getResponse(pos: Vector3, vel: Vector3): void;
  72887. }
  72888. }
  72889. declare module BABYLON {
  72890. /**
  72891. * Interface for cullable objects
  72892. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  72893. */
  72894. export interface ICullable {
  72895. /**
  72896. * Checks if the object or part of the object is in the frustum
  72897. * @param frustumPlanes Camera near/planes
  72898. * @returns true if the object is in frustum otherwise false
  72899. */
  72900. isInFrustum(frustumPlanes: Plane[]): boolean;
  72901. /**
  72902. * Checks if a cullable object (mesh...) is in the camera frustum
  72903. * Unlike isInFrustum this cheks the full bounding box
  72904. * @param frustumPlanes Camera near/planes
  72905. * @returns true if the object is in frustum otherwise false
  72906. */
  72907. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  72908. }
  72909. /**
  72910. * Info for a bounding data of a mesh
  72911. */
  72912. export class BoundingInfo implements ICullable {
  72913. /**
  72914. * Bounding box for the mesh
  72915. */
  72916. readonly boundingBox: BoundingBox;
  72917. /**
  72918. * Bounding sphere for the mesh
  72919. */
  72920. readonly boundingSphere: BoundingSphere;
  72921. private _isLocked;
  72922. private static readonly TmpVector3;
  72923. /**
  72924. * Constructs bounding info
  72925. * @param minimum min vector of the bounding box/sphere
  72926. * @param maximum max vector of the bounding box/sphere
  72927. * @param worldMatrix defines the new world matrix
  72928. */
  72929. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72930. /**
  72931. * Recreates the entire bounding info from scratch as if we call the constructor in place
  72932. * @param min defines the new minimum vector (in local space)
  72933. * @param max defines the new maximum vector (in local space)
  72934. * @param worldMatrix defines the new world matrix
  72935. */
  72936. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72937. /**
  72938. * min vector of the bounding box/sphere
  72939. */
  72940. readonly minimum: Vector3;
  72941. /**
  72942. * max vector of the bounding box/sphere
  72943. */
  72944. readonly maximum: Vector3;
  72945. /**
  72946. * If the info is locked and won't be updated to avoid perf overhead
  72947. */
  72948. isLocked: boolean;
  72949. /**
  72950. * Updates the bounding sphere and box
  72951. * @param world world matrix to be used to update
  72952. */
  72953. update(world: DeepImmutable<Matrix>): void;
  72954. /**
  72955. * Recreate the bounding info to be centered around a specific point given a specific extend.
  72956. * @param center New center of the bounding info
  72957. * @param extend New extend of the bounding info
  72958. * @returns the current bounding info
  72959. */
  72960. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  72961. /**
  72962. * Scale the current bounding info by applying a scale factor
  72963. * @param factor defines the scale factor to apply
  72964. * @returns the current bounding info
  72965. */
  72966. scale(factor: number): BoundingInfo;
  72967. /**
  72968. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  72969. * @param frustumPlanes defines the frustum to test
  72970. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  72971. * @returns true if the bounding info is in the frustum planes
  72972. */
  72973. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  72974. /**
  72975. * Gets the world distance between the min and max points of the bounding box
  72976. */
  72977. readonly diagonalLength: number;
  72978. /**
  72979. * Checks if a cullable object (mesh...) is in the camera frustum
  72980. * Unlike isInFrustum this cheks the full bounding box
  72981. * @param frustumPlanes Camera near/planes
  72982. * @returns true if the object is in frustum otherwise false
  72983. */
  72984. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72985. /** @hidden */
  72986. _checkCollision(collider: Collider): boolean;
  72987. /**
  72988. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  72989. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  72990. * @param point the point to check intersection with
  72991. * @returns if the point intersects
  72992. */
  72993. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72994. /**
  72995. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  72996. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  72997. * @param boundingInfo the bounding info to check intersection with
  72998. * @param precise if the intersection should be done using OBB
  72999. * @returns if the bounding info intersects
  73000. */
  73001. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  73002. }
  73003. }
  73004. declare module BABYLON {
  73005. /**
  73006. * Extracts minimum and maximum values from a list of indexed positions
  73007. * @param positions defines the positions to use
  73008. * @param indices defines the indices to the positions
  73009. * @param indexStart defines the start index
  73010. * @param indexCount defines the end index
  73011. * @param bias defines bias value to add to the result
  73012. * @return minimum and maximum values
  73013. */
  73014. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  73015. minimum: Vector3;
  73016. maximum: Vector3;
  73017. };
  73018. /**
  73019. * Extracts minimum and maximum values from a list of positions
  73020. * @param positions defines the positions to use
  73021. * @param start defines the start index in the positions array
  73022. * @param count defines the number of positions to handle
  73023. * @param bias defines bias value to add to the result
  73024. * @param stride defines the stride size to use (distance between two positions in the positions array)
  73025. * @return minimum and maximum values
  73026. */
  73027. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  73028. minimum: Vector3;
  73029. maximum: Vector3;
  73030. };
  73031. }
  73032. declare module BABYLON {
  73033. /**
  73034. * Enum that determines the text-wrapping mode to use.
  73035. */
  73036. export enum InspectableType {
  73037. /**
  73038. * Checkbox for booleans
  73039. */
  73040. Checkbox = 0,
  73041. /**
  73042. * Sliders for numbers
  73043. */
  73044. Slider = 1,
  73045. /**
  73046. * Vector3
  73047. */
  73048. Vector3 = 2,
  73049. /**
  73050. * Quaternions
  73051. */
  73052. Quaternion = 3,
  73053. /**
  73054. * Color3
  73055. */
  73056. Color3 = 4,
  73057. /**
  73058. * String
  73059. */
  73060. String = 5
  73061. }
  73062. /**
  73063. * Interface used to define custom inspectable properties.
  73064. * This interface is used by the inspector to display custom property grids
  73065. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73066. */
  73067. export interface IInspectable {
  73068. /**
  73069. * Gets the label to display
  73070. */
  73071. label: string;
  73072. /**
  73073. * Gets the name of the property to edit
  73074. */
  73075. propertyName: string;
  73076. /**
  73077. * Gets the type of the editor to use
  73078. */
  73079. type: InspectableType;
  73080. /**
  73081. * Gets the minimum value of the property when using in "slider" mode
  73082. */
  73083. min?: number;
  73084. /**
  73085. * Gets the maximum value of the property when using in "slider" mode
  73086. */
  73087. max?: number;
  73088. /**
  73089. * Gets the setp to use when using in "slider" mode
  73090. */
  73091. step?: number;
  73092. }
  73093. }
  73094. declare module BABYLON {
  73095. /**
  73096. * Class used to provide helper for timing
  73097. */
  73098. export class TimingTools {
  73099. /**
  73100. * Polyfill for setImmediate
  73101. * @param action defines the action to execute after the current execution block
  73102. */
  73103. static SetImmediate(action: () => void): void;
  73104. }
  73105. }
  73106. declare module BABYLON {
  73107. /**
  73108. * Class used to enable instatition of objects by class name
  73109. */
  73110. export class InstantiationTools {
  73111. /**
  73112. * Use this object to register external classes like custom textures or material
  73113. * to allow the laoders to instantiate them
  73114. */
  73115. static RegisteredExternalClasses: {
  73116. [key: string]: Object;
  73117. };
  73118. /**
  73119. * Tries to instantiate a new object from a given class name
  73120. * @param className defines the class name to instantiate
  73121. * @returns the new object or null if the system was not able to do the instantiation
  73122. */
  73123. static Instantiate(className: string): any;
  73124. }
  73125. }
  73126. declare module BABYLON {
  73127. /**
  73128. * This represents the required contract to create a new type of texture loader.
  73129. */
  73130. export interface IInternalTextureLoader {
  73131. /**
  73132. * Defines wether the loader supports cascade loading the different faces.
  73133. */
  73134. supportCascades: boolean;
  73135. /**
  73136. * This returns if the loader support the current file information.
  73137. * @param extension defines the file extension of the file being loaded
  73138. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73139. * @param fallback defines the fallback internal texture if any
  73140. * @param isBase64 defines whether the texture is encoded as a base64
  73141. * @param isBuffer defines whether the texture data are stored as a buffer
  73142. * @returns true if the loader can load the specified file
  73143. */
  73144. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  73145. /**
  73146. * Transform the url before loading if required.
  73147. * @param rootUrl the url of the texture
  73148. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73149. * @returns the transformed texture
  73150. */
  73151. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  73152. /**
  73153. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  73154. * @param rootUrl the url of the texture
  73155. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73156. * @returns the fallback texture
  73157. */
  73158. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  73159. /**
  73160. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  73161. * @param data contains the texture data
  73162. * @param texture defines the BabylonJS internal texture
  73163. * @param createPolynomials will be true if polynomials have been requested
  73164. * @param onLoad defines the callback to trigger once the texture is ready
  73165. * @param onError defines the callback to trigger in case of error
  73166. */
  73167. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  73168. /**
  73169. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  73170. * @param data contains the texture data
  73171. * @param texture defines the BabylonJS internal texture
  73172. * @param callback defines the method to call once ready to upload
  73173. */
  73174. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  73175. }
  73176. }
  73177. declare module BABYLON {
  73178. interface Engine {
  73179. /**
  73180. * Creates a depth stencil cube texture.
  73181. * This is only available in WebGL 2.
  73182. * @param size The size of face edge in the cube texture.
  73183. * @param options The options defining the cube texture.
  73184. * @returns The cube texture
  73185. */
  73186. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  73187. /**
  73188. * Creates a cube texture
  73189. * @param rootUrl defines the url where the files to load is located
  73190. * @param scene defines the current scene
  73191. * @param files defines the list of files to load (1 per face)
  73192. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73193. * @param onLoad defines an optional callback raised when the texture is loaded
  73194. * @param onError defines an optional callback raised if there is an issue to load the texture
  73195. * @param format defines the format of the data
  73196. * @param forcedExtension defines the extension to use to pick the right loader
  73197. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  73198. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73199. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73200. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  73201. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  73202. * @returns the cube texture as an InternalTexture
  73203. */
  73204. 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;
  73205. /**
  73206. * Creates a cube texture
  73207. * @param rootUrl defines the url where the files to load is located
  73208. * @param scene defines the current scene
  73209. * @param files defines the list of files to load (1 per face)
  73210. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73211. * @param onLoad defines an optional callback raised when the texture is loaded
  73212. * @param onError defines an optional callback raised if there is an issue to load the texture
  73213. * @param format defines the format of the data
  73214. * @param forcedExtension defines the extension to use to pick the right loader
  73215. * @returns the cube texture as an InternalTexture
  73216. */
  73217. 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;
  73218. /**
  73219. * Creates a cube texture
  73220. * @param rootUrl defines the url where the files to load is located
  73221. * @param scene defines the current scene
  73222. * @param files defines the list of files to load (1 per face)
  73223. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73224. * @param onLoad defines an optional callback raised when the texture is loaded
  73225. * @param onError defines an optional callback raised if there is an issue to load the texture
  73226. * @param format defines the format of the data
  73227. * @param forcedExtension defines the extension to use to pick the right loader
  73228. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  73229. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73230. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73231. * @returns the cube texture as an InternalTexture
  73232. */
  73233. 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;
  73234. /** @hidden */
  73235. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  73236. /** @hidden */
  73237. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  73238. /** @hidden */
  73239. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  73240. /** @hidden */
  73241. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  73242. }
  73243. }
  73244. declare module BABYLON {
  73245. /**
  73246. * Class for creating a cube texture
  73247. */
  73248. export class CubeTexture extends BaseTexture {
  73249. private _delayedOnLoad;
  73250. /**
  73251. * The url of the texture
  73252. */
  73253. url: string;
  73254. /**
  73255. * Gets or sets the center of the bounding box associated with the cube texture.
  73256. * It must define where the camera used to render the texture was set
  73257. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  73258. */
  73259. boundingBoxPosition: Vector3;
  73260. private _boundingBoxSize;
  73261. /**
  73262. * Gets or sets the size of the bounding box associated with the cube texture
  73263. * When defined, the cubemap will switch to local mode
  73264. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  73265. * @example https://www.babylonjs-playground.com/#RNASML
  73266. */
  73267. /**
  73268. * Returns the bounding box size
  73269. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  73270. */
  73271. boundingBoxSize: Vector3;
  73272. protected _rotationY: number;
  73273. /**
  73274. * Sets texture matrix rotation angle around Y axis in radians.
  73275. */
  73276. /**
  73277. * Gets texture matrix rotation angle around Y axis radians.
  73278. */
  73279. rotationY: number;
  73280. /**
  73281. * Are mip maps generated for this texture or not.
  73282. */
  73283. readonly noMipmap: boolean;
  73284. private _noMipmap;
  73285. private _files;
  73286. private _extensions;
  73287. private _textureMatrix;
  73288. private _format;
  73289. private _createPolynomials;
  73290. /** @hidden */
  73291. _prefiltered: boolean;
  73292. /**
  73293. * Creates a cube texture from an array of image urls
  73294. * @param files defines an array of image urls
  73295. * @param scene defines the hosting scene
  73296. * @param noMipmap specifies if mip maps are not used
  73297. * @returns a cube texture
  73298. */
  73299. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  73300. /**
  73301. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  73302. * @param url defines the url of the prefiltered texture
  73303. * @param scene defines the scene the texture is attached to
  73304. * @param forcedExtension defines the extension of the file if different from the url
  73305. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  73306. * @return the prefiltered texture
  73307. */
  73308. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  73309. /**
  73310. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  73311. * as prefiltered data.
  73312. * @param rootUrl defines the url of the texture or the root name of the six images
  73313. * @param scene defines the scene the texture is attached to
  73314. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  73315. * @param noMipmap defines if mipmaps should be created or not
  73316. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  73317. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  73318. * @param onError defines a callback triggered in case of error during load
  73319. * @param format defines the internal format to use for the texture once loaded
  73320. * @param prefiltered defines whether or not the texture is created from prefiltered data
  73321. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  73322. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  73323. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73324. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73325. * @return the cube texture
  73326. */
  73327. 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);
  73328. /**
  73329. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  73330. */
  73331. readonly isPrefiltered: boolean;
  73332. /**
  73333. * Get the current class name of the texture useful for serialization or dynamic coding.
  73334. * @returns "CubeTexture"
  73335. */
  73336. getClassName(): string;
  73337. /**
  73338. * Update the url (and optional buffer) of this texture if url was null during construction.
  73339. * @param url the url of the texture
  73340. * @param forcedExtension defines the extension to use
  73341. * @param onLoad callback called when the texture is loaded (defaults to null)
  73342. */
  73343. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  73344. /**
  73345. * Delays loading of the cube texture
  73346. * @param forcedExtension defines the extension to use
  73347. */
  73348. delayLoad(forcedExtension?: string): void;
  73349. /**
  73350. * Returns the reflection texture matrix
  73351. * @returns the reflection texture matrix
  73352. */
  73353. getReflectionTextureMatrix(): Matrix;
  73354. /**
  73355. * Sets the reflection texture matrix
  73356. * @param value Reflection texture matrix
  73357. */
  73358. setReflectionTextureMatrix(value: Matrix): void;
  73359. /**
  73360. * Parses text to create a cube texture
  73361. * @param parsedTexture define the serialized text to read from
  73362. * @param scene defines the hosting scene
  73363. * @param rootUrl defines the root url of the cube texture
  73364. * @returns a cube texture
  73365. */
  73366. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  73367. /**
  73368. * Makes a clone, or deep copy, of the cube texture
  73369. * @returns a new cube texture
  73370. */
  73371. clone(): CubeTexture;
  73372. }
  73373. }
  73374. declare module BABYLON {
  73375. /**
  73376. * Manages the defines for the Material
  73377. */
  73378. export class MaterialDefines {
  73379. /** @hidden */
  73380. protected _keys: string[];
  73381. private _isDirty;
  73382. /** @hidden */
  73383. _renderId: number;
  73384. /** @hidden */
  73385. _areLightsDirty: boolean;
  73386. /** @hidden */
  73387. _areLightsDisposed: boolean;
  73388. /** @hidden */
  73389. _areAttributesDirty: boolean;
  73390. /** @hidden */
  73391. _areTexturesDirty: boolean;
  73392. /** @hidden */
  73393. _areFresnelDirty: boolean;
  73394. /** @hidden */
  73395. _areMiscDirty: boolean;
  73396. /** @hidden */
  73397. _areImageProcessingDirty: boolean;
  73398. /** @hidden */
  73399. _normals: boolean;
  73400. /** @hidden */
  73401. _uvs: boolean;
  73402. /** @hidden */
  73403. _needNormals: boolean;
  73404. /** @hidden */
  73405. _needUVs: boolean;
  73406. [id: string]: any;
  73407. /**
  73408. * Specifies if the material needs to be re-calculated
  73409. */
  73410. readonly isDirty: boolean;
  73411. /**
  73412. * Marks the material to indicate that it has been re-calculated
  73413. */
  73414. markAsProcessed(): void;
  73415. /**
  73416. * Marks the material to indicate that it needs to be re-calculated
  73417. */
  73418. markAsUnprocessed(): void;
  73419. /**
  73420. * Marks the material to indicate all of its defines need to be re-calculated
  73421. */
  73422. markAllAsDirty(): void;
  73423. /**
  73424. * Marks the material to indicate that image processing needs to be re-calculated
  73425. */
  73426. markAsImageProcessingDirty(): void;
  73427. /**
  73428. * Marks the material to indicate the lights need to be re-calculated
  73429. * @param disposed Defines whether the light is dirty due to dispose or not
  73430. */
  73431. markAsLightDirty(disposed?: boolean): void;
  73432. /**
  73433. * Marks the attribute state as changed
  73434. */
  73435. markAsAttributesDirty(): void;
  73436. /**
  73437. * Marks the texture state as changed
  73438. */
  73439. markAsTexturesDirty(): void;
  73440. /**
  73441. * Marks the fresnel state as changed
  73442. */
  73443. markAsFresnelDirty(): void;
  73444. /**
  73445. * Marks the misc state as changed
  73446. */
  73447. markAsMiscDirty(): void;
  73448. /**
  73449. * Rebuilds the material defines
  73450. */
  73451. rebuild(): void;
  73452. /**
  73453. * Specifies if two material defines are equal
  73454. * @param other - A material define instance to compare to
  73455. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  73456. */
  73457. isEqual(other: MaterialDefines): boolean;
  73458. /**
  73459. * Clones this instance's defines to another instance
  73460. * @param other - material defines to clone values to
  73461. */
  73462. cloneTo(other: MaterialDefines): void;
  73463. /**
  73464. * Resets the material define values
  73465. */
  73466. reset(): void;
  73467. /**
  73468. * Converts the material define values to a string
  73469. * @returns - String of material define information
  73470. */
  73471. toString(): string;
  73472. }
  73473. }
  73474. declare module BABYLON {
  73475. /**
  73476. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  73477. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  73478. * 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;
  73479. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  73480. */
  73481. export class ColorCurves {
  73482. private _dirty;
  73483. private _tempColor;
  73484. private _globalCurve;
  73485. private _highlightsCurve;
  73486. private _midtonesCurve;
  73487. private _shadowsCurve;
  73488. private _positiveCurve;
  73489. private _negativeCurve;
  73490. private _globalHue;
  73491. private _globalDensity;
  73492. private _globalSaturation;
  73493. private _globalExposure;
  73494. /**
  73495. * Gets the global Hue value.
  73496. * 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).
  73497. */
  73498. /**
  73499. * Sets the global Hue value.
  73500. * 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).
  73501. */
  73502. globalHue: number;
  73503. /**
  73504. * Gets the global Density value.
  73505. * 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.
  73506. * Values less than zero provide a filter of opposite hue.
  73507. */
  73508. /**
  73509. * Sets the global Density value.
  73510. * 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.
  73511. * Values less than zero provide a filter of opposite hue.
  73512. */
  73513. globalDensity: number;
  73514. /**
  73515. * Gets the global Saturation value.
  73516. * 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.
  73517. */
  73518. /**
  73519. * Sets the global Saturation value.
  73520. * 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.
  73521. */
  73522. globalSaturation: number;
  73523. /**
  73524. * Gets the global Exposure value.
  73525. * 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.
  73526. */
  73527. /**
  73528. * Sets the global Exposure value.
  73529. * 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.
  73530. */
  73531. globalExposure: number;
  73532. private _highlightsHue;
  73533. private _highlightsDensity;
  73534. private _highlightsSaturation;
  73535. private _highlightsExposure;
  73536. /**
  73537. * Gets the highlights Hue value.
  73538. * 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).
  73539. */
  73540. /**
  73541. * Sets the highlights Hue value.
  73542. * 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).
  73543. */
  73544. highlightsHue: number;
  73545. /**
  73546. * Gets the highlights Density value.
  73547. * 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.
  73548. * Values less than zero provide a filter of opposite hue.
  73549. */
  73550. /**
  73551. * Sets the highlights Density value.
  73552. * 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.
  73553. * Values less than zero provide a filter of opposite hue.
  73554. */
  73555. highlightsDensity: number;
  73556. /**
  73557. * Gets the highlights Saturation value.
  73558. * 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.
  73559. */
  73560. /**
  73561. * Sets the highlights Saturation value.
  73562. * 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.
  73563. */
  73564. highlightsSaturation: number;
  73565. /**
  73566. * Gets the highlights Exposure value.
  73567. * 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.
  73568. */
  73569. /**
  73570. * Sets the highlights Exposure value.
  73571. * 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.
  73572. */
  73573. highlightsExposure: number;
  73574. private _midtonesHue;
  73575. private _midtonesDensity;
  73576. private _midtonesSaturation;
  73577. private _midtonesExposure;
  73578. /**
  73579. * Gets the midtones Hue value.
  73580. * 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).
  73581. */
  73582. /**
  73583. * Sets the midtones Hue value.
  73584. * 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).
  73585. */
  73586. midtonesHue: number;
  73587. /**
  73588. * Gets the midtones Density value.
  73589. * 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.
  73590. * Values less than zero provide a filter of opposite hue.
  73591. */
  73592. /**
  73593. * Sets the midtones Density value.
  73594. * 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.
  73595. * Values less than zero provide a filter of opposite hue.
  73596. */
  73597. midtonesDensity: number;
  73598. /**
  73599. * Gets the midtones Saturation value.
  73600. * 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.
  73601. */
  73602. /**
  73603. * Sets the midtones Saturation value.
  73604. * 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.
  73605. */
  73606. midtonesSaturation: number;
  73607. /**
  73608. * Gets the midtones Exposure value.
  73609. * 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.
  73610. */
  73611. /**
  73612. * Sets the midtones Exposure value.
  73613. * 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.
  73614. */
  73615. midtonesExposure: number;
  73616. private _shadowsHue;
  73617. private _shadowsDensity;
  73618. private _shadowsSaturation;
  73619. private _shadowsExposure;
  73620. /**
  73621. * Gets the shadows Hue value.
  73622. * 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).
  73623. */
  73624. /**
  73625. * Sets the shadows Hue value.
  73626. * 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).
  73627. */
  73628. shadowsHue: number;
  73629. /**
  73630. * Gets the shadows Density value.
  73631. * 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.
  73632. * Values less than zero provide a filter of opposite hue.
  73633. */
  73634. /**
  73635. * Sets the shadows Density value.
  73636. * 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.
  73637. * Values less than zero provide a filter of opposite hue.
  73638. */
  73639. shadowsDensity: number;
  73640. /**
  73641. * Gets the shadows Saturation value.
  73642. * 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.
  73643. */
  73644. /**
  73645. * Sets the shadows Saturation value.
  73646. * 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.
  73647. */
  73648. shadowsSaturation: number;
  73649. /**
  73650. * Gets the shadows Exposure value.
  73651. * 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.
  73652. */
  73653. /**
  73654. * Sets the shadows Exposure value.
  73655. * 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.
  73656. */
  73657. shadowsExposure: number;
  73658. /**
  73659. * Returns the class name
  73660. * @returns The class name
  73661. */
  73662. getClassName(): string;
  73663. /**
  73664. * Binds the color curves to the shader.
  73665. * @param colorCurves The color curve to bind
  73666. * @param effect The effect to bind to
  73667. * @param positiveUniform The positive uniform shader parameter
  73668. * @param neutralUniform The neutral uniform shader parameter
  73669. * @param negativeUniform The negative uniform shader parameter
  73670. */
  73671. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  73672. /**
  73673. * Prepare the list of uniforms associated with the ColorCurves effects.
  73674. * @param uniformsList The list of uniforms used in the effect
  73675. */
  73676. static PrepareUniforms(uniformsList: string[]): void;
  73677. /**
  73678. * Returns color grading data based on a hue, density, saturation and exposure value.
  73679. * @param filterHue The hue of the color filter.
  73680. * @param filterDensity The density of the color filter.
  73681. * @param saturation The saturation.
  73682. * @param exposure The exposure.
  73683. * @param result The result data container.
  73684. */
  73685. private getColorGradingDataToRef;
  73686. /**
  73687. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  73688. * @param value The input slider value in range [-100,100].
  73689. * @returns Adjusted value.
  73690. */
  73691. private static applyColorGradingSliderNonlinear;
  73692. /**
  73693. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  73694. * @param hue The hue (H) input.
  73695. * @param saturation The saturation (S) input.
  73696. * @param brightness The brightness (B) input.
  73697. * @result An RGBA color represented as Vector4.
  73698. */
  73699. private static fromHSBToRef;
  73700. /**
  73701. * Returns a value clamped between min and max
  73702. * @param value The value to clamp
  73703. * @param min The minimum of value
  73704. * @param max The maximum of value
  73705. * @returns The clamped value.
  73706. */
  73707. private static clamp;
  73708. /**
  73709. * Clones the current color curve instance.
  73710. * @return The cloned curves
  73711. */
  73712. clone(): ColorCurves;
  73713. /**
  73714. * Serializes the current color curve instance to a json representation.
  73715. * @return a JSON representation
  73716. */
  73717. serialize(): any;
  73718. /**
  73719. * Parses the color curve from a json representation.
  73720. * @param source the JSON source to parse
  73721. * @return The parsed curves
  73722. */
  73723. static Parse(source: any): ColorCurves;
  73724. }
  73725. }
  73726. declare module BABYLON {
  73727. /**
  73728. * Interface to follow in your material defines to integrate easily the
  73729. * Image proccessing functions.
  73730. * @hidden
  73731. */
  73732. export interface IImageProcessingConfigurationDefines {
  73733. IMAGEPROCESSING: boolean;
  73734. VIGNETTE: boolean;
  73735. VIGNETTEBLENDMODEMULTIPLY: boolean;
  73736. VIGNETTEBLENDMODEOPAQUE: boolean;
  73737. TONEMAPPING: boolean;
  73738. TONEMAPPING_ACES: boolean;
  73739. CONTRAST: boolean;
  73740. EXPOSURE: boolean;
  73741. COLORCURVES: boolean;
  73742. COLORGRADING: boolean;
  73743. COLORGRADING3D: boolean;
  73744. SAMPLER3DGREENDEPTH: boolean;
  73745. SAMPLER3DBGRMAP: boolean;
  73746. IMAGEPROCESSINGPOSTPROCESS: boolean;
  73747. }
  73748. /**
  73749. * @hidden
  73750. */
  73751. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  73752. IMAGEPROCESSING: boolean;
  73753. VIGNETTE: boolean;
  73754. VIGNETTEBLENDMODEMULTIPLY: boolean;
  73755. VIGNETTEBLENDMODEOPAQUE: boolean;
  73756. TONEMAPPING: boolean;
  73757. TONEMAPPING_ACES: boolean;
  73758. CONTRAST: boolean;
  73759. COLORCURVES: boolean;
  73760. COLORGRADING: boolean;
  73761. COLORGRADING3D: boolean;
  73762. SAMPLER3DGREENDEPTH: boolean;
  73763. SAMPLER3DBGRMAP: boolean;
  73764. IMAGEPROCESSINGPOSTPROCESS: boolean;
  73765. EXPOSURE: boolean;
  73766. constructor();
  73767. }
  73768. /**
  73769. * This groups together the common properties used for image processing either in direct forward pass
  73770. * or through post processing effect depending on the use of the image processing pipeline in your scene
  73771. * or not.
  73772. */
  73773. export class ImageProcessingConfiguration {
  73774. /**
  73775. * Default tone mapping applied in BabylonJS.
  73776. */
  73777. static readonly TONEMAPPING_STANDARD: number;
  73778. /**
  73779. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  73780. * to other engines rendering to increase portability.
  73781. */
  73782. static readonly TONEMAPPING_ACES: number;
  73783. /**
  73784. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  73785. */
  73786. colorCurves: Nullable<ColorCurves>;
  73787. private _colorCurvesEnabled;
  73788. /**
  73789. * Gets wether the color curves effect is enabled.
  73790. */
  73791. /**
  73792. * Sets wether the color curves effect is enabled.
  73793. */
  73794. colorCurvesEnabled: boolean;
  73795. private _colorGradingTexture;
  73796. /**
  73797. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  73798. */
  73799. /**
  73800. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  73801. */
  73802. colorGradingTexture: Nullable<BaseTexture>;
  73803. private _colorGradingEnabled;
  73804. /**
  73805. * Gets wether the color grading effect is enabled.
  73806. */
  73807. /**
  73808. * Sets wether the color grading effect is enabled.
  73809. */
  73810. colorGradingEnabled: boolean;
  73811. private _colorGradingWithGreenDepth;
  73812. /**
  73813. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  73814. */
  73815. /**
  73816. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  73817. */
  73818. colorGradingWithGreenDepth: boolean;
  73819. private _colorGradingBGR;
  73820. /**
  73821. * Gets wether the color grading texture contains BGR values.
  73822. */
  73823. /**
  73824. * Sets wether the color grading texture contains BGR values.
  73825. */
  73826. colorGradingBGR: boolean;
  73827. /** @hidden */
  73828. _exposure: number;
  73829. /**
  73830. * Gets the Exposure used in the effect.
  73831. */
  73832. /**
  73833. * Sets the Exposure used in the effect.
  73834. */
  73835. exposure: number;
  73836. private _toneMappingEnabled;
  73837. /**
  73838. * Gets wether the tone mapping effect is enabled.
  73839. */
  73840. /**
  73841. * Sets wether the tone mapping effect is enabled.
  73842. */
  73843. toneMappingEnabled: boolean;
  73844. private _toneMappingType;
  73845. /**
  73846. * Gets the type of tone mapping effect.
  73847. */
  73848. /**
  73849. * Sets the type of tone mapping effect used in BabylonJS.
  73850. */
  73851. toneMappingType: number;
  73852. protected _contrast: number;
  73853. /**
  73854. * Gets the contrast used in the effect.
  73855. */
  73856. /**
  73857. * Sets the contrast used in the effect.
  73858. */
  73859. contrast: number;
  73860. /**
  73861. * Vignette stretch size.
  73862. */
  73863. vignetteStretch: number;
  73864. /**
  73865. * Vignette centre X Offset.
  73866. */
  73867. vignetteCentreX: number;
  73868. /**
  73869. * Vignette centre Y Offset.
  73870. */
  73871. vignetteCentreY: number;
  73872. /**
  73873. * Vignette weight or intensity of the vignette effect.
  73874. */
  73875. vignetteWeight: number;
  73876. /**
  73877. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  73878. * if vignetteEnabled is set to true.
  73879. */
  73880. vignetteColor: Color4;
  73881. /**
  73882. * Camera field of view used by the Vignette effect.
  73883. */
  73884. vignetteCameraFov: number;
  73885. private _vignetteBlendMode;
  73886. /**
  73887. * Gets the vignette blend mode allowing different kind of effect.
  73888. */
  73889. /**
  73890. * Sets the vignette blend mode allowing different kind of effect.
  73891. */
  73892. vignetteBlendMode: number;
  73893. private _vignetteEnabled;
  73894. /**
  73895. * Gets wether the vignette effect is enabled.
  73896. */
  73897. /**
  73898. * Sets wether the vignette effect is enabled.
  73899. */
  73900. vignetteEnabled: boolean;
  73901. private _applyByPostProcess;
  73902. /**
  73903. * Gets wether the image processing is applied through a post process or not.
  73904. */
  73905. /**
  73906. * Sets wether the image processing is applied through a post process or not.
  73907. */
  73908. applyByPostProcess: boolean;
  73909. private _isEnabled;
  73910. /**
  73911. * Gets wether the image processing is enabled or not.
  73912. */
  73913. /**
  73914. * Sets wether the image processing is enabled or not.
  73915. */
  73916. isEnabled: boolean;
  73917. /**
  73918. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  73919. */
  73920. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  73921. /**
  73922. * Method called each time the image processing information changes requires to recompile the effect.
  73923. */
  73924. protected _updateParameters(): void;
  73925. /**
  73926. * Gets the current class name.
  73927. * @return "ImageProcessingConfiguration"
  73928. */
  73929. getClassName(): string;
  73930. /**
  73931. * Prepare the list of uniforms associated with the Image Processing effects.
  73932. * @param uniforms The list of uniforms used in the effect
  73933. * @param defines the list of defines currently in use
  73934. */
  73935. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  73936. /**
  73937. * Prepare the list of samplers associated with the Image Processing effects.
  73938. * @param samplersList The list of uniforms used in the effect
  73939. * @param defines the list of defines currently in use
  73940. */
  73941. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  73942. /**
  73943. * Prepare the list of defines associated to the shader.
  73944. * @param defines the list of defines to complete
  73945. * @param forPostProcess Define if we are currently in post process mode or not
  73946. */
  73947. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  73948. /**
  73949. * Returns true if all the image processing information are ready.
  73950. * @returns True if ready, otherwise, false
  73951. */
  73952. isReady(): boolean;
  73953. /**
  73954. * Binds the image processing to the shader.
  73955. * @param effect The effect to bind to
  73956. * @param aspectRatio Define the current aspect ratio of the effect
  73957. */
  73958. bind(effect: Effect, aspectRatio?: number): void;
  73959. /**
  73960. * Clones the current image processing instance.
  73961. * @return The cloned image processing
  73962. */
  73963. clone(): ImageProcessingConfiguration;
  73964. /**
  73965. * Serializes the current image processing instance to a json representation.
  73966. * @return a JSON representation
  73967. */
  73968. serialize(): any;
  73969. /**
  73970. * Parses the image processing from a json representation.
  73971. * @param source the JSON source to parse
  73972. * @return The parsed image processing
  73973. */
  73974. static Parse(source: any): ImageProcessingConfiguration;
  73975. private static _VIGNETTEMODE_MULTIPLY;
  73976. private static _VIGNETTEMODE_OPAQUE;
  73977. /**
  73978. * Used to apply the vignette as a mix with the pixel color.
  73979. */
  73980. static readonly VIGNETTEMODE_MULTIPLY: number;
  73981. /**
  73982. * Used to apply the vignette as a replacement of the pixel color.
  73983. */
  73984. static readonly VIGNETTEMODE_OPAQUE: number;
  73985. }
  73986. }
  73987. declare module BABYLON {
  73988. /** @hidden */
  73989. export var postprocessVertexShader: {
  73990. name: string;
  73991. shader: string;
  73992. };
  73993. }
  73994. declare module BABYLON {
  73995. /** Defines supported spaces */
  73996. export enum Space {
  73997. /** Local (object) space */
  73998. LOCAL = 0,
  73999. /** World space */
  74000. WORLD = 1,
  74001. /** Bone space */
  74002. BONE = 2
  74003. }
  74004. /** Defines the 3 main axes */
  74005. export class Axis {
  74006. /** X axis */
  74007. static X: Vector3;
  74008. /** Y axis */
  74009. static Y: Vector3;
  74010. /** Z axis */
  74011. static Z: Vector3;
  74012. }
  74013. }
  74014. declare module BABYLON {
  74015. /**
  74016. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  74017. * This is the base of the follow, arc rotate cameras and Free camera
  74018. * @see http://doc.babylonjs.com/features/cameras
  74019. */
  74020. export class TargetCamera extends Camera {
  74021. private static _RigCamTransformMatrix;
  74022. private static _TargetTransformMatrix;
  74023. private static _TargetFocalPoint;
  74024. /**
  74025. * Define the current direction the camera is moving to
  74026. */
  74027. cameraDirection: Vector3;
  74028. /**
  74029. * Define the current rotation the camera is rotating to
  74030. */
  74031. cameraRotation: Vector2;
  74032. /**
  74033. * When set, the up vector of the camera will be updated by the rotation of the camera
  74034. */
  74035. updateUpVectorFromRotation: boolean;
  74036. private _tmpQuaternion;
  74037. /**
  74038. * Define the current rotation of the camera
  74039. */
  74040. rotation: Vector3;
  74041. /**
  74042. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  74043. */
  74044. rotationQuaternion: Quaternion;
  74045. /**
  74046. * Define the current speed of the camera
  74047. */
  74048. speed: number;
  74049. /**
  74050. * Add cconstraint to the camera to prevent it to move freely in all directions and
  74051. * around all axis.
  74052. */
  74053. noRotationConstraint: boolean;
  74054. /**
  74055. * Define the current target of the camera as an object or a position.
  74056. */
  74057. lockedTarget: any;
  74058. /** @hidden */
  74059. _currentTarget: Vector3;
  74060. /** @hidden */
  74061. _initialFocalDistance: number;
  74062. /** @hidden */
  74063. _viewMatrix: Matrix;
  74064. /** @hidden */
  74065. _camMatrix: Matrix;
  74066. /** @hidden */
  74067. _cameraTransformMatrix: Matrix;
  74068. /** @hidden */
  74069. _cameraRotationMatrix: Matrix;
  74070. /** @hidden */
  74071. _referencePoint: Vector3;
  74072. /** @hidden */
  74073. _transformedReferencePoint: Vector3;
  74074. protected _globalCurrentTarget: Vector3;
  74075. protected _globalCurrentUpVector: Vector3;
  74076. /** @hidden */
  74077. _reset: () => void;
  74078. private _defaultUp;
  74079. /**
  74080. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  74081. * This is the base of the follow, arc rotate cameras and Free camera
  74082. * @see http://doc.babylonjs.com/features/cameras
  74083. * @param name Defines the name of the camera in the scene
  74084. * @param position Defines the start position of the camera in the scene
  74085. * @param scene Defines the scene the camera belongs to
  74086. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  74087. */
  74088. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  74089. /**
  74090. * Gets the position in front of the camera at a given distance.
  74091. * @param distance The distance from the camera we want the position to be
  74092. * @returns the position
  74093. */
  74094. getFrontPosition(distance: number): Vector3;
  74095. /** @hidden */
  74096. _getLockedTargetPosition(): Nullable<Vector3>;
  74097. private _storedPosition;
  74098. private _storedRotation;
  74099. private _storedRotationQuaternion;
  74100. /**
  74101. * Store current camera state of the camera (fov, position, rotation, etc..)
  74102. * @returns the camera
  74103. */
  74104. storeState(): Camera;
  74105. /**
  74106. * Restored camera state. You must call storeState() first
  74107. * @returns whether it was successful or not
  74108. * @hidden
  74109. */
  74110. _restoreStateValues(): boolean;
  74111. /** @hidden */
  74112. _initCache(): void;
  74113. /** @hidden */
  74114. _updateCache(ignoreParentClass?: boolean): void;
  74115. /** @hidden */
  74116. _isSynchronizedViewMatrix(): boolean;
  74117. /** @hidden */
  74118. _computeLocalCameraSpeed(): number;
  74119. /**
  74120. * Defines the target the camera should look at.
  74121. * @param target Defines the new target as a Vector or a mesh
  74122. */
  74123. setTarget(target: Vector3): void;
  74124. /**
  74125. * Return the current target position of the camera. This value is expressed in local space.
  74126. * @returns the target position
  74127. */
  74128. getTarget(): Vector3;
  74129. /** @hidden */
  74130. _decideIfNeedsToMove(): boolean;
  74131. /** @hidden */
  74132. _updatePosition(): void;
  74133. /** @hidden */
  74134. _checkInputs(): void;
  74135. protected _updateCameraRotationMatrix(): void;
  74136. /**
  74137. * 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)
  74138. * @returns the current camera
  74139. */
  74140. private _rotateUpVectorWithCameraRotationMatrix;
  74141. private _cachedRotationZ;
  74142. private _cachedQuaternionRotationZ;
  74143. /** @hidden */
  74144. _getViewMatrix(): Matrix;
  74145. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  74146. /**
  74147. * @hidden
  74148. */
  74149. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  74150. /**
  74151. * @hidden
  74152. */
  74153. _updateRigCameras(): void;
  74154. private _getRigCamPositionAndTarget;
  74155. /**
  74156. * Gets the current object class name.
  74157. * @return the class name
  74158. */
  74159. getClassName(): string;
  74160. }
  74161. }
  74162. declare module BABYLON {
  74163. /**
  74164. * Gather the list of keyboard event types as constants.
  74165. */
  74166. export class KeyboardEventTypes {
  74167. /**
  74168. * The keydown event is fired when a key becomes active (pressed).
  74169. */
  74170. static readonly KEYDOWN: number;
  74171. /**
  74172. * The keyup event is fired when a key has been released.
  74173. */
  74174. static readonly KEYUP: number;
  74175. }
  74176. /**
  74177. * This class is used to store keyboard related info for the onKeyboardObservable event.
  74178. */
  74179. export class KeyboardInfo {
  74180. /**
  74181. * Defines the type of event (KeyboardEventTypes)
  74182. */
  74183. type: number;
  74184. /**
  74185. * Defines the related dom event
  74186. */
  74187. event: KeyboardEvent;
  74188. /**
  74189. * Instantiates a new keyboard info.
  74190. * This class is used to store keyboard related info for the onKeyboardObservable event.
  74191. * @param type Defines the type of event (KeyboardEventTypes)
  74192. * @param event Defines the related dom event
  74193. */
  74194. constructor(
  74195. /**
  74196. * Defines the type of event (KeyboardEventTypes)
  74197. */
  74198. type: number,
  74199. /**
  74200. * Defines the related dom event
  74201. */
  74202. event: KeyboardEvent);
  74203. }
  74204. /**
  74205. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  74206. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  74207. */
  74208. export class KeyboardInfoPre extends KeyboardInfo {
  74209. /**
  74210. * Defines the type of event (KeyboardEventTypes)
  74211. */
  74212. type: number;
  74213. /**
  74214. * Defines the related dom event
  74215. */
  74216. event: KeyboardEvent;
  74217. /**
  74218. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  74219. */
  74220. skipOnPointerObservable: boolean;
  74221. /**
  74222. * Instantiates a new keyboard pre info.
  74223. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  74224. * @param type Defines the type of event (KeyboardEventTypes)
  74225. * @param event Defines the related dom event
  74226. */
  74227. constructor(
  74228. /**
  74229. * Defines the type of event (KeyboardEventTypes)
  74230. */
  74231. type: number,
  74232. /**
  74233. * Defines the related dom event
  74234. */
  74235. event: KeyboardEvent);
  74236. }
  74237. }
  74238. declare module BABYLON {
  74239. /**
  74240. * Manage the keyboard inputs to control the movement of a free camera.
  74241. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74242. */
  74243. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  74244. /**
  74245. * Defines the camera the input is attached to.
  74246. */
  74247. camera: FreeCamera;
  74248. /**
  74249. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  74250. */
  74251. keysUp: number[];
  74252. /**
  74253. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  74254. */
  74255. keysDown: number[];
  74256. /**
  74257. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  74258. */
  74259. keysLeft: number[];
  74260. /**
  74261. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  74262. */
  74263. keysRight: number[];
  74264. private _keys;
  74265. private _onCanvasBlurObserver;
  74266. private _onKeyboardObserver;
  74267. private _engine;
  74268. private _scene;
  74269. /**
  74270. * Attach the input controls to a specific dom element to get the input from.
  74271. * @param element Defines the element the controls should be listened from
  74272. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74273. */
  74274. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74275. /**
  74276. * Detach the current controls from the specified dom element.
  74277. * @param element Defines the element to stop listening the inputs from
  74278. */
  74279. detachControl(element: Nullable<HTMLElement>): void;
  74280. /**
  74281. * Update the current camera state depending on the inputs that have been used this frame.
  74282. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74283. */
  74284. checkInputs(): void;
  74285. /**
  74286. * Gets the class name of the current intput.
  74287. * @returns the class name
  74288. */
  74289. getClassName(): string;
  74290. /** @hidden */
  74291. _onLostFocus(): void;
  74292. /**
  74293. * Get the friendly name associated with the input class.
  74294. * @returns the input friendly name
  74295. */
  74296. getSimpleName(): string;
  74297. }
  74298. }
  74299. declare module BABYLON {
  74300. /**
  74301. * Interface describing all the common properties and methods a shadow light needs to implement.
  74302. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  74303. * as well as binding the different shadow properties to the effects.
  74304. */
  74305. export interface IShadowLight extends Light {
  74306. /**
  74307. * The light id in the scene (used in scene.findLighById for instance)
  74308. */
  74309. id: string;
  74310. /**
  74311. * The position the shdow will be casted from.
  74312. */
  74313. position: Vector3;
  74314. /**
  74315. * In 2d mode (needCube being false), the direction used to cast the shadow.
  74316. */
  74317. direction: Vector3;
  74318. /**
  74319. * The transformed position. Position of the light in world space taking parenting in account.
  74320. */
  74321. transformedPosition: Vector3;
  74322. /**
  74323. * The transformed direction. Direction of the light in world space taking parenting in account.
  74324. */
  74325. transformedDirection: Vector3;
  74326. /**
  74327. * The friendly name of the light in the scene.
  74328. */
  74329. name: string;
  74330. /**
  74331. * Defines the shadow projection clipping minimum z value.
  74332. */
  74333. shadowMinZ: number;
  74334. /**
  74335. * Defines the shadow projection clipping maximum z value.
  74336. */
  74337. shadowMaxZ: number;
  74338. /**
  74339. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  74340. * @returns true if the information has been computed, false if it does not need to (no parenting)
  74341. */
  74342. computeTransformedInformation(): boolean;
  74343. /**
  74344. * Gets the scene the light belongs to.
  74345. * @returns The scene
  74346. */
  74347. getScene(): Scene;
  74348. /**
  74349. * Callback defining a custom Projection Matrix Builder.
  74350. * This can be used to override the default projection matrix computation.
  74351. */
  74352. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  74353. /**
  74354. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  74355. * @param matrix The materix to updated with the projection information
  74356. * @param viewMatrix The transform matrix of the light
  74357. * @param renderList The list of mesh to render in the map
  74358. * @returns The current light
  74359. */
  74360. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  74361. /**
  74362. * Gets the current depth scale used in ESM.
  74363. * @returns The scale
  74364. */
  74365. getDepthScale(): number;
  74366. /**
  74367. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  74368. * @returns true if a cube texture needs to be use
  74369. */
  74370. needCube(): boolean;
  74371. /**
  74372. * Detects if the projection matrix requires to be recomputed this frame.
  74373. * @returns true if it requires to be recomputed otherwise, false.
  74374. */
  74375. needProjectionMatrixCompute(): boolean;
  74376. /**
  74377. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  74378. */
  74379. forceProjectionMatrixCompute(): void;
  74380. /**
  74381. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  74382. * @param faceIndex The index of the face we are computed the direction to generate shadow
  74383. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  74384. */
  74385. getShadowDirection(faceIndex?: number): Vector3;
  74386. /**
  74387. * Gets the minZ used for shadow according to both the scene and the light.
  74388. * @param activeCamera The camera we are returning the min for
  74389. * @returns the depth min z
  74390. */
  74391. getDepthMinZ(activeCamera: Camera): number;
  74392. /**
  74393. * Gets the maxZ used for shadow according to both the scene and the light.
  74394. * @param activeCamera The camera we are returning the max for
  74395. * @returns the depth max z
  74396. */
  74397. getDepthMaxZ(activeCamera: Camera): number;
  74398. }
  74399. /**
  74400. * Base implementation IShadowLight
  74401. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  74402. */
  74403. export abstract class ShadowLight extends Light implements IShadowLight {
  74404. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  74405. protected _position: Vector3;
  74406. protected _setPosition(value: Vector3): void;
  74407. /**
  74408. * Sets the position the shadow will be casted from. Also use as the light position for both
  74409. * point and spot lights.
  74410. */
  74411. /**
  74412. * Sets the position the shadow will be casted from. Also use as the light position for both
  74413. * point and spot lights.
  74414. */
  74415. position: Vector3;
  74416. protected _direction: Vector3;
  74417. protected _setDirection(value: Vector3): void;
  74418. /**
  74419. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  74420. * Also use as the light direction on spot and directional lights.
  74421. */
  74422. /**
  74423. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  74424. * Also use as the light direction on spot and directional lights.
  74425. */
  74426. direction: Vector3;
  74427. private _shadowMinZ;
  74428. /**
  74429. * Gets the shadow projection clipping minimum z value.
  74430. */
  74431. /**
  74432. * Sets the shadow projection clipping minimum z value.
  74433. */
  74434. shadowMinZ: number;
  74435. private _shadowMaxZ;
  74436. /**
  74437. * Sets the shadow projection clipping maximum z value.
  74438. */
  74439. /**
  74440. * Gets the shadow projection clipping maximum z value.
  74441. */
  74442. shadowMaxZ: number;
  74443. /**
  74444. * Callback defining a custom Projection Matrix Builder.
  74445. * This can be used to override the default projection matrix computation.
  74446. */
  74447. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  74448. /**
  74449. * The transformed position. Position of the light in world space taking parenting in account.
  74450. */
  74451. transformedPosition: Vector3;
  74452. /**
  74453. * The transformed direction. Direction of the light in world space taking parenting in account.
  74454. */
  74455. transformedDirection: Vector3;
  74456. private _needProjectionMatrixCompute;
  74457. /**
  74458. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  74459. * @returns true if the information has been computed, false if it does not need to (no parenting)
  74460. */
  74461. computeTransformedInformation(): boolean;
  74462. /**
  74463. * Return the depth scale used for the shadow map.
  74464. * @returns the depth scale.
  74465. */
  74466. getDepthScale(): number;
  74467. /**
  74468. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  74469. * @param faceIndex The index of the face we are computed the direction to generate shadow
  74470. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  74471. */
  74472. getShadowDirection(faceIndex?: number): Vector3;
  74473. /**
  74474. * Returns the ShadowLight absolute position in the World.
  74475. * @returns the position vector in world space
  74476. */
  74477. getAbsolutePosition(): Vector3;
  74478. /**
  74479. * Sets the ShadowLight direction toward the passed target.
  74480. * @param target The point to target in local space
  74481. * @returns the updated ShadowLight direction
  74482. */
  74483. setDirectionToTarget(target: Vector3): Vector3;
  74484. /**
  74485. * Returns the light rotation in euler definition.
  74486. * @returns the x y z rotation in local space.
  74487. */
  74488. getRotation(): Vector3;
  74489. /**
  74490. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  74491. * @returns true if a cube texture needs to be use
  74492. */
  74493. needCube(): boolean;
  74494. /**
  74495. * Detects if the projection matrix requires to be recomputed this frame.
  74496. * @returns true if it requires to be recomputed otherwise, false.
  74497. */
  74498. needProjectionMatrixCompute(): boolean;
  74499. /**
  74500. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  74501. */
  74502. forceProjectionMatrixCompute(): void;
  74503. /** @hidden */
  74504. _initCache(): void;
  74505. /** @hidden */
  74506. _isSynchronized(): boolean;
  74507. /**
  74508. * Computes the world matrix of the node
  74509. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  74510. * @returns the world matrix
  74511. */
  74512. computeWorldMatrix(force?: boolean): Matrix;
  74513. /**
  74514. * Gets the minZ used for shadow according to both the scene and the light.
  74515. * @param activeCamera The camera we are returning the min for
  74516. * @returns the depth min z
  74517. */
  74518. getDepthMinZ(activeCamera: Camera): number;
  74519. /**
  74520. * Gets the maxZ used for shadow according to both the scene and the light.
  74521. * @param activeCamera The camera we are returning the max for
  74522. * @returns the depth max z
  74523. */
  74524. getDepthMaxZ(activeCamera: Camera): number;
  74525. /**
  74526. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  74527. * @param matrix The materix to updated with the projection information
  74528. * @param viewMatrix The transform matrix of the light
  74529. * @param renderList The list of mesh to render in the map
  74530. * @returns The current light
  74531. */
  74532. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  74533. }
  74534. }
  74535. declare module BABYLON {
  74536. /**
  74537. * "Static Class" containing the most commonly used helper while dealing with material for
  74538. * rendering purpose.
  74539. *
  74540. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  74541. *
  74542. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  74543. */
  74544. export class MaterialHelper {
  74545. /**
  74546. * Bind the current view position to an effect.
  74547. * @param effect The effect to be bound
  74548. * @param scene The scene the eyes position is used from
  74549. */
  74550. static BindEyePosition(effect: Effect, scene: Scene): void;
  74551. /**
  74552. * Helps preparing the defines values about the UVs in used in the effect.
  74553. * UVs are shared as much as we can accross channels in the shaders.
  74554. * @param texture The texture we are preparing the UVs for
  74555. * @param defines The defines to update
  74556. * @param key The channel key "diffuse", "specular"... used in the shader
  74557. */
  74558. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  74559. /**
  74560. * Binds a texture matrix value to its corrsponding uniform
  74561. * @param texture The texture to bind the matrix for
  74562. * @param uniformBuffer The uniform buffer receivin the data
  74563. * @param key The channel key "diffuse", "specular"... used in the shader
  74564. */
  74565. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  74566. /**
  74567. * Gets the current status of the fog (should it be enabled?)
  74568. * @param mesh defines the mesh to evaluate for fog support
  74569. * @param scene defines the hosting scene
  74570. * @returns true if fog must be enabled
  74571. */
  74572. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  74573. /**
  74574. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  74575. * @param mesh defines the current mesh
  74576. * @param scene defines the current scene
  74577. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  74578. * @param pointsCloud defines if point cloud rendering has to be turned on
  74579. * @param fogEnabled defines if fog has to be turned on
  74580. * @param alphaTest defines if alpha testing has to be turned on
  74581. * @param defines defines the current list of defines
  74582. */
  74583. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  74584. /**
  74585. * Helper used to prepare the list of defines associated with frame values for shader compilation
  74586. * @param scene defines the current scene
  74587. * @param engine defines the current engine
  74588. * @param defines specifies the list of active defines
  74589. * @param useInstances defines if instances have to be turned on
  74590. * @param useClipPlane defines if clip plane have to be turned on
  74591. */
  74592. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  74593. /**
  74594. * Prepares the defines for bones
  74595. * @param mesh The mesh containing the geometry data we will draw
  74596. * @param defines The defines to update
  74597. */
  74598. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  74599. /**
  74600. * Prepares the defines for morph targets
  74601. * @param mesh The mesh containing the geometry data we will draw
  74602. * @param defines The defines to update
  74603. */
  74604. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  74605. /**
  74606. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  74607. * @param mesh The mesh containing the geometry data we will draw
  74608. * @param defines The defines to update
  74609. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  74610. * @param useBones Precise whether bones should be used or not (override mesh info)
  74611. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  74612. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  74613. * @returns false if defines are considered not dirty and have not been checked
  74614. */
  74615. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  74616. /**
  74617. * Prepares the defines related to multiview
  74618. * @param scene The scene we are intending to draw
  74619. * @param defines The defines to update
  74620. */
  74621. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  74622. /**
  74623. * Prepares the defines related to the light information passed in parameter
  74624. * @param scene The scene we are intending to draw
  74625. * @param mesh The mesh the effect is compiling for
  74626. * @param light The light the effect is compiling for
  74627. * @param lightIndex The index of the light
  74628. * @param defines The defines to update
  74629. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  74630. * @param state Defines the current state regarding what is needed (normals, etc...)
  74631. */
  74632. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  74633. needNormals: boolean;
  74634. needRebuild: boolean;
  74635. shadowEnabled: boolean;
  74636. specularEnabled: boolean;
  74637. lightmapMode: boolean;
  74638. }): void;
  74639. /**
  74640. * Prepares the defines related to the light information passed in parameter
  74641. * @param scene The scene we are intending to draw
  74642. * @param mesh The mesh the effect is compiling for
  74643. * @param defines The defines to update
  74644. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  74645. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  74646. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  74647. * @returns true if normals will be required for the rest of the effect
  74648. */
  74649. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  74650. /**
  74651. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  74652. * @param lightIndex defines the light index
  74653. * @param uniformsList The uniform list
  74654. * @param samplersList The sampler list
  74655. * @param projectedLightTexture defines if projected texture must be used
  74656. * @param uniformBuffersList defines an optional list of uniform buffers
  74657. */
  74658. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  74659. /**
  74660. * Prepares the uniforms and samplers list to be used in the effect
  74661. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  74662. * @param samplersList The sampler list
  74663. * @param defines The defines helping in the list generation
  74664. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  74665. */
  74666. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  74667. /**
  74668. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  74669. * @param defines The defines to update while falling back
  74670. * @param fallbacks The authorized effect fallbacks
  74671. * @param maxSimultaneousLights The maximum number of lights allowed
  74672. * @param rank the current rank of the Effect
  74673. * @returns The newly affected rank
  74674. */
  74675. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  74676. private static _TmpMorphInfluencers;
  74677. /**
  74678. * Prepares the list of attributes required for morph targets according to the effect defines.
  74679. * @param attribs The current list of supported attribs
  74680. * @param mesh The mesh to prepare the morph targets attributes for
  74681. * @param influencers The number of influencers
  74682. */
  74683. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  74684. /**
  74685. * Prepares the list of attributes required for morph targets according to the effect defines.
  74686. * @param attribs The current list of supported attribs
  74687. * @param mesh The mesh to prepare the morph targets attributes for
  74688. * @param defines The current Defines of the effect
  74689. */
  74690. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  74691. /**
  74692. * Prepares the list of attributes required for bones according to the effect defines.
  74693. * @param attribs The current list of supported attribs
  74694. * @param mesh The mesh to prepare the bones attributes for
  74695. * @param defines The current Defines of the effect
  74696. * @param fallbacks The current efffect fallback strategy
  74697. */
  74698. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  74699. /**
  74700. * Check and prepare the list of attributes required for instances according to the effect defines.
  74701. * @param attribs The current list of supported attribs
  74702. * @param defines The current MaterialDefines of the effect
  74703. */
  74704. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  74705. /**
  74706. * Add the list of attributes required for instances to the attribs array.
  74707. * @param attribs The current list of supported attribs
  74708. */
  74709. static PushAttributesForInstances(attribs: string[]): void;
  74710. /**
  74711. * Binds the light shadow information to the effect for the given mesh.
  74712. * @param light The light containing the generator
  74713. * @param scene The scene the lights belongs to
  74714. * @param mesh The mesh we are binding the information to render
  74715. * @param lightIndex The light index in the effect used to render the mesh
  74716. * @param effect The effect we are binding the data to
  74717. */
  74718. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  74719. /**
  74720. * Binds the light information to the effect.
  74721. * @param light The light containing the generator
  74722. * @param effect The effect we are binding the data to
  74723. * @param lightIndex The light index in the effect used to render
  74724. */
  74725. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  74726. /**
  74727. * Binds the lights information from the scene to the effect for the given mesh.
  74728. * @param light Light to bind
  74729. * @param lightIndex Light index
  74730. * @param scene The scene where the light belongs to
  74731. * @param mesh The mesh we are binding the information to render
  74732. * @param effect The effect we are binding the data to
  74733. * @param useSpecular Defines if specular is supported
  74734. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74735. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  74736. */
  74737. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  74738. /**
  74739. * Binds the lights information from the scene to the effect for the given mesh.
  74740. * @param scene The scene the lights belongs to
  74741. * @param mesh The mesh we are binding the information to render
  74742. * @param effect The effect we are binding the data to
  74743. * @param defines The generated defines for the effect
  74744. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  74745. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74746. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  74747. */
  74748. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  74749. private static _tempFogColor;
  74750. /**
  74751. * Binds the fog information from the scene to the effect for the given mesh.
  74752. * @param scene The scene the lights belongs to
  74753. * @param mesh The mesh we are binding the information to render
  74754. * @param effect The effect we are binding the data to
  74755. * @param linearSpace Defines if the fog effect is applied in linear space
  74756. */
  74757. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  74758. /**
  74759. * Binds the bones information from the mesh to the effect.
  74760. * @param mesh The mesh we are binding the information to render
  74761. * @param effect The effect we are binding the data to
  74762. */
  74763. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  74764. /**
  74765. * Binds the morph targets information from the mesh to the effect.
  74766. * @param abstractMesh The mesh we are binding the information to render
  74767. * @param effect The effect we are binding the data to
  74768. */
  74769. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  74770. /**
  74771. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  74772. * @param defines The generated defines used in the effect
  74773. * @param effect The effect we are binding the data to
  74774. * @param scene The scene we are willing to render with logarithmic scale for
  74775. */
  74776. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  74777. /**
  74778. * Binds the clip plane information from the scene to the effect.
  74779. * @param scene The scene the clip plane information are extracted from
  74780. * @param effect The effect we are binding the data to
  74781. */
  74782. static BindClipPlane(effect: Effect, scene: Scene): void;
  74783. }
  74784. }
  74785. declare module BABYLON {
  74786. /** @hidden */
  74787. export var packingFunctions: {
  74788. name: string;
  74789. shader: string;
  74790. };
  74791. }
  74792. declare module BABYLON {
  74793. /** @hidden */
  74794. export var shadowMapPixelShader: {
  74795. name: string;
  74796. shader: string;
  74797. };
  74798. }
  74799. declare module BABYLON {
  74800. /** @hidden */
  74801. export var bonesDeclaration: {
  74802. name: string;
  74803. shader: string;
  74804. };
  74805. }
  74806. declare module BABYLON {
  74807. /** @hidden */
  74808. export var morphTargetsVertexGlobalDeclaration: {
  74809. name: string;
  74810. shader: string;
  74811. };
  74812. }
  74813. declare module BABYLON {
  74814. /** @hidden */
  74815. export var morphTargetsVertexDeclaration: {
  74816. name: string;
  74817. shader: string;
  74818. };
  74819. }
  74820. declare module BABYLON {
  74821. /** @hidden */
  74822. export var instancesDeclaration: {
  74823. name: string;
  74824. shader: string;
  74825. };
  74826. }
  74827. declare module BABYLON {
  74828. /** @hidden */
  74829. export var helperFunctions: {
  74830. name: string;
  74831. shader: string;
  74832. };
  74833. }
  74834. declare module BABYLON {
  74835. /** @hidden */
  74836. export var morphTargetsVertex: {
  74837. name: string;
  74838. shader: string;
  74839. };
  74840. }
  74841. declare module BABYLON {
  74842. /** @hidden */
  74843. export var instancesVertex: {
  74844. name: string;
  74845. shader: string;
  74846. };
  74847. }
  74848. declare module BABYLON {
  74849. /** @hidden */
  74850. export var bonesVertex: {
  74851. name: string;
  74852. shader: string;
  74853. };
  74854. }
  74855. declare module BABYLON {
  74856. /** @hidden */
  74857. export var shadowMapVertexShader: {
  74858. name: string;
  74859. shader: string;
  74860. };
  74861. }
  74862. declare module BABYLON {
  74863. /** @hidden */
  74864. export var depthBoxBlurPixelShader: {
  74865. name: string;
  74866. shader: string;
  74867. };
  74868. }
  74869. declare module BABYLON {
  74870. /**
  74871. * Defines the options associated with the creation of a custom shader for a shadow generator.
  74872. */
  74873. export interface ICustomShaderOptions {
  74874. /**
  74875. * Gets or sets the custom shader name to use
  74876. */
  74877. shaderName: string;
  74878. /**
  74879. * The list of attribute names used in the shader
  74880. */
  74881. attributes?: string[];
  74882. /**
  74883. * The list of unifrom names used in the shader
  74884. */
  74885. uniforms?: string[];
  74886. /**
  74887. * The list of sampler names used in the shader
  74888. */
  74889. samplers?: string[];
  74890. /**
  74891. * The list of defines used in the shader
  74892. */
  74893. defines?: string[];
  74894. }
  74895. /**
  74896. * Interface to implement to create a shadow generator compatible with BJS.
  74897. */
  74898. export interface IShadowGenerator {
  74899. /**
  74900. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74901. * @returns The render target texture if present otherwise, null
  74902. */
  74903. getShadowMap(): Nullable<RenderTargetTexture>;
  74904. /**
  74905. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74906. * @returns The render target texture if the shadow map is present otherwise, null
  74907. */
  74908. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74909. /**
  74910. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74911. * @param subMesh The submesh we want to render in the shadow map
  74912. * @param useInstances Defines wether will draw in the map using instances
  74913. * @returns true if ready otherwise, false
  74914. */
  74915. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74916. /**
  74917. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74918. * @param defines Defines of the material we want to update
  74919. * @param lightIndex Index of the light in the enabled light list of the material
  74920. */
  74921. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  74922. /**
  74923. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74924. * defined in the generator but impacting the effect).
  74925. * It implies the unifroms available on the materials are the standard BJS ones.
  74926. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74927. * @param effect The effect we are binfing the information for
  74928. */
  74929. bindShadowLight(lightIndex: string, effect: Effect): void;
  74930. /**
  74931. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74932. * (eq to shadow prjection matrix * light transform matrix)
  74933. * @returns The transform matrix used to create the shadow map
  74934. */
  74935. getTransformMatrix(): Matrix;
  74936. /**
  74937. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74938. * Cube and 2D textures for instance.
  74939. */
  74940. recreateShadowMap(): void;
  74941. /**
  74942. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74943. * @param onCompiled Callback triggered at the and of the effects compilation
  74944. * @param options Sets of optional options forcing the compilation with different modes
  74945. */
  74946. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74947. useInstances: boolean;
  74948. }>): void;
  74949. /**
  74950. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74951. * @param options Sets of optional options forcing the compilation with different modes
  74952. * @returns A promise that resolves when the compilation completes
  74953. */
  74954. forceCompilationAsync(options?: Partial<{
  74955. useInstances: boolean;
  74956. }>): Promise<void>;
  74957. /**
  74958. * Serializes the shadow generator setup to a json object.
  74959. * @returns The serialized JSON object
  74960. */
  74961. serialize(): any;
  74962. /**
  74963. * Disposes the Shadow map and related Textures and effects.
  74964. */
  74965. dispose(): void;
  74966. }
  74967. /**
  74968. * Default implementation IShadowGenerator.
  74969. * This is the main object responsible of generating shadows in the framework.
  74970. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  74971. */
  74972. export class ShadowGenerator implements IShadowGenerator {
  74973. /**
  74974. * Shadow generator mode None: no filtering applied.
  74975. */
  74976. static readonly FILTER_NONE: number;
  74977. /**
  74978. * Shadow generator mode ESM: Exponential Shadow Mapping.
  74979. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74980. */
  74981. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  74982. /**
  74983. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  74984. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  74985. */
  74986. static readonly FILTER_POISSONSAMPLING: number;
  74987. /**
  74988. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  74989. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74990. */
  74991. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  74992. /**
  74993. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  74994. * edge artifacts on steep falloff.
  74995. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74996. */
  74997. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  74998. /**
  74999. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  75000. * edge artifacts on steep falloff.
  75001. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75002. */
  75003. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  75004. /**
  75005. * Shadow generator mode PCF: Percentage Closer Filtering
  75006. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  75007. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  75008. */
  75009. static readonly FILTER_PCF: number;
  75010. /**
  75011. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  75012. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  75013. * Contact Hardening
  75014. */
  75015. static readonly FILTER_PCSS: number;
  75016. /**
  75017. * Reserved for PCF and PCSS
  75018. * Highest Quality.
  75019. *
  75020. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  75021. *
  75022. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  75023. */
  75024. static readonly QUALITY_HIGH: number;
  75025. /**
  75026. * Reserved for PCF and PCSS
  75027. * Good tradeoff for quality/perf cross devices
  75028. *
  75029. * Execute PCF on a 3*3 kernel.
  75030. *
  75031. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  75032. */
  75033. static readonly QUALITY_MEDIUM: number;
  75034. /**
  75035. * Reserved for PCF and PCSS
  75036. * The lowest quality but the fastest.
  75037. *
  75038. * Execute PCF on a 1*1 kernel.
  75039. *
  75040. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  75041. */
  75042. static readonly QUALITY_LOW: number;
  75043. /** Gets or sets the custom shader name to use */
  75044. customShaderOptions: ICustomShaderOptions;
  75045. /**
  75046. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  75047. */
  75048. onBeforeShadowMapRenderObservable: Observable<Effect>;
  75049. /**
  75050. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  75051. */
  75052. onAfterShadowMapRenderObservable: Observable<Effect>;
  75053. /**
  75054. * Observable triggered before a mesh is rendered in the shadow map.
  75055. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  75056. */
  75057. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  75058. /**
  75059. * Observable triggered after a mesh is rendered in the shadow map.
  75060. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  75061. */
  75062. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  75063. private _bias;
  75064. /**
  75065. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  75066. */
  75067. /**
  75068. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  75069. */
  75070. bias: number;
  75071. private _normalBias;
  75072. /**
  75073. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  75074. */
  75075. /**
  75076. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  75077. */
  75078. normalBias: number;
  75079. private _blurBoxOffset;
  75080. /**
  75081. * Gets the blur box offset: offset applied during the blur pass.
  75082. * Only useful if useKernelBlur = false
  75083. */
  75084. /**
  75085. * Sets the blur box offset: offset applied during the blur pass.
  75086. * Only useful if useKernelBlur = false
  75087. */
  75088. blurBoxOffset: number;
  75089. private _blurScale;
  75090. /**
  75091. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  75092. * 2 means half of the size.
  75093. */
  75094. /**
  75095. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  75096. * 2 means half of the size.
  75097. */
  75098. blurScale: number;
  75099. private _blurKernel;
  75100. /**
  75101. * Gets the blur kernel: kernel size of the blur pass.
  75102. * Only useful if useKernelBlur = true
  75103. */
  75104. /**
  75105. * Sets the blur kernel: kernel size of the blur pass.
  75106. * Only useful if useKernelBlur = true
  75107. */
  75108. blurKernel: number;
  75109. private _useKernelBlur;
  75110. /**
  75111. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  75112. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  75113. */
  75114. /**
  75115. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  75116. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  75117. */
  75118. useKernelBlur: boolean;
  75119. private _depthScale;
  75120. /**
  75121. * Gets the depth scale used in ESM mode.
  75122. */
  75123. /**
  75124. * Sets the depth scale used in ESM mode.
  75125. * This can override the scale stored on the light.
  75126. */
  75127. depthScale: number;
  75128. private _filter;
  75129. /**
  75130. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  75131. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  75132. */
  75133. /**
  75134. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  75135. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  75136. */
  75137. filter: number;
  75138. /**
  75139. * Gets if the current filter is set to Poisson Sampling.
  75140. */
  75141. /**
  75142. * Sets the current filter to Poisson Sampling.
  75143. */
  75144. usePoissonSampling: boolean;
  75145. /**
  75146. * Gets if the current filter is set to ESM.
  75147. */
  75148. /**
  75149. * Sets the current filter is to ESM.
  75150. */
  75151. useExponentialShadowMap: boolean;
  75152. /**
  75153. * Gets if the current filter is set to filtered ESM.
  75154. */
  75155. /**
  75156. * Gets if the current filter is set to filtered ESM.
  75157. */
  75158. useBlurExponentialShadowMap: boolean;
  75159. /**
  75160. * Gets if the current filter is set to "close ESM" (using the inverse of the
  75161. * exponential to prevent steep falloff artifacts).
  75162. */
  75163. /**
  75164. * Sets the current filter to "close ESM" (using the inverse of the
  75165. * exponential to prevent steep falloff artifacts).
  75166. */
  75167. useCloseExponentialShadowMap: boolean;
  75168. /**
  75169. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  75170. * exponential to prevent steep falloff artifacts).
  75171. */
  75172. /**
  75173. * Sets the current filter to filtered "close ESM" (using the inverse of the
  75174. * exponential to prevent steep falloff artifacts).
  75175. */
  75176. useBlurCloseExponentialShadowMap: boolean;
  75177. /**
  75178. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  75179. */
  75180. /**
  75181. * Sets the current filter to "PCF" (percentage closer filtering).
  75182. */
  75183. usePercentageCloserFiltering: boolean;
  75184. private _filteringQuality;
  75185. /**
  75186. * Gets the PCF or PCSS Quality.
  75187. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  75188. */
  75189. /**
  75190. * Sets the PCF or PCSS Quality.
  75191. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  75192. */
  75193. filteringQuality: number;
  75194. /**
  75195. * Gets if the current filter is set to "PCSS" (contact hardening).
  75196. */
  75197. /**
  75198. * Sets the current filter to "PCSS" (contact hardening).
  75199. */
  75200. useContactHardeningShadow: boolean;
  75201. private _contactHardeningLightSizeUVRatio;
  75202. /**
  75203. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  75204. * Using a ratio helps keeping shape stability independently of the map size.
  75205. *
  75206. * It does not account for the light projection as it was having too much
  75207. * instability during the light setup or during light position changes.
  75208. *
  75209. * Only valid if useContactHardeningShadow is true.
  75210. */
  75211. /**
  75212. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  75213. * Using a ratio helps keeping shape stability independently of the map size.
  75214. *
  75215. * It does not account for the light projection as it was having too much
  75216. * instability during the light setup or during light position changes.
  75217. *
  75218. * Only valid if useContactHardeningShadow is true.
  75219. */
  75220. contactHardeningLightSizeUVRatio: number;
  75221. private _darkness;
  75222. /** Gets or sets the actual darkness of a shadow */
  75223. darkness: number;
  75224. /**
  75225. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  75226. * 0 means strongest and 1 would means no shadow.
  75227. * @returns the darkness.
  75228. */
  75229. getDarkness(): number;
  75230. /**
  75231. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  75232. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  75233. * @returns the shadow generator allowing fluent coding.
  75234. */
  75235. setDarkness(darkness: number): ShadowGenerator;
  75236. private _transparencyShadow;
  75237. /** Gets or sets the ability to have transparent shadow */
  75238. transparencyShadow: boolean;
  75239. /**
  75240. * Sets the ability to have transparent shadow (boolean).
  75241. * @param transparent True if transparent else False
  75242. * @returns the shadow generator allowing fluent coding
  75243. */
  75244. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  75245. private _shadowMap;
  75246. private _shadowMap2;
  75247. /**
  75248. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  75249. * @returns The render target texture if present otherwise, null
  75250. */
  75251. getShadowMap(): Nullable<RenderTargetTexture>;
  75252. /**
  75253. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  75254. * @returns The render target texture if the shadow map is present otherwise, null
  75255. */
  75256. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  75257. /**
  75258. * Gets the class name of that object
  75259. * @returns "ShadowGenerator"
  75260. */
  75261. getClassName(): string;
  75262. /**
  75263. * Helper function to add a mesh and its descendants to the list of shadow casters.
  75264. * @param mesh Mesh to add
  75265. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  75266. * @returns the Shadow Generator itself
  75267. */
  75268. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  75269. /**
  75270. * Helper function to remove a mesh and its descendants from the list of shadow casters
  75271. * @param mesh Mesh to remove
  75272. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  75273. * @returns the Shadow Generator itself
  75274. */
  75275. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  75276. /**
  75277. * Controls the extent to which the shadows fade out at the edge of the frustum
  75278. * Used only by directionals and spots
  75279. */
  75280. frustumEdgeFalloff: number;
  75281. private _light;
  75282. /**
  75283. * Returns the associated light object.
  75284. * @returns the light generating the shadow
  75285. */
  75286. getLight(): IShadowLight;
  75287. /**
  75288. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  75289. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  75290. * It might on the other hand introduce peter panning.
  75291. */
  75292. forceBackFacesOnly: boolean;
  75293. private _scene;
  75294. private _lightDirection;
  75295. private _effect;
  75296. private _viewMatrix;
  75297. private _projectionMatrix;
  75298. private _transformMatrix;
  75299. private _cachedPosition;
  75300. private _cachedDirection;
  75301. private _cachedDefines;
  75302. private _currentRenderID;
  75303. private _boxBlurPostprocess;
  75304. private _kernelBlurXPostprocess;
  75305. private _kernelBlurYPostprocess;
  75306. private _blurPostProcesses;
  75307. private _mapSize;
  75308. private _currentFaceIndex;
  75309. private _currentFaceIndexCache;
  75310. private _textureType;
  75311. private _defaultTextureMatrix;
  75312. /** @hidden */
  75313. static _SceneComponentInitialization: (scene: Scene) => void;
  75314. /**
  75315. * Creates a ShadowGenerator object.
  75316. * A ShadowGenerator is the required tool to use the shadows.
  75317. * Each light casting shadows needs to use its own ShadowGenerator.
  75318. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  75319. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  75320. * @param light The light object generating the shadows.
  75321. * @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.
  75322. */
  75323. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  75324. private _initializeGenerator;
  75325. private _initializeShadowMap;
  75326. private _initializeBlurRTTAndPostProcesses;
  75327. private _renderForShadowMap;
  75328. private _renderSubMeshForShadowMap;
  75329. private _applyFilterValues;
  75330. /**
  75331. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75332. * @param onCompiled Callback triggered at the and of the effects compilation
  75333. * @param options Sets of optional options forcing the compilation with different modes
  75334. */
  75335. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  75336. useInstances: boolean;
  75337. }>): void;
  75338. /**
  75339. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75340. * @param options Sets of optional options forcing the compilation with different modes
  75341. * @returns A promise that resolves when the compilation completes
  75342. */
  75343. forceCompilationAsync(options?: Partial<{
  75344. useInstances: boolean;
  75345. }>): Promise<void>;
  75346. /**
  75347. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  75348. * @param subMesh The submesh we want to render in the shadow map
  75349. * @param useInstances Defines wether will draw in the map using instances
  75350. * @returns true if ready otherwise, false
  75351. */
  75352. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75353. /**
  75354. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  75355. * @param defines Defines of the material we want to update
  75356. * @param lightIndex Index of the light in the enabled light list of the material
  75357. */
  75358. prepareDefines(defines: any, lightIndex: number): void;
  75359. /**
  75360. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  75361. * defined in the generator but impacting the effect).
  75362. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  75363. * @param effect The effect we are binfing the information for
  75364. */
  75365. bindShadowLight(lightIndex: string, effect: Effect): void;
  75366. /**
  75367. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  75368. * (eq to shadow prjection matrix * light transform matrix)
  75369. * @returns The transform matrix used to create the shadow map
  75370. */
  75371. getTransformMatrix(): Matrix;
  75372. /**
  75373. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  75374. * Cube and 2D textures for instance.
  75375. */
  75376. recreateShadowMap(): void;
  75377. private _disposeBlurPostProcesses;
  75378. private _disposeRTTandPostProcesses;
  75379. /**
  75380. * Disposes the ShadowGenerator.
  75381. * Returns nothing.
  75382. */
  75383. dispose(): void;
  75384. /**
  75385. * Serializes the shadow generator setup to a json object.
  75386. * @returns The serialized JSON object
  75387. */
  75388. serialize(): any;
  75389. /**
  75390. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  75391. * @param parsedShadowGenerator The JSON object to parse
  75392. * @param scene The scene to create the shadow map for
  75393. * @returns The parsed shadow generator
  75394. */
  75395. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  75396. }
  75397. }
  75398. declare module BABYLON {
  75399. /**
  75400. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  75401. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  75402. * 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.
  75403. */
  75404. export abstract class Light extends Node {
  75405. /**
  75406. * Falloff Default: light is falling off following the material specification:
  75407. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  75408. */
  75409. static readonly FALLOFF_DEFAULT: number;
  75410. /**
  75411. * Falloff Physical: light is falling off following the inverse squared distance law.
  75412. */
  75413. static readonly FALLOFF_PHYSICAL: number;
  75414. /**
  75415. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  75416. * to enhance interoperability with other engines.
  75417. */
  75418. static readonly FALLOFF_GLTF: number;
  75419. /**
  75420. * Falloff Standard: light is falling off like in the standard material
  75421. * to enhance interoperability with other materials.
  75422. */
  75423. static readonly FALLOFF_STANDARD: number;
  75424. /**
  75425. * If every light affecting the material is in this lightmapMode,
  75426. * material.lightmapTexture adds or multiplies
  75427. * (depends on material.useLightmapAsShadowmap)
  75428. * after every other light calculations.
  75429. */
  75430. static readonly LIGHTMAP_DEFAULT: number;
  75431. /**
  75432. * material.lightmapTexture as only diffuse lighting from this light
  75433. * adds only specular lighting from this light
  75434. * adds dynamic shadows
  75435. */
  75436. static readonly LIGHTMAP_SPECULAR: number;
  75437. /**
  75438. * material.lightmapTexture as only lighting
  75439. * no light calculation from this light
  75440. * only adds dynamic shadows from this light
  75441. */
  75442. static readonly LIGHTMAP_SHADOWSONLY: number;
  75443. /**
  75444. * Each light type uses the default quantity according to its type:
  75445. * point/spot lights use luminous intensity
  75446. * directional lights use illuminance
  75447. */
  75448. static readonly INTENSITYMODE_AUTOMATIC: number;
  75449. /**
  75450. * lumen (lm)
  75451. */
  75452. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  75453. /**
  75454. * candela (lm/sr)
  75455. */
  75456. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  75457. /**
  75458. * lux (lm/m^2)
  75459. */
  75460. static readonly INTENSITYMODE_ILLUMINANCE: number;
  75461. /**
  75462. * nit (cd/m^2)
  75463. */
  75464. static readonly INTENSITYMODE_LUMINANCE: number;
  75465. /**
  75466. * Light type const id of the point light.
  75467. */
  75468. static readonly LIGHTTYPEID_POINTLIGHT: number;
  75469. /**
  75470. * Light type const id of the directional light.
  75471. */
  75472. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  75473. /**
  75474. * Light type const id of the spot light.
  75475. */
  75476. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  75477. /**
  75478. * Light type const id of the hemispheric light.
  75479. */
  75480. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  75481. /**
  75482. * Diffuse gives the basic color to an object.
  75483. */
  75484. diffuse: Color3;
  75485. /**
  75486. * Specular produces a highlight color on an object.
  75487. * Note: This is note affecting PBR materials.
  75488. */
  75489. specular: Color3;
  75490. /**
  75491. * Defines the falloff type for this light. This lets overrriding how punctual light are
  75492. * falling off base on range or angle.
  75493. * This can be set to any values in Light.FALLOFF_x.
  75494. *
  75495. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  75496. * other types of materials.
  75497. */
  75498. falloffType: number;
  75499. /**
  75500. * Strength of the light.
  75501. * Note: By default it is define in the framework own unit.
  75502. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  75503. */
  75504. intensity: number;
  75505. private _range;
  75506. protected _inverseSquaredRange: number;
  75507. /**
  75508. * Defines how far from the source the light is impacting in scene units.
  75509. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  75510. */
  75511. /**
  75512. * Defines how far from the source the light is impacting in scene units.
  75513. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  75514. */
  75515. range: number;
  75516. /**
  75517. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  75518. * of light.
  75519. */
  75520. private _photometricScale;
  75521. private _intensityMode;
  75522. /**
  75523. * Gets the photometric scale used to interpret the intensity.
  75524. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  75525. */
  75526. /**
  75527. * Sets the photometric scale used to interpret the intensity.
  75528. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  75529. */
  75530. intensityMode: number;
  75531. private _radius;
  75532. /**
  75533. * Gets the light radius used by PBR Materials to simulate soft area lights.
  75534. */
  75535. /**
  75536. * sets the light radius used by PBR Materials to simulate soft area lights.
  75537. */
  75538. radius: number;
  75539. private _renderPriority;
  75540. /**
  75541. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  75542. * exceeding the number allowed of the materials.
  75543. */
  75544. renderPriority: number;
  75545. private _shadowEnabled;
  75546. /**
  75547. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  75548. * the current shadow generator.
  75549. */
  75550. /**
  75551. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  75552. * the current shadow generator.
  75553. */
  75554. shadowEnabled: boolean;
  75555. private _includedOnlyMeshes;
  75556. /**
  75557. * Gets the only meshes impacted by this light.
  75558. */
  75559. /**
  75560. * Sets the only meshes impacted by this light.
  75561. */
  75562. includedOnlyMeshes: AbstractMesh[];
  75563. private _excludedMeshes;
  75564. /**
  75565. * Gets the meshes not impacted by this light.
  75566. */
  75567. /**
  75568. * Sets the meshes not impacted by this light.
  75569. */
  75570. excludedMeshes: AbstractMesh[];
  75571. private _excludeWithLayerMask;
  75572. /**
  75573. * Gets the layer id use to find what meshes are not impacted by the light.
  75574. * Inactive if 0
  75575. */
  75576. /**
  75577. * Sets the layer id use to find what meshes are not impacted by the light.
  75578. * Inactive if 0
  75579. */
  75580. excludeWithLayerMask: number;
  75581. private _includeOnlyWithLayerMask;
  75582. /**
  75583. * Gets the layer id use to find what meshes are impacted by the light.
  75584. * Inactive if 0
  75585. */
  75586. /**
  75587. * Sets the layer id use to find what meshes are impacted by the light.
  75588. * Inactive if 0
  75589. */
  75590. includeOnlyWithLayerMask: number;
  75591. private _lightmapMode;
  75592. /**
  75593. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  75594. */
  75595. /**
  75596. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  75597. */
  75598. lightmapMode: number;
  75599. /**
  75600. * Shadow generator associted to the light.
  75601. * @hidden Internal use only.
  75602. */
  75603. _shadowGenerator: Nullable<IShadowGenerator>;
  75604. /**
  75605. * @hidden Internal use only.
  75606. */
  75607. _excludedMeshesIds: string[];
  75608. /**
  75609. * @hidden Internal use only.
  75610. */
  75611. _includedOnlyMeshesIds: string[];
  75612. /**
  75613. * The current light unifom buffer.
  75614. * @hidden Internal use only.
  75615. */
  75616. _uniformBuffer: UniformBuffer;
  75617. /**
  75618. * Creates a Light object in the scene.
  75619. * Documentation : https://doc.babylonjs.com/babylon101/lights
  75620. * @param name The firendly name of the light
  75621. * @param scene The scene the light belongs too
  75622. */
  75623. constructor(name: string, scene: Scene);
  75624. protected abstract _buildUniformLayout(): void;
  75625. /**
  75626. * Sets the passed Effect "effect" with the Light information.
  75627. * @param effect The effect to update
  75628. * @param lightIndex The index of the light in the effect to update
  75629. * @returns The light
  75630. */
  75631. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  75632. /**
  75633. * Sets the passed Effect "effect" with the Light information.
  75634. * @param effect The effect to update
  75635. * @param lightDataUniformName The uniform used to store light data (position or direction)
  75636. * @returns The light
  75637. */
  75638. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  75639. /**
  75640. * Returns the string "Light".
  75641. * @returns the class name
  75642. */
  75643. getClassName(): string;
  75644. /** @hidden */
  75645. readonly _isLight: boolean;
  75646. /**
  75647. * Converts the light information to a readable string for debug purpose.
  75648. * @param fullDetails Supports for multiple levels of logging within scene loading
  75649. * @returns the human readable light info
  75650. */
  75651. toString(fullDetails?: boolean): string;
  75652. /** @hidden */
  75653. protected _syncParentEnabledState(): void;
  75654. /**
  75655. * Set the enabled state of this node.
  75656. * @param value - the new enabled state
  75657. */
  75658. setEnabled(value: boolean): void;
  75659. /**
  75660. * Returns the Light associated shadow generator if any.
  75661. * @return the associated shadow generator.
  75662. */
  75663. getShadowGenerator(): Nullable<IShadowGenerator>;
  75664. /**
  75665. * Returns a Vector3, the absolute light position in the World.
  75666. * @returns the world space position of the light
  75667. */
  75668. getAbsolutePosition(): Vector3;
  75669. /**
  75670. * Specifies if the light will affect the passed mesh.
  75671. * @param mesh The mesh to test against the light
  75672. * @return true the mesh is affected otherwise, false.
  75673. */
  75674. canAffectMesh(mesh: AbstractMesh): boolean;
  75675. /**
  75676. * Sort function to order lights for rendering.
  75677. * @param a First Light object to compare to second.
  75678. * @param b Second Light object to compare first.
  75679. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  75680. */
  75681. static CompareLightsPriority(a: Light, b: Light): number;
  75682. /**
  75683. * Releases resources associated with this node.
  75684. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  75685. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  75686. */
  75687. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  75688. /**
  75689. * Returns the light type ID (integer).
  75690. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  75691. */
  75692. getTypeID(): number;
  75693. /**
  75694. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  75695. * @returns the scaled intensity in intensity mode unit
  75696. */
  75697. getScaledIntensity(): number;
  75698. /**
  75699. * Returns a new Light object, named "name", from the current one.
  75700. * @param name The name of the cloned light
  75701. * @returns the new created light
  75702. */
  75703. clone(name: string): Nullable<Light>;
  75704. /**
  75705. * Serializes the current light into a Serialization object.
  75706. * @returns the serialized object.
  75707. */
  75708. serialize(): any;
  75709. /**
  75710. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  75711. * This new light is named "name" and added to the passed scene.
  75712. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  75713. * @param name The friendly name of the light
  75714. * @param scene The scene the new light will belong to
  75715. * @returns the constructor function
  75716. */
  75717. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  75718. /**
  75719. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  75720. * @param parsedLight The JSON representation of the light
  75721. * @param scene The scene to create the parsed light in
  75722. * @returns the created light after parsing
  75723. */
  75724. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  75725. private _hookArrayForExcluded;
  75726. private _hookArrayForIncludedOnly;
  75727. private _resyncMeshes;
  75728. /**
  75729. * Forces the meshes to update their light related information in their rendering used effects
  75730. * @hidden Internal Use Only
  75731. */
  75732. _markMeshesAsLightDirty(): void;
  75733. /**
  75734. * Recomputes the cached photometric scale if needed.
  75735. */
  75736. private _computePhotometricScale;
  75737. /**
  75738. * Returns the Photometric Scale according to the light type and intensity mode.
  75739. */
  75740. private _getPhotometricScale;
  75741. /**
  75742. * Reorder the light in the scene according to their defined priority.
  75743. * @hidden Internal Use Only
  75744. */
  75745. _reorderLightsInScene(): void;
  75746. /**
  75747. * Prepares the list of defines specific to the light type.
  75748. * @param defines the list of defines
  75749. * @param lightIndex defines the index of the light for the effect
  75750. */
  75751. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  75752. }
  75753. }
  75754. declare module BABYLON {
  75755. /**
  75756. * Interface used to define Action
  75757. */
  75758. export interface IAction {
  75759. /**
  75760. * Trigger for the action
  75761. */
  75762. trigger: number;
  75763. /** Options of the trigger */
  75764. triggerOptions: any;
  75765. /**
  75766. * Gets the trigger parameters
  75767. * @returns the trigger parameters
  75768. */
  75769. getTriggerParameter(): any;
  75770. /**
  75771. * Internal only - executes current action event
  75772. * @hidden
  75773. */
  75774. _executeCurrent(evt?: ActionEvent): void;
  75775. /**
  75776. * Serialize placeholder for child classes
  75777. * @param parent of child
  75778. * @returns the serialized object
  75779. */
  75780. serialize(parent: any): any;
  75781. /**
  75782. * Internal only
  75783. * @hidden
  75784. */
  75785. _prepare(): void;
  75786. /**
  75787. * Internal only - manager for action
  75788. * @hidden
  75789. */
  75790. _actionManager: AbstractActionManager;
  75791. /**
  75792. * Adds action to chain of actions, may be a DoNothingAction
  75793. * @param action defines the next action to execute
  75794. * @returns The action passed in
  75795. * @see https://www.babylonjs-playground.com/#1T30HR#0
  75796. */
  75797. then(action: IAction): IAction;
  75798. }
  75799. /**
  75800. * The action to be carried out following a trigger
  75801. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  75802. */
  75803. export class Action implements IAction {
  75804. /** the trigger, with or without parameters, for the action */
  75805. triggerOptions: any;
  75806. /**
  75807. * Trigger for the action
  75808. */
  75809. trigger: number;
  75810. /**
  75811. * Internal only - manager for action
  75812. * @hidden
  75813. */
  75814. _actionManager: ActionManager;
  75815. private _nextActiveAction;
  75816. private _child;
  75817. private _condition?;
  75818. private _triggerParameter;
  75819. /**
  75820. * An event triggered prior to action being executed.
  75821. */
  75822. onBeforeExecuteObservable: Observable<Action>;
  75823. /**
  75824. * Creates a new Action
  75825. * @param triggerOptions the trigger, with or without parameters, for the action
  75826. * @param condition an optional determinant of action
  75827. */
  75828. constructor(
  75829. /** the trigger, with or without parameters, for the action */
  75830. triggerOptions: any, condition?: Condition);
  75831. /**
  75832. * Internal only
  75833. * @hidden
  75834. */
  75835. _prepare(): void;
  75836. /**
  75837. * Gets the trigger parameters
  75838. * @returns the trigger parameters
  75839. */
  75840. getTriggerParameter(): any;
  75841. /**
  75842. * Internal only - executes current action event
  75843. * @hidden
  75844. */
  75845. _executeCurrent(evt?: ActionEvent): void;
  75846. /**
  75847. * Execute placeholder for child classes
  75848. * @param evt optional action event
  75849. */
  75850. execute(evt?: ActionEvent): void;
  75851. /**
  75852. * Skips to next active action
  75853. */
  75854. skipToNextActiveAction(): void;
  75855. /**
  75856. * Adds action to chain of actions, may be a DoNothingAction
  75857. * @param action defines the next action to execute
  75858. * @returns The action passed in
  75859. * @see https://www.babylonjs-playground.com/#1T30HR#0
  75860. */
  75861. then(action: Action): Action;
  75862. /**
  75863. * Internal only
  75864. * @hidden
  75865. */
  75866. _getProperty(propertyPath: string): string;
  75867. /**
  75868. * Internal only
  75869. * @hidden
  75870. */
  75871. _getEffectiveTarget(target: any, propertyPath: string): any;
  75872. /**
  75873. * Serialize placeholder for child classes
  75874. * @param parent of child
  75875. * @returns the serialized object
  75876. */
  75877. serialize(parent: any): any;
  75878. /**
  75879. * Internal only called by serialize
  75880. * @hidden
  75881. */
  75882. protected _serialize(serializedAction: any, parent?: any): any;
  75883. /**
  75884. * Internal only
  75885. * @hidden
  75886. */
  75887. static _SerializeValueAsString: (value: any) => string;
  75888. /**
  75889. * Internal only
  75890. * @hidden
  75891. */
  75892. static _GetTargetProperty: (target: Node | Scene) => {
  75893. name: string;
  75894. targetType: string;
  75895. value: string;
  75896. };
  75897. }
  75898. }
  75899. declare module BABYLON {
  75900. /**
  75901. * A Condition applied to an Action
  75902. */
  75903. export class Condition {
  75904. /**
  75905. * Internal only - manager for action
  75906. * @hidden
  75907. */
  75908. _actionManager: ActionManager;
  75909. /**
  75910. * Internal only
  75911. * @hidden
  75912. */
  75913. _evaluationId: number;
  75914. /**
  75915. * Internal only
  75916. * @hidden
  75917. */
  75918. _currentResult: boolean;
  75919. /**
  75920. * Creates a new Condition
  75921. * @param actionManager the manager of the action the condition is applied to
  75922. */
  75923. constructor(actionManager: ActionManager);
  75924. /**
  75925. * Check if the current condition is valid
  75926. * @returns a boolean
  75927. */
  75928. isValid(): boolean;
  75929. /**
  75930. * Internal only
  75931. * @hidden
  75932. */
  75933. _getProperty(propertyPath: string): string;
  75934. /**
  75935. * Internal only
  75936. * @hidden
  75937. */
  75938. _getEffectiveTarget(target: any, propertyPath: string): any;
  75939. /**
  75940. * Serialize placeholder for child classes
  75941. * @returns the serialized object
  75942. */
  75943. serialize(): any;
  75944. /**
  75945. * Internal only
  75946. * @hidden
  75947. */
  75948. protected _serialize(serializedCondition: any): any;
  75949. }
  75950. /**
  75951. * Defines specific conditional operators as extensions of Condition
  75952. */
  75953. export class ValueCondition extends Condition {
  75954. /** path to specify the property of the target the conditional operator uses */
  75955. propertyPath: string;
  75956. /** the value compared by the conditional operator against the current value of the property */
  75957. value: any;
  75958. /** the conditional operator, default ValueCondition.IsEqual */
  75959. operator: number;
  75960. /**
  75961. * Internal only
  75962. * @hidden
  75963. */
  75964. private static _IsEqual;
  75965. /**
  75966. * Internal only
  75967. * @hidden
  75968. */
  75969. private static _IsDifferent;
  75970. /**
  75971. * Internal only
  75972. * @hidden
  75973. */
  75974. private static _IsGreater;
  75975. /**
  75976. * Internal only
  75977. * @hidden
  75978. */
  75979. private static _IsLesser;
  75980. /**
  75981. * returns the number for IsEqual
  75982. */
  75983. static readonly IsEqual: number;
  75984. /**
  75985. * Returns the number for IsDifferent
  75986. */
  75987. static readonly IsDifferent: number;
  75988. /**
  75989. * Returns the number for IsGreater
  75990. */
  75991. static readonly IsGreater: number;
  75992. /**
  75993. * Returns the number for IsLesser
  75994. */
  75995. static readonly IsLesser: number;
  75996. /**
  75997. * Internal only The action manager for the condition
  75998. * @hidden
  75999. */
  76000. _actionManager: ActionManager;
  76001. /**
  76002. * Internal only
  76003. * @hidden
  76004. */
  76005. private _target;
  76006. /**
  76007. * Internal only
  76008. * @hidden
  76009. */
  76010. private _effectiveTarget;
  76011. /**
  76012. * Internal only
  76013. * @hidden
  76014. */
  76015. private _property;
  76016. /**
  76017. * Creates a new ValueCondition
  76018. * @param actionManager manager for the action the condition applies to
  76019. * @param target for the action
  76020. * @param propertyPath path to specify the property of the target the conditional operator uses
  76021. * @param value the value compared by the conditional operator against the current value of the property
  76022. * @param operator the conditional operator, default ValueCondition.IsEqual
  76023. */
  76024. constructor(actionManager: ActionManager, target: any,
  76025. /** path to specify the property of the target the conditional operator uses */
  76026. propertyPath: string,
  76027. /** the value compared by the conditional operator against the current value of the property */
  76028. value: any,
  76029. /** the conditional operator, default ValueCondition.IsEqual */
  76030. operator?: number);
  76031. /**
  76032. * Compares the given value with the property value for the specified conditional operator
  76033. * @returns the result of the comparison
  76034. */
  76035. isValid(): boolean;
  76036. /**
  76037. * Serialize the ValueCondition into a JSON compatible object
  76038. * @returns serialization object
  76039. */
  76040. serialize(): any;
  76041. /**
  76042. * Gets the name of the conditional operator for the ValueCondition
  76043. * @param operator the conditional operator
  76044. * @returns the name
  76045. */
  76046. static GetOperatorName(operator: number): string;
  76047. }
  76048. /**
  76049. * Defines a predicate condition as an extension of Condition
  76050. */
  76051. export class PredicateCondition extends Condition {
  76052. /** defines the predicate function used to validate the condition */
  76053. predicate: () => boolean;
  76054. /**
  76055. * Internal only - manager for action
  76056. * @hidden
  76057. */
  76058. _actionManager: ActionManager;
  76059. /**
  76060. * Creates a new PredicateCondition
  76061. * @param actionManager manager for the action the condition applies to
  76062. * @param predicate defines the predicate function used to validate the condition
  76063. */
  76064. constructor(actionManager: ActionManager,
  76065. /** defines the predicate function used to validate the condition */
  76066. predicate: () => boolean);
  76067. /**
  76068. * @returns the validity of the predicate condition
  76069. */
  76070. isValid(): boolean;
  76071. }
  76072. /**
  76073. * Defines a state condition as an extension of Condition
  76074. */
  76075. export class StateCondition extends Condition {
  76076. /** Value to compare with target state */
  76077. value: string;
  76078. /**
  76079. * Internal only - manager for action
  76080. * @hidden
  76081. */
  76082. _actionManager: ActionManager;
  76083. /**
  76084. * Internal only
  76085. * @hidden
  76086. */
  76087. private _target;
  76088. /**
  76089. * Creates a new StateCondition
  76090. * @param actionManager manager for the action the condition applies to
  76091. * @param target of the condition
  76092. * @param value to compare with target state
  76093. */
  76094. constructor(actionManager: ActionManager, target: any,
  76095. /** Value to compare with target state */
  76096. value: string);
  76097. /**
  76098. * Gets a boolean indicating if the current condition is met
  76099. * @returns the validity of the state
  76100. */
  76101. isValid(): boolean;
  76102. /**
  76103. * Serialize the StateCondition into a JSON compatible object
  76104. * @returns serialization object
  76105. */
  76106. serialize(): any;
  76107. }
  76108. }
  76109. declare module BABYLON {
  76110. /**
  76111. * This defines an action responsible to toggle a boolean once triggered.
  76112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76113. */
  76114. export class SwitchBooleanAction extends Action {
  76115. /**
  76116. * The path to the boolean property in the target object
  76117. */
  76118. propertyPath: string;
  76119. private _target;
  76120. private _effectiveTarget;
  76121. private _property;
  76122. /**
  76123. * Instantiate the action
  76124. * @param triggerOptions defines the trigger options
  76125. * @param target defines the object containing the boolean
  76126. * @param propertyPath defines the path to the boolean property in the target object
  76127. * @param condition defines the trigger related conditions
  76128. */
  76129. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  76130. /** @hidden */
  76131. _prepare(): void;
  76132. /**
  76133. * Execute the action toggle the boolean value.
  76134. */
  76135. execute(): void;
  76136. /**
  76137. * Serializes the actions and its related information.
  76138. * @param parent defines the object to serialize in
  76139. * @returns the serialized object
  76140. */
  76141. serialize(parent: any): any;
  76142. }
  76143. /**
  76144. * This defines an action responsible to set a the state field of the target
  76145. * to a desired value once triggered.
  76146. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76147. */
  76148. export class SetStateAction extends Action {
  76149. /**
  76150. * The value to store in the state field.
  76151. */
  76152. value: string;
  76153. private _target;
  76154. /**
  76155. * Instantiate the action
  76156. * @param triggerOptions defines the trigger options
  76157. * @param target defines the object containing the state property
  76158. * @param value defines the value to store in the state field
  76159. * @param condition defines the trigger related conditions
  76160. */
  76161. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  76162. /**
  76163. * Execute the action and store the value on the target state property.
  76164. */
  76165. execute(): void;
  76166. /**
  76167. * Serializes the actions and its related information.
  76168. * @param parent defines the object to serialize in
  76169. * @returns the serialized object
  76170. */
  76171. serialize(parent: any): any;
  76172. }
  76173. /**
  76174. * This defines an action responsible to set a property of the target
  76175. * to a desired value once triggered.
  76176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76177. */
  76178. export class SetValueAction extends Action {
  76179. /**
  76180. * The path of the property to set in the target.
  76181. */
  76182. propertyPath: string;
  76183. /**
  76184. * The value to set in the property
  76185. */
  76186. value: any;
  76187. private _target;
  76188. private _effectiveTarget;
  76189. private _property;
  76190. /**
  76191. * Instantiate the action
  76192. * @param triggerOptions defines the trigger options
  76193. * @param target defines the object containing the property
  76194. * @param propertyPath defines the path of the property to set in the target
  76195. * @param value defines the value to set in the property
  76196. * @param condition defines the trigger related conditions
  76197. */
  76198. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76199. /** @hidden */
  76200. _prepare(): void;
  76201. /**
  76202. * Execute the action and set the targetted property to the desired value.
  76203. */
  76204. execute(): void;
  76205. /**
  76206. * Serializes the actions and its related information.
  76207. * @param parent defines the object to serialize in
  76208. * @returns the serialized object
  76209. */
  76210. serialize(parent: any): any;
  76211. }
  76212. /**
  76213. * This defines an action responsible to increment the target value
  76214. * to a desired value once triggered.
  76215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76216. */
  76217. export class IncrementValueAction extends Action {
  76218. /**
  76219. * The path of the property to increment in the target.
  76220. */
  76221. propertyPath: string;
  76222. /**
  76223. * The value we should increment the property by.
  76224. */
  76225. value: any;
  76226. private _target;
  76227. private _effectiveTarget;
  76228. private _property;
  76229. /**
  76230. * Instantiate the action
  76231. * @param triggerOptions defines the trigger options
  76232. * @param target defines the object containing the property
  76233. * @param propertyPath defines the path of the property to increment in the target
  76234. * @param value defines the value value we should increment the property by
  76235. * @param condition defines the trigger related conditions
  76236. */
  76237. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76238. /** @hidden */
  76239. _prepare(): void;
  76240. /**
  76241. * Execute the action and increment the target of the value amount.
  76242. */
  76243. execute(): void;
  76244. /**
  76245. * Serializes the actions and its related information.
  76246. * @param parent defines the object to serialize in
  76247. * @returns the serialized object
  76248. */
  76249. serialize(parent: any): any;
  76250. }
  76251. /**
  76252. * This defines an action responsible to start an animation once triggered.
  76253. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76254. */
  76255. export class PlayAnimationAction extends Action {
  76256. /**
  76257. * Where the animation should start (animation frame)
  76258. */
  76259. from: number;
  76260. /**
  76261. * Where the animation should stop (animation frame)
  76262. */
  76263. to: number;
  76264. /**
  76265. * Define if the animation should loop or stop after the first play.
  76266. */
  76267. loop?: boolean;
  76268. private _target;
  76269. /**
  76270. * Instantiate the action
  76271. * @param triggerOptions defines the trigger options
  76272. * @param target defines the target animation or animation name
  76273. * @param from defines from where the animation should start (animation frame)
  76274. * @param end defines where the animation should stop (animation frame)
  76275. * @param loop defines if the animation should loop or stop after the first play
  76276. * @param condition defines the trigger related conditions
  76277. */
  76278. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  76279. /** @hidden */
  76280. _prepare(): void;
  76281. /**
  76282. * Execute the action and play the animation.
  76283. */
  76284. execute(): void;
  76285. /**
  76286. * Serializes the actions and its related information.
  76287. * @param parent defines the object to serialize in
  76288. * @returns the serialized object
  76289. */
  76290. serialize(parent: any): any;
  76291. }
  76292. /**
  76293. * This defines an action responsible to stop an animation once triggered.
  76294. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76295. */
  76296. export class StopAnimationAction extends Action {
  76297. private _target;
  76298. /**
  76299. * Instantiate the action
  76300. * @param triggerOptions defines the trigger options
  76301. * @param target defines the target animation or animation name
  76302. * @param condition defines the trigger related conditions
  76303. */
  76304. constructor(triggerOptions: any, target: any, condition?: Condition);
  76305. /** @hidden */
  76306. _prepare(): void;
  76307. /**
  76308. * Execute the action and stop the animation.
  76309. */
  76310. execute(): void;
  76311. /**
  76312. * Serializes the actions and its related information.
  76313. * @param parent defines the object to serialize in
  76314. * @returns the serialized object
  76315. */
  76316. serialize(parent: any): any;
  76317. }
  76318. /**
  76319. * This defines an action responsible that does nothing once triggered.
  76320. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76321. */
  76322. export class DoNothingAction extends Action {
  76323. /**
  76324. * Instantiate the action
  76325. * @param triggerOptions defines the trigger options
  76326. * @param condition defines the trigger related conditions
  76327. */
  76328. constructor(triggerOptions?: any, condition?: Condition);
  76329. /**
  76330. * Execute the action and do nothing.
  76331. */
  76332. execute(): void;
  76333. /**
  76334. * Serializes the actions and its related information.
  76335. * @param parent defines the object to serialize in
  76336. * @returns the serialized object
  76337. */
  76338. serialize(parent: any): any;
  76339. }
  76340. /**
  76341. * This defines an action responsible to trigger several actions once triggered.
  76342. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76343. */
  76344. export class CombineAction extends Action {
  76345. /**
  76346. * The list of aggregated animations to run.
  76347. */
  76348. children: Action[];
  76349. /**
  76350. * Instantiate the action
  76351. * @param triggerOptions defines the trigger options
  76352. * @param children defines the list of aggregated animations to run
  76353. * @param condition defines the trigger related conditions
  76354. */
  76355. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  76356. /** @hidden */
  76357. _prepare(): void;
  76358. /**
  76359. * Execute the action and executes all the aggregated actions.
  76360. */
  76361. execute(evt: ActionEvent): void;
  76362. /**
  76363. * Serializes the actions and its related information.
  76364. * @param parent defines the object to serialize in
  76365. * @returns the serialized object
  76366. */
  76367. serialize(parent: any): any;
  76368. }
  76369. /**
  76370. * This defines an action responsible to run code (external event) once triggered.
  76371. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76372. */
  76373. export class ExecuteCodeAction extends Action {
  76374. /**
  76375. * The callback function to run.
  76376. */
  76377. func: (evt: ActionEvent) => void;
  76378. /**
  76379. * Instantiate the action
  76380. * @param triggerOptions defines the trigger options
  76381. * @param func defines the callback function to run
  76382. * @param condition defines the trigger related conditions
  76383. */
  76384. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  76385. /**
  76386. * Execute the action and run the attached code.
  76387. */
  76388. execute(evt: ActionEvent): void;
  76389. }
  76390. /**
  76391. * This defines an action responsible to set the parent property of the target once triggered.
  76392. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76393. */
  76394. export class SetParentAction extends Action {
  76395. private _parent;
  76396. private _target;
  76397. /**
  76398. * Instantiate the action
  76399. * @param triggerOptions defines the trigger options
  76400. * @param target defines the target containing the parent property
  76401. * @param parent defines from where the animation should start (animation frame)
  76402. * @param condition defines the trigger related conditions
  76403. */
  76404. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  76405. /** @hidden */
  76406. _prepare(): void;
  76407. /**
  76408. * Execute the action and set the parent property.
  76409. */
  76410. execute(): void;
  76411. /**
  76412. * Serializes the actions and its related information.
  76413. * @param parent defines the object to serialize in
  76414. * @returns the serialized object
  76415. */
  76416. serialize(parent: any): any;
  76417. }
  76418. }
  76419. declare module BABYLON {
  76420. /**
  76421. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  76422. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  76423. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76424. */
  76425. export class ActionManager extends AbstractActionManager {
  76426. /**
  76427. * Nothing
  76428. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76429. */
  76430. static readonly NothingTrigger: number;
  76431. /**
  76432. * On pick
  76433. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76434. */
  76435. static readonly OnPickTrigger: number;
  76436. /**
  76437. * On left pick
  76438. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76439. */
  76440. static readonly OnLeftPickTrigger: number;
  76441. /**
  76442. * On right pick
  76443. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76444. */
  76445. static readonly OnRightPickTrigger: number;
  76446. /**
  76447. * On center pick
  76448. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76449. */
  76450. static readonly OnCenterPickTrigger: number;
  76451. /**
  76452. * On pick down
  76453. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76454. */
  76455. static readonly OnPickDownTrigger: number;
  76456. /**
  76457. * On double pick
  76458. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76459. */
  76460. static readonly OnDoublePickTrigger: number;
  76461. /**
  76462. * On pick up
  76463. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76464. */
  76465. static readonly OnPickUpTrigger: number;
  76466. /**
  76467. * On pick out.
  76468. * This trigger will only be raised if you also declared a OnPickDown
  76469. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76470. */
  76471. static readonly OnPickOutTrigger: number;
  76472. /**
  76473. * On long press
  76474. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76475. */
  76476. static readonly OnLongPressTrigger: number;
  76477. /**
  76478. * On pointer over
  76479. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76480. */
  76481. static readonly OnPointerOverTrigger: number;
  76482. /**
  76483. * On pointer out
  76484. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76485. */
  76486. static readonly OnPointerOutTrigger: number;
  76487. /**
  76488. * On every frame
  76489. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76490. */
  76491. static readonly OnEveryFrameTrigger: number;
  76492. /**
  76493. * On intersection enter
  76494. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76495. */
  76496. static readonly OnIntersectionEnterTrigger: number;
  76497. /**
  76498. * On intersection exit
  76499. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76500. */
  76501. static readonly OnIntersectionExitTrigger: number;
  76502. /**
  76503. * On key down
  76504. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76505. */
  76506. static readonly OnKeyDownTrigger: number;
  76507. /**
  76508. * On key up
  76509. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76510. */
  76511. static readonly OnKeyUpTrigger: number;
  76512. private _scene;
  76513. /**
  76514. * Creates a new action manager
  76515. * @param scene defines the hosting scene
  76516. */
  76517. constructor(scene: Scene);
  76518. /**
  76519. * Releases all associated resources
  76520. */
  76521. dispose(): void;
  76522. /**
  76523. * Gets hosting scene
  76524. * @returns the hosting scene
  76525. */
  76526. getScene(): Scene;
  76527. /**
  76528. * Does this action manager handles actions of any of the given triggers
  76529. * @param triggers defines the triggers to be tested
  76530. * @return a boolean indicating whether one (or more) of the triggers is handled
  76531. */
  76532. hasSpecificTriggers(triggers: number[]): boolean;
  76533. /**
  76534. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  76535. * speed.
  76536. * @param triggerA defines the trigger to be tested
  76537. * @param triggerB defines the trigger to be tested
  76538. * @return a boolean indicating whether one (or more) of the triggers is handled
  76539. */
  76540. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  76541. /**
  76542. * Does this action manager handles actions of a given trigger
  76543. * @param trigger defines the trigger to be tested
  76544. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  76545. * @return whether the trigger is handled
  76546. */
  76547. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  76548. /**
  76549. * Does this action manager has pointer triggers
  76550. */
  76551. readonly hasPointerTriggers: boolean;
  76552. /**
  76553. * Does this action manager has pick triggers
  76554. */
  76555. readonly hasPickTriggers: boolean;
  76556. /**
  76557. * Registers an action to this action manager
  76558. * @param action defines the action to be registered
  76559. * @return the action amended (prepared) after registration
  76560. */
  76561. registerAction(action: IAction): Nullable<IAction>;
  76562. /**
  76563. * Unregisters an action to this action manager
  76564. * @param action defines the action to be unregistered
  76565. * @return a boolean indicating whether the action has been unregistered
  76566. */
  76567. unregisterAction(action: IAction): Boolean;
  76568. /**
  76569. * Process a specific trigger
  76570. * @param trigger defines the trigger to process
  76571. * @param evt defines the event details to be processed
  76572. */
  76573. processTrigger(trigger: number, evt?: IActionEvent): void;
  76574. /** @hidden */
  76575. _getEffectiveTarget(target: any, propertyPath: string): any;
  76576. /** @hidden */
  76577. _getProperty(propertyPath: string): string;
  76578. /**
  76579. * Serialize this manager to a JSON object
  76580. * @param name defines the property name to store this manager
  76581. * @returns a JSON representation of this manager
  76582. */
  76583. serialize(name: string): any;
  76584. /**
  76585. * Creates a new ActionManager from a JSON data
  76586. * @param parsedActions defines the JSON data to read from
  76587. * @param object defines the hosting mesh
  76588. * @param scene defines the hosting scene
  76589. */
  76590. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  76591. /**
  76592. * Get a trigger name by index
  76593. * @param trigger defines the trigger index
  76594. * @returns a trigger name
  76595. */
  76596. static GetTriggerName(trigger: number): string;
  76597. }
  76598. }
  76599. declare module BABYLON {
  76600. /**
  76601. * Class representing a ray with position and direction
  76602. */
  76603. export class Ray {
  76604. /** origin point */
  76605. origin: Vector3;
  76606. /** direction */
  76607. direction: Vector3;
  76608. /** length of the ray */
  76609. length: number;
  76610. private static readonly TmpVector3;
  76611. private _tmpRay;
  76612. /**
  76613. * Creates a new ray
  76614. * @param origin origin point
  76615. * @param direction direction
  76616. * @param length length of the ray
  76617. */
  76618. constructor(
  76619. /** origin point */
  76620. origin: Vector3,
  76621. /** direction */
  76622. direction: Vector3,
  76623. /** length of the ray */
  76624. length?: number);
  76625. /**
  76626. * Checks if the ray intersects a box
  76627. * @param minimum bound of the box
  76628. * @param maximum bound of the box
  76629. * @param intersectionTreshold extra extend to be added to the box in all direction
  76630. * @returns if the box was hit
  76631. */
  76632. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  76633. /**
  76634. * Checks if the ray intersects a box
  76635. * @param box the bounding box to check
  76636. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  76637. * @returns if the box was hit
  76638. */
  76639. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  76640. /**
  76641. * If the ray hits a sphere
  76642. * @param sphere the bounding sphere to check
  76643. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  76644. * @returns true if it hits the sphere
  76645. */
  76646. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  76647. /**
  76648. * If the ray hits a triange
  76649. * @param vertex0 triangle vertex
  76650. * @param vertex1 triangle vertex
  76651. * @param vertex2 triangle vertex
  76652. * @returns intersection information if hit
  76653. */
  76654. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  76655. /**
  76656. * Checks if ray intersects a plane
  76657. * @param plane the plane to check
  76658. * @returns the distance away it was hit
  76659. */
  76660. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  76661. /**
  76662. * Calculate the intercept of a ray on a given axis
  76663. * @param axis to check 'x' | 'y' | 'z'
  76664. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  76665. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  76666. */
  76667. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  76668. /**
  76669. * Checks if ray intersects a mesh
  76670. * @param mesh the mesh to check
  76671. * @param fastCheck if only the bounding box should checked
  76672. * @returns picking info of the intersecton
  76673. */
  76674. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  76675. /**
  76676. * Checks if ray intersects a mesh
  76677. * @param meshes the meshes to check
  76678. * @param fastCheck if only the bounding box should checked
  76679. * @param results array to store result in
  76680. * @returns Array of picking infos
  76681. */
  76682. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  76683. private _comparePickingInfo;
  76684. private static smallnum;
  76685. private static rayl;
  76686. /**
  76687. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  76688. * @param sega the first point of the segment to test the intersection against
  76689. * @param segb the second point of the segment to test the intersection against
  76690. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  76691. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  76692. */
  76693. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  76694. /**
  76695. * Update the ray from viewport position
  76696. * @param x position
  76697. * @param y y position
  76698. * @param viewportWidth viewport width
  76699. * @param viewportHeight viewport height
  76700. * @param world world matrix
  76701. * @param view view matrix
  76702. * @param projection projection matrix
  76703. * @returns this ray updated
  76704. */
  76705. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  76706. /**
  76707. * Creates a ray with origin and direction of 0,0,0
  76708. * @returns the new ray
  76709. */
  76710. static Zero(): Ray;
  76711. /**
  76712. * Creates a new ray from screen space and viewport
  76713. * @param x position
  76714. * @param y y position
  76715. * @param viewportWidth viewport width
  76716. * @param viewportHeight viewport height
  76717. * @param world world matrix
  76718. * @param view view matrix
  76719. * @param projection projection matrix
  76720. * @returns new ray
  76721. */
  76722. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  76723. /**
  76724. * 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
  76725. * transformed to the given world matrix.
  76726. * @param origin The origin point
  76727. * @param end The end point
  76728. * @param world a matrix to transform the ray to. Default is the identity matrix.
  76729. * @returns the new ray
  76730. */
  76731. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  76732. /**
  76733. * Transforms a ray by a matrix
  76734. * @param ray ray to transform
  76735. * @param matrix matrix to apply
  76736. * @returns the resulting new ray
  76737. */
  76738. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  76739. /**
  76740. * Transforms a ray by a matrix
  76741. * @param ray ray to transform
  76742. * @param matrix matrix to apply
  76743. * @param result ray to store result in
  76744. */
  76745. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  76746. /**
  76747. * Unproject a ray from screen space to object space
  76748. * @param sourceX defines the screen space x coordinate to use
  76749. * @param sourceY defines the screen space y coordinate to use
  76750. * @param viewportWidth defines the current width of the viewport
  76751. * @param viewportHeight defines the current height of the viewport
  76752. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76753. * @param view defines the view matrix to use
  76754. * @param projection defines the projection matrix to use
  76755. */
  76756. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  76757. }
  76758. /**
  76759. * Type used to define predicate used to select faces when a mesh intersection is detected
  76760. */
  76761. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  76762. interface Scene {
  76763. /** @hidden */
  76764. _tempPickingRay: Nullable<Ray>;
  76765. /** @hidden */
  76766. _cachedRayForTransform: Ray;
  76767. /** @hidden */
  76768. _pickWithRayInverseMatrix: Matrix;
  76769. /** @hidden */
  76770. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  76771. /** @hidden */
  76772. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  76773. }
  76774. }
  76775. declare module BABYLON {
  76776. /**
  76777. * Groups all the scene component constants in one place to ease maintenance.
  76778. * @hidden
  76779. */
  76780. export class SceneComponentConstants {
  76781. static readonly NAME_EFFECTLAYER: string;
  76782. static readonly NAME_LAYER: string;
  76783. static readonly NAME_LENSFLARESYSTEM: string;
  76784. static readonly NAME_BOUNDINGBOXRENDERER: string;
  76785. static readonly NAME_PARTICLESYSTEM: string;
  76786. static readonly NAME_GAMEPAD: string;
  76787. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  76788. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  76789. static readonly NAME_DEPTHRENDERER: string;
  76790. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  76791. static readonly NAME_SPRITE: string;
  76792. static readonly NAME_OUTLINERENDERER: string;
  76793. static readonly NAME_PROCEDURALTEXTURE: string;
  76794. static readonly NAME_SHADOWGENERATOR: string;
  76795. static readonly NAME_OCTREE: string;
  76796. static readonly NAME_PHYSICSENGINE: string;
  76797. static readonly NAME_AUDIO: string;
  76798. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  76799. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  76800. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  76801. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  76802. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  76803. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  76804. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  76805. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  76806. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  76807. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  76808. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  76809. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  76810. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  76811. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  76812. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  76813. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  76814. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  76815. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  76816. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  76817. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  76818. static readonly STEP_AFTERRENDER_AUDIO: number;
  76819. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  76820. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  76821. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  76822. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  76823. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  76824. static readonly STEP_POINTERMOVE_SPRITE: number;
  76825. static readonly STEP_POINTERDOWN_SPRITE: number;
  76826. static readonly STEP_POINTERUP_SPRITE: number;
  76827. }
  76828. /**
  76829. * This represents a scene component.
  76830. *
  76831. * This is used to decouple the dependency the scene is having on the different workloads like
  76832. * layers, post processes...
  76833. */
  76834. export interface ISceneComponent {
  76835. /**
  76836. * The name of the component. Each component must have a unique name.
  76837. */
  76838. name: string;
  76839. /**
  76840. * The scene the component belongs to.
  76841. */
  76842. scene: Scene;
  76843. /**
  76844. * Register the component to one instance of a scene.
  76845. */
  76846. register(): void;
  76847. /**
  76848. * Rebuilds the elements related to this component in case of
  76849. * context lost for instance.
  76850. */
  76851. rebuild(): void;
  76852. /**
  76853. * Disposes the component and the associated ressources.
  76854. */
  76855. dispose(): void;
  76856. }
  76857. /**
  76858. * This represents a SERIALIZABLE scene component.
  76859. *
  76860. * This extends Scene Component to add Serialization methods on top.
  76861. */
  76862. export interface ISceneSerializableComponent extends ISceneComponent {
  76863. /**
  76864. * Adds all the elements from the container to the scene
  76865. * @param container the container holding the elements
  76866. */
  76867. addFromContainer(container: AbstractScene): void;
  76868. /**
  76869. * Removes all the elements in the container from the scene
  76870. * @param container contains the elements to remove
  76871. * @param dispose if the removed element should be disposed (default: false)
  76872. */
  76873. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76874. /**
  76875. * Serializes the component data to the specified json object
  76876. * @param serializationObject The object to serialize to
  76877. */
  76878. serialize(serializationObject: any): void;
  76879. }
  76880. /**
  76881. * Strong typing of a Mesh related stage step action
  76882. */
  76883. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  76884. /**
  76885. * Strong typing of a Evaluate Sub Mesh related stage step action
  76886. */
  76887. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  76888. /**
  76889. * Strong typing of a Active Mesh related stage step action
  76890. */
  76891. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  76892. /**
  76893. * Strong typing of a Camera related stage step action
  76894. */
  76895. export type CameraStageAction = (camera: Camera) => void;
  76896. /**
  76897. * Strong typing of a Camera Frame buffer related stage step action
  76898. */
  76899. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  76900. /**
  76901. * Strong typing of a Render Target related stage step action
  76902. */
  76903. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  76904. /**
  76905. * Strong typing of a RenderingGroup related stage step action
  76906. */
  76907. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  76908. /**
  76909. * Strong typing of a Mesh Render related stage step action
  76910. */
  76911. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  76912. /**
  76913. * Strong typing of a simple stage step action
  76914. */
  76915. export type SimpleStageAction = () => void;
  76916. /**
  76917. * Strong typing of a render target action.
  76918. */
  76919. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  76920. /**
  76921. * Strong typing of a pointer move action.
  76922. */
  76923. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  76924. /**
  76925. * Strong typing of a pointer up/down action.
  76926. */
  76927. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  76928. /**
  76929. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  76930. * @hidden
  76931. */
  76932. export class Stage<T extends Function> extends Array<{
  76933. index: number;
  76934. component: ISceneComponent;
  76935. action: T;
  76936. }> {
  76937. /**
  76938. * Hide ctor from the rest of the world.
  76939. * @param items The items to add.
  76940. */
  76941. private constructor();
  76942. /**
  76943. * Creates a new Stage.
  76944. * @returns A new instance of a Stage
  76945. */
  76946. static Create<T extends Function>(): Stage<T>;
  76947. /**
  76948. * Registers a step in an ordered way in the targeted stage.
  76949. * @param index Defines the position to register the step in
  76950. * @param component Defines the component attached to the step
  76951. * @param action Defines the action to launch during the step
  76952. */
  76953. registerStep(index: number, component: ISceneComponent, action: T): void;
  76954. /**
  76955. * Clears all the steps from the stage.
  76956. */
  76957. clear(): void;
  76958. }
  76959. }
  76960. declare module BABYLON {
  76961. interface Scene {
  76962. /** @hidden */
  76963. _pointerOverSprite: Nullable<Sprite>;
  76964. /** @hidden */
  76965. _pickedDownSprite: Nullable<Sprite>;
  76966. /** @hidden */
  76967. _tempSpritePickingRay: Nullable<Ray>;
  76968. /**
  76969. * All of the sprite managers added to this scene
  76970. * @see http://doc.babylonjs.com/babylon101/sprites
  76971. */
  76972. spriteManagers: Array<ISpriteManager>;
  76973. /**
  76974. * An event triggered when sprites rendering is about to start
  76975. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  76976. */
  76977. onBeforeSpritesRenderingObservable: Observable<Scene>;
  76978. /**
  76979. * An event triggered when sprites rendering is done
  76980. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  76981. */
  76982. onAfterSpritesRenderingObservable: Observable<Scene>;
  76983. /** @hidden */
  76984. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  76985. /** Launch a ray to try to pick a sprite in the scene
  76986. * @param x position on screen
  76987. * @param y position on screen
  76988. * @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
  76989. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  76990. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  76991. * @returns a PickingInfo
  76992. */
  76993. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  76994. /** Use the given ray to pick a sprite in the scene
  76995. * @param ray The ray (in world space) to use to pick meshes
  76996. * @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
  76997. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  76998. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  76999. * @returns a PickingInfo
  77000. */
  77001. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77002. /** @hidden */
  77003. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77004. /** Launch a ray to try to pick sprites in the scene
  77005. * @param x position on screen
  77006. * @param y position on screen
  77007. * @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
  77008. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  77009. * @returns a PickingInfo array
  77010. */
  77011. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77012. /** Use the given ray to pick sprites in the scene
  77013. * @param ray The ray (in world space) to use to pick meshes
  77014. * @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
  77015. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  77016. * @returns a PickingInfo array
  77017. */
  77018. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77019. /**
  77020. * Force the sprite under the pointer
  77021. * @param sprite defines the sprite to use
  77022. */
  77023. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  77024. /**
  77025. * Gets the sprite under the pointer
  77026. * @returns a Sprite or null if no sprite is under the pointer
  77027. */
  77028. getPointerOverSprite(): Nullable<Sprite>;
  77029. }
  77030. /**
  77031. * Defines the sprite scene component responsible to manage sprites
  77032. * in a given scene.
  77033. */
  77034. export class SpriteSceneComponent implements ISceneComponent {
  77035. /**
  77036. * The component name helpfull to identify the component in the list of scene components.
  77037. */
  77038. readonly name: string;
  77039. /**
  77040. * The scene the component belongs to.
  77041. */
  77042. scene: Scene;
  77043. /** @hidden */
  77044. private _spritePredicate;
  77045. /**
  77046. * Creates a new instance of the component for the given scene
  77047. * @param scene Defines the scene to register the component in
  77048. */
  77049. constructor(scene: Scene);
  77050. /**
  77051. * Registers the component in a given scene
  77052. */
  77053. register(): void;
  77054. /**
  77055. * Rebuilds the elements related to this component in case of
  77056. * context lost for instance.
  77057. */
  77058. rebuild(): void;
  77059. /**
  77060. * Disposes the component and the associated ressources.
  77061. */
  77062. dispose(): void;
  77063. private _pickSpriteButKeepRay;
  77064. private _pointerMove;
  77065. private _pointerDown;
  77066. private _pointerUp;
  77067. }
  77068. }
  77069. declare module BABYLON {
  77070. /** @hidden */
  77071. export var fogFragmentDeclaration: {
  77072. name: string;
  77073. shader: string;
  77074. };
  77075. }
  77076. declare module BABYLON {
  77077. /** @hidden */
  77078. export var fogFragment: {
  77079. name: string;
  77080. shader: string;
  77081. };
  77082. }
  77083. declare module BABYLON {
  77084. /** @hidden */
  77085. export var spritesPixelShader: {
  77086. name: string;
  77087. shader: string;
  77088. };
  77089. }
  77090. declare module BABYLON {
  77091. /** @hidden */
  77092. export var fogVertexDeclaration: {
  77093. name: string;
  77094. shader: string;
  77095. };
  77096. }
  77097. declare module BABYLON {
  77098. /** @hidden */
  77099. export var spritesVertexShader: {
  77100. name: string;
  77101. shader: string;
  77102. };
  77103. }
  77104. declare module BABYLON {
  77105. /**
  77106. * Defines the minimum interface to fullfil in order to be a sprite manager.
  77107. */
  77108. export interface ISpriteManager extends IDisposable {
  77109. /**
  77110. * Restricts the camera to viewing objects with the same layerMask.
  77111. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  77112. */
  77113. layerMask: number;
  77114. /**
  77115. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  77116. */
  77117. isPickable: boolean;
  77118. /**
  77119. * Specifies the rendering group id for this mesh (0 by default)
  77120. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  77121. */
  77122. renderingGroupId: number;
  77123. /**
  77124. * Defines the list of sprites managed by the manager.
  77125. */
  77126. sprites: Array<Sprite>;
  77127. /**
  77128. * Tests the intersection of a sprite with a specific ray.
  77129. * @param ray The ray we are sending to test the collision
  77130. * @param camera The camera space we are sending rays in
  77131. * @param predicate A predicate allowing excluding sprites from the list of object to test
  77132. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  77133. * @returns picking info or null.
  77134. */
  77135. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  77136. /**
  77137. * Intersects the sprites with a ray
  77138. * @param ray defines the ray to intersect with
  77139. * @param camera defines the current active camera
  77140. * @param predicate defines a predicate used to select candidate sprites
  77141. * @returns null if no hit or a PickingInfo array
  77142. */
  77143. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  77144. /**
  77145. * Renders the list of sprites on screen.
  77146. */
  77147. render(): void;
  77148. }
  77149. /**
  77150. * Class used to manage multiple sprites on the same spritesheet
  77151. * @see http://doc.babylonjs.com/babylon101/sprites
  77152. */
  77153. export class SpriteManager implements ISpriteManager {
  77154. /** defines the manager's name */
  77155. name: string;
  77156. /** Gets the list of sprites */
  77157. sprites: Sprite[];
  77158. /** Gets or sets the rendering group id (0 by default) */
  77159. renderingGroupId: number;
  77160. /** Gets or sets camera layer mask */
  77161. layerMask: number;
  77162. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  77163. fogEnabled: boolean;
  77164. /** Gets or sets a boolean indicating if the sprites are pickable */
  77165. isPickable: boolean;
  77166. /** Defines the default width of a cell in the spritesheet */
  77167. cellWidth: number;
  77168. /** Defines the default height of a cell in the spritesheet */
  77169. cellHeight: number;
  77170. /** Associative array from JSON sprite data file */
  77171. private _cellData;
  77172. /** Array of sprite names from JSON sprite data file */
  77173. private _spriteMap;
  77174. /** True when packed cell data from JSON file is ready*/
  77175. private _packedAndReady;
  77176. /**
  77177. * An event triggered when the manager is disposed.
  77178. */
  77179. onDisposeObservable: Observable<SpriteManager>;
  77180. private _onDisposeObserver;
  77181. /**
  77182. * Callback called when the manager is disposed
  77183. */
  77184. onDispose: () => void;
  77185. private _capacity;
  77186. private _fromPacked;
  77187. private _spriteTexture;
  77188. private _epsilon;
  77189. private _scene;
  77190. private _vertexData;
  77191. private _buffer;
  77192. private _vertexBuffers;
  77193. private _indexBuffer;
  77194. private _effectBase;
  77195. private _effectFog;
  77196. /**
  77197. * Gets or sets the spritesheet texture
  77198. */
  77199. texture: Texture;
  77200. /**
  77201. * Creates a new sprite manager
  77202. * @param name defines the manager's name
  77203. * @param imgUrl defines the sprite sheet url
  77204. * @param capacity defines the maximum allowed number of sprites
  77205. * @param cellSize defines the size of a sprite cell
  77206. * @param scene defines the hosting scene
  77207. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77208. * @param samplingMode defines the smapling mode to use with spritesheet
  77209. * @param fromPacked set to false; do not alter
  77210. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  77211. */
  77212. constructor(
  77213. /** defines the manager's name */
  77214. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  77215. private _makePacked;
  77216. private _appendSpriteVertex;
  77217. /**
  77218. * Intersects the sprites with a ray
  77219. * @param ray defines the ray to intersect with
  77220. * @param camera defines the current active camera
  77221. * @param predicate defines a predicate used to select candidate sprites
  77222. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  77223. * @returns null if no hit or a PickingInfo
  77224. */
  77225. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  77226. /**
  77227. * Intersects the sprites with a ray
  77228. * @param ray defines the ray to intersect with
  77229. * @param camera defines the current active camera
  77230. * @param predicate defines a predicate used to select candidate sprites
  77231. * @returns null if no hit or a PickingInfo array
  77232. */
  77233. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  77234. /**
  77235. * Render all child sprites
  77236. */
  77237. render(): void;
  77238. /**
  77239. * Release associated resources
  77240. */
  77241. dispose(): void;
  77242. }
  77243. }
  77244. declare module BABYLON {
  77245. /**
  77246. * Class used to represent a sprite
  77247. * @see http://doc.babylonjs.com/babylon101/sprites
  77248. */
  77249. export class Sprite {
  77250. /** defines the name */
  77251. name: string;
  77252. /** Gets or sets the current world position */
  77253. position: Vector3;
  77254. /** Gets or sets the main color */
  77255. color: Color4;
  77256. /** Gets or sets the width */
  77257. width: number;
  77258. /** Gets or sets the height */
  77259. height: number;
  77260. /** Gets or sets rotation angle */
  77261. angle: number;
  77262. /** Gets or sets the cell index in the sprite sheet */
  77263. cellIndex: number;
  77264. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  77265. cellRef: string;
  77266. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  77267. invertU: number;
  77268. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  77269. invertV: number;
  77270. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  77271. disposeWhenFinishedAnimating: boolean;
  77272. /** Gets the list of attached animations */
  77273. animations: Animation[];
  77274. /** Gets or sets a boolean indicating if the sprite can be picked */
  77275. isPickable: boolean;
  77276. /**
  77277. * Gets or sets the associated action manager
  77278. */
  77279. actionManager: Nullable<ActionManager>;
  77280. private _animationStarted;
  77281. private _loopAnimation;
  77282. private _fromIndex;
  77283. private _toIndex;
  77284. private _delay;
  77285. private _direction;
  77286. private _manager;
  77287. private _time;
  77288. private _onAnimationEnd;
  77289. /**
  77290. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  77291. */
  77292. isVisible: boolean;
  77293. /**
  77294. * Gets or sets the sprite size
  77295. */
  77296. size: number;
  77297. /**
  77298. * Creates a new Sprite
  77299. * @param name defines the name
  77300. * @param manager defines the manager
  77301. */
  77302. constructor(
  77303. /** defines the name */
  77304. name: string, manager: ISpriteManager);
  77305. /**
  77306. * Starts an animation
  77307. * @param from defines the initial key
  77308. * @param to defines the end key
  77309. * @param loop defines if the animation must loop
  77310. * @param delay defines the start delay (in ms)
  77311. * @param onAnimationEnd defines a callback to call when animation ends
  77312. */
  77313. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  77314. /** Stops current animation (if any) */
  77315. stopAnimation(): void;
  77316. /** @hidden */
  77317. _animate(deltaTime: number): void;
  77318. /** Release associated resources */
  77319. dispose(): void;
  77320. }
  77321. }
  77322. declare module BABYLON {
  77323. /**
  77324. * Information about the result of picking within a scene
  77325. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  77326. */
  77327. export class PickingInfo {
  77328. /** @hidden */
  77329. _pickingUnavailable: boolean;
  77330. /**
  77331. * If the pick collided with an object
  77332. */
  77333. hit: boolean;
  77334. /**
  77335. * Distance away where the pick collided
  77336. */
  77337. distance: number;
  77338. /**
  77339. * The location of pick collision
  77340. */
  77341. pickedPoint: Nullable<Vector3>;
  77342. /**
  77343. * The mesh corresponding the the pick collision
  77344. */
  77345. pickedMesh: Nullable<AbstractMesh>;
  77346. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  77347. bu: number;
  77348. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  77349. bv: number;
  77350. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  77351. faceId: number;
  77352. /** Id of the the submesh that was picked */
  77353. subMeshId: number;
  77354. /** If a sprite was picked, this will be the sprite the pick collided with */
  77355. pickedSprite: Nullable<Sprite>;
  77356. /**
  77357. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  77358. */
  77359. originMesh: Nullable<AbstractMesh>;
  77360. /**
  77361. * The ray that was used to perform the picking.
  77362. */
  77363. ray: Nullable<Ray>;
  77364. /**
  77365. * Gets the normal correspodning to the face the pick collided with
  77366. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  77367. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  77368. * @returns The normal correspodning to the face the pick collided with
  77369. */
  77370. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  77371. /**
  77372. * Gets the texture coordinates of where the pick occured
  77373. * @returns the vector containing the coordnates of the texture
  77374. */
  77375. getTextureCoordinates(): Nullable<Vector2>;
  77376. }
  77377. }
  77378. declare module BABYLON {
  77379. /**
  77380. * Gather the list of pointer event types as constants.
  77381. */
  77382. export class PointerEventTypes {
  77383. /**
  77384. * 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.
  77385. */
  77386. static readonly POINTERDOWN: number;
  77387. /**
  77388. * The pointerup event is fired when a pointer is no longer active.
  77389. */
  77390. static readonly POINTERUP: number;
  77391. /**
  77392. * The pointermove event is fired when a pointer changes coordinates.
  77393. */
  77394. static readonly POINTERMOVE: number;
  77395. /**
  77396. * The pointerwheel event is fired when a mouse wheel has been rotated.
  77397. */
  77398. static readonly POINTERWHEEL: number;
  77399. /**
  77400. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  77401. */
  77402. static readonly POINTERPICK: number;
  77403. /**
  77404. * The pointertap event is fired when a the object has been touched and released without drag.
  77405. */
  77406. static readonly POINTERTAP: number;
  77407. /**
  77408. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  77409. */
  77410. static readonly POINTERDOUBLETAP: number;
  77411. }
  77412. /**
  77413. * Base class of pointer info types.
  77414. */
  77415. export class PointerInfoBase {
  77416. /**
  77417. * Defines the type of event (PointerEventTypes)
  77418. */
  77419. type: number;
  77420. /**
  77421. * Defines the related dom event
  77422. */
  77423. event: PointerEvent | MouseWheelEvent;
  77424. /**
  77425. * Instantiates the base class of pointers info.
  77426. * @param type Defines the type of event (PointerEventTypes)
  77427. * @param event Defines the related dom event
  77428. */
  77429. constructor(
  77430. /**
  77431. * Defines the type of event (PointerEventTypes)
  77432. */
  77433. type: number,
  77434. /**
  77435. * Defines the related dom event
  77436. */
  77437. event: PointerEvent | MouseWheelEvent);
  77438. }
  77439. /**
  77440. * This class is used to store pointer related info for the onPrePointerObservable event.
  77441. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  77442. */
  77443. export class PointerInfoPre extends PointerInfoBase {
  77444. /**
  77445. * Ray from a pointer if availible (eg. 6dof controller)
  77446. */
  77447. ray: Nullable<Ray>;
  77448. /**
  77449. * Defines the local position of the pointer on the canvas.
  77450. */
  77451. localPosition: Vector2;
  77452. /**
  77453. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  77454. */
  77455. skipOnPointerObservable: boolean;
  77456. /**
  77457. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  77458. * @param type Defines the type of event (PointerEventTypes)
  77459. * @param event Defines the related dom event
  77460. * @param localX Defines the local x coordinates of the pointer when the event occured
  77461. * @param localY Defines the local y coordinates of the pointer when the event occured
  77462. */
  77463. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  77464. }
  77465. /**
  77466. * This type contains all the data related to a pointer event in Babylon.js.
  77467. * 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.
  77468. */
  77469. export class PointerInfo extends PointerInfoBase {
  77470. /**
  77471. * Defines the picking info associated to the info (if any)\
  77472. */
  77473. pickInfo: Nullable<PickingInfo>;
  77474. /**
  77475. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  77476. * @param type Defines the type of event (PointerEventTypes)
  77477. * @param event Defines the related dom event
  77478. * @param pickInfo Defines the picking info associated to the info (if any)\
  77479. */
  77480. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  77481. /**
  77482. * Defines the picking info associated to the info (if any)\
  77483. */
  77484. pickInfo: Nullable<PickingInfo>);
  77485. }
  77486. /**
  77487. * Data relating to a touch event on the screen.
  77488. */
  77489. export interface PointerTouch {
  77490. /**
  77491. * X coordinate of touch.
  77492. */
  77493. x: number;
  77494. /**
  77495. * Y coordinate of touch.
  77496. */
  77497. y: number;
  77498. /**
  77499. * Id of touch. Unique for each finger.
  77500. */
  77501. pointerId: number;
  77502. /**
  77503. * Event type passed from DOM.
  77504. */
  77505. type: any;
  77506. }
  77507. }
  77508. declare module BABYLON {
  77509. /**
  77510. * Manage the mouse inputs to control the movement of a free camera.
  77511. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77512. */
  77513. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  77514. /**
  77515. * Define if touch is enabled in the mouse input
  77516. */
  77517. touchEnabled: boolean;
  77518. /**
  77519. * Defines the camera the input is attached to.
  77520. */
  77521. camera: FreeCamera;
  77522. /**
  77523. * Defines the buttons associated with the input to handle camera move.
  77524. */
  77525. buttons: number[];
  77526. /**
  77527. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  77528. */
  77529. angularSensibility: number;
  77530. private _pointerInput;
  77531. private _onMouseMove;
  77532. private _observer;
  77533. private previousPosition;
  77534. /**
  77535. * Observable for when a pointer move event occurs containing the move offset
  77536. */
  77537. onPointerMovedObservable: Observable<{
  77538. offsetX: number;
  77539. offsetY: number;
  77540. }>;
  77541. /**
  77542. * @hidden
  77543. * If the camera should be rotated automatically based on pointer movement
  77544. */
  77545. _allowCameraRotation: boolean;
  77546. /**
  77547. * Manage the mouse inputs to control the movement of a free camera.
  77548. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77549. * @param touchEnabled Defines if touch is enabled or not
  77550. */
  77551. constructor(
  77552. /**
  77553. * Define if touch is enabled in the mouse input
  77554. */
  77555. touchEnabled?: boolean);
  77556. /**
  77557. * Attach the input controls to a specific dom element to get the input from.
  77558. * @param element Defines the element the controls should be listened from
  77559. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77560. */
  77561. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77562. /**
  77563. * Called on JS contextmenu event.
  77564. * Override this method to provide functionality.
  77565. */
  77566. protected onContextMenu(evt: PointerEvent): void;
  77567. /**
  77568. * Detach the current controls from the specified dom element.
  77569. * @param element Defines the element to stop listening the inputs from
  77570. */
  77571. detachControl(element: Nullable<HTMLElement>): void;
  77572. /**
  77573. * Gets the class name of the current intput.
  77574. * @returns the class name
  77575. */
  77576. getClassName(): string;
  77577. /**
  77578. * Get the friendly name associated with the input class.
  77579. * @returns the input friendly name
  77580. */
  77581. getSimpleName(): string;
  77582. }
  77583. }
  77584. declare module BABYLON {
  77585. /**
  77586. * Manage the touch inputs to control the movement of a free camera.
  77587. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77588. */
  77589. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  77590. /**
  77591. * Defines the camera the input is attached to.
  77592. */
  77593. camera: FreeCamera;
  77594. /**
  77595. * Defines the touch sensibility for rotation.
  77596. * The higher the faster.
  77597. */
  77598. touchAngularSensibility: number;
  77599. /**
  77600. * Defines the touch sensibility for move.
  77601. * The higher the faster.
  77602. */
  77603. touchMoveSensibility: number;
  77604. private _offsetX;
  77605. private _offsetY;
  77606. private _pointerPressed;
  77607. private _pointerInput;
  77608. private _observer;
  77609. private _onLostFocus;
  77610. /**
  77611. * Attach the input controls to a specific dom element to get the input from.
  77612. * @param element Defines the element the controls should be listened from
  77613. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77614. */
  77615. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77616. /**
  77617. * Detach the current controls from the specified dom element.
  77618. * @param element Defines the element to stop listening the inputs from
  77619. */
  77620. detachControl(element: Nullable<HTMLElement>): void;
  77621. /**
  77622. * Update the current camera state depending on the inputs that have been used this frame.
  77623. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  77624. */
  77625. checkInputs(): void;
  77626. /**
  77627. * Gets the class name of the current intput.
  77628. * @returns the class name
  77629. */
  77630. getClassName(): string;
  77631. /**
  77632. * Get the friendly name associated with the input class.
  77633. * @returns the input friendly name
  77634. */
  77635. getSimpleName(): string;
  77636. }
  77637. }
  77638. declare module BABYLON {
  77639. /**
  77640. * Default Inputs manager for the FreeCamera.
  77641. * It groups all the default supported inputs for ease of use.
  77642. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77643. */
  77644. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  77645. /**
  77646. * @hidden
  77647. */
  77648. _mouseInput: Nullable<FreeCameraMouseInput>;
  77649. /**
  77650. * Instantiates a new FreeCameraInputsManager.
  77651. * @param camera Defines the camera the inputs belong to
  77652. */
  77653. constructor(camera: FreeCamera);
  77654. /**
  77655. * Add keyboard input support to the input manager.
  77656. * @returns the current input manager
  77657. */
  77658. addKeyboard(): FreeCameraInputsManager;
  77659. /**
  77660. * Add mouse input support to the input manager.
  77661. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  77662. * @returns the current input manager
  77663. */
  77664. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  77665. /**
  77666. * Removes the mouse input support from the manager
  77667. * @returns the current input manager
  77668. */
  77669. removeMouse(): FreeCameraInputsManager;
  77670. /**
  77671. * Add touch input support to the input manager.
  77672. * @returns the current input manager
  77673. */
  77674. addTouch(): FreeCameraInputsManager;
  77675. /**
  77676. * Remove all attached input methods from a camera
  77677. */
  77678. clear(): void;
  77679. }
  77680. }
  77681. declare module BABYLON {
  77682. /**
  77683. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  77684. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  77685. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  77686. */
  77687. export class FreeCamera extends TargetCamera {
  77688. /**
  77689. * Define the collision ellipsoid of the camera.
  77690. * This is helpful to simulate a camera body like the player body around the camera
  77691. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  77692. */
  77693. ellipsoid: Vector3;
  77694. /**
  77695. * Define an offset for the position of the ellipsoid around the camera.
  77696. * This can be helpful to determine the center of the body near the gravity center of the body
  77697. * instead of its head.
  77698. */
  77699. ellipsoidOffset: Vector3;
  77700. /**
  77701. * Enable or disable collisions of the camera with the rest of the scene objects.
  77702. */
  77703. checkCollisions: boolean;
  77704. /**
  77705. * Enable or disable gravity on the camera.
  77706. */
  77707. applyGravity: boolean;
  77708. /**
  77709. * Define the input manager associated to the camera.
  77710. */
  77711. inputs: FreeCameraInputsManager;
  77712. /**
  77713. * Gets the input sensibility for a mouse input. (default is 2000.0)
  77714. * Higher values reduce sensitivity.
  77715. */
  77716. /**
  77717. * Sets the input sensibility for a mouse input. (default is 2000.0)
  77718. * Higher values reduce sensitivity.
  77719. */
  77720. angularSensibility: number;
  77721. /**
  77722. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  77723. */
  77724. keysUp: number[];
  77725. /**
  77726. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  77727. */
  77728. keysDown: number[];
  77729. /**
  77730. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  77731. */
  77732. keysLeft: number[];
  77733. /**
  77734. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  77735. */
  77736. keysRight: number[];
  77737. /**
  77738. * Event raised when the camera collide with a mesh in the scene.
  77739. */
  77740. onCollide: (collidedMesh: AbstractMesh) => void;
  77741. private _collider;
  77742. private _needMoveForGravity;
  77743. private _oldPosition;
  77744. private _diffPosition;
  77745. private _newPosition;
  77746. /** @hidden */
  77747. _localDirection: Vector3;
  77748. /** @hidden */
  77749. _transformedDirection: Vector3;
  77750. /**
  77751. * Instantiates a Free Camera.
  77752. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  77753. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  77754. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  77755. * @param name Define the name of the camera in the scene
  77756. * @param position Define the start position of the camera in the scene
  77757. * @param scene Define the scene the camera belongs to
  77758. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  77759. */
  77760. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  77761. /**
  77762. * Attached controls to the current camera.
  77763. * @param element Defines the element the controls should be listened from
  77764. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77765. */
  77766. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77767. /**
  77768. * Detach the current controls from the camera.
  77769. * The camera will stop reacting to inputs.
  77770. * @param element Defines the element to stop listening the inputs from
  77771. */
  77772. detachControl(element: HTMLElement): void;
  77773. private _collisionMask;
  77774. /**
  77775. * Define a collision mask to limit the list of object the camera can collide with
  77776. */
  77777. collisionMask: number;
  77778. /** @hidden */
  77779. _collideWithWorld(displacement: Vector3): void;
  77780. private _onCollisionPositionChange;
  77781. /** @hidden */
  77782. _checkInputs(): void;
  77783. /** @hidden */
  77784. _decideIfNeedsToMove(): boolean;
  77785. /** @hidden */
  77786. _updatePosition(): void;
  77787. /**
  77788. * Destroy the camera and release the current resources hold by it.
  77789. */
  77790. dispose(): void;
  77791. /**
  77792. * Gets the current object class name.
  77793. * @return the class name
  77794. */
  77795. getClassName(): string;
  77796. }
  77797. }
  77798. declare module BABYLON {
  77799. /**
  77800. * Represents a gamepad control stick position
  77801. */
  77802. export class StickValues {
  77803. /**
  77804. * The x component of the control stick
  77805. */
  77806. x: number;
  77807. /**
  77808. * The y component of the control stick
  77809. */
  77810. y: number;
  77811. /**
  77812. * Initializes the gamepad x and y control stick values
  77813. * @param x The x component of the gamepad control stick value
  77814. * @param y The y component of the gamepad control stick value
  77815. */
  77816. constructor(
  77817. /**
  77818. * The x component of the control stick
  77819. */
  77820. x: number,
  77821. /**
  77822. * The y component of the control stick
  77823. */
  77824. y: number);
  77825. }
  77826. /**
  77827. * An interface which manages callbacks for gamepad button changes
  77828. */
  77829. export interface GamepadButtonChanges {
  77830. /**
  77831. * Called when a gamepad has been changed
  77832. */
  77833. changed: boolean;
  77834. /**
  77835. * Called when a gamepad press event has been triggered
  77836. */
  77837. pressChanged: boolean;
  77838. /**
  77839. * Called when a touch event has been triggered
  77840. */
  77841. touchChanged: boolean;
  77842. /**
  77843. * Called when a value has changed
  77844. */
  77845. valueChanged: boolean;
  77846. }
  77847. /**
  77848. * Represents a gamepad
  77849. */
  77850. export class Gamepad {
  77851. /**
  77852. * The id of the gamepad
  77853. */
  77854. id: string;
  77855. /**
  77856. * The index of the gamepad
  77857. */
  77858. index: number;
  77859. /**
  77860. * The browser gamepad
  77861. */
  77862. browserGamepad: any;
  77863. /**
  77864. * Specifies what type of gamepad this represents
  77865. */
  77866. type: number;
  77867. private _leftStick;
  77868. private _rightStick;
  77869. /** @hidden */
  77870. _isConnected: boolean;
  77871. private _leftStickAxisX;
  77872. private _leftStickAxisY;
  77873. private _rightStickAxisX;
  77874. private _rightStickAxisY;
  77875. /**
  77876. * Triggered when the left control stick has been changed
  77877. */
  77878. private _onleftstickchanged;
  77879. /**
  77880. * Triggered when the right control stick has been changed
  77881. */
  77882. private _onrightstickchanged;
  77883. /**
  77884. * Represents a gamepad controller
  77885. */
  77886. static GAMEPAD: number;
  77887. /**
  77888. * Represents a generic controller
  77889. */
  77890. static GENERIC: number;
  77891. /**
  77892. * Represents an XBox controller
  77893. */
  77894. static XBOX: number;
  77895. /**
  77896. * Represents a pose-enabled controller
  77897. */
  77898. static POSE_ENABLED: number;
  77899. /**
  77900. * Represents an Dual Shock controller
  77901. */
  77902. static DUALSHOCK: number;
  77903. /**
  77904. * Specifies whether the left control stick should be Y-inverted
  77905. */
  77906. protected _invertLeftStickY: boolean;
  77907. /**
  77908. * Specifies if the gamepad has been connected
  77909. */
  77910. readonly isConnected: boolean;
  77911. /**
  77912. * Initializes the gamepad
  77913. * @param id The id of the gamepad
  77914. * @param index The index of the gamepad
  77915. * @param browserGamepad The browser gamepad
  77916. * @param leftStickX The x component of the left joystick
  77917. * @param leftStickY The y component of the left joystick
  77918. * @param rightStickX The x component of the right joystick
  77919. * @param rightStickY The y component of the right joystick
  77920. */
  77921. constructor(
  77922. /**
  77923. * The id of the gamepad
  77924. */
  77925. id: string,
  77926. /**
  77927. * The index of the gamepad
  77928. */
  77929. index: number,
  77930. /**
  77931. * The browser gamepad
  77932. */
  77933. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  77934. /**
  77935. * Callback triggered when the left joystick has changed
  77936. * @param callback
  77937. */
  77938. onleftstickchanged(callback: (values: StickValues) => void): void;
  77939. /**
  77940. * Callback triggered when the right joystick has changed
  77941. * @param callback
  77942. */
  77943. onrightstickchanged(callback: (values: StickValues) => void): void;
  77944. /**
  77945. * Gets the left joystick
  77946. */
  77947. /**
  77948. * Sets the left joystick values
  77949. */
  77950. leftStick: StickValues;
  77951. /**
  77952. * Gets the right joystick
  77953. */
  77954. /**
  77955. * Sets the right joystick value
  77956. */
  77957. rightStick: StickValues;
  77958. /**
  77959. * Updates the gamepad joystick positions
  77960. */
  77961. update(): void;
  77962. /**
  77963. * Disposes the gamepad
  77964. */
  77965. dispose(): void;
  77966. }
  77967. /**
  77968. * Represents a generic gamepad
  77969. */
  77970. export class GenericPad extends Gamepad {
  77971. private _buttons;
  77972. private _onbuttondown;
  77973. private _onbuttonup;
  77974. /**
  77975. * Observable triggered when a button has been pressed
  77976. */
  77977. onButtonDownObservable: Observable<number>;
  77978. /**
  77979. * Observable triggered when a button has been released
  77980. */
  77981. onButtonUpObservable: Observable<number>;
  77982. /**
  77983. * Callback triggered when a button has been pressed
  77984. * @param callback Called when a button has been pressed
  77985. */
  77986. onbuttondown(callback: (buttonPressed: number) => void): void;
  77987. /**
  77988. * Callback triggered when a button has been released
  77989. * @param callback Called when a button has been released
  77990. */
  77991. onbuttonup(callback: (buttonReleased: number) => void): void;
  77992. /**
  77993. * Initializes the generic gamepad
  77994. * @param id The id of the generic gamepad
  77995. * @param index The index of the generic gamepad
  77996. * @param browserGamepad The browser gamepad
  77997. */
  77998. constructor(id: string, index: number, browserGamepad: any);
  77999. private _setButtonValue;
  78000. /**
  78001. * Updates the generic gamepad
  78002. */
  78003. update(): void;
  78004. /**
  78005. * Disposes the generic gamepad
  78006. */
  78007. dispose(): void;
  78008. }
  78009. }
  78010. declare module BABYLON {
  78011. interface Engine {
  78012. /**
  78013. * Creates a raw texture
  78014. * @param data defines the data to store in the texture
  78015. * @param width defines the width of the texture
  78016. * @param height defines the height of the texture
  78017. * @param format defines the format of the data
  78018. * @param generateMipMaps defines if the engine should generate the mip levels
  78019. * @param invertY defines if data must be stored with Y axis inverted
  78020. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78021. * @param compression defines the compression used (null by default)
  78022. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78023. * @returns the raw texture inside an InternalTexture
  78024. */
  78025. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  78026. /**
  78027. * Update a raw texture
  78028. * @param texture defines the texture to update
  78029. * @param data defines the data to store in the texture
  78030. * @param format defines the format of the data
  78031. * @param invertY defines if data must be stored with Y axis inverted
  78032. */
  78033. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78034. /**
  78035. * Update a raw texture
  78036. * @param texture defines the texture to update
  78037. * @param data defines the data to store in the texture
  78038. * @param format defines the format of the data
  78039. * @param invertY defines if data must be stored with Y axis inverted
  78040. * @param compression defines the compression used (null by default)
  78041. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78042. */
  78043. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  78044. /**
  78045. * Creates a new raw cube texture
  78046. * @param data defines the array of data to use to create each face
  78047. * @param size defines the size of the textures
  78048. * @param format defines the format of the data
  78049. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78050. * @param generateMipMaps defines if the engine should generate the mip levels
  78051. * @param invertY defines if data must be stored with Y axis inverted
  78052. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78053. * @param compression defines the compression used (null by default)
  78054. * @returns the cube texture as an InternalTexture
  78055. */
  78056. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  78057. /**
  78058. * Update a raw cube texture
  78059. * @param texture defines the texture to udpdate
  78060. * @param data defines the data to store
  78061. * @param format defines the data format
  78062. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78063. * @param invertY defines if data must be stored with Y axis inverted
  78064. */
  78065. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  78066. /**
  78067. * Update a raw cube texture
  78068. * @param texture defines the texture to udpdate
  78069. * @param data defines the data to store
  78070. * @param format defines the data format
  78071. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78072. * @param invertY defines if data must be stored with Y axis inverted
  78073. * @param compression defines the compression used (null by default)
  78074. */
  78075. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  78076. /**
  78077. * Update a raw cube texture
  78078. * @param texture defines the texture to udpdate
  78079. * @param data defines the data to store
  78080. * @param format defines the data format
  78081. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78082. * @param invertY defines if data must be stored with Y axis inverted
  78083. * @param compression defines the compression used (null by default)
  78084. * @param level defines which level of the texture to update
  78085. */
  78086. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  78087. /**
  78088. * Creates a new raw cube texture from a specified url
  78089. * @param url defines the url where the data is located
  78090. * @param scene defines the current scene
  78091. * @param size defines the size of the textures
  78092. * @param format defines the format of the data
  78093. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78094. * @param noMipmap defines if the engine should avoid generating the mip levels
  78095. * @param callback defines a callback used to extract texture data from loaded data
  78096. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78097. * @param onLoad defines a callback called when texture is loaded
  78098. * @param onError defines a callback called if there is an error
  78099. * @returns the cube texture as an InternalTexture
  78100. */
  78101. 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;
  78102. /**
  78103. * Creates a new raw cube texture from a specified url
  78104. * @param url defines the url where the data is located
  78105. * @param scene defines the current scene
  78106. * @param size defines the size of the textures
  78107. * @param format defines the format of the data
  78108. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78109. * @param noMipmap defines if the engine should avoid generating the mip levels
  78110. * @param callback defines a callback used to extract texture data from loaded data
  78111. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78112. * @param onLoad defines a callback called when texture is loaded
  78113. * @param onError defines a callback called if there is an error
  78114. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78115. * @param invertY defines if data must be stored with Y axis inverted
  78116. * @returns the cube texture as an InternalTexture
  78117. */
  78118. 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;
  78119. /**
  78120. * Creates a new raw 3D texture
  78121. * @param data defines the data used to create the texture
  78122. * @param width defines the width of the texture
  78123. * @param height defines the height of the texture
  78124. * @param depth defines the depth of the texture
  78125. * @param format defines the format of the texture
  78126. * @param generateMipMaps defines if the engine must generate mip levels
  78127. * @param invertY defines if data must be stored with Y axis inverted
  78128. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78129. * @param compression defines the compressed used (can be null)
  78130. * @param textureType defines the compressed used (can be null)
  78131. * @returns a new raw 3D texture (stored in an InternalTexture)
  78132. */
  78133. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  78134. /**
  78135. * Update a raw 3D texture
  78136. * @param texture defines the texture to update
  78137. * @param data defines the data to store
  78138. * @param format defines the data format
  78139. * @param invertY defines if data must be stored with Y axis inverted
  78140. */
  78141. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78142. /**
  78143. * Update a raw 3D texture
  78144. * @param texture defines the texture to update
  78145. * @param data defines the data to store
  78146. * @param format defines the data format
  78147. * @param invertY defines if data must be stored with Y axis inverted
  78148. * @param compression defines the used compression (can be null)
  78149. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  78150. */
  78151. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  78152. }
  78153. }
  78154. declare module BABYLON {
  78155. /**
  78156. * Raw texture can help creating a texture directly from an array of data.
  78157. * This can be super useful if you either get the data from an uncompressed source or
  78158. * if you wish to create your texture pixel by pixel.
  78159. */
  78160. export class RawTexture extends Texture {
  78161. /**
  78162. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78163. */
  78164. format: number;
  78165. private _engine;
  78166. /**
  78167. * Instantiates a new RawTexture.
  78168. * Raw texture can help creating a texture directly from an array of data.
  78169. * This can be super useful if you either get the data from an uncompressed source or
  78170. * if you wish to create your texture pixel by pixel.
  78171. * @param data define the array of data to use to create the texture
  78172. * @param width define the width of the texture
  78173. * @param height define the height of the texture
  78174. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78175. * @param scene define the scene the texture belongs to
  78176. * @param generateMipMaps define whether mip maps should be generated or not
  78177. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78178. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78179. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78180. */
  78181. constructor(data: ArrayBufferView, width: number, height: number,
  78182. /**
  78183. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78184. */
  78185. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  78186. /**
  78187. * Updates the texture underlying data.
  78188. * @param data Define the new data of the texture
  78189. */
  78190. update(data: ArrayBufferView): void;
  78191. /**
  78192. * Creates a luminance texture from some data.
  78193. * @param data Define the texture data
  78194. * @param width Define the width of the texture
  78195. * @param height Define the height of the texture
  78196. * @param scene Define the scene the texture belongs to
  78197. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78198. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78199. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78200. * @returns the luminance texture
  78201. */
  78202. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78203. /**
  78204. * Creates a luminance alpha texture from some data.
  78205. * @param data Define the texture data
  78206. * @param width Define the width of the texture
  78207. * @param height Define the height of the texture
  78208. * @param scene Define the scene the texture belongs to
  78209. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78210. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78211. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78212. * @returns the luminance alpha texture
  78213. */
  78214. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78215. /**
  78216. * Creates an alpha texture from some data.
  78217. * @param data Define the texture data
  78218. * @param width Define the width of the texture
  78219. * @param height Define the height of the texture
  78220. * @param scene Define the scene the texture belongs to
  78221. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78222. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78223. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78224. * @returns the alpha texture
  78225. */
  78226. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78227. /**
  78228. * Creates a RGB texture from some data.
  78229. * @param data Define the texture data
  78230. * @param width Define the width of the texture
  78231. * @param height Define the height of the texture
  78232. * @param scene Define the scene the texture belongs to
  78233. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78234. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78235. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78236. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78237. * @returns the RGB alpha texture
  78238. */
  78239. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78240. /**
  78241. * Creates a RGBA texture from some data.
  78242. * @param data Define the texture data
  78243. * @param width Define the width of the texture
  78244. * @param height Define the height of the texture
  78245. * @param scene Define the scene the texture belongs to
  78246. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78247. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78248. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78249. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78250. * @returns the RGBA texture
  78251. */
  78252. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78253. /**
  78254. * Creates a R texture from some data.
  78255. * @param data Define the texture data
  78256. * @param width Define the width of the texture
  78257. * @param height Define the height of the texture
  78258. * @param scene Define the scene the texture belongs to
  78259. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78260. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78261. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78262. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78263. * @returns the R texture
  78264. */
  78265. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78266. }
  78267. }
  78268. declare module BABYLON {
  78269. /**
  78270. * Interface for the size containing width and height
  78271. */
  78272. export interface ISize {
  78273. /**
  78274. * Width
  78275. */
  78276. width: number;
  78277. /**
  78278. * Heighht
  78279. */
  78280. height: number;
  78281. }
  78282. /**
  78283. * Size containing widht and height
  78284. */
  78285. export class Size implements ISize {
  78286. /**
  78287. * Width
  78288. */
  78289. width: number;
  78290. /**
  78291. * Height
  78292. */
  78293. height: number;
  78294. /**
  78295. * Creates a Size object from the given width and height (floats).
  78296. * @param width width of the new size
  78297. * @param height height of the new size
  78298. */
  78299. constructor(width: number, height: number);
  78300. /**
  78301. * Returns a string with the Size width and height
  78302. * @returns a string with the Size width and height
  78303. */
  78304. toString(): string;
  78305. /**
  78306. * "Size"
  78307. * @returns the string "Size"
  78308. */
  78309. getClassName(): string;
  78310. /**
  78311. * Returns the Size hash code.
  78312. * @returns a hash code for a unique width and height
  78313. */
  78314. getHashCode(): number;
  78315. /**
  78316. * Updates the current size from the given one.
  78317. * @param src the given size
  78318. */
  78319. copyFrom(src: Size): void;
  78320. /**
  78321. * Updates in place the current Size from the given floats.
  78322. * @param width width of the new size
  78323. * @param height height of the new size
  78324. * @returns the updated Size.
  78325. */
  78326. copyFromFloats(width: number, height: number): Size;
  78327. /**
  78328. * Updates in place the current Size from the given floats.
  78329. * @param width width to set
  78330. * @param height height to set
  78331. * @returns the updated Size.
  78332. */
  78333. set(width: number, height: number): Size;
  78334. /**
  78335. * Multiplies the width and height by numbers
  78336. * @param w factor to multiple the width by
  78337. * @param h factor to multiple the height by
  78338. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  78339. */
  78340. multiplyByFloats(w: number, h: number): Size;
  78341. /**
  78342. * Clones the size
  78343. * @returns a new Size copied from the given one.
  78344. */
  78345. clone(): Size;
  78346. /**
  78347. * True if the current Size and the given one width and height are strictly equal.
  78348. * @param other the other size to compare against
  78349. * @returns True if the current Size and the given one width and height are strictly equal.
  78350. */
  78351. equals(other: Size): boolean;
  78352. /**
  78353. * The surface of the Size : width * height (float).
  78354. */
  78355. readonly surface: number;
  78356. /**
  78357. * Create a new size of zero
  78358. * @returns a new Size set to (0.0, 0.0)
  78359. */
  78360. static Zero(): Size;
  78361. /**
  78362. * Sums the width and height of two sizes
  78363. * @param otherSize size to add to this size
  78364. * @returns a new Size set as the addition result of the current Size and the given one.
  78365. */
  78366. add(otherSize: Size): Size;
  78367. /**
  78368. * Subtracts the width and height of two
  78369. * @param otherSize size to subtract to this size
  78370. * @returns a new Size set as the subtraction result of the given one from the current Size.
  78371. */
  78372. subtract(otherSize: Size): Size;
  78373. /**
  78374. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  78375. * @param start starting size to lerp between
  78376. * @param end end size to lerp between
  78377. * @param amount amount to lerp between the start and end values
  78378. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  78379. */
  78380. static Lerp(start: Size, end: Size, amount: number): Size;
  78381. }
  78382. }
  78383. declare module BABYLON {
  78384. /**
  78385. * Defines a runtime animation
  78386. */
  78387. export class RuntimeAnimation {
  78388. private _events;
  78389. /**
  78390. * The current frame of the runtime animation
  78391. */
  78392. private _currentFrame;
  78393. /**
  78394. * The animation used by the runtime animation
  78395. */
  78396. private _animation;
  78397. /**
  78398. * The target of the runtime animation
  78399. */
  78400. private _target;
  78401. /**
  78402. * The initiating animatable
  78403. */
  78404. private _host;
  78405. /**
  78406. * The original value of the runtime animation
  78407. */
  78408. private _originalValue;
  78409. /**
  78410. * The original blend value of the runtime animation
  78411. */
  78412. private _originalBlendValue;
  78413. /**
  78414. * The offsets cache of the runtime animation
  78415. */
  78416. private _offsetsCache;
  78417. /**
  78418. * The high limits cache of the runtime animation
  78419. */
  78420. private _highLimitsCache;
  78421. /**
  78422. * Specifies if the runtime animation has been stopped
  78423. */
  78424. private _stopped;
  78425. /**
  78426. * The blending factor of the runtime animation
  78427. */
  78428. private _blendingFactor;
  78429. /**
  78430. * The BabylonJS scene
  78431. */
  78432. private _scene;
  78433. /**
  78434. * The current value of the runtime animation
  78435. */
  78436. private _currentValue;
  78437. /** @hidden */
  78438. _animationState: _IAnimationState;
  78439. /**
  78440. * The active target of the runtime animation
  78441. */
  78442. private _activeTargets;
  78443. private _currentActiveTarget;
  78444. private _directTarget;
  78445. /**
  78446. * The target path of the runtime animation
  78447. */
  78448. private _targetPath;
  78449. /**
  78450. * The weight of the runtime animation
  78451. */
  78452. private _weight;
  78453. /**
  78454. * The ratio offset of the runtime animation
  78455. */
  78456. private _ratioOffset;
  78457. /**
  78458. * The previous delay of the runtime animation
  78459. */
  78460. private _previousDelay;
  78461. /**
  78462. * The previous ratio of the runtime animation
  78463. */
  78464. private _previousRatio;
  78465. private _enableBlending;
  78466. private _keys;
  78467. private _minFrame;
  78468. private _maxFrame;
  78469. private _minValue;
  78470. private _maxValue;
  78471. private _targetIsArray;
  78472. /**
  78473. * Gets the current frame of the runtime animation
  78474. */
  78475. readonly currentFrame: number;
  78476. /**
  78477. * Gets the weight of the runtime animation
  78478. */
  78479. readonly weight: number;
  78480. /**
  78481. * Gets the current value of the runtime animation
  78482. */
  78483. readonly currentValue: any;
  78484. /**
  78485. * Gets the target path of the runtime animation
  78486. */
  78487. readonly targetPath: string;
  78488. /**
  78489. * Gets the actual target of the runtime animation
  78490. */
  78491. readonly target: any;
  78492. /** @hidden */
  78493. _onLoop: () => void;
  78494. /**
  78495. * Create a new RuntimeAnimation object
  78496. * @param target defines the target of the animation
  78497. * @param animation defines the source animation object
  78498. * @param scene defines the hosting scene
  78499. * @param host defines the initiating Animatable
  78500. */
  78501. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  78502. private _preparePath;
  78503. /**
  78504. * Gets the animation from the runtime animation
  78505. */
  78506. readonly animation: Animation;
  78507. /**
  78508. * Resets the runtime animation to the beginning
  78509. * @param restoreOriginal defines whether to restore the target property to the original value
  78510. */
  78511. reset(restoreOriginal?: boolean): void;
  78512. /**
  78513. * Specifies if the runtime animation is stopped
  78514. * @returns Boolean specifying if the runtime animation is stopped
  78515. */
  78516. isStopped(): boolean;
  78517. /**
  78518. * Disposes of the runtime animation
  78519. */
  78520. dispose(): void;
  78521. /**
  78522. * Apply the interpolated value to the target
  78523. * @param currentValue defines the value computed by the animation
  78524. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  78525. */
  78526. setValue(currentValue: any, weight: number): void;
  78527. private _getOriginalValues;
  78528. private _setValue;
  78529. /**
  78530. * Gets the loop pmode of the runtime animation
  78531. * @returns Loop Mode
  78532. */
  78533. private _getCorrectLoopMode;
  78534. /**
  78535. * Move the current animation to a given frame
  78536. * @param frame defines the frame to move to
  78537. */
  78538. goToFrame(frame: number): void;
  78539. /**
  78540. * @hidden Internal use only
  78541. */
  78542. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  78543. /**
  78544. * Execute the current animation
  78545. * @param delay defines the delay to add to the current frame
  78546. * @param from defines the lower bound of the animation range
  78547. * @param to defines the upper bound of the animation range
  78548. * @param loop defines if the current animation must loop
  78549. * @param speedRatio defines the current speed ratio
  78550. * @param weight defines the weight of the animation (default is -1 so no weight)
  78551. * @param onLoop optional callback called when animation loops
  78552. * @returns a boolean indicating if the animation is running
  78553. */
  78554. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  78555. }
  78556. }
  78557. declare module BABYLON {
  78558. /**
  78559. * Class used to store an actual running animation
  78560. */
  78561. export class Animatable {
  78562. /** defines the target object */
  78563. target: any;
  78564. /** defines the starting frame number (default is 0) */
  78565. fromFrame: number;
  78566. /** defines the ending frame number (default is 100) */
  78567. toFrame: number;
  78568. /** defines if the animation must loop (default is false) */
  78569. loopAnimation: boolean;
  78570. /** defines a callback to call when animation ends if it is not looping */
  78571. onAnimationEnd?: (() => void) | null | undefined;
  78572. /** defines a callback to call when animation loops */
  78573. onAnimationLoop?: (() => void) | null | undefined;
  78574. private _localDelayOffset;
  78575. private _pausedDelay;
  78576. private _runtimeAnimations;
  78577. private _paused;
  78578. private _scene;
  78579. private _speedRatio;
  78580. private _weight;
  78581. private _syncRoot;
  78582. /**
  78583. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  78584. * This will only apply for non looping animation (default is true)
  78585. */
  78586. disposeOnEnd: boolean;
  78587. /**
  78588. * Gets a boolean indicating if the animation has started
  78589. */
  78590. animationStarted: boolean;
  78591. /**
  78592. * Observer raised when the animation ends
  78593. */
  78594. onAnimationEndObservable: Observable<Animatable>;
  78595. /**
  78596. * Observer raised when the animation loops
  78597. */
  78598. onAnimationLoopObservable: Observable<Animatable>;
  78599. /**
  78600. * Gets the root Animatable used to synchronize and normalize animations
  78601. */
  78602. readonly syncRoot: Nullable<Animatable>;
  78603. /**
  78604. * Gets the current frame of the first RuntimeAnimation
  78605. * Used to synchronize Animatables
  78606. */
  78607. readonly masterFrame: number;
  78608. /**
  78609. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  78610. */
  78611. weight: number;
  78612. /**
  78613. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  78614. */
  78615. speedRatio: number;
  78616. /**
  78617. * Creates a new Animatable
  78618. * @param scene defines the hosting scene
  78619. * @param target defines the target object
  78620. * @param fromFrame defines the starting frame number (default is 0)
  78621. * @param toFrame defines the ending frame number (default is 100)
  78622. * @param loopAnimation defines if the animation must loop (default is false)
  78623. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  78624. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  78625. * @param animations defines a group of animation to add to the new Animatable
  78626. * @param onAnimationLoop defines a callback to call when animation loops
  78627. */
  78628. constructor(scene: Scene,
  78629. /** defines the target object */
  78630. target: any,
  78631. /** defines the starting frame number (default is 0) */
  78632. fromFrame?: number,
  78633. /** defines the ending frame number (default is 100) */
  78634. toFrame?: number,
  78635. /** defines if the animation must loop (default is false) */
  78636. loopAnimation?: boolean, speedRatio?: number,
  78637. /** defines a callback to call when animation ends if it is not looping */
  78638. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  78639. /** defines a callback to call when animation loops */
  78640. onAnimationLoop?: (() => void) | null | undefined);
  78641. /**
  78642. * Synchronize and normalize current Animatable with a source Animatable
  78643. * This is useful when using animation weights and when animations are not of the same length
  78644. * @param root defines the root Animatable to synchronize with
  78645. * @returns the current Animatable
  78646. */
  78647. syncWith(root: Animatable): Animatable;
  78648. /**
  78649. * Gets the list of runtime animations
  78650. * @returns an array of RuntimeAnimation
  78651. */
  78652. getAnimations(): RuntimeAnimation[];
  78653. /**
  78654. * Adds more animations to the current animatable
  78655. * @param target defines the target of the animations
  78656. * @param animations defines the new animations to add
  78657. */
  78658. appendAnimations(target: any, animations: Animation[]): void;
  78659. /**
  78660. * Gets the source animation for a specific property
  78661. * @param property defines the propertyu to look for
  78662. * @returns null or the source animation for the given property
  78663. */
  78664. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  78665. /**
  78666. * Gets the runtime animation for a specific property
  78667. * @param property defines the propertyu to look for
  78668. * @returns null or the runtime animation for the given property
  78669. */
  78670. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  78671. /**
  78672. * Resets the animatable to its original state
  78673. */
  78674. reset(): void;
  78675. /**
  78676. * Allows the animatable to blend with current running animations
  78677. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78678. * @param blendingSpeed defines the blending speed to use
  78679. */
  78680. enableBlending(blendingSpeed: number): void;
  78681. /**
  78682. * Disable animation blending
  78683. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78684. */
  78685. disableBlending(): void;
  78686. /**
  78687. * Jump directly to a given frame
  78688. * @param frame defines the frame to jump to
  78689. */
  78690. goToFrame(frame: number): void;
  78691. /**
  78692. * Pause the animation
  78693. */
  78694. pause(): void;
  78695. /**
  78696. * Restart the animation
  78697. */
  78698. restart(): void;
  78699. private _raiseOnAnimationEnd;
  78700. /**
  78701. * Stop and delete the current animation
  78702. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  78703. * @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)
  78704. */
  78705. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  78706. /**
  78707. * Wait asynchronously for the animation to end
  78708. * @returns a promise which will be fullfilled when the animation ends
  78709. */
  78710. waitAsync(): Promise<Animatable>;
  78711. /** @hidden */
  78712. _animate(delay: number): boolean;
  78713. }
  78714. interface Scene {
  78715. /** @hidden */
  78716. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  78717. /** @hidden */
  78718. _processLateAnimationBindingsForMatrices(holder: {
  78719. totalWeight: number;
  78720. animations: RuntimeAnimation[];
  78721. originalValue: Matrix;
  78722. }): any;
  78723. /** @hidden */
  78724. _processLateAnimationBindingsForQuaternions(holder: {
  78725. totalWeight: number;
  78726. animations: RuntimeAnimation[];
  78727. originalValue: Quaternion;
  78728. }, refQuaternion: Quaternion): Quaternion;
  78729. /** @hidden */
  78730. _processLateAnimationBindings(): void;
  78731. /**
  78732. * Will start the animation sequence of a given target
  78733. * @param target defines the target
  78734. * @param from defines from which frame should animation start
  78735. * @param to defines until which frame should animation run.
  78736. * @param weight defines the weight to apply to the animation (1.0 by default)
  78737. * @param loop defines if the animation loops
  78738. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78739. * @param onAnimationEnd defines the function to be executed when the animation ends
  78740. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78741. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78742. * @param onAnimationLoop defines the callback to call when an animation loops
  78743. * @returns the animatable object created for this animation
  78744. */
  78745. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78746. /**
  78747. * Will start the animation sequence of a given target
  78748. * @param target defines the target
  78749. * @param from defines from which frame should animation start
  78750. * @param to defines until which frame should animation run.
  78751. * @param loop defines if the animation loops
  78752. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78753. * @param onAnimationEnd defines the function to be executed when the animation ends
  78754. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78755. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78756. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  78757. * @param onAnimationLoop defines the callback to call when an animation loops
  78758. * @returns the animatable object created for this animation
  78759. */
  78760. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78761. /**
  78762. * Will start the animation sequence of a given target and its hierarchy
  78763. * @param target defines the target
  78764. * @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.
  78765. * @param from defines from which frame should animation start
  78766. * @param to defines until which frame should animation run.
  78767. * @param loop defines if the animation loops
  78768. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78769. * @param onAnimationEnd defines the function to be executed when the animation ends
  78770. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78771. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78772. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78773. * @param onAnimationLoop defines the callback to call when an animation loops
  78774. * @returns the list of created animatables
  78775. */
  78776. 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[];
  78777. /**
  78778. * Begin a new animation on a given node
  78779. * @param target defines the target where the animation will take place
  78780. * @param animations defines the list of animations to start
  78781. * @param from defines the initial value
  78782. * @param to defines the final value
  78783. * @param loop defines if you want animation to loop (off by default)
  78784. * @param speedRatio defines the speed ratio to apply to all animations
  78785. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78786. * @param onAnimationLoop defines the callback to call when an animation loops
  78787. * @returns the list of created animatables
  78788. */
  78789. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  78790. /**
  78791. * Begin a new animation on a given node and its hierarchy
  78792. * @param target defines the root node where the animation will take place
  78793. * @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.
  78794. * @param animations defines the list of animations to start
  78795. * @param from defines the initial value
  78796. * @param to defines the final value
  78797. * @param loop defines if you want animation to loop (off by default)
  78798. * @param speedRatio defines the speed ratio to apply to all animations
  78799. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78800. * @param onAnimationLoop defines the callback to call when an animation loops
  78801. * @returns the list of animatables created for all nodes
  78802. */
  78803. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  78804. /**
  78805. * Gets the animatable associated with a specific target
  78806. * @param target defines the target of the animatable
  78807. * @returns the required animatable if found
  78808. */
  78809. getAnimatableByTarget(target: any): Nullable<Animatable>;
  78810. /**
  78811. * Gets all animatables associated with a given target
  78812. * @param target defines the target to look animatables for
  78813. * @returns an array of Animatables
  78814. */
  78815. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  78816. /**
  78817. * Stops and removes all animations that have been applied to the scene
  78818. */
  78819. stopAllAnimations(): void;
  78820. }
  78821. interface Bone {
  78822. /**
  78823. * Copy an animation range from another bone
  78824. * @param source defines the source bone
  78825. * @param rangeName defines the range name to copy
  78826. * @param frameOffset defines the frame offset
  78827. * @param rescaleAsRequired defines if rescaling must be applied if required
  78828. * @param skelDimensionsRatio defines the scaling ratio
  78829. * @returns true if operation was successful
  78830. */
  78831. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  78832. }
  78833. }
  78834. declare module BABYLON {
  78835. /**
  78836. * Class used to override all child animations of a given target
  78837. */
  78838. export class AnimationPropertiesOverride {
  78839. /**
  78840. * Gets or sets a value indicating if animation blending must be used
  78841. */
  78842. enableBlending: boolean;
  78843. /**
  78844. * Gets or sets the blending speed to use when enableBlending is true
  78845. */
  78846. blendingSpeed: number;
  78847. /**
  78848. * Gets or sets the default loop mode to use
  78849. */
  78850. loopMode: number;
  78851. }
  78852. }
  78853. declare module BABYLON {
  78854. /**
  78855. * Class used to handle skinning animations
  78856. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78857. */
  78858. export class Skeleton implements IAnimatable {
  78859. /** defines the skeleton name */
  78860. name: string;
  78861. /** defines the skeleton Id */
  78862. id: string;
  78863. /**
  78864. * Defines the list of child bones
  78865. */
  78866. bones: Bone[];
  78867. /**
  78868. * Defines an estimate of the dimension of the skeleton at rest
  78869. */
  78870. dimensionsAtRest: Vector3;
  78871. /**
  78872. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  78873. */
  78874. needInitialSkinMatrix: boolean;
  78875. /**
  78876. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  78877. */
  78878. overrideMesh: Nullable<AbstractMesh>;
  78879. /**
  78880. * Gets the list of animations attached to this skeleton
  78881. */
  78882. animations: Array<Animation>;
  78883. private _scene;
  78884. private _isDirty;
  78885. private _transformMatrices;
  78886. private _transformMatrixTexture;
  78887. private _meshesWithPoseMatrix;
  78888. private _animatables;
  78889. private _identity;
  78890. private _synchronizedWithMesh;
  78891. private _ranges;
  78892. private _lastAbsoluteTransformsUpdateId;
  78893. private _canUseTextureForBones;
  78894. private _uniqueId;
  78895. /** @hidden */
  78896. _numBonesWithLinkedTransformNode: number;
  78897. /** @hidden */
  78898. _hasWaitingData: Nullable<boolean>;
  78899. /**
  78900. * Specifies if the skeleton should be serialized
  78901. */
  78902. doNotSerialize: boolean;
  78903. private _useTextureToStoreBoneMatrices;
  78904. /**
  78905. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  78906. * Please note that this option is not available if the hardware does not support it
  78907. */
  78908. useTextureToStoreBoneMatrices: boolean;
  78909. private _animationPropertiesOverride;
  78910. /**
  78911. * Gets or sets the animation properties override
  78912. */
  78913. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78914. /**
  78915. * List of inspectable custom properties (used by the Inspector)
  78916. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78917. */
  78918. inspectableCustomProperties: IInspectable[];
  78919. /**
  78920. * An observable triggered before computing the skeleton's matrices
  78921. */
  78922. onBeforeComputeObservable: Observable<Skeleton>;
  78923. /**
  78924. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  78925. */
  78926. readonly isUsingTextureForMatrices: boolean;
  78927. /**
  78928. * Gets the unique ID of this skeleton
  78929. */
  78930. readonly uniqueId: number;
  78931. /**
  78932. * Creates a new skeleton
  78933. * @param name defines the skeleton name
  78934. * @param id defines the skeleton Id
  78935. * @param scene defines the hosting scene
  78936. */
  78937. constructor(
  78938. /** defines the skeleton name */
  78939. name: string,
  78940. /** defines the skeleton Id */
  78941. id: string, scene: Scene);
  78942. /**
  78943. * Gets the current object class name.
  78944. * @return the class name
  78945. */
  78946. getClassName(): string;
  78947. /**
  78948. * Returns an array containing the root bones
  78949. * @returns an array containing the root bones
  78950. */
  78951. getChildren(): Array<Bone>;
  78952. /**
  78953. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  78954. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78955. * @returns a Float32Array containing matrices data
  78956. */
  78957. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  78958. /**
  78959. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  78960. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78961. * @returns a raw texture containing the data
  78962. */
  78963. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  78964. /**
  78965. * Gets the current hosting scene
  78966. * @returns a scene object
  78967. */
  78968. getScene(): Scene;
  78969. /**
  78970. * Gets a string representing the current skeleton data
  78971. * @param fullDetails defines a boolean indicating if we want a verbose version
  78972. * @returns a string representing the current skeleton data
  78973. */
  78974. toString(fullDetails?: boolean): string;
  78975. /**
  78976. * Get bone's index searching by name
  78977. * @param name defines bone's name to search for
  78978. * @return the indice of the bone. Returns -1 if not found
  78979. */
  78980. getBoneIndexByName(name: string): number;
  78981. /**
  78982. * Creater a new animation range
  78983. * @param name defines the name of the range
  78984. * @param from defines the start key
  78985. * @param to defines the end key
  78986. */
  78987. createAnimationRange(name: string, from: number, to: number): void;
  78988. /**
  78989. * Delete a specific animation range
  78990. * @param name defines the name of the range
  78991. * @param deleteFrames defines if frames must be removed as well
  78992. */
  78993. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  78994. /**
  78995. * Gets a specific animation range
  78996. * @param name defines the name of the range to look for
  78997. * @returns the requested animation range or null if not found
  78998. */
  78999. getAnimationRange(name: string): Nullable<AnimationRange>;
  79000. /**
  79001. * Gets the list of all animation ranges defined on this skeleton
  79002. * @returns an array
  79003. */
  79004. getAnimationRanges(): Nullable<AnimationRange>[];
  79005. /**
  79006. * Copy animation range from a source skeleton.
  79007. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  79008. * @param source defines the source skeleton
  79009. * @param name defines the name of the range to copy
  79010. * @param rescaleAsRequired defines if rescaling must be applied if required
  79011. * @returns true if operation was successful
  79012. */
  79013. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  79014. /**
  79015. * Forces the skeleton to go to rest pose
  79016. */
  79017. returnToRest(): void;
  79018. private _getHighestAnimationFrame;
  79019. /**
  79020. * Begin a specific animation range
  79021. * @param name defines the name of the range to start
  79022. * @param loop defines if looping must be turned on (false by default)
  79023. * @param speedRatio defines the speed ratio to apply (1 by default)
  79024. * @param onAnimationEnd defines a callback which will be called when animation will end
  79025. * @returns a new animatable
  79026. */
  79027. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  79028. /** @hidden */
  79029. _markAsDirty(): void;
  79030. /** @hidden */
  79031. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79032. /** @hidden */
  79033. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79034. private _computeTransformMatrices;
  79035. /**
  79036. * Build all resources required to render a skeleton
  79037. */
  79038. prepare(): void;
  79039. /**
  79040. * Gets the list of animatables currently running for this skeleton
  79041. * @returns an array of animatables
  79042. */
  79043. getAnimatables(): IAnimatable[];
  79044. /**
  79045. * Clone the current skeleton
  79046. * @param name defines the name of the new skeleton
  79047. * @param id defines the id of the new skeleton
  79048. * @returns the new skeleton
  79049. */
  79050. clone(name: string, id: string): Skeleton;
  79051. /**
  79052. * Enable animation blending for this skeleton
  79053. * @param blendingSpeed defines the blending speed to apply
  79054. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79055. */
  79056. enableBlending(blendingSpeed?: number): void;
  79057. /**
  79058. * Releases all resources associated with the current skeleton
  79059. */
  79060. dispose(): void;
  79061. /**
  79062. * Serialize the skeleton in a JSON object
  79063. * @returns a JSON object
  79064. */
  79065. serialize(): any;
  79066. /**
  79067. * Creates a new skeleton from serialized data
  79068. * @param parsedSkeleton defines the serialized data
  79069. * @param scene defines the hosting scene
  79070. * @returns a new skeleton
  79071. */
  79072. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  79073. /**
  79074. * Compute all node absolute transforms
  79075. * @param forceUpdate defines if computation must be done even if cache is up to date
  79076. */
  79077. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  79078. /**
  79079. * Gets the root pose matrix
  79080. * @returns a matrix
  79081. */
  79082. getPoseMatrix(): Nullable<Matrix>;
  79083. /**
  79084. * Sorts bones per internal index
  79085. */
  79086. sortBones(): void;
  79087. private _sortBones;
  79088. }
  79089. }
  79090. declare module BABYLON {
  79091. /**
  79092. * Class used to store bone information
  79093. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79094. */
  79095. export class Bone extends Node {
  79096. /**
  79097. * defines the bone name
  79098. */
  79099. name: string;
  79100. private static _tmpVecs;
  79101. private static _tmpQuat;
  79102. private static _tmpMats;
  79103. /**
  79104. * Gets the list of child bones
  79105. */
  79106. children: Bone[];
  79107. /** Gets the animations associated with this bone */
  79108. animations: Animation[];
  79109. /**
  79110. * Gets or sets bone length
  79111. */
  79112. length: number;
  79113. /**
  79114. * @hidden Internal only
  79115. * Set this value to map this bone to a different index in the transform matrices
  79116. * Set this value to -1 to exclude the bone from the transform matrices
  79117. */
  79118. _index: Nullable<number>;
  79119. private _skeleton;
  79120. private _localMatrix;
  79121. private _restPose;
  79122. private _baseMatrix;
  79123. private _absoluteTransform;
  79124. private _invertedAbsoluteTransform;
  79125. private _parent;
  79126. private _scalingDeterminant;
  79127. private _worldTransform;
  79128. private _localScaling;
  79129. private _localRotation;
  79130. private _localPosition;
  79131. private _needToDecompose;
  79132. private _needToCompose;
  79133. /** @hidden */
  79134. _linkedTransformNode: Nullable<TransformNode>;
  79135. /** @hidden */
  79136. _waitingTransformNodeId: Nullable<string>;
  79137. /** @hidden */
  79138. /** @hidden */
  79139. _matrix: Matrix;
  79140. /**
  79141. * Create a new bone
  79142. * @param name defines the bone name
  79143. * @param skeleton defines the parent skeleton
  79144. * @param parentBone defines the parent (can be null if the bone is the root)
  79145. * @param localMatrix defines the local matrix
  79146. * @param restPose defines the rest pose matrix
  79147. * @param baseMatrix defines the base matrix
  79148. * @param index defines index of the bone in the hiearchy
  79149. */
  79150. constructor(
  79151. /**
  79152. * defines the bone name
  79153. */
  79154. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  79155. /**
  79156. * Gets the current object class name.
  79157. * @return the class name
  79158. */
  79159. getClassName(): string;
  79160. /**
  79161. * Gets the parent skeleton
  79162. * @returns a skeleton
  79163. */
  79164. getSkeleton(): Skeleton;
  79165. /**
  79166. * Gets parent bone
  79167. * @returns a bone or null if the bone is the root of the bone hierarchy
  79168. */
  79169. getParent(): Nullable<Bone>;
  79170. /**
  79171. * Returns an array containing the root bones
  79172. * @returns an array containing the root bones
  79173. */
  79174. getChildren(): Array<Bone>;
  79175. /**
  79176. * Sets the parent bone
  79177. * @param parent defines the parent (can be null if the bone is the root)
  79178. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  79179. */
  79180. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  79181. /**
  79182. * Gets the local matrix
  79183. * @returns a matrix
  79184. */
  79185. getLocalMatrix(): Matrix;
  79186. /**
  79187. * Gets the base matrix (initial matrix which remains unchanged)
  79188. * @returns a matrix
  79189. */
  79190. getBaseMatrix(): Matrix;
  79191. /**
  79192. * Gets the rest pose matrix
  79193. * @returns a matrix
  79194. */
  79195. getRestPose(): Matrix;
  79196. /**
  79197. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  79198. */
  79199. getWorldMatrix(): Matrix;
  79200. /**
  79201. * Sets the local matrix to rest pose matrix
  79202. */
  79203. returnToRest(): void;
  79204. /**
  79205. * Gets the inverse of the absolute transform matrix.
  79206. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  79207. * @returns a matrix
  79208. */
  79209. getInvertedAbsoluteTransform(): Matrix;
  79210. /**
  79211. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  79212. * @returns a matrix
  79213. */
  79214. getAbsoluteTransform(): Matrix;
  79215. /**
  79216. * Links with the given transform node.
  79217. * The local matrix of this bone is copied from the transform node every frame.
  79218. * @param transformNode defines the transform node to link to
  79219. */
  79220. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  79221. /**
  79222. * Gets the node used to drive the bone's transformation
  79223. * @returns a transform node or null
  79224. */
  79225. getTransformNode(): Nullable<TransformNode>;
  79226. /** Gets or sets current position (in local space) */
  79227. position: Vector3;
  79228. /** Gets or sets current rotation (in local space) */
  79229. rotation: Vector3;
  79230. /** Gets or sets current rotation quaternion (in local space) */
  79231. rotationQuaternion: Quaternion;
  79232. /** Gets or sets current scaling (in local space) */
  79233. scaling: Vector3;
  79234. /**
  79235. * Gets the animation properties override
  79236. */
  79237. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79238. private _decompose;
  79239. private _compose;
  79240. /**
  79241. * Update the base and local matrices
  79242. * @param matrix defines the new base or local matrix
  79243. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  79244. * @param updateLocalMatrix defines if the local matrix should be updated
  79245. */
  79246. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  79247. /** @hidden */
  79248. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  79249. /**
  79250. * Flag the bone as dirty (Forcing it to update everything)
  79251. */
  79252. markAsDirty(): void;
  79253. /** @hidden */
  79254. _markAsDirtyAndCompose(): void;
  79255. private _markAsDirtyAndDecompose;
  79256. /**
  79257. * Translate the bone in local or world space
  79258. * @param vec The amount to translate the bone
  79259. * @param space The space that the translation is in
  79260. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79261. */
  79262. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79263. /**
  79264. * Set the postion of the bone in local or world space
  79265. * @param position The position to set the bone
  79266. * @param space The space that the position is in
  79267. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79268. */
  79269. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79270. /**
  79271. * Set the absolute position of the bone (world space)
  79272. * @param position The position to set the bone
  79273. * @param mesh The mesh that this bone is attached to
  79274. */
  79275. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  79276. /**
  79277. * Scale the bone on the x, y and z axes (in local space)
  79278. * @param x The amount to scale the bone on the x axis
  79279. * @param y The amount to scale the bone on the y axis
  79280. * @param z The amount to scale the bone on the z axis
  79281. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  79282. */
  79283. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  79284. /**
  79285. * Set the bone scaling in local space
  79286. * @param scale defines the scaling vector
  79287. */
  79288. setScale(scale: Vector3): void;
  79289. /**
  79290. * Gets the current scaling in local space
  79291. * @returns the current scaling vector
  79292. */
  79293. getScale(): Vector3;
  79294. /**
  79295. * Gets the current scaling in local space and stores it in a target vector
  79296. * @param result defines the target vector
  79297. */
  79298. getScaleToRef(result: Vector3): void;
  79299. /**
  79300. * Set the yaw, pitch, and roll of the bone in local or world space
  79301. * @param yaw The rotation of the bone on the y axis
  79302. * @param pitch The rotation of the bone on the x axis
  79303. * @param roll The rotation of the bone on the z axis
  79304. * @param space The space that the axes of rotation are in
  79305. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79306. */
  79307. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  79308. /**
  79309. * Add a rotation to the bone on an axis in local or world space
  79310. * @param axis The axis to rotate the bone on
  79311. * @param amount The amount to rotate the bone
  79312. * @param space The space that the axis is in
  79313. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79314. */
  79315. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  79316. /**
  79317. * Set the rotation of the bone to a particular axis angle in local or world space
  79318. * @param axis The axis to rotate the bone on
  79319. * @param angle The angle that the bone should be rotated to
  79320. * @param space The space that the axis is in
  79321. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79322. */
  79323. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  79324. /**
  79325. * Set the euler rotation of the bone in local of world space
  79326. * @param rotation The euler rotation that the bone should be set to
  79327. * @param space The space that the rotation is in
  79328. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79329. */
  79330. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79331. /**
  79332. * Set the quaternion rotation of the bone in local of world space
  79333. * @param quat The quaternion rotation that the bone should be set to
  79334. * @param space The space that the rotation is in
  79335. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79336. */
  79337. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  79338. /**
  79339. * Set the rotation matrix of the bone in local of world space
  79340. * @param rotMat The rotation matrix that the bone should be set to
  79341. * @param space The space that the rotation is in
  79342. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79343. */
  79344. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  79345. private _rotateWithMatrix;
  79346. private _getNegativeRotationToRef;
  79347. /**
  79348. * Get the position of the bone in local or world space
  79349. * @param space The space that the returned position is in
  79350. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79351. * @returns The position of the bone
  79352. */
  79353. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  79354. /**
  79355. * Copy the position of the bone to a vector3 in local or world space
  79356. * @param space The space that the returned position is in
  79357. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79358. * @param result The vector3 to copy the position to
  79359. */
  79360. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  79361. /**
  79362. * Get the absolute position of the bone (world space)
  79363. * @param mesh The mesh that this bone is attached to
  79364. * @returns The absolute position of the bone
  79365. */
  79366. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  79367. /**
  79368. * Copy the absolute position of the bone (world space) to the result param
  79369. * @param mesh The mesh that this bone is attached to
  79370. * @param result The vector3 to copy the absolute position to
  79371. */
  79372. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  79373. /**
  79374. * Compute the absolute transforms of this bone and its children
  79375. */
  79376. computeAbsoluteTransforms(): void;
  79377. /**
  79378. * Get the world direction from an axis that is in the local space of the bone
  79379. * @param localAxis The local direction that is used to compute the world direction
  79380. * @param mesh The mesh that this bone is attached to
  79381. * @returns The world direction
  79382. */
  79383. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79384. /**
  79385. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  79386. * @param localAxis The local direction that is used to compute the world direction
  79387. * @param mesh The mesh that this bone is attached to
  79388. * @param result The vector3 that the world direction will be copied to
  79389. */
  79390. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79391. /**
  79392. * Get the euler rotation of the bone in local or world space
  79393. * @param space The space that the rotation should be in
  79394. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79395. * @returns The euler rotation
  79396. */
  79397. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  79398. /**
  79399. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  79400. * @param space The space that the rotation should be in
  79401. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79402. * @param result The vector3 that the rotation should be copied to
  79403. */
  79404. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79405. /**
  79406. * Get the quaternion rotation of the bone in either local or world space
  79407. * @param space The space that the rotation should be in
  79408. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79409. * @returns The quaternion rotation
  79410. */
  79411. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  79412. /**
  79413. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  79414. * @param space The space that the rotation should be in
  79415. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79416. * @param result The quaternion that the rotation should be copied to
  79417. */
  79418. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  79419. /**
  79420. * Get the rotation matrix of the bone in local or world space
  79421. * @param space The space that the rotation should be in
  79422. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79423. * @returns The rotation matrix
  79424. */
  79425. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  79426. /**
  79427. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  79428. * @param space The space that the rotation should be in
  79429. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79430. * @param result The quaternion that the rotation should be copied to
  79431. */
  79432. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  79433. /**
  79434. * Get the world position of a point that is in the local space of the bone
  79435. * @param position The local position
  79436. * @param mesh The mesh that this bone is attached to
  79437. * @returns The world position
  79438. */
  79439. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79440. /**
  79441. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  79442. * @param position The local position
  79443. * @param mesh The mesh that this bone is attached to
  79444. * @param result The vector3 that the world position should be copied to
  79445. */
  79446. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79447. /**
  79448. * Get the local position of a point that is in world space
  79449. * @param position The world position
  79450. * @param mesh The mesh that this bone is attached to
  79451. * @returns The local position
  79452. */
  79453. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79454. /**
  79455. * Get the local position of a point that is in world space and copy it to the result param
  79456. * @param position The world position
  79457. * @param mesh The mesh that this bone is attached to
  79458. * @param result The vector3 that the local position should be copied to
  79459. */
  79460. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79461. }
  79462. }
  79463. declare module BABYLON {
  79464. /**
  79465. * 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.
  79466. * @see https://doc.babylonjs.com/how_to/transformnode
  79467. */
  79468. export class TransformNode extends Node {
  79469. /**
  79470. * Object will not rotate to face the camera
  79471. */
  79472. static BILLBOARDMODE_NONE: number;
  79473. /**
  79474. * Object will rotate to face the camera but only on the x axis
  79475. */
  79476. static BILLBOARDMODE_X: number;
  79477. /**
  79478. * Object will rotate to face the camera but only on the y axis
  79479. */
  79480. static BILLBOARDMODE_Y: number;
  79481. /**
  79482. * Object will rotate to face the camera but only on the z axis
  79483. */
  79484. static BILLBOARDMODE_Z: number;
  79485. /**
  79486. * Object will rotate to face the camera
  79487. */
  79488. static BILLBOARDMODE_ALL: number;
  79489. /**
  79490. * Object will rotate to face the camera's position instead of orientation
  79491. */
  79492. static BILLBOARDMODE_USE_POSITION: number;
  79493. private _forward;
  79494. private _forwardInverted;
  79495. private _up;
  79496. private _right;
  79497. private _rightInverted;
  79498. private _position;
  79499. private _rotation;
  79500. private _rotationQuaternion;
  79501. protected _scaling: Vector3;
  79502. protected _isDirty: boolean;
  79503. private _transformToBoneReferal;
  79504. private _isAbsoluteSynced;
  79505. private _billboardMode;
  79506. /**
  79507. * Gets or sets the billboard mode. Default is 0.
  79508. *
  79509. * | Value | Type | Description |
  79510. * | --- | --- | --- |
  79511. * | 0 | BILLBOARDMODE_NONE | |
  79512. * | 1 | BILLBOARDMODE_X | |
  79513. * | 2 | BILLBOARDMODE_Y | |
  79514. * | 4 | BILLBOARDMODE_Z | |
  79515. * | 7 | BILLBOARDMODE_ALL | |
  79516. *
  79517. */
  79518. billboardMode: number;
  79519. private _preserveParentRotationForBillboard;
  79520. /**
  79521. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  79522. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  79523. */
  79524. preserveParentRotationForBillboard: boolean;
  79525. /**
  79526. * 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
  79527. */
  79528. scalingDeterminant: number;
  79529. private _infiniteDistance;
  79530. /**
  79531. * Gets or sets the distance of the object to max, often used by skybox
  79532. */
  79533. infiniteDistance: boolean;
  79534. /**
  79535. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  79536. * By default the system will update normals to compensate
  79537. */
  79538. ignoreNonUniformScaling: boolean;
  79539. /**
  79540. * 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
  79541. */
  79542. reIntegrateRotationIntoRotationQuaternion: boolean;
  79543. /** @hidden */
  79544. _poseMatrix: Nullable<Matrix>;
  79545. /** @hidden */
  79546. _localMatrix: Matrix;
  79547. private _usePivotMatrix;
  79548. private _absolutePosition;
  79549. private _absoluteScaling;
  79550. private _absoluteRotationQuaternion;
  79551. private _pivotMatrix;
  79552. private _pivotMatrixInverse;
  79553. protected _postMultiplyPivotMatrix: boolean;
  79554. protected _isWorldMatrixFrozen: boolean;
  79555. /** @hidden */
  79556. _indexInSceneTransformNodesArray: number;
  79557. /**
  79558. * An event triggered after the world matrix is updated
  79559. */
  79560. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  79561. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  79562. /**
  79563. * Gets a string identifying the name of the class
  79564. * @returns "TransformNode" string
  79565. */
  79566. getClassName(): string;
  79567. /**
  79568. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  79569. */
  79570. position: Vector3;
  79571. /**
  79572. * 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)).
  79573. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  79574. */
  79575. rotation: Vector3;
  79576. /**
  79577. * 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)).
  79578. */
  79579. scaling: Vector3;
  79580. /**
  79581. * 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).
  79582. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  79583. */
  79584. rotationQuaternion: Nullable<Quaternion>;
  79585. /**
  79586. * The forward direction of that transform in world space.
  79587. */
  79588. readonly forward: Vector3;
  79589. /**
  79590. * The up direction of that transform in world space.
  79591. */
  79592. readonly up: Vector3;
  79593. /**
  79594. * The right direction of that transform in world space.
  79595. */
  79596. readonly right: Vector3;
  79597. /**
  79598. * Copies the parameter passed Matrix into the mesh Pose matrix.
  79599. * @param matrix the matrix to copy the pose from
  79600. * @returns this TransformNode.
  79601. */
  79602. updatePoseMatrix(matrix: Matrix): TransformNode;
  79603. /**
  79604. * Returns the mesh Pose matrix.
  79605. * @returns the pose matrix
  79606. */
  79607. getPoseMatrix(): Matrix;
  79608. /** @hidden */
  79609. _isSynchronized(): boolean;
  79610. /** @hidden */
  79611. _initCache(): void;
  79612. /**
  79613. * Flag the transform node as dirty (Forcing it to update everything)
  79614. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  79615. * @returns this transform node
  79616. */
  79617. markAsDirty(property: string): TransformNode;
  79618. /**
  79619. * Returns the current mesh absolute position.
  79620. * Returns a Vector3.
  79621. */
  79622. readonly absolutePosition: Vector3;
  79623. /**
  79624. * Returns the current mesh absolute scaling.
  79625. * Returns a Vector3.
  79626. */
  79627. readonly absoluteScaling: Vector3;
  79628. /**
  79629. * Returns the current mesh absolute rotation.
  79630. * Returns a Quaternion.
  79631. */
  79632. readonly absoluteRotationQuaternion: Quaternion;
  79633. /**
  79634. * Sets a new matrix to apply before all other transformation
  79635. * @param matrix defines the transform matrix
  79636. * @returns the current TransformNode
  79637. */
  79638. setPreTransformMatrix(matrix: Matrix): TransformNode;
  79639. /**
  79640. * Sets a new pivot matrix to the current node
  79641. * @param matrix defines the new pivot matrix to use
  79642. * @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
  79643. * @returns the current TransformNode
  79644. */
  79645. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  79646. /**
  79647. * Returns the mesh pivot matrix.
  79648. * Default : Identity.
  79649. * @returns the matrix
  79650. */
  79651. getPivotMatrix(): Matrix;
  79652. /**
  79653. * Instantiate (when possible) or clone that node with its hierarchy
  79654. * @param newParent defines the new parent to use for the instance (or clone)
  79655. * @returns an instance (or a clone) of the current node with its hiearchy
  79656. */
  79657. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  79658. /**
  79659. * Prevents the World matrix to be computed any longer
  79660. * @param newWorldMatrix defines an optional matrix to use as world matrix
  79661. * @returns the TransformNode.
  79662. */
  79663. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  79664. /**
  79665. * Allows back the World matrix computation.
  79666. * @returns the TransformNode.
  79667. */
  79668. unfreezeWorldMatrix(): this;
  79669. /**
  79670. * True if the World matrix has been frozen.
  79671. */
  79672. readonly isWorldMatrixFrozen: boolean;
  79673. /**
  79674. * Retuns the mesh absolute position in the World.
  79675. * @returns a Vector3.
  79676. */
  79677. getAbsolutePosition(): Vector3;
  79678. /**
  79679. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  79680. * @param absolutePosition the absolute position to set
  79681. * @returns the TransformNode.
  79682. */
  79683. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  79684. /**
  79685. * Sets the mesh position in its local space.
  79686. * @param vector3 the position to set in localspace
  79687. * @returns the TransformNode.
  79688. */
  79689. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  79690. /**
  79691. * Returns the mesh position in the local space from the current World matrix values.
  79692. * @returns a new Vector3.
  79693. */
  79694. getPositionExpressedInLocalSpace(): Vector3;
  79695. /**
  79696. * Translates the mesh along the passed Vector3 in its local space.
  79697. * @param vector3 the distance to translate in localspace
  79698. * @returns the TransformNode.
  79699. */
  79700. locallyTranslate(vector3: Vector3): TransformNode;
  79701. private static _lookAtVectorCache;
  79702. /**
  79703. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  79704. * @param targetPoint the position (must be in same space as current mesh) to look at
  79705. * @param yawCor optional yaw (y-axis) correction in radians
  79706. * @param pitchCor optional pitch (x-axis) correction in radians
  79707. * @param rollCor optional roll (z-axis) correction in radians
  79708. * @param space the choosen space of the target
  79709. * @returns the TransformNode.
  79710. */
  79711. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  79712. /**
  79713. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  79714. * This Vector3 is expressed in the World space.
  79715. * @param localAxis axis to rotate
  79716. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  79717. */
  79718. getDirection(localAxis: Vector3): Vector3;
  79719. /**
  79720. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  79721. * localAxis is expressed in the mesh local space.
  79722. * result is computed in the Wordl space from the mesh World matrix.
  79723. * @param localAxis axis to rotate
  79724. * @param result the resulting transformnode
  79725. * @returns this TransformNode.
  79726. */
  79727. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  79728. /**
  79729. * Sets this transform node rotation to the given local axis.
  79730. * @param localAxis the axis in local space
  79731. * @param yawCor optional yaw (y-axis) correction in radians
  79732. * @param pitchCor optional pitch (x-axis) correction in radians
  79733. * @param rollCor optional roll (z-axis) correction in radians
  79734. * @returns this TransformNode
  79735. */
  79736. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  79737. /**
  79738. * Sets a new pivot point to the current node
  79739. * @param point defines the new pivot point to use
  79740. * @param space defines if the point is in world or local space (local by default)
  79741. * @returns the current TransformNode
  79742. */
  79743. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  79744. /**
  79745. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  79746. * @returns the pivot point
  79747. */
  79748. getPivotPoint(): Vector3;
  79749. /**
  79750. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  79751. * @param result the vector3 to store the result
  79752. * @returns this TransformNode.
  79753. */
  79754. getPivotPointToRef(result: Vector3): TransformNode;
  79755. /**
  79756. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  79757. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  79758. */
  79759. getAbsolutePivotPoint(): Vector3;
  79760. /**
  79761. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  79762. * @param result vector3 to store the result
  79763. * @returns this TransformNode.
  79764. */
  79765. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  79766. /**
  79767. * Defines the passed node as the parent of the current node.
  79768. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  79769. * @see https://doc.babylonjs.com/how_to/parenting
  79770. * @param node the node ot set as the parent
  79771. * @returns this TransformNode.
  79772. */
  79773. setParent(node: Nullable<Node>): TransformNode;
  79774. private _nonUniformScaling;
  79775. /**
  79776. * True if the scaling property of this object is non uniform eg. (1,2,1)
  79777. */
  79778. readonly nonUniformScaling: boolean;
  79779. /** @hidden */
  79780. _updateNonUniformScalingState(value: boolean): boolean;
  79781. /**
  79782. * Attach the current TransformNode to another TransformNode associated with a bone
  79783. * @param bone Bone affecting the TransformNode
  79784. * @param affectedTransformNode TransformNode associated with the bone
  79785. * @returns this object
  79786. */
  79787. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  79788. /**
  79789. * Detach the transform node if its associated with a bone
  79790. * @returns this object
  79791. */
  79792. detachFromBone(): TransformNode;
  79793. private static _rotationAxisCache;
  79794. /**
  79795. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  79796. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  79797. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  79798. * The passed axis is also normalized.
  79799. * @param axis the axis to rotate around
  79800. * @param amount the amount to rotate in radians
  79801. * @param space Space to rotate in (Default: local)
  79802. * @returns the TransformNode.
  79803. */
  79804. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  79805. /**
  79806. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  79807. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  79808. * The passed axis is also normalized. .
  79809. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  79810. * @param point the point to rotate around
  79811. * @param axis the axis to rotate around
  79812. * @param amount the amount to rotate in radians
  79813. * @returns the TransformNode
  79814. */
  79815. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  79816. /**
  79817. * Translates the mesh along the axis vector for the passed distance in the given space.
  79818. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  79819. * @param axis the axis to translate in
  79820. * @param distance the distance to translate
  79821. * @param space Space to rotate in (Default: local)
  79822. * @returns the TransformNode.
  79823. */
  79824. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  79825. /**
  79826. * Adds a rotation step to the mesh current rotation.
  79827. * x, y, z are Euler angles expressed in radians.
  79828. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  79829. * This means this rotation is made in the mesh local space only.
  79830. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  79831. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  79832. * ```javascript
  79833. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  79834. * ```
  79835. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  79836. * 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.
  79837. * @param x Rotation to add
  79838. * @param y Rotation to add
  79839. * @param z Rotation to add
  79840. * @returns the TransformNode.
  79841. */
  79842. addRotation(x: number, y: number, z: number): TransformNode;
  79843. /**
  79844. * @hidden
  79845. */
  79846. protected _getEffectiveParent(): Nullable<Node>;
  79847. /**
  79848. * Computes the world matrix of the node
  79849. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79850. * @returns the world matrix
  79851. */
  79852. computeWorldMatrix(force?: boolean): Matrix;
  79853. protected _afterComputeWorldMatrix(): void;
  79854. /**
  79855. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  79856. * @param func callback function to add
  79857. *
  79858. * @returns the TransformNode.
  79859. */
  79860. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  79861. /**
  79862. * Removes a registered callback function.
  79863. * @param func callback function to remove
  79864. * @returns the TransformNode.
  79865. */
  79866. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  79867. /**
  79868. * Gets the position of the current mesh in camera space
  79869. * @param camera defines the camera to use
  79870. * @returns a position
  79871. */
  79872. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  79873. /**
  79874. * Returns the distance from the mesh to the active camera
  79875. * @param camera defines the camera to use
  79876. * @returns the distance
  79877. */
  79878. getDistanceToCamera(camera?: Nullable<Camera>): number;
  79879. /**
  79880. * Clone the current transform node
  79881. * @param name Name of the new clone
  79882. * @param newParent New parent for the clone
  79883. * @param doNotCloneChildren Do not clone children hierarchy
  79884. * @returns the new transform node
  79885. */
  79886. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  79887. /**
  79888. * Serializes the objects information.
  79889. * @param currentSerializationObject defines the object to serialize in
  79890. * @returns the serialized object
  79891. */
  79892. serialize(currentSerializationObject?: any): any;
  79893. /**
  79894. * Returns a new TransformNode object parsed from the source provided.
  79895. * @param parsedTransformNode is the source.
  79896. * @param scene the scne the object belongs to
  79897. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  79898. * @returns a new TransformNode object parsed from the source provided.
  79899. */
  79900. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  79901. /**
  79902. * Get all child-transformNodes of this node
  79903. * @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
  79904. * @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
  79905. * @returns an array of TransformNode
  79906. */
  79907. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  79908. /**
  79909. * Releases resources associated with this transform node.
  79910. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79911. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79912. */
  79913. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79914. /**
  79915. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  79916. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  79917. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  79918. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  79919. * @returns the current mesh
  79920. */
  79921. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  79922. private _syncAbsoluteScalingAndRotation;
  79923. }
  79924. }
  79925. declare module BABYLON {
  79926. /**
  79927. * Defines the types of pose enabled controllers that are supported
  79928. */
  79929. export enum PoseEnabledControllerType {
  79930. /**
  79931. * HTC Vive
  79932. */
  79933. VIVE = 0,
  79934. /**
  79935. * Oculus Rift
  79936. */
  79937. OCULUS = 1,
  79938. /**
  79939. * Windows mixed reality
  79940. */
  79941. WINDOWS = 2,
  79942. /**
  79943. * Samsung gear VR
  79944. */
  79945. GEAR_VR = 3,
  79946. /**
  79947. * Google Daydream
  79948. */
  79949. DAYDREAM = 4,
  79950. /**
  79951. * Generic
  79952. */
  79953. GENERIC = 5
  79954. }
  79955. /**
  79956. * Defines the MutableGamepadButton interface for the state of a gamepad button
  79957. */
  79958. export interface MutableGamepadButton {
  79959. /**
  79960. * Value of the button/trigger
  79961. */
  79962. value: number;
  79963. /**
  79964. * If the button/trigger is currently touched
  79965. */
  79966. touched: boolean;
  79967. /**
  79968. * If the button/trigger is currently pressed
  79969. */
  79970. pressed: boolean;
  79971. }
  79972. /**
  79973. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  79974. * @hidden
  79975. */
  79976. export interface ExtendedGamepadButton extends GamepadButton {
  79977. /**
  79978. * If the button/trigger is currently pressed
  79979. */
  79980. readonly pressed: boolean;
  79981. /**
  79982. * If the button/trigger is currently touched
  79983. */
  79984. readonly touched: boolean;
  79985. /**
  79986. * Value of the button/trigger
  79987. */
  79988. readonly value: number;
  79989. }
  79990. /** @hidden */
  79991. export interface _GamePadFactory {
  79992. /**
  79993. * Returns wether or not the current gamepad can be created for this type of controller.
  79994. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79995. * @returns true if it can be created, otherwise false
  79996. */
  79997. canCreate(gamepadInfo: any): boolean;
  79998. /**
  79999. * Creates a new instance of the Gamepad.
  80000. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80001. * @returns the new gamepad instance
  80002. */
  80003. create(gamepadInfo: any): Gamepad;
  80004. }
  80005. /**
  80006. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80007. */
  80008. export class PoseEnabledControllerHelper {
  80009. /** @hidden */
  80010. static _ControllerFactories: _GamePadFactory[];
  80011. /** @hidden */
  80012. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  80013. /**
  80014. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80015. * @param vrGamepad the gamepad to initialized
  80016. * @returns a vr controller of the type the gamepad identified as
  80017. */
  80018. static InitiateController(vrGamepad: any): Gamepad;
  80019. }
  80020. /**
  80021. * Defines the PoseEnabledController object that contains state of a vr capable controller
  80022. */
  80023. export class PoseEnabledController extends Gamepad implements PoseControlled {
  80024. /**
  80025. * If the controller is used in a webXR session
  80026. */
  80027. isXR: boolean;
  80028. private _deviceRoomPosition;
  80029. private _deviceRoomRotationQuaternion;
  80030. /**
  80031. * The device position in babylon space
  80032. */
  80033. devicePosition: Vector3;
  80034. /**
  80035. * The device rotation in babylon space
  80036. */
  80037. deviceRotationQuaternion: Quaternion;
  80038. /**
  80039. * The scale factor of the device in babylon space
  80040. */
  80041. deviceScaleFactor: number;
  80042. /**
  80043. * (Likely devicePosition should be used instead) The device position in its room space
  80044. */
  80045. position: Vector3;
  80046. /**
  80047. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  80048. */
  80049. rotationQuaternion: Quaternion;
  80050. /**
  80051. * The type of controller (Eg. Windows mixed reality)
  80052. */
  80053. controllerType: PoseEnabledControllerType;
  80054. protected _calculatedPosition: Vector3;
  80055. private _calculatedRotation;
  80056. /**
  80057. * The raw pose from the device
  80058. */
  80059. rawPose: DevicePose;
  80060. private _trackPosition;
  80061. private _maxRotationDistFromHeadset;
  80062. private _draggedRoomRotation;
  80063. /**
  80064. * @hidden
  80065. */
  80066. _disableTrackPosition(fixedPosition: Vector3): void;
  80067. /**
  80068. * Internal, the mesh attached to the controller
  80069. * @hidden
  80070. */
  80071. _mesh: Nullable<AbstractMesh>;
  80072. private _poseControlledCamera;
  80073. private _leftHandSystemQuaternion;
  80074. /**
  80075. * Internal, matrix used to convert room space to babylon space
  80076. * @hidden
  80077. */
  80078. _deviceToWorld: Matrix;
  80079. /**
  80080. * Node to be used when casting a ray from the controller
  80081. * @hidden
  80082. */
  80083. _pointingPoseNode: Nullable<TransformNode>;
  80084. /**
  80085. * Name of the child mesh that can be used to cast a ray from the controller
  80086. */
  80087. static readonly POINTING_POSE: string;
  80088. /**
  80089. * Creates a new PoseEnabledController from a gamepad
  80090. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  80091. */
  80092. constructor(browserGamepad: any);
  80093. private _workingMatrix;
  80094. /**
  80095. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  80096. */
  80097. update(): void;
  80098. /**
  80099. * Updates only the pose device and mesh without doing any button event checking
  80100. */
  80101. protected _updatePoseAndMesh(): void;
  80102. /**
  80103. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  80104. * @param poseData raw pose fromthe device
  80105. */
  80106. updateFromDevice(poseData: DevicePose): void;
  80107. /**
  80108. * @hidden
  80109. */
  80110. _meshAttachedObservable: Observable<AbstractMesh>;
  80111. /**
  80112. * Attaches a mesh to the controller
  80113. * @param mesh the mesh to be attached
  80114. */
  80115. attachToMesh(mesh: AbstractMesh): void;
  80116. /**
  80117. * Attaches the controllers mesh to a camera
  80118. * @param camera the camera the mesh should be attached to
  80119. */
  80120. attachToPoseControlledCamera(camera: TargetCamera): void;
  80121. /**
  80122. * Disposes of the controller
  80123. */
  80124. dispose(): void;
  80125. /**
  80126. * The mesh that is attached to the controller
  80127. */
  80128. readonly mesh: Nullable<AbstractMesh>;
  80129. /**
  80130. * Gets the ray of the controller in the direction the controller is pointing
  80131. * @param length the length the resulting ray should be
  80132. * @returns a ray in the direction the controller is pointing
  80133. */
  80134. getForwardRay(length?: number): Ray;
  80135. }
  80136. }
  80137. declare module BABYLON {
  80138. /**
  80139. * Defines the WebVRController object that represents controllers tracked in 3D space
  80140. */
  80141. export abstract class WebVRController extends PoseEnabledController {
  80142. /**
  80143. * Internal, the default controller model for the controller
  80144. */
  80145. protected _defaultModel: AbstractMesh;
  80146. /**
  80147. * Fired when the trigger state has changed
  80148. */
  80149. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  80150. /**
  80151. * Fired when the main button state has changed
  80152. */
  80153. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80154. /**
  80155. * Fired when the secondary button state has changed
  80156. */
  80157. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80158. /**
  80159. * Fired when the pad state has changed
  80160. */
  80161. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  80162. /**
  80163. * Fired when controllers stick values have changed
  80164. */
  80165. onPadValuesChangedObservable: Observable<StickValues>;
  80166. /**
  80167. * Array of button availible on the controller
  80168. */
  80169. protected _buttons: Array<MutableGamepadButton>;
  80170. private _onButtonStateChange;
  80171. /**
  80172. * Fired when a controller button's state has changed
  80173. * @param callback the callback containing the button that was modified
  80174. */
  80175. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  80176. /**
  80177. * X and Y axis corresponding to the controllers joystick
  80178. */
  80179. pad: StickValues;
  80180. /**
  80181. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  80182. */
  80183. hand: string;
  80184. /**
  80185. * The default controller model for the controller
  80186. */
  80187. readonly defaultModel: AbstractMesh;
  80188. /**
  80189. * Creates a new WebVRController from a gamepad
  80190. * @param vrGamepad the gamepad that the WebVRController should be created from
  80191. */
  80192. constructor(vrGamepad: any);
  80193. /**
  80194. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  80195. */
  80196. update(): void;
  80197. /**
  80198. * Function to be called when a button is modified
  80199. */
  80200. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  80201. /**
  80202. * Loads a mesh and attaches it to the controller
  80203. * @param scene the scene the mesh should be added to
  80204. * @param meshLoaded callback for when the mesh has been loaded
  80205. */
  80206. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  80207. private _setButtonValue;
  80208. private _changes;
  80209. private _checkChanges;
  80210. /**
  80211. * Disposes of th webVRCOntroller
  80212. */
  80213. dispose(): void;
  80214. }
  80215. }
  80216. declare module BABYLON {
  80217. /**
  80218. * The HemisphericLight simulates the ambient environment light,
  80219. * so the passed direction is the light reflection direction, not the incoming direction.
  80220. */
  80221. export class HemisphericLight extends Light {
  80222. /**
  80223. * The groundColor is the light in the opposite direction to the one specified during creation.
  80224. * 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.
  80225. */
  80226. groundColor: Color3;
  80227. /**
  80228. * The light reflection direction, not the incoming direction.
  80229. */
  80230. direction: Vector3;
  80231. /**
  80232. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  80233. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  80234. * The HemisphericLight can't cast shadows.
  80235. * Documentation : https://doc.babylonjs.com/babylon101/lights
  80236. * @param name The friendly name of the light
  80237. * @param direction The direction of the light reflection
  80238. * @param scene The scene the light belongs to
  80239. */
  80240. constructor(name: string, direction: Vector3, scene: Scene);
  80241. protected _buildUniformLayout(): void;
  80242. /**
  80243. * Returns the string "HemisphericLight".
  80244. * @return The class name
  80245. */
  80246. getClassName(): string;
  80247. /**
  80248. * Sets the HemisphericLight direction towards the passed target (Vector3).
  80249. * Returns the updated direction.
  80250. * @param target The target the direction should point to
  80251. * @return The computed direction
  80252. */
  80253. setDirectionToTarget(target: Vector3): Vector3;
  80254. /**
  80255. * Returns the shadow generator associated to the light.
  80256. * @returns Always null for hemispheric lights because it does not support shadows.
  80257. */
  80258. getShadowGenerator(): Nullable<IShadowGenerator>;
  80259. /**
  80260. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  80261. * @param effect The effect to update
  80262. * @param lightIndex The index of the light in the effect to update
  80263. * @returns The hemispheric light
  80264. */
  80265. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  80266. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  80267. /**
  80268. * Computes the world matrix of the node
  80269. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80270. * @param useWasUpdatedFlag defines a reserved property
  80271. * @returns the world matrix
  80272. */
  80273. computeWorldMatrix(): Matrix;
  80274. /**
  80275. * Returns the integer 3.
  80276. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  80277. */
  80278. getTypeID(): number;
  80279. /**
  80280. * Prepares the list of defines specific to the light type.
  80281. * @param defines the list of defines
  80282. * @param lightIndex defines the index of the light for the effect
  80283. */
  80284. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  80285. }
  80286. }
  80287. declare module BABYLON {
  80288. /** @hidden */
  80289. export var vrMultiviewToSingleviewPixelShader: {
  80290. name: string;
  80291. shader: string;
  80292. };
  80293. }
  80294. declare module BABYLON {
  80295. /**
  80296. * Renders to multiple views with a single draw call
  80297. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  80298. */
  80299. export class MultiviewRenderTarget extends RenderTargetTexture {
  80300. /**
  80301. * Creates a multiview render target
  80302. * @param scene scene used with the render target
  80303. * @param size the size of the render target (used for each view)
  80304. */
  80305. constructor(scene: Scene, size?: number | {
  80306. width: number;
  80307. height: number;
  80308. } | {
  80309. ratio: number;
  80310. });
  80311. /**
  80312. * @hidden
  80313. * @param faceIndex the face index, if its a cube texture
  80314. */
  80315. _bindFrameBuffer(faceIndex?: number): void;
  80316. /**
  80317. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  80318. * @returns the view count
  80319. */
  80320. getViewCount(): number;
  80321. }
  80322. }
  80323. declare module BABYLON {
  80324. /**
  80325. * Represents a camera frustum
  80326. */
  80327. export class Frustum {
  80328. /**
  80329. * Gets the planes representing the frustum
  80330. * @param transform matrix to be applied to the returned planes
  80331. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  80332. */
  80333. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  80334. /**
  80335. * Gets the near frustum plane transformed by the transform matrix
  80336. * @param transform transformation matrix to be applied to the resulting frustum plane
  80337. * @param frustumPlane the resuling frustum plane
  80338. */
  80339. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80340. /**
  80341. * Gets the far frustum plane transformed by the transform matrix
  80342. * @param transform transformation matrix to be applied to the resulting frustum plane
  80343. * @param frustumPlane the resuling frustum plane
  80344. */
  80345. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80346. /**
  80347. * Gets the left frustum plane transformed by the transform matrix
  80348. * @param transform transformation matrix to be applied to the resulting frustum plane
  80349. * @param frustumPlane the resuling frustum plane
  80350. */
  80351. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80352. /**
  80353. * Gets the right frustum plane transformed by the transform matrix
  80354. * @param transform transformation matrix to be applied to the resulting frustum plane
  80355. * @param frustumPlane the resuling frustum plane
  80356. */
  80357. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80358. /**
  80359. * Gets the top frustum plane transformed by the transform matrix
  80360. * @param transform transformation matrix to be applied to the resulting frustum plane
  80361. * @param frustumPlane the resuling frustum plane
  80362. */
  80363. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80364. /**
  80365. * Gets the bottom frustum plane transformed by the transform matrix
  80366. * @param transform transformation matrix to be applied to the resulting frustum plane
  80367. * @param frustumPlane the resuling frustum plane
  80368. */
  80369. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80370. /**
  80371. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  80372. * @param transform transformation matrix to be applied to the resulting frustum planes
  80373. * @param frustumPlanes the resuling frustum planes
  80374. */
  80375. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  80376. }
  80377. }
  80378. declare module BABYLON {
  80379. interface Engine {
  80380. /**
  80381. * Creates a new multiview render target
  80382. * @param width defines the width of the texture
  80383. * @param height defines the height of the texture
  80384. * @returns the created multiview texture
  80385. */
  80386. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  80387. /**
  80388. * Binds a multiview framebuffer to be drawn to
  80389. * @param multiviewTexture texture to bind
  80390. */
  80391. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  80392. }
  80393. interface Camera {
  80394. /**
  80395. * @hidden
  80396. * 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)
  80397. */
  80398. _useMultiviewToSingleView: boolean;
  80399. /**
  80400. * @hidden
  80401. * 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)
  80402. */
  80403. _multiviewTexture: Nullable<RenderTargetTexture>;
  80404. /**
  80405. * @hidden
  80406. * ensures the multiview texture of the camera exists and has the specified width/height
  80407. * @param width height to set on the multiview texture
  80408. * @param height width to set on the multiview texture
  80409. */
  80410. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  80411. }
  80412. interface Scene {
  80413. /** @hidden */
  80414. _transformMatrixR: Matrix;
  80415. /** @hidden */
  80416. _multiviewSceneUbo: Nullable<UniformBuffer>;
  80417. /** @hidden */
  80418. _createMultiviewUbo(): void;
  80419. /** @hidden */
  80420. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  80421. /** @hidden */
  80422. _renderMultiviewToSingleView(camera: Camera): void;
  80423. }
  80424. }
  80425. declare module BABYLON {
  80426. /**
  80427. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  80428. * This will not be used for webXR as it supports displaying texture arrays directly
  80429. */
  80430. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  80431. /**
  80432. * Initializes a VRMultiviewToSingleview
  80433. * @param name name of the post process
  80434. * @param camera camera to be applied to
  80435. * @param scaleFactor scaling factor to the size of the output texture
  80436. */
  80437. constructor(name: string, camera: Camera, scaleFactor: number);
  80438. }
  80439. }
  80440. declare module BABYLON {
  80441. interface Engine {
  80442. /** @hidden */
  80443. _vrDisplay: any;
  80444. /** @hidden */
  80445. _vrSupported: boolean;
  80446. /** @hidden */
  80447. _oldSize: Size;
  80448. /** @hidden */
  80449. _oldHardwareScaleFactor: number;
  80450. /** @hidden */
  80451. _vrExclusivePointerMode: boolean;
  80452. /** @hidden */
  80453. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  80454. /** @hidden */
  80455. _onVRDisplayPointerRestricted: () => void;
  80456. /** @hidden */
  80457. _onVRDisplayPointerUnrestricted: () => void;
  80458. /** @hidden */
  80459. _onVrDisplayConnect: Nullable<(display: any) => void>;
  80460. /** @hidden */
  80461. _onVrDisplayDisconnect: Nullable<() => void>;
  80462. /** @hidden */
  80463. _onVrDisplayPresentChange: Nullable<() => void>;
  80464. /**
  80465. * Observable signaled when VR display mode changes
  80466. */
  80467. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  80468. /**
  80469. * Observable signaled when VR request present is complete
  80470. */
  80471. onVRRequestPresentComplete: Observable<boolean>;
  80472. /**
  80473. * Observable signaled when VR request present starts
  80474. */
  80475. onVRRequestPresentStart: Observable<Engine>;
  80476. /**
  80477. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  80478. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  80479. */
  80480. isInVRExclusivePointerMode: boolean;
  80481. /**
  80482. * Gets a boolean indicating if a webVR device was detected
  80483. * @returns true if a webVR device was detected
  80484. */
  80485. isVRDevicePresent(): boolean;
  80486. /**
  80487. * Gets the current webVR device
  80488. * @returns the current webVR device (or null)
  80489. */
  80490. getVRDevice(): any;
  80491. /**
  80492. * Initializes a webVR display and starts listening to display change events
  80493. * The onVRDisplayChangedObservable will be notified upon these changes
  80494. * @returns A promise containing a VRDisplay and if vr is supported
  80495. */
  80496. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  80497. /** @hidden */
  80498. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  80499. /**
  80500. * Call this function to switch to webVR mode
  80501. * Will do nothing if webVR is not supported or if there is no webVR device
  80502. * @see http://doc.babylonjs.com/how_to/webvr_camera
  80503. */
  80504. enableVR(): void;
  80505. /** @hidden */
  80506. _onVRFullScreenTriggered(): void;
  80507. }
  80508. }
  80509. declare module BABYLON {
  80510. /**
  80511. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  80512. * IMPORTANT!! The data is right-hand data.
  80513. * @export
  80514. * @interface DevicePose
  80515. */
  80516. export interface DevicePose {
  80517. /**
  80518. * The position of the device, values in array are [x,y,z].
  80519. */
  80520. readonly position: Nullable<Float32Array>;
  80521. /**
  80522. * The linearVelocity of the device, values in array are [x,y,z].
  80523. */
  80524. readonly linearVelocity: Nullable<Float32Array>;
  80525. /**
  80526. * The linearAcceleration of the device, values in array are [x,y,z].
  80527. */
  80528. readonly linearAcceleration: Nullable<Float32Array>;
  80529. /**
  80530. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  80531. */
  80532. readonly orientation: Nullable<Float32Array>;
  80533. /**
  80534. * The angularVelocity of the device, values in array are [x,y,z].
  80535. */
  80536. readonly angularVelocity: Nullable<Float32Array>;
  80537. /**
  80538. * The angularAcceleration of the device, values in array are [x,y,z].
  80539. */
  80540. readonly angularAcceleration: Nullable<Float32Array>;
  80541. }
  80542. /**
  80543. * Interface representing a pose controlled object in Babylon.
  80544. * A pose controlled object has both regular pose values as well as pose values
  80545. * from an external device such as a VR head mounted display
  80546. */
  80547. export interface PoseControlled {
  80548. /**
  80549. * The position of the object in babylon space.
  80550. */
  80551. position: Vector3;
  80552. /**
  80553. * The rotation quaternion of the object in babylon space.
  80554. */
  80555. rotationQuaternion: Quaternion;
  80556. /**
  80557. * The position of the device in babylon space.
  80558. */
  80559. devicePosition?: Vector3;
  80560. /**
  80561. * The rotation quaternion of the device in babylon space.
  80562. */
  80563. deviceRotationQuaternion: Quaternion;
  80564. /**
  80565. * The raw pose coming from the device.
  80566. */
  80567. rawPose: Nullable<DevicePose>;
  80568. /**
  80569. * The scale of the device to be used when translating from device space to babylon space.
  80570. */
  80571. deviceScaleFactor: number;
  80572. /**
  80573. * Updates the poseControlled values based on the input device pose.
  80574. * @param poseData the pose data to update the object with
  80575. */
  80576. updateFromDevice(poseData: DevicePose): void;
  80577. }
  80578. /**
  80579. * Set of options to customize the webVRCamera
  80580. */
  80581. export interface WebVROptions {
  80582. /**
  80583. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  80584. */
  80585. trackPosition?: boolean;
  80586. /**
  80587. * Sets the scale of the vrDevice in babylon space. (default: 1)
  80588. */
  80589. positionScale?: number;
  80590. /**
  80591. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  80592. */
  80593. displayName?: string;
  80594. /**
  80595. * Should the native controller meshes be initialized. (default: true)
  80596. */
  80597. controllerMeshes?: boolean;
  80598. /**
  80599. * Creating a default HemiLight only on controllers. (default: true)
  80600. */
  80601. defaultLightingOnControllers?: boolean;
  80602. /**
  80603. * If you don't want to use the default VR button of the helper. (default: false)
  80604. */
  80605. useCustomVRButton?: boolean;
  80606. /**
  80607. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  80608. */
  80609. customVRButton?: HTMLButtonElement;
  80610. /**
  80611. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  80612. */
  80613. rayLength?: number;
  80614. /**
  80615. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  80616. */
  80617. defaultHeight?: number;
  80618. /**
  80619. * If multiview should be used if availible (default: false)
  80620. */
  80621. useMultiview?: boolean;
  80622. }
  80623. /**
  80624. * This represents a WebVR camera.
  80625. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  80626. * @example http://doc.babylonjs.com/how_to/webvr_camera
  80627. */
  80628. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  80629. private webVROptions;
  80630. /**
  80631. * @hidden
  80632. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  80633. */
  80634. _vrDevice: any;
  80635. /**
  80636. * The rawPose of the vrDevice.
  80637. */
  80638. rawPose: Nullable<DevicePose>;
  80639. private _onVREnabled;
  80640. private _specsVersion;
  80641. private _attached;
  80642. private _frameData;
  80643. protected _descendants: Array<Node>;
  80644. private _deviceRoomPosition;
  80645. /** @hidden */
  80646. _deviceRoomRotationQuaternion: Quaternion;
  80647. private _standingMatrix;
  80648. /**
  80649. * Represents device position in babylon space.
  80650. */
  80651. devicePosition: Vector3;
  80652. /**
  80653. * Represents device rotation in babylon space.
  80654. */
  80655. deviceRotationQuaternion: Quaternion;
  80656. /**
  80657. * The scale of the device to be used when translating from device space to babylon space.
  80658. */
  80659. deviceScaleFactor: number;
  80660. private _deviceToWorld;
  80661. private _worldToDevice;
  80662. /**
  80663. * References to the webVR controllers for the vrDevice.
  80664. */
  80665. controllers: Array<WebVRController>;
  80666. /**
  80667. * Emits an event when a controller is attached.
  80668. */
  80669. onControllersAttachedObservable: Observable<WebVRController[]>;
  80670. /**
  80671. * Emits an event when a controller's mesh has been loaded;
  80672. */
  80673. onControllerMeshLoadedObservable: Observable<WebVRController>;
  80674. /**
  80675. * Emits an event when the HMD's pose has been updated.
  80676. */
  80677. onPoseUpdatedFromDeviceObservable: Observable<any>;
  80678. private _poseSet;
  80679. /**
  80680. * If the rig cameras be used as parent instead of this camera.
  80681. */
  80682. rigParenting: boolean;
  80683. private _lightOnControllers;
  80684. private _defaultHeight?;
  80685. /**
  80686. * Instantiates a WebVRFreeCamera.
  80687. * @param name The name of the WebVRFreeCamera
  80688. * @param position The starting anchor position for the camera
  80689. * @param scene The scene the camera belongs to
  80690. * @param webVROptions a set of customizable options for the webVRCamera
  80691. */
  80692. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  80693. /**
  80694. * Gets the device distance from the ground in meters.
  80695. * @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.
  80696. */
  80697. deviceDistanceToRoomGround(): number;
  80698. /**
  80699. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80700. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  80701. */
  80702. useStandingMatrix(callback?: (bool: boolean) => void): void;
  80703. /**
  80704. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80705. * @returns A promise with a boolean set to if the standing matrix is supported.
  80706. */
  80707. useStandingMatrixAsync(): Promise<boolean>;
  80708. /**
  80709. * Disposes the camera
  80710. */
  80711. dispose(): void;
  80712. /**
  80713. * Gets a vrController by name.
  80714. * @param name The name of the controller to retreive
  80715. * @returns the controller matching the name specified or null if not found
  80716. */
  80717. getControllerByName(name: string): Nullable<WebVRController>;
  80718. private _leftController;
  80719. /**
  80720. * The controller corresponding to the users left hand.
  80721. */
  80722. readonly leftController: Nullable<WebVRController>;
  80723. private _rightController;
  80724. /**
  80725. * The controller corresponding to the users right hand.
  80726. */
  80727. readonly rightController: Nullable<WebVRController>;
  80728. /**
  80729. * Casts a ray forward from the vrCamera's gaze.
  80730. * @param length Length of the ray (default: 100)
  80731. * @returns the ray corresponding to the gaze
  80732. */
  80733. getForwardRay(length?: number): Ray;
  80734. /**
  80735. * @hidden
  80736. * Updates the camera based on device's frame data
  80737. */
  80738. _checkInputs(): void;
  80739. /**
  80740. * Updates the poseControlled values based on the input device pose.
  80741. * @param poseData Pose coming from the device
  80742. */
  80743. updateFromDevice(poseData: DevicePose): void;
  80744. private _htmlElementAttached;
  80745. private _detachIfAttached;
  80746. /**
  80747. * WebVR's attach control will start broadcasting frames to the device.
  80748. * Note that in certain browsers (chrome for example) this function must be called
  80749. * within a user-interaction callback. Example:
  80750. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  80751. *
  80752. * @param element html element to attach the vrDevice to
  80753. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  80754. */
  80755. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80756. /**
  80757. * Detaches the camera from the html element and disables VR
  80758. *
  80759. * @param element html element to detach from
  80760. */
  80761. detachControl(element: HTMLElement): void;
  80762. /**
  80763. * @returns the name of this class
  80764. */
  80765. getClassName(): string;
  80766. /**
  80767. * Calls resetPose on the vrDisplay
  80768. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  80769. */
  80770. resetToCurrentRotation(): void;
  80771. /**
  80772. * @hidden
  80773. * Updates the rig cameras (left and right eye)
  80774. */
  80775. _updateRigCameras(): void;
  80776. private _workingVector;
  80777. private _oneVector;
  80778. private _workingMatrix;
  80779. private updateCacheCalled;
  80780. private _correctPositionIfNotTrackPosition;
  80781. /**
  80782. * @hidden
  80783. * Updates the cached values of the camera
  80784. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  80785. */
  80786. _updateCache(ignoreParentClass?: boolean): void;
  80787. /**
  80788. * @hidden
  80789. * Get current device position in babylon world
  80790. */
  80791. _computeDevicePosition(): void;
  80792. /**
  80793. * Updates the current device position and rotation in the babylon world
  80794. */
  80795. update(): void;
  80796. /**
  80797. * @hidden
  80798. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  80799. * @returns an identity matrix
  80800. */
  80801. _getViewMatrix(): Matrix;
  80802. private _tmpMatrix;
  80803. /**
  80804. * This function is called by the two RIG cameras.
  80805. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  80806. * @hidden
  80807. */
  80808. _getWebVRViewMatrix(): Matrix;
  80809. /** @hidden */
  80810. _getWebVRProjectionMatrix(): Matrix;
  80811. private _onGamepadConnectedObserver;
  80812. private _onGamepadDisconnectedObserver;
  80813. private _updateCacheWhenTrackingDisabledObserver;
  80814. /**
  80815. * Initializes the controllers and their meshes
  80816. */
  80817. initControllers(): void;
  80818. }
  80819. }
  80820. declare module BABYLON {
  80821. /**
  80822. * Size options for a post process
  80823. */
  80824. export type PostProcessOptions = {
  80825. width: number;
  80826. height: number;
  80827. };
  80828. /**
  80829. * PostProcess can be used to apply a shader to a texture after it has been rendered
  80830. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80831. */
  80832. export class PostProcess {
  80833. /** Name of the PostProcess. */
  80834. name: string;
  80835. /**
  80836. * Gets or sets the unique id of the post process
  80837. */
  80838. uniqueId: number;
  80839. /**
  80840. * Width of the texture to apply the post process on
  80841. */
  80842. width: number;
  80843. /**
  80844. * Height of the texture to apply the post process on
  80845. */
  80846. height: number;
  80847. /**
  80848. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  80849. * @hidden
  80850. */
  80851. _outputTexture: Nullable<InternalTexture>;
  80852. /**
  80853. * Sampling mode used by the shader
  80854. * See https://doc.babylonjs.com/classes/3.1/texture
  80855. */
  80856. renderTargetSamplingMode: number;
  80857. /**
  80858. * Clear color to use when screen clearing
  80859. */
  80860. clearColor: Color4;
  80861. /**
  80862. * If the buffer needs to be cleared before applying the post process. (default: true)
  80863. * Should be set to false if shader will overwrite all previous pixels.
  80864. */
  80865. autoClear: boolean;
  80866. /**
  80867. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  80868. */
  80869. alphaMode: number;
  80870. /**
  80871. * Sets the setAlphaBlendConstants of the babylon engine
  80872. */
  80873. alphaConstants: Color4;
  80874. /**
  80875. * Animations to be used for the post processing
  80876. */
  80877. animations: Animation[];
  80878. /**
  80879. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  80880. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  80881. */
  80882. enablePixelPerfectMode: boolean;
  80883. /**
  80884. * Force the postprocess to be applied without taking in account viewport
  80885. */
  80886. forceFullscreenViewport: boolean;
  80887. /**
  80888. * List of inspectable custom properties (used by the Inspector)
  80889. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80890. */
  80891. inspectableCustomProperties: IInspectable[];
  80892. /**
  80893. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  80894. *
  80895. * | Value | Type | Description |
  80896. * | ----- | ----------------------------------- | ----------- |
  80897. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  80898. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  80899. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  80900. *
  80901. */
  80902. scaleMode: number;
  80903. /**
  80904. * Force textures to be a power of two (default: false)
  80905. */
  80906. alwaysForcePOT: boolean;
  80907. private _samples;
  80908. /**
  80909. * Number of sample textures (default: 1)
  80910. */
  80911. samples: number;
  80912. /**
  80913. * Modify the scale of the post process to be the same as the viewport (default: false)
  80914. */
  80915. adaptScaleToCurrentViewport: boolean;
  80916. private _camera;
  80917. private _scene;
  80918. private _engine;
  80919. private _options;
  80920. private _reusable;
  80921. private _textureType;
  80922. /**
  80923. * Smart array of input and output textures for the post process.
  80924. * @hidden
  80925. */
  80926. _textures: SmartArray<InternalTexture>;
  80927. /**
  80928. * The index in _textures that corresponds to the output texture.
  80929. * @hidden
  80930. */
  80931. _currentRenderTextureInd: number;
  80932. private _effect;
  80933. private _samplers;
  80934. private _fragmentUrl;
  80935. private _vertexUrl;
  80936. private _parameters;
  80937. private _scaleRatio;
  80938. protected _indexParameters: any;
  80939. private _shareOutputWithPostProcess;
  80940. private _texelSize;
  80941. private _forcedOutputTexture;
  80942. /**
  80943. * Returns the fragment url or shader name used in the post process.
  80944. * @returns the fragment url or name in the shader store.
  80945. */
  80946. getEffectName(): string;
  80947. /**
  80948. * An event triggered when the postprocess is activated.
  80949. */
  80950. onActivateObservable: Observable<Camera>;
  80951. private _onActivateObserver;
  80952. /**
  80953. * A function that is added to the onActivateObservable
  80954. */
  80955. onActivate: Nullable<(camera: Camera) => void>;
  80956. /**
  80957. * An event triggered when the postprocess changes its size.
  80958. */
  80959. onSizeChangedObservable: Observable<PostProcess>;
  80960. private _onSizeChangedObserver;
  80961. /**
  80962. * A function that is added to the onSizeChangedObservable
  80963. */
  80964. onSizeChanged: (postProcess: PostProcess) => void;
  80965. /**
  80966. * An event triggered when the postprocess applies its effect.
  80967. */
  80968. onApplyObservable: Observable<Effect>;
  80969. private _onApplyObserver;
  80970. /**
  80971. * A function that is added to the onApplyObservable
  80972. */
  80973. onApply: (effect: Effect) => void;
  80974. /**
  80975. * An event triggered before rendering the postprocess
  80976. */
  80977. onBeforeRenderObservable: Observable<Effect>;
  80978. private _onBeforeRenderObserver;
  80979. /**
  80980. * A function that is added to the onBeforeRenderObservable
  80981. */
  80982. onBeforeRender: (effect: Effect) => void;
  80983. /**
  80984. * An event triggered after rendering the postprocess
  80985. */
  80986. onAfterRenderObservable: Observable<Effect>;
  80987. private _onAfterRenderObserver;
  80988. /**
  80989. * A function that is added to the onAfterRenderObservable
  80990. */
  80991. onAfterRender: (efect: Effect) => void;
  80992. /**
  80993. * 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
  80994. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  80995. */
  80996. inputTexture: InternalTexture;
  80997. /**
  80998. * Gets the camera which post process is applied to.
  80999. * @returns The camera the post process is applied to.
  81000. */
  81001. getCamera(): Camera;
  81002. /**
  81003. * Gets the texel size of the postprocess.
  81004. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  81005. */
  81006. readonly texelSize: Vector2;
  81007. /**
  81008. * Creates a new instance PostProcess
  81009. * @param name The name of the PostProcess.
  81010. * @param fragmentUrl The url of the fragment shader to be used.
  81011. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  81012. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  81013. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81014. * @param camera The camera to apply the render pass to.
  81015. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81016. * @param engine The engine which the post process will be applied. (default: current engine)
  81017. * @param reusable If the post process can be reused on the same frame. (default: false)
  81018. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  81019. * @param textureType Type of textures used when performing the post process. (default: 0)
  81020. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  81021. * @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
  81022. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  81023. */
  81024. constructor(
  81025. /** Name of the PostProcess. */
  81026. 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);
  81027. /**
  81028. * Gets a string idenfifying the name of the class
  81029. * @returns "PostProcess" string
  81030. */
  81031. getClassName(): string;
  81032. /**
  81033. * Gets the engine which this post process belongs to.
  81034. * @returns The engine the post process was enabled with.
  81035. */
  81036. getEngine(): Engine;
  81037. /**
  81038. * The effect that is created when initializing the post process.
  81039. * @returns The created effect corresponding the the postprocess.
  81040. */
  81041. getEffect(): Effect;
  81042. /**
  81043. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  81044. * @param postProcess The post process to share the output with.
  81045. * @returns This post process.
  81046. */
  81047. shareOutputWith(postProcess: PostProcess): PostProcess;
  81048. /**
  81049. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  81050. * This should be called if the post process that shares output with this post process is disabled/disposed.
  81051. */
  81052. useOwnOutput(): void;
  81053. /**
  81054. * Updates the effect with the current post process compile time values and recompiles the shader.
  81055. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81056. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81057. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81058. * @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
  81059. * @param onCompiled Called when the shader has been compiled.
  81060. * @param onError Called if there is an error when compiling a shader.
  81061. */
  81062. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81063. /**
  81064. * The post process is reusable if it can be used multiple times within one frame.
  81065. * @returns If the post process is reusable
  81066. */
  81067. isReusable(): boolean;
  81068. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  81069. markTextureDirty(): void;
  81070. /**
  81071. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  81072. * 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.
  81073. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  81074. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  81075. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  81076. * @returns The target texture that was bound to be written to.
  81077. */
  81078. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  81079. /**
  81080. * If the post process is supported.
  81081. */
  81082. readonly isSupported: boolean;
  81083. /**
  81084. * The aspect ratio of the output texture.
  81085. */
  81086. readonly aspectRatio: number;
  81087. /**
  81088. * Get a value indicating if the post-process is ready to be used
  81089. * @returns true if the post-process is ready (shader is compiled)
  81090. */
  81091. isReady(): boolean;
  81092. /**
  81093. * Binds all textures and uniforms to the shader, this will be run on every pass.
  81094. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  81095. */
  81096. apply(): Nullable<Effect>;
  81097. private _disposeTextures;
  81098. /**
  81099. * Disposes the post process.
  81100. * @param camera The camera to dispose the post process on.
  81101. */
  81102. dispose(camera?: Camera): void;
  81103. }
  81104. }
  81105. declare module BABYLON {
  81106. /** @hidden */
  81107. export var kernelBlurVaryingDeclaration: {
  81108. name: string;
  81109. shader: string;
  81110. };
  81111. }
  81112. declare module BABYLON {
  81113. /** @hidden */
  81114. export var kernelBlurFragment: {
  81115. name: string;
  81116. shader: string;
  81117. };
  81118. }
  81119. declare module BABYLON {
  81120. /** @hidden */
  81121. export var kernelBlurFragment2: {
  81122. name: string;
  81123. shader: string;
  81124. };
  81125. }
  81126. declare module BABYLON {
  81127. /** @hidden */
  81128. export var kernelBlurPixelShader: {
  81129. name: string;
  81130. shader: string;
  81131. };
  81132. }
  81133. declare module BABYLON {
  81134. /** @hidden */
  81135. export var kernelBlurVertex: {
  81136. name: string;
  81137. shader: string;
  81138. };
  81139. }
  81140. declare module BABYLON {
  81141. /** @hidden */
  81142. export var kernelBlurVertexShader: {
  81143. name: string;
  81144. shader: string;
  81145. };
  81146. }
  81147. declare module BABYLON {
  81148. /**
  81149. * The Blur Post Process which blurs an image based on a kernel and direction.
  81150. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  81151. */
  81152. export class BlurPostProcess extends PostProcess {
  81153. /** The direction in which to blur the image. */
  81154. direction: Vector2;
  81155. private blockCompilation;
  81156. protected _kernel: number;
  81157. protected _idealKernel: number;
  81158. protected _packedFloat: boolean;
  81159. private _staticDefines;
  81160. /**
  81161. * Sets the length in pixels of the blur sample region
  81162. */
  81163. /**
  81164. * Gets the length in pixels of the blur sample region
  81165. */
  81166. kernel: number;
  81167. /**
  81168. * Sets wether or not the blur needs to unpack/repack floats
  81169. */
  81170. /**
  81171. * Gets wether or not the blur is unpacking/repacking floats
  81172. */
  81173. packedFloat: boolean;
  81174. /**
  81175. * Creates a new instance BlurPostProcess
  81176. * @param name The name of the effect.
  81177. * @param direction The direction in which to blur the image.
  81178. * @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.
  81179. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81180. * @param camera The camera to apply the render pass to.
  81181. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81182. * @param engine The engine which the post process will be applied. (default: current engine)
  81183. * @param reusable If the post process can be reused on the same frame. (default: false)
  81184. * @param textureType Type of textures used when performing the post process. (default: 0)
  81185. * @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)
  81186. */
  81187. constructor(name: string,
  81188. /** The direction in which to blur the image. */
  81189. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  81190. /**
  81191. * Updates the effect with the current post process compile time values and recompiles the shader.
  81192. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81193. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81194. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81195. * @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
  81196. * @param onCompiled Called when the shader has been compiled.
  81197. * @param onError Called if there is an error when compiling a shader.
  81198. */
  81199. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81200. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81201. /**
  81202. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  81203. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  81204. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  81205. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  81206. * The gaps between physical kernels are compensated for in the weighting of the samples
  81207. * @param idealKernel Ideal blur kernel.
  81208. * @return Nearest best kernel.
  81209. */
  81210. protected _nearestBestKernel(idealKernel: number): number;
  81211. /**
  81212. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  81213. * @param x The point on the Gaussian distribution to sample.
  81214. * @return the value of the Gaussian function at x.
  81215. */
  81216. protected _gaussianWeight(x: number): number;
  81217. /**
  81218. * Generates a string that can be used as a floating point number in GLSL.
  81219. * @param x Value to print.
  81220. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  81221. * @return GLSL float string.
  81222. */
  81223. protected _glslFloat(x: number, decimalFigures?: number): string;
  81224. }
  81225. }
  81226. declare module BABYLON {
  81227. /**
  81228. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81229. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81230. * You can then easily use it as a reflectionTexture on a flat surface.
  81231. * In case the surface is not a plane, please consider relying on reflection probes.
  81232. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81233. */
  81234. export class MirrorTexture extends RenderTargetTexture {
  81235. private scene;
  81236. /**
  81237. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  81238. * 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.
  81239. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81240. */
  81241. mirrorPlane: Plane;
  81242. /**
  81243. * Define the blur ratio used to blur the reflection if needed.
  81244. */
  81245. blurRatio: number;
  81246. /**
  81247. * Define the adaptive blur kernel used to blur the reflection if needed.
  81248. * This will autocompute the closest best match for the `blurKernel`
  81249. */
  81250. adaptiveBlurKernel: number;
  81251. /**
  81252. * Define the blur kernel used to blur the reflection if needed.
  81253. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81254. */
  81255. blurKernel: number;
  81256. /**
  81257. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  81258. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81259. */
  81260. blurKernelX: number;
  81261. /**
  81262. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  81263. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81264. */
  81265. blurKernelY: number;
  81266. private _autoComputeBlurKernel;
  81267. protected _onRatioRescale(): void;
  81268. private _updateGammaSpace;
  81269. private _imageProcessingConfigChangeObserver;
  81270. private _transformMatrix;
  81271. private _mirrorMatrix;
  81272. private _savedViewMatrix;
  81273. private _blurX;
  81274. private _blurY;
  81275. private _adaptiveBlurKernel;
  81276. private _blurKernelX;
  81277. private _blurKernelY;
  81278. private _blurRatio;
  81279. /**
  81280. * Instantiates a Mirror Texture.
  81281. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81282. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81283. * You can then easily use it as a reflectionTexture on a flat surface.
  81284. * In case the surface is not a plane, please consider relying on reflection probes.
  81285. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81286. * @param name
  81287. * @param size
  81288. * @param scene
  81289. * @param generateMipMaps
  81290. * @param type
  81291. * @param samplingMode
  81292. * @param generateDepthBuffer
  81293. */
  81294. constructor(name: string, size: number | {
  81295. width: number;
  81296. height: number;
  81297. } | {
  81298. ratio: number;
  81299. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  81300. private _preparePostProcesses;
  81301. /**
  81302. * Clone the mirror texture.
  81303. * @returns the cloned texture
  81304. */
  81305. clone(): MirrorTexture;
  81306. /**
  81307. * Serialize the texture to a JSON representation you could use in Parse later on
  81308. * @returns the serialized JSON representation
  81309. */
  81310. serialize(): any;
  81311. /**
  81312. * Dispose the texture and release its associated resources.
  81313. */
  81314. dispose(): void;
  81315. }
  81316. }
  81317. declare module BABYLON {
  81318. /**
  81319. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81320. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81321. */
  81322. export class Texture extends BaseTexture {
  81323. /**
  81324. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  81325. */
  81326. static SerializeBuffers: boolean;
  81327. /** @hidden */
  81328. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  81329. /** @hidden */
  81330. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  81331. /** @hidden */
  81332. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  81333. /** nearest is mag = nearest and min = nearest and mip = linear */
  81334. static readonly NEAREST_SAMPLINGMODE: number;
  81335. /** nearest is mag = nearest and min = nearest and mip = linear */
  81336. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  81337. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81338. static readonly BILINEAR_SAMPLINGMODE: number;
  81339. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81340. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  81341. /** Trilinear is mag = linear and min = linear and mip = linear */
  81342. static readonly TRILINEAR_SAMPLINGMODE: number;
  81343. /** Trilinear is mag = linear and min = linear and mip = linear */
  81344. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  81345. /** mag = nearest and min = nearest and mip = nearest */
  81346. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  81347. /** mag = nearest and min = linear and mip = nearest */
  81348. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  81349. /** mag = nearest and min = linear and mip = linear */
  81350. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  81351. /** mag = nearest and min = linear and mip = none */
  81352. static readonly NEAREST_LINEAR: number;
  81353. /** mag = nearest and min = nearest and mip = none */
  81354. static readonly NEAREST_NEAREST: number;
  81355. /** mag = linear and min = nearest and mip = nearest */
  81356. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  81357. /** mag = linear and min = nearest and mip = linear */
  81358. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  81359. /** mag = linear and min = linear and mip = none */
  81360. static readonly LINEAR_LINEAR: number;
  81361. /** mag = linear and min = nearest and mip = none */
  81362. static readonly LINEAR_NEAREST: number;
  81363. /** Explicit coordinates mode */
  81364. static readonly EXPLICIT_MODE: number;
  81365. /** Spherical coordinates mode */
  81366. static readonly SPHERICAL_MODE: number;
  81367. /** Planar coordinates mode */
  81368. static readonly PLANAR_MODE: number;
  81369. /** Cubic coordinates mode */
  81370. static readonly CUBIC_MODE: number;
  81371. /** Projection coordinates mode */
  81372. static readonly PROJECTION_MODE: number;
  81373. /** Inverse Cubic coordinates mode */
  81374. static readonly SKYBOX_MODE: number;
  81375. /** Inverse Cubic coordinates mode */
  81376. static readonly INVCUBIC_MODE: number;
  81377. /** Equirectangular coordinates mode */
  81378. static readonly EQUIRECTANGULAR_MODE: number;
  81379. /** Equirectangular Fixed coordinates mode */
  81380. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  81381. /** Equirectangular Fixed Mirrored coordinates mode */
  81382. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81383. /** Texture is not repeating outside of 0..1 UVs */
  81384. static readonly CLAMP_ADDRESSMODE: number;
  81385. /** Texture is repeating outside of 0..1 UVs */
  81386. static readonly WRAP_ADDRESSMODE: number;
  81387. /** Texture is repeating and mirrored */
  81388. static readonly MIRROR_ADDRESSMODE: number;
  81389. /**
  81390. * 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
  81391. */
  81392. static UseSerializedUrlIfAny: boolean;
  81393. /**
  81394. * Define the url of the texture.
  81395. */
  81396. url: Nullable<string>;
  81397. /**
  81398. * Define an offset on the texture to offset the u coordinates of the UVs
  81399. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81400. */
  81401. uOffset: number;
  81402. /**
  81403. * Define an offset on the texture to offset the v coordinates of the UVs
  81404. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81405. */
  81406. vOffset: number;
  81407. /**
  81408. * Define an offset on the texture to scale the u coordinates of the UVs
  81409. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81410. */
  81411. uScale: number;
  81412. /**
  81413. * Define an offset on the texture to scale the v coordinates of the UVs
  81414. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81415. */
  81416. vScale: number;
  81417. /**
  81418. * Define an offset on the texture to rotate around the u coordinates of the UVs
  81419. * @see http://doc.babylonjs.com/how_to/more_materials
  81420. */
  81421. uAng: number;
  81422. /**
  81423. * Define an offset on the texture to rotate around the v coordinates of the UVs
  81424. * @see http://doc.babylonjs.com/how_to/more_materials
  81425. */
  81426. vAng: number;
  81427. /**
  81428. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  81429. * @see http://doc.babylonjs.com/how_to/more_materials
  81430. */
  81431. wAng: number;
  81432. /**
  81433. * Defines the center of rotation (U)
  81434. */
  81435. uRotationCenter: number;
  81436. /**
  81437. * Defines the center of rotation (V)
  81438. */
  81439. vRotationCenter: number;
  81440. /**
  81441. * Defines the center of rotation (W)
  81442. */
  81443. wRotationCenter: number;
  81444. /**
  81445. * Are mip maps generated for this texture or not.
  81446. */
  81447. readonly noMipmap: boolean;
  81448. /**
  81449. * List of inspectable custom properties (used by the Inspector)
  81450. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81451. */
  81452. inspectableCustomProperties: Nullable<IInspectable[]>;
  81453. private _noMipmap;
  81454. /** @hidden */
  81455. _invertY: boolean;
  81456. private _rowGenerationMatrix;
  81457. private _cachedTextureMatrix;
  81458. private _projectionModeMatrix;
  81459. private _t0;
  81460. private _t1;
  81461. private _t2;
  81462. private _cachedUOffset;
  81463. private _cachedVOffset;
  81464. private _cachedUScale;
  81465. private _cachedVScale;
  81466. private _cachedUAng;
  81467. private _cachedVAng;
  81468. private _cachedWAng;
  81469. private _cachedProjectionMatrixId;
  81470. private _cachedCoordinatesMode;
  81471. /** @hidden */
  81472. protected _initialSamplingMode: number;
  81473. /** @hidden */
  81474. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  81475. private _deleteBuffer;
  81476. protected _format: Nullable<number>;
  81477. private _delayedOnLoad;
  81478. private _delayedOnError;
  81479. /**
  81480. * Observable triggered once the texture has been loaded.
  81481. */
  81482. onLoadObservable: Observable<Texture>;
  81483. protected _isBlocking: boolean;
  81484. /**
  81485. * Is the texture preventing material to render while loading.
  81486. * If false, a default texture will be used instead of the loading one during the preparation step.
  81487. */
  81488. isBlocking: boolean;
  81489. /**
  81490. * Get the current sampling mode associated with the texture.
  81491. */
  81492. readonly samplingMode: number;
  81493. /**
  81494. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  81495. */
  81496. readonly invertY: boolean;
  81497. /**
  81498. * Instantiates a new texture.
  81499. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81500. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81501. * @param url define the url of the picture to load as a texture
  81502. * @param scene define the scene or engine the texture will belong to
  81503. * @param noMipmap define if the texture will require mip maps or not
  81504. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81505. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81506. * @param onLoad define a callback triggered when the texture has been loaded
  81507. * @param onError define a callback triggered when an error occurred during the loading session
  81508. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81509. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81510. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81511. */
  81512. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  81513. /**
  81514. * Update the url (and optional buffer) of this texture if url was null during construction.
  81515. * @param url the url of the texture
  81516. * @param buffer the buffer of the texture (defaults to null)
  81517. * @param onLoad callback called when the texture is loaded (defaults to null)
  81518. */
  81519. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  81520. /**
  81521. * Finish the loading sequence of a texture flagged as delayed load.
  81522. * @hidden
  81523. */
  81524. delayLoad(): void;
  81525. private _prepareRowForTextureGeneration;
  81526. /**
  81527. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  81528. * @returns the transform matrix of the texture.
  81529. */
  81530. getTextureMatrix(): Matrix;
  81531. /**
  81532. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  81533. * @returns The reflection texture transform
  81534. */
  81535. getReflectionTextureMatrix(): Matrix;
  81536. /**
  81537. * Clones the texture.
  81538. * @returns the cloned texture
  81539. */
  81540. clone(): Texture;
  81541. /**
  81542. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  81543. * @returns The JSON representation of the texture
  81544. */
  81545. serialize(): any;
  81546. /**
  81547. * Get the current class name of the texture useful for serialization or dynamic coding.
  81548. * @returns "Texture"
  81549. */
  81550. getClassName(): string;
  81551. /**
  81552. * Dispose the texture and release its associated resources.
  81553. */
  81554. dispose(): void;
  81555. /**
  81556. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  81557. * @param parsedTexture Define the JSON representation of the texture
  81558. * @param scene Define the scene the parsed texture should be instantiated in
  81559. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  81560. * @returns The parsed texture if successful
  81561. */
  81562. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  81563. /**
  81564. * Creates a texture from its base 64 representation.
  81565. * @param data Define the base64 payload without the data: prefix
  81566. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81567. * @param scene Define the scene the texture should belong to
  81568. * @param noMipmap Forces the texture to not create mip map information if true
  81569. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81570. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81571. * @param onLoad define a callback triggered when the texture has been loaded
  81572. * @param onError define a callback triggered when an error occurred during the loading session
  81573. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81574. * @returns the created texture
  81575. */
  81576. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  81577. /**
  81578. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  81579. * @param data Define the base64 payload without the data: prefix
  81580. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81581. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81582. * @param scene Define the scene the texture should belong to
  81583. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81584. * @param noMipmap Forces the texture to not create mip map information if true
  81585. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81586. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81587. * @param onLoad define a callback triggered when the texture has been loaded
  81588. * @param onError define a callback triggered when an error occurred during the loading session
  81589. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81590. * @returns the created texture
  81591. */
  81592. 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;
  81593. }
  81594. }
  81595. declare module BABYLON {
  81596. /**
  81597. * PostProcessManager is used to manage one or more post processes or post process pipelines
  81598. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81599. */
  81600. export class PostProcessManager {
  81601. private _scene;
  81602. private _indexBuffer;
  81603. private _vertexBuffers;
  81604. /**
  81605. * Creates a new instance PostProcess
  81606. * @param scene The scene that the post process is associated with.
  81607. */
  81608. constructor(scene: Scene);
  81609. private _prepareBuffers;
  81610. private _buildIndexBuffer;
  81611. /**
  81612. * Rebuilds the vertex buffers of the manager.
  81613. * @hidden
  81614. */
  81615. _rebuild(): void;
  81616. /**
  81617. * Prepares a frame to be run through a post process.
  81618. * @param sourceTexture The input texture to the post procesess. (default: null)
  81619. * @param postProcesses An array of post processes to be run. (default: null)
  81620. * @returns True if the post processes were able to be run.
  81621. * @hidden
  81622. */
  81623. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  81624. /**
  81625. * Manually render a set of post processes to a texture.
  81626. * @param postProcesses An array of post processes to be run.
  81627. * @param targetTexture The target texture to render to.
  81628. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  81629. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  81630. * @param lodLevel defines which lod of the texture to render to
  81631. */
  81632. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  81633. /**
  81634. * Finalize the result of the output of the postprocesses.
  81635. * @param doNotPresent If true the result will not be displayed to the screen.
  81636. * @param targetTexture The target texture to render to.
  81637. * @param faceIndex The index of the face to bind the target texture to.
  81638. * @param postProcesses The array of post processes to render.
  81639. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  81640. * @hidden
  81641. */
  81642. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  81643. /**
  81644. * Disposes of the post process manager.
  81645. */
  81646. dispose(): void;
  81647. }
  81648. }
  81649. declare module BABYLON {
  81650. /** Interface used by value gradients (color, factor, ...) */
  81651. export interface IValueGradient {
  81652. /**
  81653. * Gets or sets the gradient value (between 0 and 1)
  81654. */
  81655. gradient: number;
  81656. }
  81657. /** Class used to store color4 gradient */
  81658. export class ColorGradient implements IValueGradient {
  81659. /**
  81660. * Gets or sets the gradient value (between 0 and 1)
  81661. */
  81662. gradient: number;
  81663. /**
  81664. * Gets or sets first associated color
  81665. */
  81666. color1: Color4;
  81667. /**
  81668. * Gets or sets second associated color
  81669. */
  81670. color2?: Color4;
  81671. /**
  81672. * Will get a color picked randomly between color1 and color2.
  81673. * If color2 is undefined then color1 will be used
  81674. * @param result defines the target Color4 to store the result in
  81675. */
  81676. getColorToRef(result: Color4): void;
  81677. }
  81678. /** Class used to store color 3 gradient */
  81679. export class Color3Gradient implements IValueGradient {
  81680. /**
  81681. * Gets or sets the gradient value (between 0 and 1)
  81682. */
  81683. gradient: number;
  81684. /**
  81685. * Gets or sets the associated color
  81686. */
  81687. color: Color3;
  81688. }
  81689. /** Class used to store factor gradient */
  81690. export class FactorGradient implements IValueGradient {
  81691. /**
  81692. * Gets or sets the gradient value (between 0 and 1)
  81693. */
  81694. gradient: number;
  81695. /**
  81696. * Gets or sets first associated factor
  81697. */
  81698. factor1: number;
  81699. /**
  81700. * Gets or sets second associated factor
  81701. */
  81702. factor2?: number;
  81703. /**
  81704. * Will get a number picked randomly between factor1 and factor2.
  81705. * If factor2 is undefined then factor1 will be used
  81706. * @returns the picked number
  81707. */
  81708. getFactor(): number;
  81709. }
  81710. /**
  81711. * Helper used to simplify some generic gradient tasks
  81712. */
  81713. export class GradientHelper {
  81714. /**
  81715. * Gets the current gradient from an array of IValueGradient
  81716. * @param ratio defines the current ratio to get
  81717. * @param gradients defines the array of IValueGradient
  81718. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  81719. */
  81720. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  81721. }
  81722. }
  81723. declare module BABYLON {
  81724. interface AbstractScene {
  81725. /**
  81726. * The list of procedural textures added to the scene
  81727. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81728. */
  81729. proceduralTextures: Array<ProceduralTexture>;
  81730. }
  81731. /**
  81732. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  81733. * in a given scene.
  81734. */
  81735. export class ProceduralTextureSceneComponent implements ISceneComponent {
  81736. /**
  81737. * The component name helpfull to identify the component in the list of scene components.
  81738. */
  81739. readonly name: string;
  81740. /**
  81741. * The scene the component belongs to.
  81742. */
  81743. scene: Scene;
  81744. /**
  81745. * Creates a new instance of the component for the given scene
  81746. * @param scene Defines the scene to register the component in
  81747. */
  81748. constructor(scene: Scene);
  81749. /**
  81750. * Registers the component in a given scene
  81751. */
  81752. register(): void;
  81753. /**
  81754. * Rebuilds the elements related to this component in case of
  81755. * context lost for instance.
  81756. */
  81757. rebuild(): void;
  81758. /**
  81759. * Disposes the component and the associated ressources.
  81760. */
  81761. dispose(): void;
  81762. private _beforeClear;
  81763. }
  81764. }
  81765. declare module BABYLON {
  81766. interface Engine {
  81767. /**
  81768. * Creates a new render target cube texture
  81769. * @param size defines the size of the texture
  81770. * @param options defines the options used to create the texture
  81771. * @returns a new render target cube texture stored in an InternalTexture
  81772. */
  81773. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  81774. }
  81775. }
  81776. declare module BABYLON {
  81777. /** @hidden */
  81778. export var proceduralVertexShader: {
  81779. name: string;
  81780. shader: string;
  81781. };
  81782. }
  81783. declare module BABYLON {
  81784. /**
  81785. * 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.
  81786. * This is the base class of any Procedural texture and contains most of the shareable code.
  81787. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81788. */
  81789. export class ProceduralTexture extends Texture {
  81790. isCube: boolean;
  81791. /**
  81792. * Define if the texture is enabled or not (disabled texture will not render)
  81793. */
  81794. isEnabled: boolean;
  81795. /**
  81796. * Define if the texture must be cleared before rendering (default is true)
  81797. */
  81798. autoClear: boolean;
  81799. /**
  81800. * Callback called when the texture is generated
  81801. */
  81802. onGenerated: () => void;
  81803. /**
  81804. * Event raised when the texture is generated
  81805. */
  81806. onGeneratedObservable: Observable<ProceduralTexture>;
  81807. /** @hidden */
  81808. _generateMipMaps: boolean;
  81809. /** @hidden **/
  81810. _effect: Effect;
  81811. /** @hidden */
  81812. _textures: {
  81813. [key: string]: Texture;
  81814. };
  81815. private _size;
  81816. private _currentRefreshId;
  81817. private _refreshRate;
  81818. private _vertexBuffers;
  81819. private _indexBuffer;
  81820. private _uniforms;
  81821. private _samplers;
  81822. private _fragment;
  81823. private _floats;
  81824. private _ints;
  81825. private _floatsArrays;
  81826. private _colors3;
  81827. private _colors4;
  81828. private _vectors2;
  81829. private _vectors3;
  81830. private _matrices;
  81831. private _fallbackTexture;
  81832. private _fallbackTextureUsed;
  81833. private _engine;
  81834. private _cachedDefines;
  81835. private _contentUpdateId;
  81836. private _contentData;
  81837. /**
  81838. * Instantiates a new procedural texture.
  81839. * 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.
  81840. * This is the base class of any Procedural texture and contains most of the shareable code.
  81841. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81842. * @param name Define the name of the texture
  81843. * @param size Define the size of the texture to create
  81844. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  81845. * @param scene Define the scene the texture belongs to
  81846. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  81847. * @param generateMipMaps Define if the texture should creates mip maps or not
  81848. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  81849. */
  81850. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  81851. /**
  81852. * The effect that is created when initializing the post process.
  81853. * @returns The created effect corresponding the the postprocess.
  81854. */
  81855. getEffect(): Effect;
  81856. /**
  81857. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  81858. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  81859. */
  81860. getContent(): Nullable<ArrayBufferView>;
  81861. private _createIndexBuffer;
  81862. /** @hidden */
  81863. _rebuild(): void;
  81864. /**
  81865. * Resets the texture in order to recreate its associated resources.
  81866. * This can be called in case of context loss
  81867. */
  81868. reset(): void;
  81869. protected _getDefines(): string;
  81870. /**
  81871. * Is the texture ready to be used ? (rendered at least once)
  81872. * @returns true if ready, otherwise, false.
  81873. */
  81874. isReady(): boolean;
  81875. /**
  81876. * Resets the refresh counter of the texture and start bak from scratch.
  81877. * Could be useful to regenerate the texture if it is setup to render only once.
  81878. */
  81879. resetRefreshCounter(): void;
  81880. /**
  81881. * Set the fragment shader to use in order to render the texture.
  81882. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  81883. */
  81884. setFragment(fragment: any): void;
  81885. /**
  81886. * Define the refresh rate of the texture or the rendering frequency.
  81887. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  81888. */
  81889. refreshRate: number;
  81890. /** @hidden */
  81891. _shouldRender(): boolean;
  81892. /**
  81893. * Get the size the texture is rendering at.
  81894. * @returns the size (texture is always squared)
  81895. */
  81896. getRenderSize(): number;
  81897. /**
  81898. * Resize the texture to new value.
  81899. * @param size Define the new size the texture should have
  81900. * @param generateMipMaps Define whether the new texture should create mip maps
  81901. */
  81902. resize(size: number, generateMipMaps: boolean): void;
  81903. private _checkUniform;
  81904. /**
  81905. * Set a texture in the shader program used to render.
  81906. * @param name Define the name of the uniform samplers as defined in the shader
  81907. * @param texture Define the texture to bind to this sampler
  81908. * @return the texture itself allowing "fluent" like uniform updates
  81909. */
  81910. setTexture(name: string, texture: Texture): ProceduralTexture;
  81911. /**
  81912. * Set a float in the shader.
  81913. * @param name Define the name of the uniform as defined in the shader
  81914. * @param value Define the value to give to the uniform
  81915. * @return the texture itself allowing "fluent" like uniform updates
  81916. */
  81917. setFloat(name: string, value: number): ProceduralTexture;
  81918. /**
  81919. * Set a int in the shader.
  81920. * @param name Define the name of the uniform as defined in the shader
  81921. * @param value Define the value to give to the uniform
  81922. * @return the texture itself allowing "fluent" like uniform updates
  81923. */
  81924. setInt(name: string, value: number): ProceduralTexture;
  81925. /**
  81926. * Set an array of floats in the shader.
  81927. * @param name Define the name of the uniform as defined in the shader
  81928. * @param value Define the value to give to the uniform
  81929. * @return the texture itself allowing "fluent" like uniform updates
  81930. */
  81931. setFloats(name: string, value: number[]): ProceduralTexture;
  81932. /**
  81933. * Set a vec3 in the shader from a Color3.
  81934. * @param name Define the name of the uniform as defined in the shader
  81935. * @param value Define the value to give to the uniform
  81936. * @return the texture itself allowing "fluent" like uniform updates
  81937. */
  81938. setColor3(name: string, value: Color3): ProceduralTexture;
  81939. /**
  81940. * Set a vec4 in the shader from a Color4.
  81941. * @param name Define the name of the uniform as defined in the shader
  81942. * @param value Define the value to give to the uniform
  81943. * @return the texture itself allowing "fluent" like uniform updates
  81944. */
  81945. setColor4(name: string, value: Color4): ProceduralTexture;
  81946. /**
  81947. * Set a vec2 in the shader from a Vector2.
  81948. * @param name Define the name of the uniform as defined in the shader
  81949. * @param value Define the value to give to the uniform
  81950. * @return the texture itself allowing "fluent" like uniform updates
  81951. */
  81952. setVector2(name: string, value: Vector2): ProceduralTexture;
  81953. /**
  81954. * Set a vec3 in the shader from a Vector3.
  81955. * @param name Define the name of the uniform as defined in the shader
  81956. * @param value Define the value to give to the uniform
  81957. * @return the texture itself allowing "fluent" like uniform updates
  81958. */
  81959. setVector3(name: string, value: Vector3): ProceduralTexture;
  81960. /**
  81961. * Set a mat4 in the shader from a MAtrix.
  81962. * @param name Define the name of the uniform as defined in the shader
  81963. * @param value Define the value to give to the uniform
  81964. * @return the texture itself allowing "fluent" like uniform updates
  81965. */
  81966. setMatrix(name: string, value: Matrix): ProceduralTexture;
  81967. /**
  81968. * Render the texture to its associated render target.
  81969. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  81970. */
  81971. render(useCameraPostProcess?: boolean): void;
  81972. /**
  81973. * Clone the texture.
  81974. * @returns the cloned texture
  81975. */
  81976. clone(): ProceduralTexture;
  81977. /**
  81978. * Dispose the texture and release its asoociated resources.
  81979. */
  81980. dispose(): void;
  81981. }
  81982. }
  81983. declare module BABYLON {
  81984. /**
  81985. * This represents the base class for particle system in Babylon.
  81986. * 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.
  81987. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  81988. * @example https://doc.babylonjs.com/babylon101/particles
  81989. */
  81990. export class BaseParticleSystem {
  81991. /**
  81992. * Source color is added to the destination color without alpha affecting the result
  81993. */
  81994. static BLENDMODE_ONEONE: number;
  81995. /**
  81996. * Blend current color and particle color using particle’s alpha
  81997. */
  81998. static BLENDMODE_STANDARD: number;
  81999. /**
  82000. * Add current color and particle color multiplied by particle’s alpha
  82001. */
  82002. static BLENDMODE_ADD: number;
  82003. /**
  82004. * Multiply current color with particle color
  82005. */
  82006. static BLENDMODE_MULTIPLY: number;
  82007. /**
  82008. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  82009. */
  82010. static BLENDMODE_MULTIPLYADD: number;
  82011. /**
  82012. * List of animations used by the particle system.
  82013. */
  82014. animations: Animation[];
  82015. /**
  82016. * The id of the Particle system.
  82017. */
  82018. id: string;
  82019. /**
  82020. * The friendly name of the Particle system.
  82021. */
  82022. name: string;
  82023. /**
  82024. * The rendering group used by the Particle system to chose when to render.
  82025. */
  82026. renderingGroupId: number;
  82027. /**
  82028. * The emitter represents the Mesh or position we are attaching the particle system to.
  82029. */
  82030. emitter: Nullable<AbstractMesh | Vector3>;
  82031. /**
  82032. * The maximum number of particles to emit per frame
  82033. */
  82034. emitRate: number;
  82035. /**
  82036. * If you want to launch only a few particles at once, that can be done, as well.
  82037. */
  82038. manualEmitCount: number;
  82039. /**
  82040. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  82041. */
  82042. updateSpeed: number;
  82043. /**
  82044. * The amount of time the particle system is running (depends of the overall update speed).
  82045. */
  82046. targetStopDuration: number;
  82047. /**
  82048. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  82049. */
  82050. disposeOnStop: boolean;
  82051. /**
  82052. * Minimum power of emitting particles.
  82053. */
  82054. minEmitPower: number;
  82055. /**
  82056. * Maximum power of emitting particles.
  82057. */
  82058. maxEmitPower: number;
  82059. /**
  82060. * Minimum life time of emitting particles.
  82061. */
  82062. minLifeTime: number;
  82063. /**
  82064. * Maximum life time of emitting particles.
  82065. */
  82066. maxLifeTime: number;
  82067. /**
  82068. * Minimum Size of emitting particles.
  82069. */
  82070. minSize: number;
  82071. /**
  82072. * Maximum Size of emitting particles.
  82073. */
  82074. maxSize: number;
  82075. /**
  82076. * Minimum scale of emitting particles on X axis.
  82077. */
  82078. minScaleX: number;
  82079. /**
  82080. * Maximum scale of emitting particles on X axis.
  82081. */
  82082. maxScaleX: number;
  82083. /**
  82084. * Minimum scale of emitting particles on Y axis.
  82085. */
  82086. minScaleY: number;
  82087. /**
  82088. * Maximum scale of emitting particles on Y axis.
  82089. */
  82090. maxScaleY: number;
  82091. /**
  82092. * Gets or sets the minimal initial rotation in radians.
  82093. */
  82094. minInitialRotation: number;
  82095. /**
  82096. * Gets or sets the maximal initial rotation in radians.
  82097. */
  82098. maxInitialRotation: number;
  82099. /**
  82100. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  82101. */
  82102. minAngularSpeed: number;
  82103. /**
  82104. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  82105. */
  82106. maxAngularSpeed: number;
  82107. /**
  82108. * The texture used to render each particle. (this can be a spritesheet)
  82109. */
  82110. particleTexture: Nullable<Texture>;
  82111. /**
  82112. * The layer mask we are rendering the particles through.
  82113. */
  82114. layerMask: number;
  82115. /**
  82116. * This can help using your own shader to render the particle system.
  82117. * The according effect will be created
  82118. */
  82119. customShader: any;
  82120. /**
  82121. * By default particle system starts as soon as they are created. This prevents the
  82122. * automatic start to happen and let you decide when to start emitting particles.
  82123. */
  82124. preventAutoStart: boolean;
  82125. private _noiseTexture;
  82126. /**
  82127. * Gets or sets a texture used to add random noise to particle positions
  82128. */
  82129. noiseTexture: Nullable<ProceduralTexture>;
  82130. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  82131. noiseStrength: Vector3;
  82132. /**
  82133. * Callback triggered when the particle animation is ending.
  82134. */
  82135. onAnimationEnd: Nullable<() => void>;
  82136. /**
  82137. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  82138. */
  82139. blendMode: number;
  82140. /**
  82141. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  82142. * to override the particles.
  82143. */
  82144. forceDepthWrite: boolean;
  82145. /** 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 */
  82146. preWarmCycles: number;
  82147. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  82148. preWarmStepOffset: number;
  82149. /**
  82150. * 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)
  82151. */
  82152. spriteCellChangeSpeed: number;
  82153. /**
  82154. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  82155. */
  82156. startSpriteCellID: number;
  82157. /**
  82158. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  82159. */
  82160. endSpriteCellID: number;
  82161. /**
  82162. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  82163. */
  82164. spriteCellWidth: number;
  82165. /**
  82166. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  82167. */
  82168. spriteCellHeight: number;
  82169. /**
  82170. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  82171. */
  82172. spriteRandomStartCell: boolean;
  82173. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  82174. translationPivot: Vector2;
  82175. /** @hidden */
  82176. protected _isAnimationSheetEnabled: boolean;
  82177. /**
  82178. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  82179. */
  82180. beginAnimationOnStart: boolean;
  82181. /**
  82182. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  82183. */
  82184. beginAnimationFrom: number;
  82185. /**
  82186. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  82187. */
  82188. beginAnimationTo: number;
  82189. /**
  82190. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  82191. */
  82192. beginAnimationLoop: boolean;
  82193. /**
  82194. * Gets or sets a world offset applied to all particles
  82195. */
  82196. worldOffset: Vector3;
  82197. /**
  82198. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  82199. */
  82200. isAnimationSheetEnabled: boolean;
  82201. /**
  82202. * Get hosting scene
  82203. * @returns the scene
  82204. */
  82205. getScene(): Scene;
  82206. /**
  82207. * You can use gravity if you want to give an orientation to your particles.
  82208. */
  82209. gravity: Vector3;
  82210. protected _colorGradients: Nullable<Array<ColorGradient>>;
  82211. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  82212. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  82213. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  82214. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  82215. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  82216. protected _dragGradients: Nullable<Array<FactorGradient>>;
  82217. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  82218. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  82219. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  82220. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  82221. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  82222. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  82223. /**
  82224. * Defines the delay in milliseconds before starting the system (0 by default)
  82225. */
  82226. startDelay: number;
  82227. /**
  82228. * Gets the current list of drag gradients.
  82229. * You must use addDragGradient and removeDragGradient to udpate this list
  82230. * @returns the list of drag gradients
  82231. */
  82232. getDragGradients(): Nullable<Array<FactorGradient>>;
  82233. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  82234. limitVelocityDamping: number;
  82235. /**
  82236. * Gets the current list of limit velocity gradients.
  82237. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  82238. * @returns the list of limit velocity gradients
  82239. */
  82240. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  82241. /**
  82242. * Gets the current list of color gradients.
  82243. * You must use addColorGradient and removeColorGradient to udpate this list
  82244. * @returns the list of color gradients
  82245. */
  82246. getColorGradients(): Nullable<Array<ColorGradient>>;
  82247. /**
  82248. * Gets the current list of size gradients.
  82249. * You must use addSizeGradient and removeSizeGradient to udpate this list
  82250. * @returns the list of size gradients
  82251. */
  82252. getSizeGradients(): Nullable<Array<FactorGradient>>;
  82253. /**
  82254. * Gets the current list of color remap gradients.
  82255. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  82256. * @returns the list of color remap gradients
  82257. */
  82258. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  82259. /**
  82260. * Gets the current list of alpha remap gradients.
  82261. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  82262. * @returns the list of alpha remap gradients
  82263. */
  82264. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  82265. /**
  82266. * Gets the current list of life time gradients.
  82267. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  82268. * @returns the list of life time gradients
  82269. */
  82270. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  82271. /**
  82272. * Gets the current list of angular speed gradients.
  82273. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  82274. * @returns the list of angular speed gradients
  82275. */
  82276. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  82277. /**
  82278. * Gets the current list of velocity gradients.
  82279. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  82280. * @returns the list of velocity gradients
  82281. */
  82282. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  82283. /**
  82284. * Gets the current list of start size gradients.
  82285. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  82286. * @returns the list of start size gradients
  82287. */
  82288. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  82289. /**
  82290. * Gets the current list of emit rate gradients.
  82291. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  82292. * @returns the list of emit rate gradients
  82293. */
  82294. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  82295. /**
  82296. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82297. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82298. */
  82299. direction1: Vector3;
  82300. /**
  82301. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82302. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82303. */
  82304. direction2: Vector3;
  82305. /**
  82306. * 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.
  82307. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82308. */
  82309. minEmitBox: Vector3;
  82310. /**
  82311. * 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.
  82312. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82313. */
  82314. maxEmitBox: Vector3;
  82315. /**
  82316. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82317. */
  82318. color1: Color4;
  82319. /**
  82320. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82321. */
  82322. color2: Color4;
  82323. /**
  82324. * Color the particle will have at the end of its lifetime
  82325. */
  82326. colorDead: Color4;
  82327. /**
  82328. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  82329. */
  82330. textureMask: Color4;
  82331. /**
  82332. * The particle emitter type defines the emitter used by the particle system.
  82333. * It can be for example box, sphere, or cone...
  82334. */
  82335. particleEmitterType: IParticleEmitterType;
  82336. /** @hidden */
  82337. _isSubEmitter: boolean;
  82338. /**
  82339. * Gets or sets the billboard mode to use when isBillboardBased = true.
  82340. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  82341. */
  82342. billboardMode: number;
  82343. protected _isBillboardBased: boolean;
  82344. /**
  82345. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  82346. */
  82347. isBillboardBased: boolean;
  82348. /**
  82349. * The scene the particle system belongs to.
  82350. */
  82351. protected _scene: Scene;
  82352. /**
  82353. * Local cache of defines for image processing.
  82354. */
  82355. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  82356. /**
  82357. * Default configuration related to image processing available in the standard Material.
  82358. */
  82359. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  82360. /**
  82361. * Gets the image processing configuration used either in this material.
  82362. */
  82363. /**
  82364. * Sets the Default image processing configuration used either in the this material.
  82365. *
  82366. * If sets to null, the scene one is in use.
  82367. */
  82368. imageProcessingConfiguration: ImageProcessingConfiguration;
  82369. /**
  82370. * Attaches a new image processing configuration to the Standard Material.
  82371. * @param configuration
  82372. */
  82373. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  82374. /** @hidden */
  82375. protected _reset(): void;
  82376. /** @hidden */
  82377. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  82378. /**
  82379. * Instantiates a particle system.
  82380. * 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.
  82381. * @param name The name of the particle system
  82382. */
  82383. constructor(name: string);
  82384. /**
  82385. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82386. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82387. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82388. * @returns the emitter
  82389. */
  82390. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82391. /**
  82392. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  82393. * @param radius The radius of the hemisphere to emit from
  82394. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82395. * @returns the emitter
  82396. */
  82397. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  82398. /**
  82399. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  82400. * @param radius The radius of the sphere to emit from
  82401. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82402. * @returns the emitter
  82403. */
  82404. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  82405. /**
  82406. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  82407. * @param radius The radius of the sphere to emit from
  82408. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  82409. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  82410. * @returns the emitter
  82411. */
  82412. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  82413. /**
  82414. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  82415. * @param radius The radius of the emission cylinder
  82416. * @param height The height of the emission cylinder
  82417. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82418. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82419. * @returns the emitter
  82420. */
  82421. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  82422. /**
  82423. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82424. * @param radius The radius of the cylinder to emit from
  82425. * @param height The height of the emission cylinder
  82426. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82427. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82428. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82429. * @returns the emitter
  82430. */
  82431. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  82432. /**
  82433. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82434. * @param radius The radius of the cone to emit from
  82435. * @param angle The base angle of the cone
  82436. * @returns the emitter
  82437. */
  82438. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  82439. /**
  82440. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82441. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82442. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82443. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82444. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82445. * @returns the emitter
  82446. */
  82447. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82448. }
  82449. }
  82450. declare module BABYLON {
  82451. /**
  82452. * Type of sub emitter
  82453. */
  82454. export enum SubEmitterType {
  82455. /**
  82456. * Attached to the particle over it's lifetime
  82457. */
  82458. ATTACHED = 0,
  82459. /**
  82460. * Created when the particle dies
  82461. */
  82462. END = 1
  82463. }
  82464. /**
  82465. * Sub emitter class used to emit particles from an existing particle
  82466. */
  82467. export class SubEmitter {
  82468. /**
  82469. * the particle system to be used by the sub emitter
  82470. */
  82471. particleSystem: ParticleSystem;
  82472. /**
  82473. * Type of the submitter (Default: END)
  82474. */
  82475. type: SubEmitterType;
  82476. /**
  82477. * 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)
  82478. * Note: This only is supported when using an emitter of type Mesh
  82479. */
  82480. inheritDirection: boolean;
  82481. /**
  82482. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  82483. */
  82484. inheritedVelocityAmount: number;
  82485. /**
  82486. * Creates a sub emitter
  82487. * @param particleSystem the particle system to be used by the sub emitter
  82488. */
  82489. constructor(
  82490. /**
  82491. * the particle system to be used by the sub emitter
  82492. */
  82493. particleSystem: ParticleSystem);
  82494. /**
  82495. * Clones the sub emitter
  82496. * @returns the cloned sub emitter
  82497. */
  82498. clone(): SubEmitter;
  82499. /**
  82500. * Serialize current object to a JSON object
  82501. * @returns the serialized object
  82502. */
  82503. serialize(): any;
  82504. /** @hidden */
  82505. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  82506. /**
  82507. * Creates a new SubEmitter from a serialized JSON version
  82508. * @param serializationObject defines the JSON object to read from
  82509. * @param scene defines the hosting scene
  82510. * @param rootUrl defines the rootUrl for data loading
  82511. * @returns a new SubEmitter
  82512. */
  82513. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  82514. /** Release associated resources */
  82515. dispose(): void;
  82516. }
  82517. }
  82518. declare module BABYLON {
  82519. /** @hidden */
  82520. export var clipPlaneFragmentDeclaration: {
  82521. name: string;
  82522. shader: string;
  82523. };
  82524. }
  82525. declare module BABYLON {
  82526. /** @hidden */
  82527. export var imageProcessingDeclaration: {
  82528. name: string;
  82529. shader: string;
  82530. };
  82531. }
  82532. declare module BABYLON {
  82533. /** @hidden */
  82534. export var imageProcessingFunctions: {
  82535. name: string;
  82536. shader: string;
  82537. };
  82538. }
  82539. declare module BABYLON {
  82540. /** @hidden */
  82541. export var clipPlaneFragment: {
  82542. name: string;
  82543. shader: string;
  82544. };
  82545. }
  82546. declare module BABYLON {
  82547. /** @hidden */
  82548. export var particlesPixelShader: {
  82549. name: string;
  82550. shader: string;
  82551. };
  82552. }
  82553. declare module BABYLON {
  82554. /** @hidden */
  82555. export var clipPlaneVertexDeclaration: {
  82556. name: string;
  82557. shader: string;
  82558. };
  82559. }
  82560. declare module BABYLON {
  82561. /** @hidden */
  82562. export var clipPlaneVertex: {
  82563. name: string;
  82564. shader: string;
  82565. };
  82566. }
  82567. declare module BABYLON {
  82568. /** @hidden */
  82569. export var particlesVertexShader: {
  82570. name: string;
  82571. shader: string;
  82572. };
  82573. }
  82574. declare module BABYLON {
  82575. /**
  82576. * This represents a particle system in Babylon.
  82577. * 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.
  82578. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82579. * @example https://doc.babylonjs.com/babylon101/particles
  82580. */
  82581. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  82582. /**
  82583. * Billboard mode will only apply to Y axis
  82584. */
  82585. static readonly BILLBOARDMODE_Y: number;
  82586. /**
  82587. * Billboard mode will apply to all axes
  82588. */
  82589. static readonly BILLBOARDMODE_ALL: number;
  82590. /**
  82591. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82592. */
  82593. static readonly BILLBOARDMODE_STRETCHED: number;
  82594. /**
  82595. * This function can be defined to provide custom update for active particles.
  82596. * This function will be called instead of regular update (age, position, color, etc.).
  82597. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  82598. */
  82599. updateFunction: (particles: Particle[]) => void;
  82600. private _emitterWorldMatrix;
  82601. /**
  82602. * This function can be defined to specify initial direction for every new particle.
  82603. * It by default use the emitterType defined function
  82604. */
  82605. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  82606. /**
  82607. * This function can be defined to specify initial position for every new particle.
  82608. * It by default use the emitterType defined function
  82609. */
  82610. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  82611. /**
  82612. * @hidden
  82613. */
  82614. _inheritedVelocityOffset: Vector3;
  82615. /**
  82616. * An event triggered when the system is disposed
  82617. */
  82618. onDisposeObservable: Observable<ParticleSystem>;
  82619. private _onDisposeObserver;
  82620. /**
  82621. * Sets a callback that will be triggered when the system is disposed
  82622. */
  82623. onDispose: () => void;
  82624. private _particles;
  82625. private _epsilon;
  82626. private _capacity;
  82627. private _stockParticles;
  82628. private _newPartsExcess;
  82629. private _vertexData;
  82630. private _vertexBuffer;
  82631. private _vertexBuffers;
  82632. private _spriteBuffer;
  82633. private _indexBuffer;
  82634. private _effect;
  82635. private _customEffect;
  82636. private _cachedDefines;
  82637. private _scaledColorStep;
  82638. private _colorDiff;
  82639. private _scaledDirection;
  82640. private _scaledGravity;
  82641. private _currentRenderId;
  82642. private _alive;
  82643. private _useInstancing;
  82644. private _started;
  82645. private _stopped;
  82646. private _actualFrame;
  82647. private _scaledUpdateSpeed;
  82648. private _vertexBufferSize;
  82649. /** @hidden */
  82650. _currentEmitRateGradient: Nullable<FactorGradient>;
  82651. /** @hidden */
  82652. _currentEmitRate1: number;
  82653. /** @hidden */
  82654. _currentEmitRate2: number;
  82655. /** @hidden */
  82656. _currentStartSizeGradient: Nullable<FactorGradient>;
  82657. /** @hidden */
  82658. _currentStartSize1: number;
  82659. /** @hidden */
  82660. _currentStartSize2: number;
  82661. private readonly _rawTextureWidth;
  82662. private _rampGradientsTexture;
  82663. private _useRampGradients;
  82664. /** Gets or sets a boolean indicating that ramp gradients must be used
  82665. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82666. */
  82667. useRampGradients: boolean;
  82668. /**
  82669. * 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.
  82670. * 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: [])
  82671. */
  82672. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  82673. private _subEmitters;
  82674. /**
  82675. * @hidden
  82676. * If the particle systems emitter should be disposed when the particle system is disposed
  82677. */
  82678. _disposeEmitterOnDispose: boolean;
  82679. /**
  82680. * The current active Sub-systems, this property is used by the root particle system only.
  82681. */
  82682. activeSubSystems: Array<ParticleSystem>;
  82683. private _rootParticleSystem;
  82684. /**
  82685. * Gets the current list of active particles
  82686. */
  82687. readonly particles: Particle[];
  82688. /**
  82689. * Returns the string "ParticleSystem"
  82690. * @returns a string containing the class name
  82691. */
  82692. getClassName(): string;
  82693. /**
  82694. * Instantiates a particle system.
  82695. * 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.
  82696. * @param name The name of the particle system
  82697. * @param capacity The max number of particles alive at the same time
  82698. * @param scene The scene the particle system belongs to
  82699. * @param customEffect a custom effect used to change the way particles are rendered by default
  82700. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  82701. * @param epsilon Offset used to render the particles
  82702. */
  82703. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  82704. private _addFactorGradient;
  82705. private _removeFactorGradient;
  82706. /**
  82707. * Adds a new life time gradient
  82708. * @param gradient defines the gradient to use (between 0 and 1)
  82709. * @param factor defines the life time factor to affect to the specified gradient
  82710. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82711. * @returns the current particle system
  82712. */
  82713. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82714. /**
  82715. * Remove a specific life time gradient
  82716. * @param gradient defines the gradient to remove
  82717. * @returns the current particle system
  82718. */
  82719. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82720. /**
  82721. * Adds a new size gradient
  82722. * @param gradient defines the gradient to use (between 0 and 1)
  82723. * @param factor defines the size factor to affect to the specified gradient
  82724. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82725. * @returns the current particle system
  82726. */
  82727. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82728. /**
  82729. * Remove a specific size gradient
  82730. * @param gradient defines the gradient to remove
  82731. * @returns the current particle system
  82732. */
  82733. removeSizeGradient(gradient: number): IParticleSystem;
  82734. /**
  82735. * Adds a new color remap gradient
  82736. * @param gradient defines the gradient to use (between 0 and 1)
  82737. * @param min defines the color remap minimal range
  82738. * @param max defines the color remap maximal range
  82739. * @returns the current particle system
  82740. */
  82741. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82742. /**
  82743. * Remove a specific color remap gradient
  82744. * @param gradient defines the gradient to remove
  82745. * @returns the current particle system
  82746. */
  82747. removeColorRemapGradient(gradient: number): IParticleSystem;
  82748. /**
  82749. * Adds a new alpha remap gradient
  82750. * @param gradient defines the gradient to use (between 0 and 1)
  82751. * @param min defines the alpha remap minimal range
  82752. * @param max defines the alpha remap maximal range
  82753. * @returns the current particle system
  82754. */
  82755. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82756. /**
  82757. * Remove a specific alpha remap gradient
  82758. * @param gradient defines the gradient to remove
  82759. * @returns the current particle system
  82760. */
  82761. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  82762. /**
  82763. * Adds a new angular speed gradient
  82764. * @param gradient defines the gradient to use (between 0 and 1)
  82765. * @param factor defines the angular speed to affect to the specified gradient
  82766. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82767. * @returns the current particle system
  82768. */
  82769. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82770. /**
  82771. * Remove a specific angular speed gradient
  82772. * @param gradient defines the gradient to remove
  82773. * @returns the current particle system
  82774. */
  82775. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82776. /**
  82777. * Adds a new velocity gradient
  82778. * @param gradient defines the gradient to use (between 0 and 1)
  82779. * @param factor defines the velocity to affect to the specified gradient
  82780. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82781. * @returns the current particle system
  82782. */
  82783. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82784. /**
  82785. * Remove a specific velocity gradient
  82786. * @param gradient defines the gradient to remove
  82787. * @returns the current particle system
  82788. */
  82789. removeVelocityGradient(gradient: number): IParticleSystem;
  82790. /**
  82791. * Adds a new limit velocity gradient
  82792. * @param gradient defines the gradient to use (between 0 and 1)
  82793. * @param factor defines the limit velocity value to affect to the specified gradient
  82794. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82795. * @returns the current particle system
  82796. */
  82797. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82798. /**
  82799. * Remove a specific limit velocity gradient
  82800. * @param gradient defines the gradient to remove
  82801. * @returns the current particle system
  82802. */
  82803. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82804. /**
  82805. * Adds a new drag gradient
  82806. * @param gradient defines the gradient to use (between 0 and 1)
  82807. * @param factor defines the drag value to affect to the specified gradient
  82808. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82809. * @returns the current particle system
  82810. */
  82811. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82812. /**
  82813. * Remove a specific drag gradient
  82814. * @param gradient defines the gradient to remove
  82815. * @returns the current particle system
  82816. */
  82817. removeDragGradient(gradient: number): IParticleSystem;
  82818. /**
  82819. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82820. * @param gradient defines the gradient to use (between 0 and 1)
  82821. * @param factor defines the emit rate value to affect to the specified gradient
  82822. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82823. * @returns the current particle system
  82824. */
  82825. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82826. /**
  82827. * Remove a specific emit rate gradient
  82828. * @param gradient defines the gradient to remove
  82829. * @returns the current particle system
  82830. */
  82831. removeEmitRateGradient(gradient: number): IParticleSystem;
  82832. /**
  82833. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82834. * @param gradient defines the gradient to use (between 0 and 1)
  82835. * @param factor defines the start size value to affect to the specified gradient
  82836. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82837. * @returns the current particle system
  82838. */
  82839. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82840. /**
  82841. * Remove a specific start size gradient
  82842. * @param gradient defines the gradient to remove
  82843. * @returns the current particle system
  82844. */
  82845. removeStartSizeGradient(gradient: number): IParticleSystem;
  82846. private _createRampGradientTexture;
  82847. /**
  82848. * Gets the current list of ramp gradients.
  82849. * You must use addRampGradient and removeRampGradient to udpate this list
  82850. * @returns the list of ramp gradients
  82851. */
  82852. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82853. /**
  82854. * Adds a new ramp gradient used to remap particle colors
  82855. * @param gradient defines the gradient to use (between 0 and 1)
  82856. * @param color defines the color to affect to the specified gradient
  82857. * @returns the current particle system
  82858. */
  82859. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  82860. /**
  82861. * Remove a specific ramp gradient
  82862. * @param gradient defines the gradient to remove
  82863. * @returns the current particle system
  82864. */
  82865. removeRampGradient(gradient: number): ParticleSystem;
  82866. /**
  82867. * Adds a new color gradient
  82868. * @param gradient defines the gradient to use (between 0 and 1)
  82869. * @param color1 defines the color to affect to the specified gradient
  82870. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82871. * @returns this particle system
  82872. */
  82873. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82874. /**
  82875. * Remove a specific color gradient
  82876. * @param gradient defines the gradient to remove
  82877. * @returns this particle system
  82878. */
  82879. removeColorGradient(gradient: number): IParticleSystem;
  82880. private _fetchR;
  82881. protected _reset(): void;
  82882. private _resetEffect;
  82883. private _createVertexBuffers;
  82884. private _createIndexBuffer;
  82885. /**
  82886. * Gets the maximum number of particles active at the same time.
  82887. * @returns The max number of active particles.
  82888. */
  82889. getCapacity(): number;
  82890. /**
  82891. * Gets whether there are still active particles in the system.
  82892. * @returns True if it is alive, otherwise false.
  82893. */
  82894. isAlive(): boolean;
  82895. /**
  82896. * Gets if the system has been started. (Note: this will still be true after stop is called)
  82897. * @returns True if it has been started, otherwise false.
  82898. */
  82899. isStarted(): boolean;
  82900. private _prepareSubEmitterInternalArray;
  82901. /**
  82902. * Starts the particle system and begins to emit
  82903. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  82904. */
  82905. start(delay?: number): void;
  82906. /**
  82907. * Stops the particle system.
  82908. * @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.
  82909. */
  82910. stop(stopSubEmitters?: boolean): void;
  82911. /**
  82912. * Remove all active particles
  82913. */
  82914. reset(): void;
  82915. /**
  82916. * @hidden (for internal use only)
  82917. */
  82918. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  82919. /**
  82920. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  82921. * Its lifetime will start back at 0.
  82922. */
  82923. recycleParticle: (particle: Particle) => void;
  82924. private _stopSubEmitters;
  82925. private _createParticle;
  82926. private _removeFromRoot;
  82927. private _emitFromParticle;
  82928. private _update;
  82929. /** @hidden */
  82930. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  82931. /** @hidden */
  82932. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  82933. /** @hidden */
  82934. private _getEffect;
  82935. /**
  82936. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  82937. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  82938. */
  82939. animate(preWarmOnly?: boolean): void;
  82940. private _appendParticleVertices;
  82941. /**
  82942. * Rebuilds the particle system.
  82943. */
  82944. rebuild(): void;
  82945. /**
  82946. * Is this system ready to be used/rendered
  82947. * @return true if the system is ready
  82948. */
  82949. isReady(): boolean;
  82950. private _render;
  82951. /**
  82952. * Renders the particle system in its current state.
  82953. * @returns the current number of particles
  82954. */
  82955. render(): number;
  82956. /**
  82957. * Disposes the particle system and free the associated resources
  82958. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  82959. */
  82960. dispose(disposeTexture?: boolean): void;
  82961. /**
  82962. * Clones the particle system.
  82963. * @param name The name of the cloned object
  82964. * @param newEmitter The new emitter to use
  82965. * @returns the cloned particle system
  82966. */
  82967. clone(name: string, newEmitter: any): ParticleSystem;
  82968. /**
  82969. * Serializes the particle system to a JSON object.
  82970. * @returns the JSON object
  82971. */
  82972. serialize(): any;
  82973. /** @hidden */
  82974. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  82975. /** @hidden */
  82976. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  82977. /**
  82978. * Parses a JSON object to create a particle system.
  82979. * @param parsedParticleSystem The JSON object to parse
  82980. * @param scene The scene to create the particle system in
  82981. * @param rootUrl The root url to use to load external dependencies like texture
  82982. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  82983. * @returns the Parsed particle system
  82984. */
  82985. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  82986. }
  82987. }
  82988. declare module BABYLON {
  82989. /**
  82990. * A particle represents one of the element emitted by a particle system.
  82991. * This is mainly define by its coordinates, direction, velocity and age.
  82992. */
  82993. export class Particle {
  82994. /**
  82995. * The particle system the particle belongs to.
  82996. */
  82997. particleSystem: ParticleSystem;
  82998. private static _Count;
  82999. /**
  83000. * Unique ID of the particle
  83001. */
  83002. id: number;
  83003. /**
  83004. * The world position of the particle in the scene.
  83005. */
  83006. position: Vector3;
  83007. /**
  83008. * The world direction of the particle in the scene.
  83009. */
  83010. direction: Vector3;
  83011. /**
  83012. * The color of the particle.
  83013. */
  83014. color: Color4;
  83015. /**
  83016. * The color change of the particle per step.
  83017. */
  83018. colorStep: Color4;
  83019. /**
  83020. * Defines how long will the life of the particle be.
  83021. */
  83022. lifeTime: number;
  83023. /**
  83024. * The current age of the particle.
  83025. */
  83026. age: number;
  83027. /**
  83028. * The current size of the particle.
  83029. */
  83030. size: number;
  83031. /**
  83032. * The current scale of the particle.
  83033. */
  83034. scale: Vector2;
  83035. /**
  83036. * The current angle of the particle.
  83037. */
  83038. angle: number;
  83039. /**
  83040. * Defines how fast is the angle changing.
  83041. */
  83042. angularSpeed: number;
  83043. /**
  83044. * Defines the cell index used by the particle to be rendered from a sprite.
  83045. */
  83046. cellIndex: number;
  83047. /**
  83048. * The information required to support color remapping
  83049. */
  83050. remapData: Vector4;
  83051. /** @hidden */
  83052. _randomCellOffset?: number;
  83053. /** @hidden */
  83054. _initialDirection: Nullable<Vector3>;
  83055. /** @hidden */
  83056. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  83057. /** @hidden */
  83058. _initialStartSpriteCellID: number;
  83059. /** @hidden */
  83060. _initialEndSpriteCellID: number;
  83061. /** @hidden */
  83062. _currentColorGradient: Nullable<ColorGradient>;
  83063. /** @hidden */
  83064. _currentColor1: Color4;
  83065. /** @hidden */
  83066. _currentColor2: Color4;
  83067. /** @hidden */
  83068. _currentSizeGradient: Nullable<FactorGradient>;
  83069. /** @hidden */
  83070. _currentSize1: number;
  83071. /** @hidden */
  83072. _currentSize2: number;
  83073. /** @hidden */
  83074. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  83075. /** @hidden */
  83076. _currentAngularSpeed1: number;
  83077. /** @hidden */
  83078. _currentAngularSpeed2: number;
  83079. /** @hidden */
  83080. _currentVelocityGradient: Nullable<FactorGradient>;
  83081. /** @hidden */
  83082. _currentVelocity1: number;
  83083. /** @hidden */
  83084. _currentVelocity2: number;
  83085. /** @hidden */
  83086. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  83087. /** @hidden */
  83088. _currentLimitVelocity1: number;
  83089. /** @hidden */
  83090. _currentLimitVelocity2: number;
  83091. /** @hidden */
  83092. _currentDragGradient: Nullable<FactorGradient>;
  83093. /** @hidden */
  83094. _currentDrag1: number;
  83095. /** @hidden */
  83096. _currentDrag2: number;
  83097. /** @hidden */
  83098. _randomNoiseCoordinates1: Vector3;
  83099. /** @hidden */
  83100. _randomNoiseCoordinates2: Vector3;
  83101. /**
  83102. * Creates a new instance Particle
  83103. * @param particleSystem the particle system the particle belongs to
  83104. */
  83105. constructor(
  83106. /**
  83107. * The particle system the particle belongs to.
  83108. */
  83109. particleSystem: ParticleSystem);
  83110. private updateCellInfoFromSystem;
  83111. /**
  83112. * Defines how the sprite cell index is updated for the particle
  83113. */
  83114. updateCellIndex(): void;
  83115. /** @hidden */
  83116. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  83117. /** @hidden */
  83118. _inheritParticleInfoToSubEmitters(): void;
  83119. /** @hidden */
  83120. _reset(): void;
  83121. /**
  83122. * Copy the properties of particle to another one.
  83123. * @param other the particle to copy the information to.
  83124. */
  83125. copyTo(other: Particle): void;
  83126. }
  83127. }
  83128. declare module BABYLON {
  83129. /**
  83130. * Particle emitter represents a volume emitting particles.
  83131. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  83132. */
  83133. export interface IParticleEmitterType {
  83134. /**
  83135. * Called by the particle System when the direction is computed for the created particle.
  83136. * @param worldMatrix is the world matrix of the particle system
  83137. * @param directionToUpdate is the direction vector to update with the result
  83138. * @param particle is the particle we are computed the direction for
  83139. */
  83140. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83141. /**
  83142. * Called by the particle System when the position is computed for the created particle.
  83143. * @param worldMatrix is the world matrix of the particle system
  83144. * @param positionToUpdate is the position vector to update with the result
  83145. * @param particle is the particle we are computed the position for
  83146. */
  83147. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83148. /**
  83149. * Clones the current emitter and returns a copy of it
  83150. * @returns the new emitter
  83151. */
  83152. clone(): IParticleEmitterType;
  83153. /**
  83154. * Called by the GPUParticleSystem to setup the update shader
  83155. * @param effect defines the update shader
  83156. */
  83157. applyToShader(effect: Effect): void;
  83158. /**
  83159. * Returns a string to use to update the GPU particles update shader
  83160. * @returns the effect defines string
  83161. */
  83162. getEffectDefines(): string;
  83163. /**
  83164. * Returns a string representing the class name
  83165. * @returns a string containing the class name
  83166. */
  83167. getClassName(): string;
  83168. /**
  83169. * Serializes the particle system to a JSON object.
  83170. * @returns the JSON object
  83171. */
  83172. serialize(): any;
  83173. /**
  83174. * Parse properties from a JSON object
  83175. * @param serializationObject defines the JSON object
  83176. */
  83177. parse(serializationObject: any): void;
  83178. }
  83179. }
  83180. declare module BABYLON {
  83181. /**
  83182. * Particle emitter emitting particles from the inside of a box.
  83183. * It emits the particles randomly between 2 given directions.
  83184. */
  83185. export class BoxParticleEmitter implements IParticleEmitterType {
  83186. /**
  83187. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83188. */
  83189. direction1: Vector3;
  83190. /**
  83191. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83192. */
  83193. direction2: Vector3;
  83194. /**
  83195. * 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.
  83196. */
  83197. minEmitBox: Vector3;
  83198. /**
  83199. * 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.
  83200. */
  83201. maxEmitBox: Vector3;
  83202. /**
  83203. * Creates a new instance BoxParticleEmitter
  83204. */
  83205. constructor();
  83206. /**
  83207. * Called by the particle System when the direction is computed for the created particle.
  83208. * @param worldMatrix is the world matrix of the particle system
  83209. * @param directionToUpdate is the direction vector to update with the result
  83210. * @param particle is the particle we are computed the direction for
  83211. */
  83212. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83213. /**
  83214. * Called by the particle System when the position is computed for the created particle.
  83215. * @param worldMatrix is the world matrix of the particle system
  83216. * @param positionToUpdate is the position vector to update with the result
  83217. * @param particle is the particle we are computed the position for
  83218. */
  83219. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83220. /**
  83221. * Clones the current emitter and returns a copy of it
  83222. * @returns the new emitter
  83223. */
  83224. clone(): BoxParticleEmitter;
  83225. /**
  83226. * Called by the GPUParticleSystem to setup the update shader
  83227. * @param effect defines the update shader
  83228. */
  83229. applyToShader(effect: Effect): void;
  83230. /**
  83231. * Returns a string to use to update the GPU particles update shader
  83232. * @returns a string containng the defines string
  83233. */
  83234. getEffectDefines(): string;
  83235. /**
  83236. * Returns the string "BoxParticleEmitter"
  83237. * @returns a string containing the class name
  83238. */
  83239. getClassName(): string;
  83240. /**
  83241. * Serializes the particle system to a JSON object.
  83242. * @returns the JSON object
  83243. */
  83244. serialize(): any;
  83245. /**
  83246. * Parse properties from a JSON object
  83247. * @param serializationObject defines the JSON object
  83248. */
  83249. parse(serializationObject: any): void;
  83250. }
  83251. }
  83252. declare module BABYLON {
  83253. /**
  83254. * Particle emitter emitting particles from the inside of a cone.
  83255. * It emits the particles alongside the cone volume from the base to the particle.
  83256. * The emission direction might be randomized.
  83257. */
  83258. export class ConeParticleEmitter implements IParticleEmitterType {
  83259. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83260. directionRandomizer: number;
  83261. private _radius;
  83262. private _angle;
  83263. private _height;
  83264. /**
  83265. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  83266. */
  83267. radiusRange: number;
  83268. /**
  83269. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  83270. */
  83271. heightRange: number;
  83272. /**
  83273. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  83274. */
  83275. emitFromSpawnPointOnly: boolean;
  83276. /**
  83277. * Gets or sets the radius of the emission cone
  83278. */
  83279. radius: number;
  83280. /**
  83281. * Gets or sets the angle of the emission cone
  83282. */
  83283. angle: number;
  83284. private _buildHeight;
  83285. /**
  83286. * Creates a new instance ConeParticleEmitter
  83287. * @param radius the radius of the emission cone (1 by default)
  83288. * @param angle the cone base angle (PI by default)
  83289. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  83290. */
  83291. constructor(radius?: number, angle?: number,
  83292. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83293. directionRandomizer?: number);
  83294. /**
  83295. * Called by the particle System when the direction is computed for the created particle.
  83296. * @param worldMatrix is the world matrix of the particle system
  83297. * @param directionToUpdate is the direction vector to update with the result
  83298. * @param particle is the particle we are computed the direction for
  83299. */
  83300. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83301. /**
  83302. * Called by the particle System when the position is computed for the created particle.
  83303. * @param worldMatrix is the world matrix of the particle system
  83304. * @param positionToUpdate is the position vector to update with the result
  83305. * @param particle is the particle we are computed the position for
  83306. */
  83307. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83308. /**
  83309. * Clones the current emitter and returns a copy of it
  83310. * @returns the new emitter
  83311. */
  83312. clone(): ConeParticleEmitter;
  83313. /**
  83314. * Called by the GPUParticleSystem to setup the update shader
  83315. * @param effect defines the update shader
  83316. */
  83317. applyToShader(effect: Effect): void;
  83318. /**
  83319. * Returns a string to use to update the GPU particles update shader
  83320. * @returns a string containng the defines string
  83321. */
  83322. getEffectDefines(): string;
  83323. /**
  83324. * Returns the string "ConeParticleEmitter"
  83325. * @returns a string containing the class name
  83326. */
  83327. getClassName(): string;
  83328. /**
  83329. * Serializes the particle system to a JSON object.
  83330. * @returns the JSON object
  83331. */
  83332. serialize(): any;
  83333. /**
  83334. * Parse properties from a JSON object
  83335. * @param serializationObject defines the JSON object
  83336. */
  83337. parse(serializationObject: any): void;
  83338. }
  83339. }
  83340. declare module BABYLON {
  83341. /**
  83342. * Particle emitter emitting particles from the inside of a cylinder.
  83343. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  83344. */
  83345. export class CylinderParticleEmitter implements IParticleEmitterType {
  83346. /**
  83347. * The radius of the emission cylinder.
  83348. */
  83349. radius: number;
  83350. /**
  83351. * The height of the emission cylinder.
  83352. */
  83353. height: number;
  83354. /**
  83355. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83356. */
  83357. radiusRange: number;
  83358. /**
  83359. * How much to randomize the particle direction [0-1].
  83360. */
  83361. directionRandomizer: number;
  83362. /**
  83363. * Creates a new instance CylinderParticleEmitter
  83364. * @param radius the radius of the emission cylinder (1 by default)
  83365. * @param height the height of the emission cylinder (1 by default)
  83366. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83367. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83368. */
  83369. constructor(
  83370. /**
  83371. * The radius of the emission cylinder.
  83372. */
  83373. radius?: number,
  83374. /**
  83375. * The height of the emission cylinder.
  83376. */
  83377. height?: number,
  83378. /**
  83379. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83380. */
  83381. radiusRange?: number,
  83382. /**
  83383. * How much to randomize the particle direction [0-1].
  83384. */
  83385. directionRandomizer?: number);
  83386. /**
  83387. * Called by the particle System when the direction is computed for the created particle.
  83388. * @param worldMatrix is the world matrix of the particle system
  83389. * @param directionToUpdate is the direction vector to update with the result
  83390. * @param particle is the particle we are computed the direction for
  83391. */
  83392. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83393. /**
  83394. * Called by the particle System when the position is computed for the created particle.
  83395. * @param worldMatrix is the world matrix of the particle system
  83396. * @param positionToUpdate is the position vector to update with the result
  83397. * @param particle is the particle we are computed the position for
  83398. */
  83399. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83400. /**
  83401. * Clones the current emitter and returns a copy of it
  83402. * @returns the new emitter
  83403. */
  83404. clone(): CylinderParticleEmitter;
  83405. /**
  83406. * Called by the GPUParticleSystem to setup the update shader
  83407. * @param effect defines the update shader
  83408. */
  83409. applyToShader(effect: Effect): void;
  83410. /**
  83411. * Returns a string to use to update the GPU particles update shader
  83412. * @returns a string containng the defines string
  83413. */
  83414. getEffectDefines(): string;
  83415. /**
  83416. * Returns the string "CylinderParticleEmitter"
  83417. * @returns a string containing the class name
  83418. */
  83419. getClassName(): string;
  83420. /**
  83421. * Serializes the particle system to a JSON object.
  83422. * @returns the JSON object
  83423. */
  83424. serialize(): any;
  83425. /**
  83426. * Parse properties from a JSON object
  83427. * @param serializationObject defines the JSON object
  83428. */
  83429. parse(serializationObject: any): void;
  83430. }
  83431. /**
  83432. * Particle emitter emitting particles from the inside of a cylinder.
  83433. * It emits the particles randomly between two vectors.
  83434. */
  83435. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  83436. /**
  83437. * The min limit of the emission direction.
  83438. */
  83439. direction1: Vector3;
  83440. /**
  83441. * The max limit of the emission direction.
  83442. */
  83443. direction2: Vector3;
  83444. /**
  83445. * Creates a new instance CylinderDirectedParticleEmitter
  83446. * @param radius the radius of the emission cylinder (1 by default)
  83447. * @param height the height of the emission cylinder (1 by default)
  83448. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83449. * @param direction1 the min limit of the emission direction (up vector by default)
  83450. * @param direction2 the max limit of the emission direction (up vector by default)
  83451. */
  83452. constructor(radius?: number, height?: number, radiusRange?: number,
  83453. /**
  83454. * The min limit of the emission direction.
  83455. */
  83456. direction1?: Vector3,
  83457. /**
  83458. * The max limit of the emission direction.
  83459. */
  83460. direction2?: Vector3);
  83461. /**
  83462. * Called by the particle System when the direction is computed for the created particle.
  83463. * @param worldMatrix is the world matrix of the particle system
  83464. * @param directionToUpdate is the direction vector to update with the result
  83465. * @param particle is the particle we are computed the direction for
  83466. */
  83467. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83468. /**
  83469. * Clones the current emitter and returns a copy of it
  83470. * @returns the new emitter
  83471. */
  83472. clone(): CylinderDirectedParticleEmitter;
  83473. /**
  83474. * Called by the GPUParticleSystem to setup the update shader
  83475. * @param effect defines the update shader
  83476. */
  83477. applyToShader(effect: Effect): void;
  83478. /**
  83479. * Returns a string to use to update the GPU particles update shader
  83480. * @returns a string containng the defines string
  83481. */
  83482. getEffectDefines(): string;
  83483. /**
  83484. * Returns the string "CylinderDirectedParticleEmitter"
  83485. * @returns a string containing the class name
  83486. */
  83487. getClassName(): string;
  83488. /**
  83489. * Serializes the particle system to a JSON object.
  83490. * @returns the JSON object
  83491. */
  83492. serialize(): any;
  83493. /**
  83494. * Parse properties from a JSON object
  83495. * @param serializationObject defines the JSON object
  83496. */
  83497. parse(serializationObject: any): void;
  83498. }
  83499. }
  83500. declare module BABYLON {
  83501. /**
  83502. * Particle emitter emitting particles from the inside of a hemisphere.
  83503. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  83504. */
  83505. export class HemisphericParticleEmitter implements IParticleEmitterType {
  83506. /**
  83507. * The radius of the emission hemisphere.
  83508. */
  83509. radius: number;
  83510. /**
  83511. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83512. */
  83513. radiusRange: number;
  83514. /**
  83515. * How much to randomize the particle direction [0-1].
  83516. */
  83517. directionRandomizer: number;
  83518. /**
  83519. * Creates a new instance HemisphericParticleEmitter
  83520. * @param radius the radius of the emission hemisphere (1 by default)
  83521. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83522. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83523. */
  83524. constructor(
  83525. /**
  83526. * The radius of the emission hemisphere.
  83527. */
  83528. radius?: number,
  83529. /**
  83530. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83531. */
  83532. radiusRange?: number,
  83533. /**
  83534. * How much to randomize the particle direction [0-1].
  83535. */
  83536. directionRandomizer?: number);
  83537. /**
  83538. * Called by the particle System when the direction is computed for the created particle.
  83539. * @param worldMatrix is the world matrix of the particle system
  83540. * @param directionToUpdate is the direction vector to update with the result
  83541. * @param particle is the particle we are computed the direction for
  83542. */
  83543. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83544. /**
  83545. * Called by the particle System when the position is computed for the created particle.
  83546. * @param worldMatrix is the world matrix of the particle system
  83547. * @param positionToUpdate is the position vector to update with the result
  83548. * @param particle is the particle we are computed the position for
  83549. */
  83550. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83551. /**
  83552. * Clones the current emitter and returns a copy of it
  83553. * @returns the new emitter
  83554. */
  83555. clone(): HemisphericParticleEmitter;
  83556. /**
  83557. * Called by the GPUParticleSystem to setup the update shader
  83558. * @param effect defines the update shader
  83559. */
  83560. applyToShader(effect: Effect): void;
  83561. /**
  83562. * Returns a string to use to update the GPU particles update shader
  83563. * @returns a string containng the defines string
  83564. */
  83565. getEffectDefines(): string;
  83566. /**
  83567. * Returns the string "HemisphericParticleEmitter"
  83568. * @returns a string containing the class name
  83569. */
  83570. getClassName(): string;
  83571. /**
  83572. * Serializes the particle system to a JSON object.
  83573. * @returns the JSON object
  83574. */
  83575. serialize(): any;
  83576. /**
  83577. * Parse properties from a JSON object
  83578. * @param serializationObject defines the JSON object
  83579. */
  83580. parse(serializationObject: any): void;
  83581. }
  83582. }
  83583. declare module BABYLON {
  83584. /**
  83585. * Particle emitter emitting particles from a point.
  83586. * It emits the particles randomly between 2 given directions.
  83587. */
  83588. export class PointParticleEmitter implements IParticleEmitterType {
  83589. /**
  83590. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83591. */
  83592. direction1: Vector3;
  83593. /**
  83594. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83595. */
  83596. direction2: Vector3;
  83597. /**
  83598. * Creates a new instance PointParticleEmitter
  83599. */
  83600. constructor();
  83601. /**
  83602. * Called by the particle System when the direction is computed for the created particle.
  83603. * @param worldMatrix is the world matrix of the particle system
  83604. * @param directionToUpdate is the direction vector to update with the result
  83605. * @param particle is the particle we are computed the direction for
  83606. */
  83607. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83608. /**
  83609. * Called by the particle System when the position is computed for the created particle.
  83610. * @param worldMatrix is the world matrix of the particle system
  83611. * @param positionToUpdate is the position vector to update with the result
  83612. * @param particle is the particle we are computed the position for
  83613. */
  83614. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83615. /**
  83616. * Clones the current emitter and returns a copy of it
  83617. * @returns the new emitter
  83618. */
  83619. clone(): PointParticleEmitter;
  83620. /**
  83621. * Called by the GPUParticleSystem to setup the update shader
  83622. * @param effect defines the update shader
  83623. */
  83624. applyToShader(effect: Effect): void;
  83625. /**
  83626. * Returns a string to use to update the GPU particles update shader
  83627. * @returns a string containng the defines string
  83628. */
  83629. getEffectDefines(): string;
  83630. /**
  83631. * Returns the string "PointParticleEmitter"
  83632. * @returns a string containing the class name
  83633. */
  83634. getClassName(): string;
  83635. /**
  83636. * Serializes the particle system to a JSON object.
  83637. * @returns the JSON object
  83638. */
  83639. serialize(): any;
  83640. /**
  83641. * Parse properties from a JSON object
  83642. * @param serializationObject defines the JSON object
  83643. */
  83644. parse(serializationObject: any): void;
  83645. }
  83646. }
  83647. declare module BABYLON {
  83648. /**
  83649. * Particle emitter emitting particles from the inside of a sphere.
  83650. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  83651. */
  83652. export class SphereParticleEmitter implements IParticleEmitterType {
  83653. /**
  83654. * The radius of the emission sphere.
  83655. */
  83656. radius: number;
  83657. /**
  83658. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83659. */
  83660. radiusRange: number;
  83661. /**
  83662. * How much to randomize the particle direction [0-1].
  83663. */
  83664. directionRandomizer: number;
  83665. /**
  83666. * Creates a new instance SphereParticleEmitter
  83667. * @param radius the radius of the emission sphere (1 by default)
  83668. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83669. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83670. */
  83671. constructor(
  83672. /**
  83673. * The radius of the emission sphere.
  83674. */
  83675. radius?: number,
  83676. /**
  83677. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83678. */
  83679. radiusRange?: number,
  83680. /**
  83681. * How much to randomize the particle direction [0-1].
  83682. */
  83683. directionRandomizer?: number);
  83684. /**
  83685. * Called by the particle System when the direction is computed for the created particle.
  83686. * @param worldMatrix is the world matrix of the particle system
  83687. * @param directionToUpdate is the direction vector to update with the result
  83688. * @param particle is the particle we are computed the direction for
  83689. */
  83690. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83691. /**
  83692. * Called by the particle System when the position is computed for the created particle.
  83693. * @param worldMatrix is the world matrix of the particle system
  83694. * @param positionToUpdate is the position vector to update with the result
  83695. * @param particle is the particle we are computed the position for
  83696. */
  83697. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83698. /**
  83699. * Clones the current emitter and returns a copy of it
  83700. * @returns the new emitter
  83701. */
  83702. clone(): SphereParticleEmitter;
  83703. /**
  83704. * Called by the GPUParticleSystem to setup the update shader
  83705. * @param effect defines the update shader
  83706. */
  83707. applyToShader(effect: Effect): void;
  83708. /**
  83709. * Returns a string to use to update the GPU particles update shader
  83710. * @returns a string containng the defines string
  83711. */
  83712. getEffectDefines(): string;
  83713. /**
  83714. * Returns the string "SphereParticleEmitter"
  83715. * @returns a string containing the class name
  83716. */
  83717. getClassName(): string;
  83718. /**
  83719. * Serializes the particle system to a JSON object.
  83720. * @returns the JSON object
  83721. */
  83722. serialize(): any;
  83723. /**
  83724. * Parse properties from a JSON object
  83725. * @param serializationObject defines the JSON object
  83726. */
  83727. parse(serializationObject: any): void;
  83728. }
  83729. /**
  83730. * Particle emitter emitting particles from the inside of a sphere.
  83731. * It emits the particles randomly between two vectors.
  83732. */
  83733. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  83734. /**
  83735. * The min limit of the emission direction.
  83736. */
  83737. direction1: Vector3;
  83738. /**
  83739. * The max limit of the emission direction.
  83740. */
  83741. direction2: Vector3;
  83742. /**
  83743. * Creates a new instance SphereDirectedParticleEmitter
  83744. * @param radius the radius of the emission sphere (1 by default)
  83745. * @param direction1 the min limit of the emission direction (up vector by default)
  83746. * @param direction2 the max limit of the emission direction (up vector by default)
  83747. */
  83748. constructor(radius?: number,
  83749. /**
  83750. * The min limit of the emission direction.
  83751. */
  83752. direction1?: Vector3,
  83753. /**
  83754. * The max limit of the emission direction.
  83755. */
  83756. direction2?: Vector3);
  83757. /**
  83758. * Called by the particle System when the direction is computed for the created particle.
  83759. * @param worldMatrix is the world matrix of the particle system
  83760. * @param directionToUpdate is the direction vector to update with the result
  83761. * @param particle is the particle we are computed the direction for
  83762. */
  83763. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83764. /**
  83765. * Clones the current emitter and returns a copy of it
  83766. * @returns the new emitter
  83767. */
  83768. clone(): SphereDirectedParticleEmitter;
  83769. /**
  83770. * Called by the GPUParticleSystem to setup the update shader
  83771. * @param effect defines the update shader
  83772. */
  83773. applyToShader(effect: Effect): void;
  83774. /**
  83775. * Returns a string to use to update the GPU particles update shader
  83776. * @returns a string containng the defines string
  83777. */
  83778. getEffectDefines(): string;
  83779. /**
  83780. * Returns the string "SphereDirectedParticleEmitter"
  83781. * @returns a string containing the class name
  83782. */
  83783. getClassName(): string;
  83784. /**
  83785. * Serializes the particle system to a JSON object.
  83786. * @returns the JSON object
  83787. */
  83788. serialize(): any;
  83789. /**
  83790. * Parse properties from a JSON object
  83791. * @param serializationObject defines the JSON object
  83792. */
  83793. parse(serializationObject: any): void;
  83794. }
  83795. }
  83796. declare module BABYLON {
  83797. /**
  83798. * Interface representing a particle system in Babylon.js.
  83799. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  83800. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  83801. */
  83802. export interface IParticleSystem {
  83803. /**
  83804. * List of animations used by the particle system.
  83805. */
  83806. animations: Animation[];
  83807. /**
  83808. * The id of the Particle system.
  83809. */
  83810. id: string;
  83811. /**
  83812. * The name of the Particle system.
  83813. */
  83814. name: string;
  83815. /**
  83816. * The emitter represents the Mesh or position we are attaching the particle system to.
  83817. */
  83818. emitter: Nullable<AbstractMesh | Vector3>;
  83819. /**
  83820. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83821. */
  83822. isBillboardBased: boolean;
  83823. /**
  83824. * The rendering group used by the Particle system to chose when to render.
  83825. */
  83826. renderingGroupId: number;
  83827. /**
  83828. * The layer mask we are rendering the particles through.
  83829. */
  83830. layerMask: number;
  83831. /**
  83832. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83833. */
  83834. updateSpeed: number;
  83835. /**
  83836. * The amount of time the particle system is running (depends of the overall update speed).
  83837. */
  83838. targetStopDuration: number;
  83839. /**
  83840. * The texture used to render each particle. (this can be a spritesheet)
  83841. */
  83842. particleTexture: Nullable<Texture>;
  83843. /**
  83844. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  83845. */
  83846. blendMode: number;
  83847. /**
  83848. * Minimum life time of emitting particles.
  83849. */
  83850. minLifeTime: number;
  83851. /**
  83852. * Maximum life time of emitting particles.
  83853. */
  83854. maxLifeTime: number;
  83855. /**
  83856. * Minimum Size of emitting particles.
  83857. */
  83858. minSize: number;
  83859. /**
  83860. * Maximum Size of emitting particles.
  83861. */
  83862. maxSize: number;
  83863. /**
  83864. * Minimum scale of emitting particles on X axis.
  83865. */
  83866. minScaleX: number;
  83867. /**
  83868. * Maximum scale of emitting particles on X axis.
  83869. */
  83870. maxScaleX: number;
  83871. /**
  83872. * Minimum scale of emitting particles on Y axis.
  83873. */
  83874. minScaleY: number;
  83875. /**
  83876. * Maximum scale of emitting particles on Y axis.
  83877. */
  83878. maxScaleY: number;
  83879. /**
  83880. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83881. */
  83882. color1: Color4;
  83883. /**
  83884. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83885. */
  83886. color2: Color4;
  83887. /**
  83888. * Color the particle will have at the end of its lifetime.
  83889. */
  83890. colorDead: Color4;
  83891. /**
  83892. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  83893. */
  83894. emitRate: number;
  83895. /**
  83896. * You can use gravity if you want to give an orientation to your particles.
  83897. */
  83898. gravity: Vector3;
  83899. /**
  83900. * Minimum power of emitting particles.
  83901. */
  83902. minEmitPower: number;
  83903. /**
  83904. * Maximum power of emitting particles.
  83905. */
  83906. maxEmitPower: number;
  83907. /**
  83908. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83909. */
  83910. minAngularSpeed: number;
  83911. /**
  83912. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83913. */
  83914. maxAngularSpeed: number;
  83915. /**
  83916. * Gets or sets the minimal initial rotation in radians.
  83917. */
  83918. minInitialRotation: number;
  83919. /**
  83920. * Gets or sets the maximal initial rotation in radians.
  83921. */
  83922. maxInitialRotation: number;
  83923. /**
  83924. * The particle emitter type defines the emitter used by the particle system.
  83925. * It can be for example box, sphere, or cone...
  83926. */
  83927. particleEmitterType: Nullable<IParticleEmitterType>;
  83928. /**
  83929. * Defines the delay in milliseconds before starting the system (0 by default)
  83930. */
  83931. startDelay: number;
  83932. /**
  83933. * 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
  83934. */
  83935. preWarmCycles: number;
  83936. /**
  83937. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  83938. */
  83939. preWarmStepOffset: number;
  83940. /**
  83941. * 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)
  83942. */
  83943. spriteCellChangeSpeed: number;
  83944. /**
  83945. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83946. */
  83947. startSpriteCellID: number;
  83948. /**
  83949. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83950. */
  83951. endSpriteCellID: number;
  83952. /**
  83953. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83954. */
  83955. spriteCellWidth: number;
  83956. /**
  83957. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83958. */
  83959. spriteCellHeight: number;
  83960. /**
  83961. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83962. */
  83963. spriteRandomStartCell: boolean;
  83964. /**
  83965. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  83966. */
  83967. isAnimationSheetEnabled: boolean;
  83968. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83969. translationPivot: Vector2;
  83970. /**
  83971. * Gets or sets a texture used to add random noise to particle positions
  83972. */
  83973. noiseTexture: Nullable<BaseTexture>;
  83974. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83975. noiseStrength: Vector3;
  83976. /**
  83977. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83978. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83979. */
  83980. billboardMode: number;
  83981. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83982. limitVelocityDamping: number;
  83983. /**
  83984. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83985. */
  83986. beginAnimationOnStart: boolean;
  83987. /**
  83988. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83989. */
  83990. beginAnimationFrom: number;
  83991. /**
  83992. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83993. */
  83994. beginAnimationTo: number;
  83995. /**
  83996. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83997. */
  83998. beginAnimationLoop: boolean;
  83999. /**
  84000. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84001. */
  84002. disposeOnStop: boolean;
  84003. /**
  84004. * Gets the maximum number of particles active at the same time.
  84005. * @returns The max number of active particles.
  84006. */
  84007. getCapacity(): number;
  84008. /**
  84009. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84010. * @returns True if it has been started, otherwise false.
  84011. */
  84012. isStarted(): boolean;
  84013. /**
  84014. * Animates the particle system for this frame.
  84015. */
  84016. animate(): void;
  84017. /**
  84018. * Renders the particle system in its current state.
  84019. * @returns the current number of particles
  84020. */
  84021. render(): number;
  84022. /**
  84023. * Dispose the particle system and frees its associated resources.
  84024. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84025. */
  84026. dispose(disposeTexture?: boolean): void;
  84027. /**
  84028. * Clones the particle system.
  84029. * @param name The name of the cloned object
  84030. * @param newEmitter The new emitter to use
  84031. * @returns the cloned particle system
  84032. */
  84033. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  84034. /**
  84035. * Serializes the particle system to a JSON object.
  84036. * @returns the JSON object
  84037. */
  84038. serialize(): any;
  84039. /**
  84040. * Rebuild the particle system
  84041. */
  84042. rebuild(): void;
  84043. /**
  84044. * Starts the particle system and begins to emit
  84045. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  84046. */
  84047. start(delay?: number): void;
  84048. /**
  84049. * Stops the particle system.
  84050. */
  84051. stop(): void;
  84052. /**
  84053. * Remove all active particles
  84054. */
  84055. reset(): void;
  84056. /**
  84057. * Is this system ready to be used/rendered
  84058. * @return true if the system is ready
  84059. */
  84060. isReady(): boolean;
  84061. /**
  84062. * Adds a new color gradient
  84063. * @param gradient defines the gradient to use (between 0 and 1)
  84064. * @param color1 defines the color to affect to the specified gradient
  84065. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84066. * @returns the current particle system
  84067. */
  84068. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84069. /**
  84070. * Remove a specific color gradient
  84071. * @param gradient defines the gradient to remove
  84072. * @returns the current particle system
  84073. */
  84074. removeColorGradient(gradient: number): IParticleSystem;
  84075. /**
  84076. * Adds a new size gradient
  84077. * @param gradient defines the gradient to use (between 0 and 1)
  84078. * @param factor defines the size factor to affect to the specified gradient
  84079. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84080. * @returns the current particle system
  84081. */
  84082. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84083. /**
  84084. * Remove a specific size gradient
  84085. * @param gradient defines the gradient to remove
  84086. * @returns the current particle system
  84087. */
  84088. removeSizeGradient(gradient: number): IParticleSystem;
  84089. /**
  84090. * Gets the current list of color gradients.
  84091. * You must use addColorGradient and removeColorGradient to udpate this list
  84092. * @returns the list of color gradients
  84093. */
  84094. getColorGradients(): Nullable<Array<ColorGradient>>;
  84095. /**
  84096. * Gets the current list of size gradients.
  84097. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84098. * @returns the list of size gradients
  84099. */
  84100. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84101. /**
  84102. * Gets the current list of angular speed gradients.
  84103. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84104. * @returns the list of angular speed gradients
  84105. */
  84106. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84107. /**
  84108. * Adds a new angular speed gradient
  84109. * @param gradient defines the gradient to use (between 0 and 1)
  84110. * @param factor defines the angular speed to affect to the specified gradient
  84111. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84112. * @returns the current particle system
  84113. */
  84114. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84115. /**
  84116. * Remove a specific angular speed gradient
  84117. * @param gradient defines the gradient to remove
  84118. * @returns the current particle system
  84119. */
  84120. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84121. /**
  84122. * Gets the current list of velocity gradients.
  84123. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84124. * @returns the list of velocity gradients
  84125. */
  84126. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84127. /**
  84128. * Adds a new velocity gradient
  84129. * @param gradient defines the gradient to use (between 0 and 1)
  84130. * @param factor defines the velocity to affect to the specified gradient
  84131. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84132. * @returns the current particle system
  84133. */
  84134. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84135. /**
  84136. * Remove a specific velocity gradient
  84137. * @param gradient defines the gradient to remove
  84138. * @returns the current particle system
  84139. */
  84140. removeVelocityGradient(gradient: number): IParticleSystem;
  84141. /**
  84142. * Gets the current list of limit velocity gradients.
  84143. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84144. * @returns the list of limit velocity gradients
  84145. */
  84146. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84147. /**
  84148. * Adds a new limit velocity gradient
  84149. * @param gradient defines the gradient to use (between 0 and 1)
  84150. * @param factor defines the limit velocity to affect to the specified gradient
  84151. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84152. * @returns the current particle system
  84153. */
  84154. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84155. /**
  84156. * Remove a specific limit velocity gradient
  84157. * @param gradient defines the gradient to remove
  84158. * @returns the current particle system
  84159. */
  84160. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84161. /**
  84162. * Adds a new drag gradient
  84163. * @param gradient defines the gradient to use (between 0 and 1)
  84164. * @param factor defines the drag to affect to the specified gradient
  84165. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84166. * @returns the current particle system
  84167. */
  84168. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84169. /**
  84170. * Remove a specific drag gradient
  84171. * @param gradient defines the gradient to remove
  84172. * @returns the current particle system
  84173. */
  84174. removeDragGradient(gradient: number): IParticleSystem;
  84175. /**
  84176. * Gets the current list of drag gradients.
  84177. * You must use addDragGradient and removeDragGradient to udpate this list
  84178. * @returns the list of drag gradients
  84179. */
  84180. getDragGradients(): Nullable<Array<FactorGradient>>;
  84181. /**
  84182. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84183. * @param gradient defines the gradient to use (between 0 and 1)
  84184. * @param factor defines the emit rate to affect to the specified gradient
  84185. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84186. * @returns the current particle system
  84187. */
  84188. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84189. /**
  84190. * Remove a specific emit rate gradient
  84191. * @param gradient defines the gradient to remove
  84192. * @returns the current particle system
  84193. */
  84194. removeEmitRateGradient(gradient: number): IParticleSystem;
  84195. /**
  84196. * Gets the current list of emit rate gradients.
  84197. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84198. * @returns the list of emit rate gradients
  84199. */
  84200. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84201. /**
  84202. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84203. * @param gradient defines the gradient to use (between 0 and 1)
  84204. * @param factor defines the start size to affect to the specified gradient
  84205. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84206. * @returns the current particle system
  84207. */
  84208. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84209. /**
  84210. * Remove a specific start size gradient
  84211. * @param gradient defines the gradient to remove
  84212. * @returns the current particle system
  84213. */
  84214. removeStartSizeGradient(gradient: number): IParticleSystem;
  84215. /**
  84216. * Gets the current list of start size gradients.
  84217. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84218. * @returns the list of start size gradients
  84219. */
  84220. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84221. /**
  84222. * Adds a new life time gradient
  84223. * @param gradient defines the gradient to use (between 0 and 1)
  84224. * @param factor defines the life time factor to affect to the specified gradient
  84225. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84226. * @returns the current particle system
  84227. */
  84228. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84229. /**
  84230. * Remove a specific life time gradient
  84231. * @param gradient defines the gradient to remove
  84232. * @returns the current particle system
  84233. */
  84234. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84235. /**
  84236. * Gets the current list of life time gradients.
  84237. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84238. * @returns the list of life time gradients
  84239. */
  84240. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84241. /**
  84242. * Gets the current list of color gradients.
  84243. * You must use addColorGradient and removeColorGradient to udpate this list
  84244. * @returns the list of color gradients
  84245. */
  84246. getColorGradients(): Nullable<Array<ColorGradient>>;
  84247. /**
  84248. * Adds a new ramp gradient used to remap particle colors
  84249. * @param gradient defines the gradient to use (between 0 and 1)
  84250. * @param color defines the color to affect to the specified gradient
  84251. * @returns the current particle system
  84252. */
  84253. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  84254. /**
  84255. * Gets the current list of ramp gradients.
  84256. * You must use addRampGradient and removeRampGradient to udpate this list
  84257. * @returns the list of ramp gradients
  84258. */
  84259. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84260. /** Gets or sets a boolean indicating that ramp gradients must be used
  84261. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84262. */
  84263. useRampGradients: boolean;
  84264. /**
  84265. * Adds a new color remap gradient
  84266. * @param gradient defines the gradient to use (between 0 and 1)
  84267. * @param min defines the color remap minimal range
  84268. * @param max defines the color remap maximal range
  84269. * @returns the current particle system
  84270. */
  84271. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84272. /**
  84273. * Gets the current list of color remap gradients.
  84274. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84275. * @returns the list of color remap gradients
  84276. */
  84277. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84278. /**
  84279. * Adds a new alpha remap gradient
  84280. * @param gradient defines the gradient to use (between 0 and 1)
  84281. * @param min defines the alpha remap minimal range
  84282. * @param max defines the alpha remap maximal range
  84283. * @returns the current particle system
  84284. */
  84285. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84286. /**
  84287. * Gets the current list of alpha remap gradients.
  84288. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84289. * @returns the list of alpha remap gradients
  84290. */
  84291. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84292. /**
  84293. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84294. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84295. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84296. * @returns the emitter
  84297. */
  84298. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84299. /**
  84300. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84301. * @param radius The radius of the hemisphere to emit from
  84302. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84303. * @returns the emitter
  84304. */
  84305. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  84306. /**
  84307. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84308. * @param radius The radius of the sphere to emit from
  84309. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84310. * @returns the emitter
  84311. */
  84312. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  84313. /**
  84314. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84315. * @param radius The radius of the sphere to emit from
  84316. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84317. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84318. * @returns the emitter
  84319. */
  84320. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84321. /**
  84322. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84323. * @param radius The radius of the emission cylinder
  84324. * @param height The height of the emission cylinder
  84325. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84326. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84327. * @returns the emitter
  84328. */
  84329. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  84330. /**
  84331. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84332. * @param radius The radius of the cylinder to emit from
  84333. * @param height The height of the emission cylinder
  84334. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84335. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84336. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84337. * @returns the emitter
  84338. */
  84339. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84340. /**
  84341. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84342. * @param radius The radius of the cone to emit from
  84343. * @param angle The base angle of the cone
  84344. * @returns the emitter
  84345. */
  84346. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  84347. /**
  84348. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84349. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84350. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84351. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84352. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84353. * @returns the emitter
  84354. */
  84355. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84356. /**
  84357. * Get hosting scene
  84358. * @returns the scene
  84359. */
  84360. getScene(): Scene;
  84361. }
  84362. }
  84363. declare module BABYLON {
  84364. /**
  84365. * Creates an instance based on a source mesh.
  84366. */
  84367. export class InstancedMesh extends AbstractMesh {
  84368. private _sourceMesh;
  84369. private _currentLOD;
  84370. /** @hidden */
  84371. _indexInSourceMeshInstanceArray: number;
  84372. constructor(name: string, source: Mesh);
  84373. /**
  84374. * Returns the string "InstancedMesh".
  84375. */
  84376. getClassName(): string;
  84377. /** Gets the list of lights affecting that mesh */
  84378. readonly lightSources: Light[];
  84379. _resyncLightSources(): void;
  84380. _resyncLighSource(light: Light): void;
  84381. _removeLightSource(light: Light, dispose: boolean): void;
  84382. /**
  84383. * If the source mesh receives shadows
  84384. */
  84385. readonly receiveShadows: boolean;
  84386. /**
  84387. * The material of the source mesh
  84388. */
  84389. readonly material: Nullable<Material>;
  84390. /**
  84391. * Visibility of the source mesh
  84392. */
  84393. readonly visibility: number;
  84394. /**
  84395. * Skeleton of the source mesh
  84396. */
  84397. readonly skeleton: Nullable<Skeleton>;
  84398. /**
  84399. * Rendering ground id of the source mesh
  84400. */
  84401. renderingGroupId: number;
  84402. /**
  84403. * Returns the total number of vertices (integer).
  84404. */
  84405. getTotalVertices(): number;
  84406. /**
  84407. * Returns a positive integer : the total number of indices in this mesh geometry.
  84408. * @returns the numner of indices or zero if the mesh has no geometry.
  84409. */
  84410. getTotalIndices(): number;
  84411. /**
  84412. * The source mesh of the instance
  84413. */
  84414. readonly sourceMesh: Mesh;
  84415. /**
  84416. * Is this node ready to be used/rendered
  84417. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84418. * @return {boolean} is it ready
  84419. */
  84420. isReady(completeCheck?: boolean): boolean;
  84421. /**
  84422. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  84423. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  84424. * @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.
  84425. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  84426. */
  84427. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  84428. /**
  84429. * Sets the vertex data of the mesh geometry for the requested `kind`.
  84430. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  84431. * The `data` are either a numeric array either a Float32Array.
  84432. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  84433. * 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).
  84434. * Note that a new underlying VertexBuffer object is created each call.
  84435. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  84436. *
  84437. * Possible `kind` values :
  84438. * - VertexBuffer.PositionKind
  84439. * - VertexBuffer.UVKind
  84440. * - VertexBuffer.UV2Kind
  84441. * - VertexBuffer.UV3Kind
  84442. * - VertexBuffer.UV4Kind
  84443. * - VertexBuffer.UV5Kind
  84444. * - VertexBuffer.UV6Kind
  84445. * - VertexBuffer.ColorKind
  84446. * - VertexBuffer.MatricesIndicesKind
  84447. * - VertexBuffer.MatricesIndicesExtraKind
  84448. * - VertexBuffer.MatricesWeightsKind
  84449. * - VertexBuffer.MatricesWeightsExtraKind
  84450. *
  84451. * Returns the Mesh.
  84452. */
  84453. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  84454. /**
  84455. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  84456. * If the mesh has no geometry, it is simply returned as it is.
  84457. * The `data` are either a numeric array either a Float32Array.
  84458. * No new underlying VertexBuffer object is created.
  84459. * 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.
  84460. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  84461. *
  84462. * Possible `kind` values :
  84463. * - VertexBuffer.PositionKind
  84464. * - VertexBuffer.UVKind
  84465. * - VertexBuffer.UV2Kind
  84466. * - VertexBuffer.UV3Kind
  84467. * - VertexBuffer.UV4Kind
  84468. * - VertexBuffer.UV5Kind
  84469. * - VertexBuffer.UV6Kind
  84470. * - VertexBuffer.ColorKind
  84471. * - VertexBuffer.MatricesIndicesKind
  84472. * - VertexBuffer.MatricesIndicesExtraKind
  84473. * - VertexBuffer.MatricesWeightsKind
  84474. * - VertexBuffer.MatricesWeightsExtraKind
  84475. *
  84476. * Returns the Mesh.
  84477. */
  84478. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  84479. /**
  84480. * Sets the mesh indices.
  84481. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  84482. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  84483. * This method creates a new index buffer each call.
  84484. * Returns the Mesh.
  84485. */
  84486. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  84487. /**
  84488. * Boolean : True if the mesh owns the requested kind of data.
  84489. */
  84490. isVerticesDataPresent(kind: string): boolean;
  84491. /**
  84492. * Returns an array of indices (IndicesArray).
  84493. */
  84494. getIndices(): Nullable<IndicesArray>;
  84495. readonly _positions: Nullable<Vector3[]>;
  84496. /**
  84497. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84498. * This means the mesh underlying bounding box and sphere are recomputed.
  84499. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84500. * @returns the current mesh
  84501. */
  84502. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  84503. /** @hidden */
  84504. _preActivate(): InstancedMesh;
  84505. /** @hidden */
  84506. _activate(renderId: number, intermediateRendering: boolean): boolean;
  84507. /** @hidden */
  84508. _postActivate(): void;
  84509. getWorldMatrix(): Matrix;
  84510. readonly isAnInstance: boolean;
  84511. /**
  84512. * Returns the current associated LOD AbstractMesh.
  84513. */
  84514. getLOD(camera: Camera): AbstractMesh;
  84515. /** @hidden */
  84516. _syncSubMeshes(): InstancedMesh;
  84517. /** @hidden */
  84518. _generatePointsArray(): boolean;
  84519. /**
  84520. * Creates a new InstancedMesh from the current mesh.
  84521. * - name (string) : the cloned mesh name
  84522. * - newParent (optional Node) : the optional Node to parent the clone to.
  84523. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  84524. *
  84525. * Returns the clone.
  84526. */
  84527. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84528. /**
  84529. * Disposes the InstancedMesh.
  84530. * Returns nothing.
  84531. */
  84532. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84533. }
  84534. }
  84535. declare module BABYLON {
  84536. /**
  84537. * Defines the options associated with the creation of a shader material.
  84538. */
  84539. export interface IShaderMaterialOptions {
  84540. /**
  84541. * Does the material work in alpha blend mode
  84542. */
  84543. needAlphaBlending: boolean;
  84544. /**
  84545. * Does the material work in alpha test mode
  84546. */
  84547. needAlphaTesting: boolean;
  84548. /**
  84549. * The list of attribute names used in the shader
  84550. */
  84551. attributes: string[];
  84552. /**
  84553. * The list of unifrom names used in the shader
  84554. */
  84555. uniforms: string[];
  84556. /**
  84557. * The list of UBO names used in the shader
  84558. */
  84559. uniformBuffers: string[];
  84560. /**
  84561. * The list of sampler names used in the shader
  84562. */
  84563. samplers: string[];
  84564. /**
  84565. * The list of defines used in the shader
  84566. */
  84567. defines: string[];
  84568. }
  84569. /**
  84570. * 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.
  84571. *
  84572. * This returned material effects how the mesh will look based on the code in the shaders.
  84573. *
  84574. * @see http://doc.babylonjs.com/how_to/shader_material
  84575. */
  84576. export class ShaderMaterial extends Material {
  84577. private _shaderPath;
  84578. private _options;
  84579. private _textures;
  84580. private _textureArrays;
  84581. private _floats;
  84582. private _ints;
  84583. private _floatsArrays;
  84584. private _colors3;
  84585. private _colors3Arrays;
  84586. private _colors4;
  84587. private _colors4Arrays;
  84588. private _vectors2;
  84589. private _vectors3;
  84590. private _vectors4;
  84591. private _matrices;
  84592. private _matrices3x3;
  84593. private _matrices2x2;
  84594. private _vectors2Arrays;
  84595. private _vectors3Arrays;
  84596. private _vectors4Arrays;
  84597. private _cachedWorldViewMatrix;
  84598. private _cachedWorldViewProjectionMatrix;
  84599. private _renderId;
  84600. /**
  84601. * Instantiate a new shader material.
  84602. * 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.
  84603. * This returned material effects how the mesh will look based on the code in the shaders.
  84604. * @see http://doc.babylonjs.com/how_to/shader_material
  84605. * @param name Define the name of the material in the scene
  84606. * @param scene Define the scene the material belongs to
  84607. * @param shaderPath Defines the route to the shader code in one of three ways:
  84608. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  84609. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  84610. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  84611. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  84612. * @param options Define the options used to create the shader
  84613. */
  84614. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  84615. /**
  84616. * Gets the options used to compile the shader.
  84617. * They can be modified to trigger a new compilation
  84618. */
  84619. readonly options: IShaderMaterialOptions;
  84620. /**
  84621. * Gets the current class name of the material e.g. "ShaderMaterial"
  84622. * Mainly use in serialization.
  84623. * @returns the class name
  84624. */
  84625. getClassName(): string;
  84626. /**
  84627. * Specifies if the material will require alpha blending
  84628. * @returns a boolean specifying if alpha blending is needed
  84629. */
  84630. needAlphaBlending(): boolean;
  84631. /**
  84632. * Specifies if this material should be rendered in alpha test mode
  84633. * @returns a boolean specifying if an alpha test is needed.
  84634. */
  84635. needAlphaTesting(): boolean;
  84636. private _checkUniform;
  84637. /**
  84638. * Set a texture in the shader.
  84639. * @param name Define the name of the uniform samplers as defined in the shader
  84640. * @param texture Define the texture to bind to this sampler
  84641. * @return the material itself allowing "fluent" like uniform updates
  84642. */
  84643. setTexture(name: string, texture: Texture): ShaderMaterial;
  84644. /**
  84645. * Set a texture array in the shader.
  84646. * @param name Define the name of the uniform sampler array as defined in the shader
  84647. * @param textures Define the list of textures to bind to this sampler
  84648. * @return the material itself allowing "fluent" like uniform updates
  84649. */
  84650. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  84651. /**
  84652. * Set a float in the shader.
  84653. * @param name Define the name of the uniform as defined in the shader
  84654. * @param value Define the value to give to the uniform
  84655. * @return the material itself allowing "fluent" like uniform updates
  84656. */
  84657. setFloat(name: string, value: number): ShaderMaterial;
  84658. /**
  84659. * Set a int in the shader.
  84660. * @param name Define the name of the uniform as defined in the shader
  84661. * @param value Define the value to give to the uniform
  84662. * @return the material itself allowing "fluent" like uniform updates
  84663. */
  84664. setInt(name: string, value: number): ShaderMaterial;
  84665. /**
  84666. * Set an array of floats in the shader.
  84667. * @param name Define the name of the uniform as defined in the shader
  84668. * @param value Define the value to give to the uniform
  84669. * @return the material itself allowing "fluent" like uniform updates
  84670. */
  84671. setFloats(name: string, value: number[]): ShaderMaterial;
  84672. /**
  84673. * Set a vec3 in the shader from a Color3.
  84674. * @param name Define the name of the uniform as defined in the shader
  84675. * @param value Define the value to give to the uniform
  84676. * @return the material itself allowing "fluent" like uniform updates
  84677. */
  84678. setColor3(name: string, value: Color3): ShaderMaterial;
  84679. /**
  84680. * Set a vec3 array in the shader from a Color3 array.
  84681. * @param name Define the name of the uniform as defined in the shader
  84682. * @param value Define the value to give to the uniform
  84683. * @return the material itself allowing "fluent" like uniform updates
  84684. */
  84685. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  84686. /**
  84687. * Set a vec4 in the shader from a Color4.
  84688. * @param name Define the name of the uniform as defined in the shader
  84689. * @param value Define the value to give to the uniform
  84690. * @return the material itself allowing "fluent" like uniform updates
  84691. */
  84692. setColor4(name: string, value: Color4): ShaderMaterial;
  84693. /**
  84694. * Set a vec4 array in the shader from a Color4 array.
  84695. * @param name Define the name of the uniform as defined in the shader
  84696. * @param value Define the value to give to the uniform
  84697. * @return the material itself allowing "fluent" like uniform updates
  84698. */
  84699. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  84700. /**
  84701. * Set a vec2 in the shader from a Vector2.
  84702. * @param name Define the name of the uniform as defined in the shader
  84703. * @param value Define the value to give to the uniform
  84704. * @return the material itself allowing "fluent" like uniform updates
  84705. */
  84706. setVector2(name: string, value: Vector2): ShaderMaterial;
  84707. /**
  84708. * Set a vec3 in the shader from a Vector3.
  84709. * @param name Define the name of the uniform as defined in the shader
  84710. * @param value Define the value to give to the uniform
  84711. * @return the material itself allowing "fluent" like uniform updates
  84712. */
  84713. setVector3(name: string, value: Vector3): ShaderMaterial;
  84714. /**
  84715. * Set a vec4 in the shader from a Vector4.
  84716. * @param name Define the name of the uniform as defined in the shader
  84717. * @param value Define the value to give to the uniform
  84718. * @return the material itself allowing "fluent" like uniform updates
  84719. */
  84720. setVector4(name: string, value: Vector4): ShaderMaterial;
  84721. /**
  84722. * Set a mat4 in the shader from a Matrix.
  84723. * @param name Define the name of the uniform as defined in the shader
  84724. * @param value Define the value to give to the uniform
  84725. * @return the material itself allowing "fluent" like uniform updates
  84726. */
  84727. setMatrix(name: string, value: Matrix): ShaderMaterial;
  84728. /**
  84729. * Set a mat3 in the shader from a Float32Array.
  84730. * @param name Define the name of the uniform as defined in the shader
  84731. * @param value Define the value to give to the uniform
  84732. * @return the material itself allowing "fluent" like uniform updates
  84733. */
  84734. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  84735. /**
  84736. * Set a mat2 in the shader from a Float32Array.
  84737. * @param name Define the name of the uniform as defined in the shader
  84738. * @param value Define the value to give to the uniform
  84739. * @return the material itself allowing "fluent" like uniform updates
  84740. */
  84741. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  84742. /**
  84743. * Set a vec2 array in the shader from a number array.
  84744. * @param name Define the name of the uniform as defined in the shader
  84745. * @param value Define the value to give to the uniform
  84746. * @return the material itself allowing "fluent" like uniform updates
  84747. */
  84748. setArray2(name: string, value: number[]): ShaderMaterial;
  84749. /**
  84750. * Set a vec3 array in the shader from a number array.
  84751. * @param name Define the name of the uniform as defined in the shader
  84752. * @param value Define the value to give to the uniform
  84753. * @return the material itself allowing "fluent" like uniform updates
  84754. */
  84755. setArray3(name: string, value: number[]): ShaderMaterial;
  84756. /**
  84757. * Set a vec4 array in the shader from a number array.
  84758. * @param name Define the name of the uniform as defined in the shader
  84759. * @param value Define the value to give to the uniform
  84760. * @return the material itself allowing "fluent" like uniform updates
  84761. */
  84762. setArray4(name: string, value: number[]): ShaderMaterial;
  84763. private _checkCache;
  84764. /**
  84765. * Specifies that the submesh is ready to be used
  84766. * @param mesh defines the mesh to check
  84767. * @param subMesh defines which submesh to check
  84768. * @param useInstances specifies that instances should be used
  84769. * @returns a boolean indicating that the submesh is ready or not
  84770. */
  84771. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84772. /**
  84773. * Checks if the material is ready to render the requested mesh
  84774. * @param mesh Define the mesh to render
  84775. * @param useInstances Define whether or not the material is used with instances
  84776. * @returns true if ready, otherwise false
  84777. */
  84778. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  84779. /**
  84780. * Binds the world matrix to the material
  84781. * @param world defines the world transformation matrix
  84782. */
  84783. bindOnlyWorldMatrix(world: Matrix): void;
  84784. /**
  84785. * Binds the material to the mesh
  84786. * @param world defines the world transformation matrix
  84787. * @param mesh defines the mesh to bind the material to
  84788. */
  84789. bind(world: Matrix, mesh?: Mesh): void;
  84790. /**
  84791. * Gets the active textures from the material
  84792. * @returns an array of textures
  84793. */
  84794. getActiveTextures(): BaseTexture[];
  84795. /**
  84796. * Specifies if the material uses a texture
  84797. * @param texture defines the texture to check against the material
  84798. * @returns a boolean specifying if the material uses the texture
  84799. */
  84800. hasTexture(texture: BaseTexture): boolean;
  84801. /**
  84802. * Makes a duplicate of the material, and gives it a new name
  84803. * @param name defines the new name for the duplicated material
  84804. * @returns the cloned material
  84805. */
  84806. clone(name: string): ShaderMaterial;
  84807. /**
  84808. * Disposes the material
  84809. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84810. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  84811. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  84812. */
  84813. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  84814. /**
  84815. * Serializes this material in a JSON representation
  84816. * @returns the serialized material object
  84817. */
  84818. serialize(): any;
  84819. /**
  84820. * Creates a shader material from parsed shader material data
  84821. * @param source defines the JSON represnetation of the material
  84822. * @param scene defines the hosting scene
  84823. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  84824. * @returns a new material
  84825. */
  84826. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  84827. }
  84828. }
  84829. declare module BABYLON {
  84830. /** @hidden */
  84831. export var colorPixelShader: {
  84832. name: string;
  84833. shader: string;
  84834. };
  84835. }
  84836. declare module BABYLON {
  84837. /** @hidden */
  84838. export var colorVertexShader: {
  84839. name: string;
  84840. shader: string;
  84841. };
  84842. }
  84843. declare module BABYLON {
  84844. /**
  84845. * Line mesh
  84846. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  84847. */
  84848. export class LinesMesh extends Mesh {
  84849. /**
  84850. * If vertex color should be applied to the mesh
  84851. */
  84852. readonly useVertexColor?: boolean | undefined;
  84853. /**
  84854. * If vertex alpha should be applied to the mesh
  84855. */
  84856. readonly useVertexAlpha?: boolean | undefined;
  84857. /**
  84858. * Color of the line (Default: White)
  84859. */
  84860. color: Color3;
  84861. /**
  84862. * Alpha of the line (Default: 1)
  84863. */
  84864. alpha: number;
  84865. /**
  84866. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  84867. * This margin is expressed in world space coordinates, so its value may vary.
  84868. * Default value is 0.1
  84869. */
  84870. intersectionThreshold: number;
  84871. private _colorShader;
  84872. private color4;
  84873. /**
  84874. * Creates a new LinesMesh
  84875. * @param name defines the name
  84876. * @param scene defines the hosting scene
  84877. * @param parent defines the parent mesh if any
  84878. * @param source defines the optional source LinesMesh used to clone data from
  84879. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  84880. * When false, achieved by calling a clone(), also passing False.
  84881. * This will make creation of children, recursive.
  84882. * @param useVertexColor defines if this LinesMesh supports vertex color
  84883. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  84884. */
  84885. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  84886. /**
  84887. * If vertex color should be applied to the mesh
  84888. */
  84889. useVertexColor?: boolean | undefined,
  84890. /**
  84891. * If vertex alpha should be applied to the mesh
  84892. */
  84893. useVertexAlpha?: boolean | undefined);
  84894. private _addClipPlaneDefine;
  84895. private _removeClipPlaneDefine;
  84896. isReady(): boolean;
  84897. /**
  84898. * Returns the string "LineMesh"
  84899. */
  84900. getClassName(): string;
  84901. /**
  84902. * @hidden
  84903. */
  84904. /**
  84905. * @hidden
  84906. */
  84907. material: Material;
  84908. /**
  84909. * @hidden
  84910. */
  84911. readonly checkCollisions: boolean;
  84912. /** @hidden */
  84913. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  84914. /** @hidden */
  84915. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  84916. /**
  84917. * Disposes of the line mesh
  84918. * @param doNotRecurse If children should be disposed
  84919. */
  84920. dispose(doNotRecurse?: boolean): void;
  84921. /**
  84922. * Returns a new LineMesh object cloned from the current one.
  84923. */
  84924. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84925. /**
  84926. * Creates a new InstancedLinesMesh object from the mesh model.
  84927. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  84928. * @param name defines the name of the new instance
  84929. * @returns a new InstancedLinesMesh
  84930. */
  84931. createInstance(name: string): InstancedLinesMesh;
  84932. }
  84933. /**
  84934. * Creates an instance based on a source LinesMesh
  84935. */
  84936. export class InstancedLinesMesh extends InstancedMesh {
  84937. /**
  84938. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  84939. * This margin is expressed in world space coordinates, so its value may vary.
  84940. * Initilized with the intersectionThreshold value of the source LinesMesh
  84941. */
  84942. intersectionThreshold: number;
  84943. constructor(name: string, source: LinesMesh);
  84944. /**
  84945. * Returns the string "InstancedLinesMesh".
  84946. */
  84947. getClassName(): string;
  84948. }
  84949. }
  84950. declare module BABYLON {
  84951. /** @hidden */
  84952. export var linePixelShader: {
  84953. name: string;
  84954. shader: string;
  84955. };
  84956. }
  84957. declare module BABYLON {
  84958. /** @hidden */
  84959. export var lineVertexShader: {
  84960. name: string;
  84961. shader: string;
  84962. };
  84963. }
  84964. declare module BABYLON {
  84965. interface AbstractMesh {
  84966. /**
  84967. * Gets the edgesRenderer associated with the mesh
  84968. */
  84969. edgesRenderer: Nullable<EdgesRenderer>;
  84970. }
  84971. interface LinesMesh {
  84972. /**
  84973. * Enables the edge rendering mode on the mesh.
  84974. * This mode makes the mesh edges visible
  84975. * @param epsilon defines the maximal distance between two angles to detect a face
  84976. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84977. * @returns the currentAbstractMesh
  84978. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84979. */
  84980. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  84981. }
  84982. interface InstancedLinesMesh {
  84983. /**
  84984. * Enables the edge rendering mode on the mesh.
  84985. * This mode makes the mesh edges visible
  84986. * @param epsilon defines the maximal distance between two angles to detect a face
  84987. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84988. * @returns the current InstancedLinesMesh
  84989. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84990. */
  84991. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  84992. }
  84993. /**
  84994. * Defines the minimum contract an Edges renderer should follow.
  84995. */
  84996. export interface IEdgesRenderer extends IDisposable {
  84997. /**
  84998. * Gets or sets a boolean indicating if the edgesRenderer is active
  84999. */
  85000. isEnabled: boolean;
  85001. /**
  85002. * Renders the edges of the attached mesh,
  85003. */
  85004. render(): void;
  85005. /**
  85006. * Checks wether or not the edges renderer is ready to render.
  85007. * @return true if ready, otherwise false.
  85008. */
  85009. isReady(): boolean;
  85010. }
  85011. /**
  85012. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  85013. */
  85014. export class EdgesRenderer implements IEdgesRenderer {
  85015. /**
  85016. * Define the size of the edges with an orthographic camera
  85017. */
  85018. edgesWidthScalerForOrthographic: number;
  85019. /**
  85020. * Define the size of the edges with a perspective camera
  85021. */
  85022. edgesWidthScalerForPerspective: number;
  85023. protected _source: AbstractMesh;
  85024. protected _linesPositions: number[];
  85025. protected _linesNormals: number[];
  85026. protected _linesIndices: number[];
  85027. protected _epsilon: number;
  85028. protected _indicesCount: number;
  85029. protected _lineShader: ShaderMaterial;
  85030. protected _ib: DataBuffer;
  85031. protected _buffers: {
  85032. [key: string]: Nullable<VertexBuffer>;
  85033. };
  85034. protected _checkVerticesInsteadOfIndices: boolean;
  85035. private _meshRebuildObserver;
  85036. private _meshDisposeObserver;
  85037. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  85038. isEnabled: boolean;
  85039. /**
  85040. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  85041. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  85042. * @param source Mesh used to create edges
  85043. * @param epsilon sum of angles in adjacency to check for edge
  85044. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  85045. * @param generateEdgesLines - should generate Lines or only prepare resources.
  85046. */
  85047. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  85048. protected _prepareRessources(): void;
  85049. /** @hidden */
  85050. _rebuild(): void;
  85051. /**
  85052. * Releases the required resources for the edges renderer
  85053. */
  85054. dispose(): void;
  85055. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  85056. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  85057. /**
  85058. * Checks if the pair of p0 and p1 is en edge
  85059. * @param faceIndex
  85060. * @param edge
  85061. * @param faceNormals
  85062. * @param p0
  85063. * @param p1
  85064. * @private
  85065. */
  85066. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  85067. /**
  85068. * push line into the position, normal and index buffer
  85069. * @protected
  85070. */
  85071. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  85072. /**
  85073. * Generates lines edges from adjacencjes
  85074. * @private
  85075. */
  85076. _generateEdgesLines(): void;
  85077. /**
  85078. * Checks wether or not the edges renderer is ready to render.
  85079. * @return true if ready, otherwise false.
  85080. */
  85081. isReady(): boolean;
  85082. /**
  85083. * Renders the edges of the attached mesh,
  85084. */
  85085. render(): void;
  85086. }
  85087. /**
  85088. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  85089. */
  85090. export class LineEdgesRenderer extends EdgesRenderer {
  85091. /**
  85092. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  85093. * @param source LineMesh used to generate edges
  85094. * @param epsilon not important (specified angle for edge detection)
  85095. * @param checkVerticesInsteadOfIndices not important for LineMesh
  85096. */
  85097. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  85098. /**
  85099. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  85100. */
  85101. _generateEdgesLines(): void;
  85102. }
  85103. }
  85104. declare module BABYLON {
  85105. /**
  85106. * This represents the object necessary to create a rendering group.
  85107. * This is exclusively used and created by the rendering manager.
  85108. * To modify the behavior, you use the available helpers in your scene or meshes.
  85109. * @hidden
  85110. */
  85111. export class RenderingGroup {
  85112. index: number;
  85113. private static _zeroVector;
  85114. private _scene;
  85115. private _opaqueSubMeshes;
  85116. private _transparentSubMeshes;
  85117. private _alphaTestSubMeshes;
  85118. private _depthOnlySubMeshes;
  85119. private _particleSystems;
  85120. private _spriteManagers;
  85121. private _opaqueSortCompareFn;
  85122. private _alphaTestSortCompareFn;
  85123. private _transparentSortCompareFn;
  85124. private _renderOpaque;
  85125. private _renderAlphaTest;
  85126. private _renderTransparent;
  85127. /** @hidden */
  85128. _edgesRenderers: SmartArray<IEdgesRenderer>;
  85129. onBeforeTransparentRendering: () => void;
  85130. /**
  85131. * Set the opaque sort comparison function.
  85132. * If null the sub meshes will be render in the order they were created
  85133. */
  85134. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85135. /**
  85136. * Set the alpha test sort comparison function.
  85137. * If null the sub meshes will be render in the order they were created
  85138. */
  85139. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85140. /**
  85141. * Set the transparent sort comparison function.
  85142. * If null the sub meshes will be render in the order they were created
  85143. */
  85144. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85145. /**
  85146. * Creates a new rendering group.
  85147. * @param index The rendering group index
  85148. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  85149. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  85150. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  85151. */
  85152. 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>);
  85153. /**
  85154. * Render all the sub meshes contained in the group.
  85155. * @param customRenderFunction Used to override the default render behaviour of the group.
  85156. * @returns true if rendered some submeshes.
  85157. */
  85158. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  85159. /**
  85160. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  85161. * @param subMeshes The submeshes to render
  85162. */
  85163. private renderOpaqueSorted;
  85164. /**
  85165. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  85166. * @param subMeshes The submeshes to render
  85167. */
  85168. private renderAlphaTestSorted;
  85169. /**
  85170. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  85171. * @param subMeshes The submeshes to render
  85172. */
  85173. private renderTransparentSorted;
  85174. /**
  85175. * Renders the submeshes in a specified order.
  85176. * @param subMeshes The submeshes to sort before render
  85177. * @param sortCompareFn The comparison function use to sort
  85178. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  85179. * @param transparent Specifies to activate blending if true
  85180. */
  85181. private static renderSorted;
  85182. /**
  85183. * Renders the submeshes in the order they were dispatched (no sort applied).
  85184. * @param subMeshes The submeshes to render
  85185. */
  85186. private static renderUnsorted;
  85187. /**
  85188. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85189. * are rendered back to front if in the same alpha index.
  85190. *
  85191. * @param a The first submesh
  85192. * @param b The second submesh
  85193. * @returns The result of the comparison
  85194. */
  85195. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  85196. /**
  85197. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85198. * are rendered back to front.
  85199. *
  85200. * @param a The first submesh
  85201. * @param b The second submesh
  85202. * @returns The result of the comparison
  85203. */
  85204. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  85205. /**
  85206. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85207. * are rendered front to back (prevent overdraw).
  85208. *
  85209. * @param a The first submesh
  85210. * @param b The second submesh
  85211. * @returns The result of the comparison
  85212. */
  85213. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  85214. /**
  85215. * Resets the different lists of submeshes to prepare a new frame.
  85216. */
  85217. prepare(): void;
  85218. dispose(): void;
  85219. /**
  85220. * Inserts the submesh in its correct queue depending on its material.
  85221. * @param subMesh The submesh to dispatch
  85222. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  85223. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  85224. */
  85225. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  85226. dispatchSprites(spriteManager: ISpriteManager): void;
  85227. dispatchParticles(particleSystem: IParticleSystem): void;
  85228. private _renderParticles;
  85229. private _renderSprites;
  85230. }
  85231. }
  85232. declare module BABYLON {
  85233. /**
  85234. * Interface describing the different options available in the rendering manager
  85235. * regarding Auto Clear between groups.
  85236. */
  85237. export interface IRenderingManagerAutoClearSetup {
  85238. /**
  85239. * Defines whether or not autoclear is enable.
  85240. */
  85241. autoClear: boolean;
  85242. /**
  85243. * Defines whether or not to autoclear the depth buffer.
  85244. */
  85245. depth: boolean;
  85246. /**
  85247. * Defines whether or not to autoclear the stencil buffer.
  85248. */
  85249. stencil: boolean;
  85250. }
  85251. /**
  85252. * This class is used by the onRenderingGroupObservable
  85253. */
  85254. export class RenderingGroupInfo {
  85255. /**
  85256. * The Scene that being rendered
  85257. */
  85258. scene: Scene;
  85259. /**
  85260. * The camera currently used for the rendering pass
  85261. */
  85262. camera: Nullable<Camera>;
  85263. /**
  85264. * The ID of the renderingGroup being processed
  85265. */
  85266. renderingGroupId: number;
  85267. }
  85268. /**
  85269. * This is the manager responsible of all the rendering for meshes sprites and particles.
  85270. * It is enable to manage the different groups as well as the different necessary sort functions.
  85271. * This should not be used directly aside of the few static configurations
  85272. */
  85273. export class RenderingManager {
  85274. /**
  85275. * The max id used for rendering groups (not included)
  85276. */
  85277. static MAX_RENDERINGGROUPS: number;
  85278. /**
  85279. * The min id used for rendering groups (included)
  85280. */
  85281. static MIN_RENDERINGGROUPS: number;
  85282. /**
  85283. * Used to globally prevent autoclearing scenes.
  85284. */
  85285. static AUTOCLEAR: boolean;
  85286. /**
  85287. * @hidden
  85288. */
  85289. _useSceneAutoClearSetup: boolean;
  85290. private _scene;
  85291. private _renderingGroups;
  85292. private _depthStencilBufferAlreadyCleaned;
  85293. private _autoClearDepthStencil;
  85294. private _customOpaqueSortCompareFn;
  85295. private _customAlphaTestSortCompareFn;
  85296. private _customTransparentSortCompareFn;
  85297. private _renderingGroupInfo;
  85298. /**
  85299. * Instantiates a new rendering group for a particular scene
  85300. * @param scene Defines the scene the groups belongs to
  85301. */
  85302. constructor(scene: Scene);
  85303. private _clearDepthStencilBuffer;
  85304. /**
  85305. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  85306. * @hidden
  85307. */
  85308. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  85309. /**
  85310. * Resets the different information of the group to prepare a new frame
  85311. * @hidden
  85312. */
  85313. reset(): void;
  85314. /**
  85315. * Dispose and release the group and its associated resources.
  85316. * @hidden
  85317. */
  85318. dispose(): void;
  85319. /**
  85320. * Clear the info related to rendering groups preventing retention points during dispose.
  85321. */
  85322. freeRenderingGroups(): void;
  85323. private _prepareRenderingGroup;
  85324. /**
  85325. * Add a sprite manager to the rendering manager in order to render it this frame.
  85326. * @param spriteManager Define the sprite manager to render
  85327. */
  85328. dispatchSprites(spriteManager: ISpriteManager): void;
  85329. /**
  85330. * Add a particle system to the rendering manager in order to render it this frame.
  85331. * @param particleSystem Define the particle system to render
  85332. */
  85333. dispatchParticles(particleSystem: IParticleSystem): void;
  85334. /**
  85335. * Add a submesh to the manager in order to render it this frame
  85336. * @param subMesh The submesh to dispatch
  85337. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  85338. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  85339. */
  85340. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  85341. /**
  85342. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  85343. * This allowed control for front to back rendering or reversly depending of the special needs.
  85344. *
  85345. * @param renderingGroupId The rendering group id corresponding to its index
  85346. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  85347. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  85348. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  85349. */
  85350. 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;
  85351. /**
  85352. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  85353. *
  85354. * @param renderingGroupId The rendering group id corresponding to its index
  85355. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  85356. * @param depth Automatically clears depth between groups if true and autoClear is true.
  85357. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  85358. */
  85359. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  85360. /**
  85361. * Gets the current auto clear configuration for one rendering group of the rendering
  85362. * manager.
  85363. * @param index the rendering group index to get the information for
  85364. * @returns The auto clear setup for the requested rendering group
  85365. */
  85366. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  85367. }
  85368. }
  85369. declare module BABYLON {
  85370. /**
  85371. * This Helps creating a texture that will be created from a camera in your scene.
  85372. * It is basically a dynamic texture that could be used to create special effects for instance.
  85373. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  85374. */
  85375. export class RenderTargetTexture extends Texture {
  85376. isCube: boolean;
  85377. /**
  85378. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  85379. */
  85380. static readonly REFRESHRATE_RENDER_ONCE: number;
  85381. /**
  85382. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  85383. */
  85384. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  85385. /**
  85386. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  85387. * the central point of your effect and can save a lot of performances.
  85388. */
  85389. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  85390. /**
  85391. * Use this predicate to dynamically define the list of mesh you want to render.
  85392. * If set, the renderList property will be overwritten.
  85393. */
  85394. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  85395. private _renderList;
  85396. /**
  85397. * Use this list to define the list of mesh you want to render.
  85398. */
  85399. renderList: Nullable<Array<AbstractMesh>>;
  85400. private _hookArray;
  85401. /**
  85402. * Define if particles should be rendered in your texture.
  85403. */
  85404. renderParticles: boolean;
  85405. /**
  85406. * Define if sprites should be rendered in your texture.
  85407. */
  85408. renderSprites: boolean;
  85409. /**
  85410. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  85411. */
  85412. coordinatesMode: number;
  85413. /**
  85414. * Define the camera used to render the texture.
  85415. */
  85416. activeCamera: Nullable<Camera>;
  85417. /**
  85418. * Override the render function of the texture with your own one.
  85419. */
  85420. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  85421. /**
  85422. * Define if camera post processes should be use while rendering the texture.
  85423. */
  85424. useCameraPostProcesses: boolean;
  85425. /**
  85426. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  85427. */
  85428. ignoreCameraViewport: boolean;
  85429. private _postProcessManager;
  85430. private _postProcesses;
  85431. private _resizeObserver;
  85432. /**
  85433. * An event triggered when the texture is unbind.
  85434. */
  85435. onBeforeBindObservable: Observable<RenderTargetTexture>;
  85436. /**
  85437. * An event triggered when the texture is unbind.
  85438. */
  85439. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  85440. private _onAfterUnbindObserver;
  85441. /**
  85442. * Set a after unbind callback in the texture.
  85443. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  85444. */
  85445. onAfterUnbind: () => void;
  85446. /**
  85447. * An event triggered before rendering the texture
  85448. */
  85449. onBeforeRenderObservable: Observable<number>;
  85450. private _onBeforeRenderObserver;
  85451. /**
  85452. * Set a before render callback in the texture.
  85453. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  85454. */
  85455. onBeforeRender: (faceIndex: number) => void;
  85456. /**
  85457. * An event triggered after rendering the texture
  85458. */
  85459. onAfterRenderObservable: Observable<number>;
  85460. private _onAfterRenderObserver;
  85461. /**
  85462. * Set a after render callback in the texture.
  85463. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  85464. */
  85465. onAfterRender: (faceIndex: number) => void;
  85466. /**
  85467. * An event triggered after the texture clear
  85468. */
  85469. onClearObservable: Observable<Engine>;
  85470. private _onClearObserver;
  85471. /**
  85472. * Set a clear callback in the texture.
  85473. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  85474. */
  85475. onClear: (Engine: Engine) => void;
  85476. /**
  85477. * An event triggered when the texture is resized.
  85478. */
  85479. onResizeObservable: Observable<RenderTargetTexture>;
  85480. /**
  85481. * Define the clear color of the Render Target if it should be different from the scene.
  85482. */
  85483. clearColor: Color4;
  85484. protected _size: number | {
  85485. width: number;
  85486. height: number;
  85487. };
  85488. protected _initialSizeParameter: number | {
  85489. width: number;
  85490. height: number;
  85491. } | {
  85492. ratio: number;
  85493. };
  85494. protected _sizeRatio: Nullable<number>;
  85495. /** @hidden */
  85496. _generateMipMaps: boolean;
  85497. protected _renderingManager: RenderingManager;
  85498. /** @hidden */
  85499. _waitingRenderList: string[];
  85500. protected _doNotChangeAspectRatio: boolean;
  85501. protected _currentRefreshId: number;
  85502. protected _refreshRate: number;
  85503. protected _textureMatrix: Matrix;
  85504. protected _samples: number;
  85505. protected _renderTargetOptions: RenderTargetCreationOptions;
  85506. /**
  85507. * Gets render target creation options that were used.
  85508. */
  85509. readonly renderTargetOptions: RenderTargetCreationOptions;
  85510. protected _engine: Engine;
  85511. protected _onRatioRescale(): void;
  85512. /**
  85513. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  85514. * It must define where the camera used to render the texture is set
  85515. */
  85516. boundingBoxPosition: Vector3;
  85517. private _boundingBoxSize;
  85518. /**
  85519. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  85520. * When defined, the cubemap will switch to local mode
  85521. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  85522. * @example https://www.babylonjs-playground.com/#RNASML
  85523. */
  85524. boundingBoxSize: Vector3;
  85525. /**
  85526. * In case the RTT has been created with a depth texture, get the associated
  85527. * depth texture.
  85528. * Otherwise, return null.
  85529. */
  85530. depthStencilTexture: Nullable<InternalTexture>;
  85531. /**
  85532. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  85533. * or used a shadow, depth texture...
  85534. * @param name The friendly name of the texture
  85535. * @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)
  85536. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  85537. * @param generateMipMaps True if mip maps need to be generated after render.
  85538. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  85539. * @param type The type of the buffer in the RTT (int, half float, float...)
  85540. * @param isCube True if a cube texture needs to be created
  85541. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  85542. * @param generateDepthBuffer True to generate a depth buffer
  85543. * @param generateStencilBuffer True to generate a stencil buffer
  85544. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  85545. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  85546. * @param delayAllocation if the texture allocation should be delayed (default: false)
  85547. */
  85548. constructor(name: string, size: number | {
  85549. width: number;
  85550. height: number;
  85551. } | {
  85552. ratio: number;
  85553. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  85554. /**
  85555. * Creates a depth stencil texture.
  85556. * This is only available in WebGL 2 or with the depth texture extension available.
  85557. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  85558. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  85559. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  85560. */
  85561. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  85562. private _processSizeParameter;
  85563. /**
  85564. * Define the number of samples to use in case of MSAA.
  85565. * It defaults to one meaning no MSAA has been enabled.
  85566. */
  85567. samples: number;
  85568. /**
  85569. * Resets the refresh counter of the texture and start bak from scratch.
  85570. * Could be useful to regenerate the texture if it is setup to render only once.
  85571. */
  85572. resetRefreshCounter(): void;
  85573. /**
  85574. * Define the refresh rate of the texture or the rendering frequency.
  85575. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  85576. */
  85577. refreshRate: number;
  85578. /**
  85579. * Adds a post process to the render target rendering passes.
  85580. * @param postProcess define the post process to add
  85581. */
  85582. addPostProcess(postProcess: PostProcess): void;
  85583. /**
  85584. * Clear all the post processes attached to the render target
  85585. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  85586. */
  85587. clearPostProcesses(dispose?: boolean): void;
  85588. /**
  85589. * Remove one of the post process from the list of attached post processes to the texture
  85590. * @param postProcess define the post process to remove from the list
  85591. */
  85592. removePostProcess(postProcess: PostProcess): void;
  85593. /** @hidden */
  85594. _shouldRender(): boolean;
  85595. /**
  85596. * Gets the actual render size of the texture.
  85597. * @returns the width of the render size
  85598. */
  85599. getRenderSize(): number;
  85600. /**
  85601. * Gets the actual render width of the texture.
  85602. * @returns the width of the render size
  85603. */
  85604. getRenderWidth(): number;
  85605. /**
  85606. * Gets the actual render height of the texture.
  85607. * @returns the height of the render size
  85608. */
  85609. getRenderHeight(): number;
  85610. /**
  85611. * Get if the texture can be rescaled or not.
  85612. */
  85613. readonly canRescale: boolean;
  85614. /**
  85615. * Resize the texture using a ratio.
  85616. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  85617. */
  85618. scale(ratio: number): void;
  85619. /**
  85620. * Get the texture reflection matrix used to rotate/transform the reflection.
  85621. * @returns the reflection matrix
  85622. */
  85623. getReflectionTextureMatrix(): Matrix;
  85624. /**
  85625. * Resize the texture to a new desired size.
  85626. * Be carrefull as it will recreate all the data in the new texture.
  85627. * @param size Define the new size. It can be:
  85628. * - a number for squared texture,
  85629. * - an object containing { width: number, height: number }
  85630. * - or an object containing a ratio { ratio: number }
  85631. */
  85632. resize(size: number | {
  85633. width: number;
  85634. height: number;
  85635. } | {
  85636. ratio: number;
  85637. }): void;
  85638. /**
  85639. * Renders all the objects from the render list into the texture.
  85640. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  85641. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  85642. */
  85643. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  85644. private _bestReflectionRenderTargetDimension;
  85645. /**
  85646. * @hidden
  85647. * @param faceIndex face index to bind to if this is a cubetexture
  85648. */
  85649. _bindFrameBuffer(faceIndex?: number): void;
  85650. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  85651. private renderToTarget;
  85652. /**
  85653. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  85654. * This allowed control for front to back rendering or reversly depending of the special needs.
  85655. *
  85656. * @param renderingGroupId The rendering group id corresponding to its index
  85657. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  85658. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  85659. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  85660. */
  85661. 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;
  85662. /**
  85663. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  85664. *
  85665. * @param renderingGroupId The rendering group id corresponding to its index
  85666. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  85667. */
  85668. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  85669. /**
  85670. * Clones the texture.
  85671. * @returns the cloned texture
  85672. */
  85673. clone(): RenderTargetTexture;
  85674. /**
  85675. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  85676. * @returns The JSON representation of the texture
  85677. */
  85678. serialize(): any;
  85679. /**
  85680. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  85681. */
  85682. disposeFramebufferObjects(): void;
  85683. /**
  85684. * Dispose the texture and release its associated resources.
  85685. */
  85686. dispose(): void;
  85687. /** @hidden */
  85688. _rebuild(): void;
  85689. /**
  85690. * Clear the info related to rendering groups preventing retention point in material dispose.
  85691. */
  85692. freeRenderingGroups(): void;
  85693. /**
  85694. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  85695. * @returns the view count
  85696. */
  85697. getViewCount(): number;
  85698. }
  85699. }
  85700. declare module BABYLON {
  85701. /**
  85702. * Base class for the main features of a material in Babylon.js
  85703. */
  85704. export class Material implements IAnimatable {
  85705. /**
  85706. * Returns the triangle fill mode
  85707. */
  85708. static readonly TriangleFillMode: number;
  85709. /**
  85710. * Returns the wireframe mode
  85711. */
  85712. static readonly WireFrameFillMode: number;
  85713. /**
  85714. * Returns the point fill mode
  85715. */
  85716. static readonly PointFillMode: number;
  85717. /**
  85718. * Returns the point list draw mode
  85719. */
  85720. static readonly PointListDrawMode: number;
  85721. /**
  85722. * Returns the line list draw mode
  85723. */
  85724. static readonly LineListDrawMode: number;
  85725. /**
  85726. * Returns the line loop draw mode
  85727. */
  85728. static readonly LineLoopDrawMode: number;
  85729. /**
  85730. * Returns the line strip draw mode
  85731. */
  85732. static readonly LineStripDrawMode: number;
  85733. /**
  85734. * Returns the triangle strip draw mode
  85735. */
  85736. static readonly TriangleStripDrawMode: number;
  85737. /**
  85738. * Returns the triangle fan draw mode
  85739. */
  85740. static readonly TriangleFanDrawMode: number;
  85741. /**
  85742. * Stores the clock-wise side orientation
  85743. */
  85744. static readonly ClockWiseSideOrientation: number;
  85745. /**
  85746. * Stores the counter clock-wise side orientation
  85747. */
  85748. static readonly CounterClockWiseSideOrientation: number;
  85749. /**
  85750. * The dirty texture flag value
  85751. */
  85752. static readonly TextureDirtyFlag: number;
  85753. /**
  85754. * The dirty light flag value
  85755. */
  85756. static readonly LightDirtyFlag: number;
  85757. /**
  85758. * The dirty fresnel flag value
  85759. */
  85760. static readonly FresnelDirtyFlag: number;
  85761. /**
  85762. * The dirty attribute flag value
  85763. */
  85764. static readonly AttributesDirtyFlag: number;
  85765. /**
  85766. * The dirty misc flag value
  85767. */
  85768. static readonly MiscDirtyFlag: number;
  85769. /**
  85770. * The all dirty flag value
  85771. */
  85772. static readonly AllDirtyFlag: number;
  85773. /**
  85774. * The ID of the material
  85775. */
  85776. id: string;
  85777. /**
  85778. * Gets or sets the unique id of the material
  85779. */
  85780. uniqueId: number;
  85781. /**
  85782. * The name of the material
  85783. */
  85784. name: string;
  85785. /**
  85786. * Gets or sets user defined metadata
  85787. */
  85788. metadata: any;
  85789. /**
  85790. * For internal use only. Please do not use.
  85791. */
  85792. reservedDataStore: any;
  85793. /**
  85794. * Specifies if the ready state should be checked on each call
  85795. */
  85796. checkReadyOnEveryCall: boolean;
  85797. /**
  85798. * Specifies if the ready state should be checked once
  85799. */
  85800. checkReadyOnlyOnce: boolean;
  85801. /**
  85802. * The state of the material
  85803. */
  85804. state: string;
  85805. /**
  85806. * The alpha value of the material
  85807. */
  85808. protected _alpha: number;
  85809. /**
  85810. * List of inspectable custom properties (used by the Inspector)
  85811. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85812. */
  85813. inspectableCustomProperties: IInspectable[];
  85814. /**
  85815. * Sets the alpha value of the material
  85816. */
  85817. /**
  85818. * Gets the alpha value of the material
  85819. */
  85820. alpha: number;
  85821. /**
  85822. * Specifies if back face culling is enabled
  85823. */
  85824. protected _backFaceCulling: boolean;
  85825. /**
  85826. * Sets the back-face culling state
  85827. */
  85828. /**
  85829. * Gets the back-face culling state
  85830. */
  85831. backFaceCulling: boolean;
  85832. /**
  85833. * Stores the value for side orientation
  85834. */
  85835. sideOrientation: number;
  85836. /**
  85837. * Callback triggered when the material is compiled
  85838. */
  85839. onCompiled: Nullable<(effect: Effect) => void>;
  85840. /**
  85841. * Callback triggered when an error occurs
  85842. */
  85843. onError: Nullable<(effect: Effect, errors: string) => void>;
  85844. /**
  85845. * Callback triggered to get the render target textures
  85846. */
  85847. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  85848. /**
  85849. * Gets a boolean indicating that current material needs to register RTT
  85850. */
  85851. readonly hasRenderTargetTextures: boolean;
  85852. /**
  85853. * Specifies if the material should be serialized
  85854. */
  85855. doNotSerialize: boolean;
  85856. /**
  85857. * @hidden
  85858. */
  85859. _storeEffectOnSubMeshes: boolean;
  85860. /**
  85861. * Stores the animations for the material
  85862. */
  85863. animations: Nullable<Array<Animation>>;
  85864. /**
  85865. * An event triggered when the material is disposed
  85866. */
  85867. onDisposeObservable: Observable<Material>;
  85868. /**
  85869. * An observer which watches for dispose events
  85870. */
  85871. private _onDisposeObserver;
  85872. private _onUnBindObservable;
  85873. /**
  85874. * Called during a dispose event
  85875. */
  85876. onDispose: () => void;
  85877. private _onBindObservable;
  85878. /**
  85879. * An event triggered when the material is bound
  85880. */
  85881. readonly onBindObservable: Observable<AbstractMesh>;
  85882. /**
  85883. * An observer which watches for bind events
  85884. */
  85885. private _onBindObserver;
  85886. /**
  85887. * Called during a bind event
  85888. */
  85889. onBind: (Mesh: AbstractMesh) => void;
  85890. /**
  85891. * An event triggered when the material is unbound
  85892. */
  85893. readonly onUnBindObservable: Observable<Material>;
  85894. /**
  85895. * Stores the value of the alpha mode
  85896. */
  85897. private _alphaMode;
  85898. /**
  85899. * Sets the value of the alpha mode.
  85900. *
  85901. * | Value | Type | Description |
  85902. * | --- | --- | --- |
  85903. * | 0 | ALPHA_DISABLE | |
  85904. * | 1 | ALPHA_ADD | |
  85905. * | 2 | ALPHA_COMBINE | |
  85906. * | 3 | ALPHA_SUBTRACT | |
  85907. * | 4 | ALPHA_MULTIPLY | |
  85908. * | 5 | ALPHA_MAXIMIZED | |
  85909. * | 6 | ALPHA_ONEONE | |
  85910. * | 7 | ALPHA_PREMULTIPLIED | |
  85911. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  85912. * | 9 | ALPHA_INTERPOLATE | |
  85913. * | 10 | ALPHA_SCREENMODE | |
  85914. *
  85915. */
  85916. /**
  85917. * Gets the value of the alpha mode
  85918. */
  85919. alphaMode: number;
  85920. /**
  85921. * Stores the state of the need depth pre-pass value
  85922. */
  85923. private _needDepthPrePass;
  85924. /**
  85925. * Sets the need depth pre-pass value
  85926. */
  85927. /**
  85928. * Gets the depth pre-pass value
  85929. */
  85930. needDepthPrePass: boolean;
  85931. /**
  85932. * Specifies if depth writing should be disabled
  85933. */
  85934. disableDepthWrite: boolean;
  85935. /**
  85936. * Specifies if depth writing should be forced
  85937. */
  85938. forceDepthWrite: boolean;
  85939. /**
  85940. * Specifies if there should be a separate pass for culling
  85941. */
  85942. separateCullingPass: boolean;
  85943. /**
  85944. * Stores the state specifing if fog should be enabled
  85945. */
  85946. private _fogEnabled;
  85947. /**
  85948. * Sets the state for enabling fog
  85949. */
  85950. /**
  85951. * Gets the value of the fog enabled state
  85952. */
  85953. fogEnabled: boolean;
  85954. /**
  85955. * Stores the size of points
  85956. */
  85957. pointSize: number;
  85958. /**
  85959. * Stores the z offset value
  85960. */
  85961. zOffset: number;
  85962. /**
  85963. * Gets a value specifying if wireframe mode is enabled
  85964. */
  85965. /**
  85966. * Sets the state of wireframe mode
  85967. */
  85968. wireframe: boolean;
  85969. /**
  85970. * Gets the value specifying if point clouds are enabled
  85971. */
  85972. /**
  85973. * Sets the state of point cloud mode
  85974. */
  85975. pointsCloud: boolean;
  85976. /**
  85977. * Gets the material fill mode
  85978. */
  85979. /**
  85980. * Sets the material fill mode
  85981. */
  85982. fillMode: number;
  85983. /**
  85984. * @hidden
  85985. * Stores the effects for the material
  85986. */
  85987. _effect: Nullable<Effect>;
  85988. /**
  85989. * @hidden
  85990. * Specifies if the material was previously ready
  85991. */
  85992. _wasPreviouslyReady: boolean;
  85993. /**
  85994. * Specifies if uniform buffers should be used
  85995. */
  85996. private _useUBO;
  85997. /**
  85998. * Stores a reference to the scene
  85999. */
  86000. private _scene;
  86001. /**
  86002. * Stores the fill mode state
  86003. */
  86004. private _fillMode;
  86005. /**
  86006. * Specifies if the depth write state should be cached
  86007. */
  86008. private _cachedDepthWriteState;
  86009. /**
  86010. * Stores the uniform buffer
  86011. */
  86012. protected _uniformBuffer: UniformBuffer;
  86013. /** @hidden */
  86014. _indexInSceneMaterialArray: number;
  86015. /** @hidden */
  86016. meshMap: Nullable<{
  86017. [id: string]: AbstractMesh | undefined;
  86018. }>;
  86019. /**
  86020. * Creates a material instance
  86021. * @param name defines the name of the material
  86022. * @param scene defines the scene to reference
  86023. * @param doNotAdd specifies if the material should be added to the scene
  86024. */
  86025. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  86026. /**
  86027. * Returns a string representation of the current material
  86028. * @param fullDetails defines a boolean indicating which levels of logging is desired
  86029. * @returns a string with material information
  86030. */
  86031. toString(fullDetails?: boolean): string;
  86032. /**
  86033. * Gets the class name of the material
  86034. * @returns a string with the class name of the material
  86035. */
  86036. getClassName(): string;
  86037. /**
  86038. * Specifies if updates for the material been locked
  86039. */
  86040. readonly isFrozen: boolean;
  86041. /**
  86042. * Locks updates for the material
  86043. */
  86044. freeze(): void;
  86045. /**
  86046. * Unlocks updates for the material
  86047. */
  86048. unfreeze(): void;
  86049. /**
  86050. * Specifies if the material is ready to be used
  86051. * @param mesh defines the mesh to check
  86052. * @param useInstances specifies if instances should be used
  86053. * @returns a boolean indicating if the material is ready to be used
  86054. */
  86055. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  86056. /**
  86057. * Specifies that the submesh is ready to be used
  86058. * @param mesh defines the mesh to check
  86059. * @param subMesh defines which submesh to check
  86060. * @param useInstances specifies that instances should be used
  86061. * @returns a boolean indicating that the submesh is ready or not
  86062. */
  86063. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86064. /**
  86065. * Returns the material effect
  86066. * @returns the effect associated with the material
  86067. */
  86068. getEffect(): Nullable<Effect>;
  86069. /**
  86070. * Returns the current scene
  86071. * @returns a Scene
  86072. */
  86073. getScene(): Scene;
  86074. /**
  86075. * Specifies if the material will require alpha blending
  86076. * @returns a boolean specifying if alpha blending is needed
  86077. */
  86078. needAlphaBlending(): boolean;
  86079. /**
  86080. * Specifies if the mesh will require alpha blending
  86081. * @param mesh defines the mesh to check
  86082. * @returns a boolean specifying if alpha blending is needed for the mesh
  86083. */
  86084. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  86085. /**
  86086. * Specifies if this material should be rendered in alpha test mode
  86087. * @returns a boolean specifying if an alpha test is needed.
  86088. */
  86089. needAlphaTesting(): boolean;
  86090. /**
  86091. * Gets the texture used for the alpha test
  86092. * @returns the texture to use for alpha testing
  86093. */
  86094. getAlphaTestTexture(): Nullable<BaseTexture>;
  86095. /**
  86096. * Marks the material to indicate that it needs to be re-calculated
  86097. */
  86098. markDirty(): void;
  86099. /** @hidden */
  86100. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  86101. /**
  86102. * Binds the material to the mesh
  86103. * @param world defines the world transformation matrix
  86104. * @param mesh defines the mesh to bind the material to
  86105. */
  86106. bind(world: Matrix, mesh?: Mesh): void;
  86107. /**
  86108. * Binds the submesh to the material
  86109. * @param world defines the world transformation matrix
  86110. * @param mesh defines the mesh containing the submesh
  86111. * @param subMesh defines the submesh to bind the material to
  86112. */
  86113. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  86114. /**
  86115. * Binds the world matrix to the material
  86116. * @param world defines the world transformation matrix
  86117. */
  86118. bindOnlyWorldMatrix(world: Matrix): void;
  86119. /**
  86120. * Binds the scene's uniform buffer to the effect.
  86121. * @param effect defines the effect to bind to the scene uniform buffer
  86122. * @param sceneUbo defines the uniform buffer storing scene data
  86123. */
  86124. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  86125. /**
  86126. * Binds the view matrix to the effect
  86127. * @param effect defines the effect to bind the view matrix to
  86128. */
  86129. bindView(effect: Effect): void;
  86130. /**
  86131. * Binds the view projection matrix to the effect
  86132. * @param effect defines the effect to bind the view projection matrix to
  86133. */
  86134. bindViewProjection(effect: Effect): void;
  86135. /**
  86136. * Specifies if material alpha testing should be turned on for the mesh
  86137. * @param mesh defines the mesh to check
  86138. */
  86139. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  86140. /**
  86141. * Processes to execute after binding the material to a mesh
  86142. * @param mesh defines the rendered mesh
  86143. */
  86144. protected _afterBind(mesh?: Mesh): void;
  86145. /**
  86146. * Unbinds the material from the mesh
  86147. */
  86148. unbind(): void;
  86149. /**
  86150. * Gets the active textures from the material
  86151. * @returns an array of textures
  86152. */
  86153. getActiveTextures(): BaseTexture[];
  86154. /**
  86155. * Specifies if the material uses a texture
  86156. * @param texture defines the texture to check against the material
  86157. * @returns a boolean specifying if the material uses the texture
  86158. */
  86159. hasTexture(texture: BaseTexture): boolean;
  86160. /**
  86161. * Makes a duplicate of the material, and gives it a new name
  86162. * @param name defines the new name for the duplicated material
  86163. * @returns the cloned material
  86164. */
  86165. clone(name: string): Nullable<Material>;
  86166. /**
  86167. * Gets the meshes bound to the material
  86168. * @returns an array of meshes bound to the material
  86169. */
  86170. getBindedMeshes(): AbstractMesh[];
  86171. /**
  86172. * Force shader compilation
  86173. * @param mesh defines the mesh associated with this material
  86174. * @param onCompiled defines a function to execute once the material is compiled
  86175. * @param options defines the options to configure the compilation
  86176. */
  86177. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  86178. clipPlane: boolean;
  86179. }>): void;
  86180. /**
  86181. * Force shader compilation
  86182. * @param mesh defines the mesh that will use this material
  86183. * @param options defines additional options for compiling the shaders
  86184. * @returns a promise that resolves when the compilation completes
  86185. */
  86186. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  86187. clipPlane: boolean;
  86188. }>): Promise<void>;
  86189. private static readonly _AllDirtyCallBack;
  86190. private static readonly _ImageProcessingDirtyCallBack;
  86191. private static readonly _TextureDirtyCallBack;
  86192. private static readonly _FresnelDirtyCallBack;
  86193. private static readonly _MiscDirtyCallBack;
  86194. private static readonly _LightsDirtyCallBack;
  86195. private static readonly _AttributeDirtyCallBack;
  86196. private static _FresnelAndMiscDirtyCallBack;
  86197. private static _TextureAndMiscDirtyCallBack;
  86198. private static readonly _DirtyCallbackArray;
  86199. private static readonly _RunDirtyCallBacks;
  86200. /**
  86201. * Marks a define in the material to indicate that it needs to be re-computed
  86202. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  86203. */
  86204. markAsDirty(flag: number): void;
  86205. /**
  86206. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  86207. * @param func defines a function which checks material defines against the submeshes
  86208. */
  86209. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  86210. /**
  86211. * Indicates that we need to re-calculated for all submeshes
  86212. */
  86213. protected _markAllSubMeshesAsAllDirty(): void;
  86214. /**
  86215. * Indicates that image processing needs to be re-calculated for all submeshes
  86216. */
  86217. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  86218. /**
  86219. * Indicates that textures need to be re-calculated for all submeshes
  86220. */
  86221. protected _markAllSubMeshesAsTexturesDirty(): void;
  86222. /**
  86223. * Indicates that fresnel needs to be re-calculated for all submeshes
  86224. */
  86225. protected _markAllSubMeshesAsFresnelDirty(): void;
  86226. /**
  86227. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  86228. */
  86229. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  86230. /**
  86231. * Indicates that lights need to be re-calculated for all submeshes
  86232. */
  86233. protected _markAllSubMeshesAsLightsDirty(): void;
  86234. /**
  86235. * Indicates that attributes need to be re-calculated for all submeshes
  86236. */
  86237. protected _markAllSubMeshesAsAttributesDirty(): void;
  86238. /**
  86239. * Indicates that misc needs to be re-calculated for all submeshes
  86240. */
  86241. protected _markAllSubMeshesAsMiscDirty(): void;
  86242. /**
  86243. * Indicates that textures and misc need to be re-calculated for all submeshes
  86244. */
  86245. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  86246. /**
  86247. * Disposes the material
  86248. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86249. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  86250. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  86251. */
  86252. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  86253. /** @hidden */
  86254. private releaseVertexArrayObject;
  86255. /**
  86256. * Serializes this material
  86257. * @returns the serialized material object
  86258. */
  86259. serialize(): any;
  86260. /**
  86261. * Creates a material from parsed material data
  86262. * @param parsedMaterial defines parsed material data
  86263. * @param scene defines the hosting scene
  86264. * @param rootUrl defines the root URL to use to load textures
  86265. * @returns a new material
  86266. */
  86267. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  86268. }
  86269. }
  86270. declare module BABYLON {
  86271. /**
  86272. * A multi-material is used to apply different materials to different parts of the same object without the need of
  86273. * separate meshes. This can be use to improve performances.
  86274. * @see http://doc.babylonjs.com/how_to/multi_materials
  86275. */
  86276. export class MultiMaterial extends Material {
  86277. private _subMaterials;
  86278. /**
  86279. * Gets or Sets the list of Materials used within the multi material.
  86280. * They need to be ordered according to the submeshes order in the associated mesh
  86281. */
  86282. subMaterials: Nullable<Material>[];
  86283. /**
  86284. * Function used to align with Node.getChildren()
  86285. * @returns the list of Materials used within the multi material
  86286. */
  86287. getChildren(): Nullable<Material>[];
  86288. /**
  86289. * Instantiates a new Multi Material
  86290. * A multi-material is used to apply different materials to different parts of the same object without the need of
  86291. * separate meshes. This can be use to improve performances.
  86292. * @see http://doc.babylonjs.com/how_to/multi_materials
  86293. * @param name Define the name in the scene
  86294. * @param scene Define the scene the material belongs to
  86295. */
  86296. constructor(name: string, scene: Scene);
  86297. private _hookArray;
  86298. /**
  86299. * Get one of the submaterial by its index in the submaterials array
  86300. * @param index The index to look the sub material at
  86301. * @returns The Material if the index has been defined
  86302. */
  86303. getSubMaterial(index: number): Nullable<Material>;
  86304. /**
  86305. * Get the list of active textures for the whole sub materials list.
  86306. * @returns All the textures that will be used during the rendering
  86307. */
  86308. getActiveTextures(): BaseTexture[];
  86309. /**
  86310. * Gets the current class name of the material e.g. "MultiMaterial"
  86311. * Mainly use in serialization.
  86312. * @returns the class name
  86313. */
  86314. getClassName(): string;
  86315. /**
  86316. * Checks if the material is ready to render the requested sub mesh
  86317. * @param mesh Define the mesh the submesh belongs to
  86318. * @param subMesh Define the sub mesh to look readyness for
  86319. * @param useInstances Define whether or not the material is used with instances
  86320. * @returns true if ready, otherwise false
  86321. */
  86322. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86323. /**
  86324. * Clones the current material and its related sub materials
  86325. * @param name Define the name of the newly cloned material
  86326. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  86327. * @returns the cloned material
  86328. */
  86329. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  86330. /**
  86331. * Serializes the materials into a JSON representation.
  86332. * @returns the JSON representation
  86333. */
  86334. serialize(): any;
  86335. /**
  86336. * Dispose the material and release its associated resources
  86337. * @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)
  86338. * @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)
  86339. * @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)
  86340. */
  86341. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  86342. /**
  86343. * Creates a MultiMaterial from parsed MultiMaterial data.
  86344. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  86345. * @param scene defines the hosting scene
  86346. * @returns a new MultiMaterial
  86347. */
  86348. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  86349. }
  86350. }
  86351. declare module BABYLON {
  86352. /**
  86353. * Base class for submeshes
  86354. */
  86355. export class BaseSubMesh {
  86356. /** @hidden */
  86357. _materialDefines: Nullable<MaterialDefines>;
  86358. /** @hidden */
  86359. _materialEffect: Nullable<Effect>;
  86360. /**
  86361. * Gets associated effect
  86362. */
  86363. readonly effect: Nullable<Effect>;
  86364. /**
  86365. * Sets associated effect (effect used to render this submesh)
  86366. * @param effect defines the effect to associate with
  86367. * @param defines defines the set of defines used to compile this effect
  86368. */
  86369. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  86370. }
  86371. /**
  86372. * Defines a subdivision inside a mesh
  86373. */
  86374. export class SubMesh extends BaseSubMesh implements ICullable {
  86375. /** the material index to use */
  86376. materialIndex: number;
  86377. /** vertex index start */
  86378. verticesStart: number;
  86379. /** vertices count */
  86380. verticesCount: number;
  86381. /** index start */
  86382. indexStart: number;
  86383. /** indices count */
  86384. indexCount: number;
  86385. /** @hidden */
  86386. _linesIndexCount: number;
  86387. private _mesh;
  86388. private _renderingMesh;
  86389. private _boundingInfo;
  86390. private _linesIndexBuffer;
  86391. /** @hidden */
  86392. _lastColliderWorldVertices: Nullable<Vector3[]>;
  86393. /** @hidden */
  86394. _trianglePlanes: Plane[];
  86395. /** @hidden */
  86396. _lastColliderTransformMatrix: Nullable<Matrix>;
  86397. /** @hidden */
  86398. _renderId: number;
  86399. /** @hidden */
  86400. _alphaIndex: number;
  86401. /** @hidden */
  86402. _distanceToCamera: number;
  86403. /** @hidden */
  86404. _id: number;
  86405. private _currentMaterial;
  86406. /**
  86407. * Add a new submesh to a mesh
  86408. * @param materialIndex defines the material index to use
  86409. * @param verticesStart defines vertex index start
  86410. * @param verticesCount defines vertices count
  86411. * @param indexStart defines index start
  86412. * @param indexCount defines indices count
  86413. * @param mesh defines the parent mesh
  86414. * @param renderingMesh defines an optional rendering mesh
  86415. * @param createBoundingBox defines if bounding box should be created for this submesh
  86416. * @returns the new submesh
  86417. */
  86418. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  86419. /**
  86420. * Creates a new submesh
  86421. * @param materialIndex defines the material index to use
  86422. * @param verticesStart defines vertex index start
  86423. * @param verticesCount defines vertices count
  86424. * @param indexStart defines index start
  86425. * @param indexCount defines indices count
  86426. * @param mesh defines the parent mesh
  86427. * @param renderingMesh defines an optional rendering mesh
  86428. * @param createBoundingBox defines if bounding box should be created for this submesh
  86429. */
  86430. constructor(
  86431. /** the material index to use */
  86432. materialIndex: number,
  86433. /** vertex index start */
  86434. verticesStart: number,
  86435. /** vertices count */
  86436. verticesCount: number,
  86437. /** index start */
  86438. indexStart: number,
  86439. /** indices count */
  86440. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  86441. /**
  86442. * Returns true if this submesh covers the entire parent mesh
  86443. * @ignorenaming
  86444. */
  86445. readonly IsGlobal: boolean;
  86446. /**
  86447. * Returns the submesh BoudingInfo object
  86448. * @returns current bounding info (or mesh's one if the submesh is global)
  86449. */
  86450. getBoundingInfo(): BoundingInfo;
  86451. /**
  86452. * Sets the submesh BoundingInfo
  86453. * @param boundingInfo defines the new bounding info to use
  86454. * @returns the SubMesh
  86455. */
  86456. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  86457. /**
  86458. * Returns the mesh of the current submesh
  86459. * @return the parent mesh
  86460. */
  86461. getMesh(): AbstractMesh;
  86462. /**
  86463. * Returns the rendering mesh of the submesh
  86464. * @returns the rendering mesh (could be different from parent mesh)
  86465. */
  86466. getRenderingMesh(): Mesh;
  86467. /**
  86468. * Returns the submesh material
  86469. * @returns null or the current material
  86470. */
  86471. getMaterial(): Nullable<Material>;
  86472. /**
  86473. * Sets a new updated BoundingInfo object to the submesh
  86474. * @param data defines an optional position array to use to determine the bounding info
  86475. * @returns the SubMesh
  86476. */
  86477. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  86478. /** @hidden */
  86479. _checkCollision(collider: Collider): boolean;
  86480. /**
  86481. * Updates the submesh BoundingInfo
  86482. * @param world defines the world matrix to use to update the bounding info
  86483. * @returns the submesh
  86484. */
  86485. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  86486. /**
  86487. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  86488. * @param frustumPlanes defines the frustum planes
  86489. * @returns true if the submesh is intersecting with the frustum
  86490. */
  86491. isInFrustum(frustumPlanes: Plane[]): boolean;
  86492. /**
  86493. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  86494. * @param frustumPlanes defines the frustum planes
  86495. * @returns true if the submesh is inside the frustum
  86496. */
  86497. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  86498. /**
  86499. * Renders the submesh
  86500. * @param enableAlphaMode defines if alpha needs to be used
  86501. * @returns the submesh
  86502. */
  86503. render(enableAlphaMode: boolean): SubMesh;
  86504. /**
  86505. * @hidden
  86506. */
  86507. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  86508. /**
  86509. * Checks if the submesh intersects with a ray
  86510. * @param ray defines the ray to test
  86511. * @returns true is the passed ray intersects the submesh bounding box
  86512. */
  86513. canIntersects(ray: Ray): boolean;
  86514. /**
  86515. * Intersects current submesh with a ray
  86516. * @param ray defines the ray to test
  86517. * @param positions defines mesh's positions array
  86518. * @param indices defines mesh's indices array
  86519. * @param fastCheck defines if only bounding info should be used
  86520. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  86521. * @returns intersection info or null if no intersection
  86522. */
  86523. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  86524. /** @hidden */
  86525. private _intersectLines;
  86526. /** @hidden */
  86527. private _intersectUnIndexedLines;
  86528. /** @hidden */
  86529. private _intersectTriangles;
  86530. /** @hidden */
  86531. private _intersectUnIndexedTriangles;
  86532. /** @hidden */
  86533. _rebuild(): void;
  86534. /**
  86535. * Creates a new submesh from the passed mesh
  86536. * @param newMesh defines the new hosting mesh
  86537. * @param newRenderingMesh defines an optional rendering mesh
  86538. * @returns the new submesh
  86539. */
  86540. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  86541. /**
  86542. * Release associated resources
  86543. */
  86544. dispose(): void;
  86545. /**
  86546. * Gets the class name
  86547. * @returns the string "SubMesh".
  86548. */
  86549. getClassName(): string;
  86550. /**
  86551. * Creates a new submesh from indices data
  86552. * @param materialIndex the index of the main mesh material
  86553. * @param startIndex the index where to start the copy in the mesh indices array
  86554. * @param indexCount the number of indices to copy then from the startIndex
  86555. * @param mesh the main mesh to create the submesh from
  86556. * @param renderingMesh the optional rendering mesh
  86557. * @returns a new submesh
  86558. */
  86559. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  86560. }
  86561. }
  86562. declare module BABYLON {
  86563. /**
  86564. * Class used to represent data loading progression
  86565. */
  86566. export class SceneLoaderFlags {
  86567. private static _ForceFullSceneLoadingForIncremental;
  86568. private static _ShowLoadingScreen;
  86569. private static _CleanBoneMatrixWeights;
  86570. private static _loggingLevel;
  86571. /**
  86572. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  86573. */
  86574. static ForceFullSceneLoadingForIncremental: boolean;
  86575. /**
  86576. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  86577. */
  86578. static ShowLoadingScreen: boolean;
  86579. /**
  86580. * Defines the current logging level (while loading the scene)
  86581. * @ignorenaming
  86582. */
  86583. static loggingLevel: number;
  86584. /**
  86585. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  86586. */
  86587. static CleanBoneMatrixWeights: boolean;
  86588. }
  86589. }
  86590. declare module BABYLON {
  86591. /**
  86592. * Class used to store geometry data (vertex buffers + index buffer)
  86593. */
  86594. export class Geometry implements IGetSetVerticesData {
  86595. /**
  86596. * Gets or sets the ID of the geometry
  86597. */
  86598. id: string;
  86599. /**
  86600. * Gets or sets the unique ID of the geometry
  86601. */
  86602. uniqueId: number;
  86603. /**
  86604. * Gets the delay loading state of the geometry (none by default which means not delayed)
  86605. */
  86606. delayLoadState: number;
  86607. /**
  86608. * Gets the file containing the data to load when running in delay load state
  86609. */
  86610. delayLoadingFile: Nullable<string>;
  86611. /**
  86612. * Callback called when the geometry is updated
  86613. */
  86614. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  86615. private _scene;
  86616. private _engine;
  86617. private _meshes;
  86618. private _totalVertices;
  86619. /** @hidden */
  86620. _indices: IndicesArray;
  86621. /** @hidden */
  86622. _vertexBuffers: {
  86623. [key: string]: VertexBuffer;
  86624. };
  86625. private _isDisposed;
  86626. private _extend;
  86627. private _boundingBias;
  86628. /** @hidden */
  86629. _delayInfo: Array<string>;
  86630. private _indexBuffer;
  86631. private _indexBufferIsUpdatable;
  86632. /** @hidden */
  86633. _boundingInfo: Nullable<BoundingInfo>;
  86634. /** @hidden */
  86635. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  86636. /** @hidden */
  86637. _softwareSkinningFrameId: number;
  86638. private _vertexArrayObjects;
  86639. private _updatable;
  86640. /** @hidden */
  86641. _positions: Nullable<Vector3[]>;
  86642. /**
  86643. * 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
  86644. */
  86645. /**
  86646. * 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
  86647. */
  86648. boundingBias: Vector2;
  86649. /**
  86650. * Static function used to attach a new empty geometry to a mesh
  86651. * @param mesh defines the mesh to attach the geometry to
  86652. * @returns the new Geometry
  86653. */
  86654. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  86655. /**
  86656. * Creates a new geometry
  86657. * @param id defines the unique ID
  86658. * @param scene defines the hosting scene
  86659. * @param vertexData defines the VertexData used to get geometry data
  86660. * @param updatable defines if geometry must be updatable (false by default)
  86661. * @param mesh defines the mesh that will be associated with the geometry
  86662. */
  86663. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  86664. /**
  86665. * Gets the current extend of the geometry
  86666. */
  86667. readonly extend: {
  86668. minimum: Vector3;
  86669. maximum: Vector3;
  86670. };
  86671. /**
  86672. * Gets the hosting scene
  86673. * @returns the hosting Scene
  86674. */
  86675. getScene(): Scene;
  86676. /**
  86677. * Gets the hosting engine
  86678. * @returns the hosting Engine
  86679. */
  86680. getEngine(): Engine;
  86681. /**
  86682. * Defines if the geometry is ready to use
  86683. * @returns true if the geometry is ready to be used
  86684. */
  86685. isReady(): boolean;
  86686. /**
  86687. * Gets a value indicating that the geometry should not be serialized
  86688. */
  86689. readonly doNotSerialize: boolean;
  86690. /** @hidden */
  86691. _rebuild(): void;
  86692. /**
  86693. * Affects all geometry data in one call
  86694. * @param vertexData defines the geometry data
  86695. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  86696. */
  86697. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  86698. /**
  86699. * Set specific vertex data
  86700. * @param kind defines the data kind (Position, normal, etc...)
  86701. * @param data defines the vertex data to use
  86702. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  86703. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  86704. */
  86705. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  86706. /**
  86707. * Removes a specific vertex data
  86708. * @param kind defines the data kind (Position, normal, etc...)
  86709. */
  86710. removeVerticesData(kind: string): void;
  86711. /**
  86712. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  86713. * @param buffer defines the vertex buffer to use
  86714. * @param totalVertices defines the total number of vertices for position kind (could be null)
  86715. */
  86716. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  86717. /**
  86718. * Update a specific vertex buffer
  86719. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  86720. * It will do nothing if the buffer is not updatable
  86721. * @param kind defines the data kind (Position, normal, etc...)
  86722. * @param data defines the data to use
  86723. * @param offset defines the offset in the target buffer where to store the data
  86724. * @param useBytes set to true if the offset is in bytes
  86725. */
  86726. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  86727. /**
  86728. * Update a specific vertex buffer
  86729. * This function will create a new buffer if the current one is not updatable
  86730. * @param kind defines the data kind (Position, normal, etc...)
  86731. * @param data defines the data to use
  86732. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  86733. */
  86734. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  86735. private _updateBoundingInfo;
  86736. /** @hidden */
  86737. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  86738. /**
  86739. * Gets total number of vertices
  86740. * @returns the total number of vertices
  86741. */
  86742. getTotalVertices(): number;
  86743. /**
  86744. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  86745. * @param kind defines the data kind (Position, normal, etc...)
  86746. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86747. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86748. * @returns a float array containing vertex data
  86749. */
  86750. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  86751. /**
  86752. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  86753. * @param kind defines the data kind (Position, normal, etc...)
  86754. * @returns true if the vertex buffer with the specified kind is updatable
  86755. */
  86756. isVertexBufferUpdatable(kind: string): boolean;
  86757. /**
  86758. * Gets a specific vertex buffer
  86759. * @param kind defines the data kind (Position, normal, etc...)
  86760. * @returns a VertexBuffer
  86761. */
  86762. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  86763. /**
  86764. * Returns all vertex buffers
  86765. * @return an object holding all vertex buffers indexed by kind
  86766. */
  86767. getVertexBuffers(): Nullable<{
  86768. [key: string]: VertexBuffer;
  86769. }>;
  86770. /**
  86771. * Gets a boolean indicating if specific vertex buffer is present
  86772. * @param kind defines the data kind (Position, normal, etc...)
  86773. * @returns true if data is present
  86774. */
  86775. isVerticesDataPresent(kind: string): boolean;
  86776. /**
  86777. * Gets a list of all attached data kinds (Position, normal, etc...)
  86778. * @returns a list of string containing all kinds
  86779. */
  86780. getVerticesDataKinds(): string[];
  86781. /**
  86782. * Update index buffer
  86783. * @param indices defines the indices to store in the index buffer
  86784. * @param offset defines the offset in the target buffer where to store the data
  86785. * @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)
  86786. */
  86787. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  86788. /**
  86789. * Creates a new index buffer
  86790. * @param indices defines the indices to store in the index buffer
  86791. * @param totalVertices defines the total number of vertices (could be null)
  86792. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  86793. */
  86794. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  86795. /**
  86796. * Return the total number of indices
  86797. * @returns the total number of indices
  86798. */
  86799. getTotalIndices(): number;
  86800. /**
  86801. * Gets the index buffer array
  86802. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86803. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86804. * @returns the index buffer array
  86805. */
  86806. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86807. /**
  86808. * Gets the index buffer
  86809. * @return the index buffer
  86810. */
  86811. getIndexBuffer(): Nullable<DataBuffer>;
  86812. /** @hidden */
  86813. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  86814. /**
  86815. * Release the associated resources for a specific mesh
  86816. * @param mesh defines the source mesh
  86817. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  86818. */
  86819. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  86820. /**
  86821. * Apply current geometry to a given mesh
  86822. * @param mesh defines the mesh to apply geometry to
  86823. */
  86824. applyToMesh(mesh: Mesh): void;
  86825. private _updateExtend;
  86826. private _applyToMesh;
  86827. private notifyUpdate;
  86828. /**
  86829. * Load the geometry if it was flagged as delay loaded
  86830. * @param scene defines the hosting scene
  86831. * @param onLoaded defines a callback called when the geometry is loaded
  86832. */
  86833. load(scene: Scene, onLoaded?: () => void): void;
  86834. private _queueLoad;
  86835. /**
  86836. * Invert the geometry to move from a right handed system to a left handed one.
  86837. */
  86838. toLeftHanded(): void;
  86839. /** @hidden */
  86840. _resetPointsArrayCache(): void;
  86841. /** @hidden */
  86842. _generatePointsArray(): boolean;
  86843. /**
  86844. * Gets a value indicating if the geometry is disposed
  86845. * @returns true if the geometry was disposed
  86846. */
  86847. isDisposed(): boolean;
  86848. private _disposeVertexArrayObjects;
  86849. /**
  86850. * Free all associated resources
  86851. */
  86852. dispose(): void;
  86853. /**
  86854. * Clone the current geometry into a new geometry
  86855. * @param id defines the unique ID of the new geometry
  86856. * @returns a new geometry object
  86857. */
  86858. copy(id: string): Geometry;
  86859. /**
  86860. * Serialize the current geometry info (and not the vertices data) into a JSON object
  86861. * @return a JSON representation of the current geometry data (without the vertices data)
  86862. */
  86863. serialize(): any;
  86864. private toNumberArray;
  86865. /**
  86866. * Serialize all vertices data into a JSON oject
  86867. * @returns a JSON representation of the current geometry data
  86868. */
  86869. serializeVerticeData(): any;
  86870. /**
  86871. * Extracts a clone of a mesh geometry
  86872. * @param mesh defines the source mesh
  86873. * @param id defines the unique ID of the new geometry object
  86874. * @returns the new geometry object
  86875. */
  86876. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  86877. /**
  86878. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  86879. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  86880. * Be aware Math.random() could cause collisions, but:
  86881. * "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"
  86882. * @returns a string containing a new GUID
  86883. */
  86884. static RandomId(): string;
  86885. /** @hidden */
  86886. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  86887. private static _CleanMatricesWeights;
  86888. /**
  86889. * Create a new geometry from persisted data (Using .babylon file format)
  86890. * @param parsedVertexData defines the persisted data
  86891. * @param scene defines the hosting scene
  86892. * @param rootUrl defines the root url to use to load assets (like delayed data)
  86893. * @returns the new geometry object
  86894. */
  86895. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  86896. }
  86897. }
  86898. declare module BABYLON {
  86899. /**
  86900. * Define an interface for all classes that will get and set the data on vertices
  86901. */
  86902. export interface IGetSetVerticesData {
  86903. /**
  86904. * Gets a boolean indicating if specific vertex data is present
  86905. * @param kind defines the vertex data kind to use
  86906. * @returns true is data kind is present
  86907. */
  86908. isVerticesDataPresent(kind: string): boolean;
  86909. /**
  86910. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  86911. * @param kind defines the data kind (Position, normal, etc...)
  86912. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86913. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86914. * @returns a float array containing vertex data
  86915. */
  86916. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  86917. /**
  86918. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86919. * @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.
  86920. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86921. * @returns the indices array or an empty array if the mesh has no geometry
  86922. */
  86923. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86924. /**
  86925. * Set specific vertex data
  86926. * @param kind defines the data kind (Position, normal, etc...)
  86927. * @param data defines the vertex data to use
  86928. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  86929. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  86930. */
  86931. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  86932. /**
  86933. * Update a specific associated vertex buffer
  86934. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  86935. * - VertexBuffer.PositionKind
  86936. * - VertexBuffer.UVKind
  86937. * - VertexBuffer.UV2Kind
  86938. * - VertexBuffer.UV3Kind
  86939. * - VertexBuffer.UV4Kind
  86940. * - VertexBuffer.UV5Kind
  86941. * - VertexBuffer.UV6Kind
  86942. * - VertexBuffer.ColorKind
  86943. * - VertexBuffer.MatricesIndicesKind
  86944. * - VertexBuffer.MatricesIndicesExtraKind
  86945. * - VertexBuffer.MatricesWeightsKind
  86946. * - VertexBuffer.MatricesWeightsExtraKind
  86947. * @param data defines the data source
  86948. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  86949. * @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)
  86950. */
  86951. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  86952. /**
  86953. * Creates a new index buffer
  86954. * @param indices defines the indices to store in the index buffer
  86955. * @param totalVertices defines the total number of vertices (could be null)
  86956. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  86957. */
  86958. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  86959. }
  86960. /**
  86961. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  86962. */
  86963. export class VertexData {
  86964. /**
  86965. * Mesh side orientation : usually the external or front surface
  86966. */
  86967. static readonly FRONTSIDE: number;
  86968. /**
  86969. * Mesh side orientation : usually the internal or back surface
  86970. */
  86971. static readonly BACKSIDE: number;
  86972. /**
  86973. * Mesh side orientation : both internal and external or front and back surfaces
  86974. */
  86975. static readonly DOUBLESIDE: number;
  86976. /**
  86977. * Mesh side orientation : by default, `FRONTSIDE`
  86978. */
  86979. static readonly DEFAULTSIDE: number;
  86980. /**
  86981. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  86982. */
  86983. positions: Nullable<FloatArray>;
  86984. /**
  86985. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  86986. */
  86987. normals: Nullable<FloatArray>;
  86988. /**
  86989. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  86990. */
  86991. tangents: Nullable<FloatArray>;
  86992. /**
  86993. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86994. */
  86995. uvs: Nullable<FloatArray>;
  86996. /**
  86997. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86998. */
  86999. uvs2: Nullable<FloatArray>;
  87000. /**
  87001. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87002. */
  87003. uvs3: Nullable<FloatArray>;
  87004. /**
  87005. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87006. */
  87007. uvs4: Nullable<FloatArray>;
  87008. /**
  87009. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87010. */
  87011. uvs5: Nullable<FloatArray>;
  87012. /**
  87013. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87014. */
  87015. uvs6: Nullable<FloatArray>;
  87016. /**
  87017. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  87018. */
  87019. colors: Nullable<FloatArray>;
  87020. /**
  87021. * 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).
  87022. */
  87023. matricesIndices: Nullable<FloatArray>;
  87024. /**
  87025. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  87026. */
  87027. matricesWeights: Nullable<FloatArray>;
  87028. /**
  87029. * An array extending the number of possible indices
  87030. */
  87031. matricesIndicesExtra: Nullable<FloatArray>;
  87032. /**
  87033. * An array extending the number of possible weights when the number of indices is extended
  87034. */
  87035. matricesWeightsExtra: Nullable<FloatArray>;
  87036. /**
  87037. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  87038. */
  87039. indices: Nullable<IndicesArray>;
  87040. /**
  87041. * Uses the passed data array to set the set the values for the specified kind of data
  87042. * @param data a linear array of floating numbers
  87043. * @param kind the type of data that is being set, eg positions, colors etc
  87044. */
  87045. set(data: FloatArray, kind: string): void;
  87046. /**
  87047. * Associates the vertexData to the passed Mesh.
  87048. * Sets it as updatable or not (default `false`)
  87049. * @param mesh the mesh the vertexData is applied to
  87050. * @param updatable when used and having the value true allows new data to update the vertexData
  87051. * @returns the VertexData
  87052. */
  87053. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  87054. /**
  87055. * Associates the vertexData to the passed Geometry.
  87056. * Sets it as updatable or not (default `false`)
  87057. * @param geometry the geometry the vertexData is applied to
  87058. * @param updatable when used and having the value true allows new data to update the vertexData
  87059. * @returns VertexData
  87060. */
  87061. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  87062. /**
  87063. * Updates the associated mesh
  87064. * @param mesh the mesh to be updated
  87065. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87066. * @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
  87067. * @returns VertexData
  87068. */
  87069. updateMesh(mesh: Mesh): VertexData;
  87070. /**
  87071. * Updates the associated geometry
  87072. * @param geometry the geometry to be updated
  87073. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87074. * @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
  87075. * @returns VertexData.
  87076. */
  87077. updateGeometry(geometry: Geometry): VertexData;
  87078. private _applyTo;
  87079. private _update;
  87080. /**
  87081. * Transforms each position and each normal of the vertexData according to the passed Matrix
  87082. * @param matrix the transforming matrix
  87083. * @returns the VertexData
  87084. */
  87085. transform(matrix: Matrix): VertexData;
  87086. /**
  87087. * Merges the passed VertexData into the current one
  87088. * @param other the VertexData to be merged into the current one
  87089. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  87090. * @returns the modified VertexData
  87091. */
  87092. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  87093. private _mergeElement;
  87094. private _validate;
  87095. /**
  87096. * Serializes the VertexData
  87097. * @returns a serialized object
  87098. */
  87099. serialize(): any;
  87100. /**
  87101. * Extracts the vertexData from a mesh
  87102. * @param mesh the mesh from which to extract the VertexData
  87103. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  87104. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87105. * @returns the object VertexData associated to the passed mesh
  87106. */
  87107. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  87108. /**
  87109. * Extracts the vertexData from the geometry
  87110. * @param geometry the geometry from which to extract the VertexData
  87111. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  87112. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87113. * @returns the object VertexData associated to the passed mesh
  87114. */
  87115. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  87116. private static _ExtractFrom;
  87117. /**
  87118. * Creates the VertexData for a Ribbon
  87119. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  87120. * * pathArray array of paths, each of which an array of successive Vector3
  87121. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  87122. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  87123. * * 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
  87124. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87125. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  87126. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  87127. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  87128. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  87129. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  87130. * @returns the VertexData of the ribbon
  87131. */
  87132. static CreateRibbon(options: {
  87133. pathArray: Vector3[][];
  87134. closeArray?: boolean;
  87135. closePath?: boolean;
  87136. offset?: number;
  87137. sideOrientation?: number;
  87138. frontUVs?: Vector4;
  87139. backUVs?: Vector4;
  87140. invertUV?: boolean;
  87141. uvs?: Vector2[];
  87142. colors?: Color4[];
  87143. }): VertexData;
  87144. /**
  87145. * Creates the VertexData for a box
  87146. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87147. * * size sets the width, height and depth of the box to the value of size, optional default 1
  87148. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  87149. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  87150. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  87151. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  87152. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  87153. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87154. * * 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)
  87155. * * 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)
  87156. * @returns the VertexData of the box
  87157. */
  87158. static CreateBox(options: {
  87159. size?: number;
  87160. width?: number;
  87161. height?: number;
  87162. depth?: number;
  87163. faceUV?: Vector4[];
  87164. faceColors?: Color4[];
  87165. sideOrientation?: number;
  87166. frontUVs?: Vector4;
  87167. backUVs?: Vector4;
  87168. }): VertexData;
  87169. /**
  87170. * Creates the VertexData for a tiled box
  87171. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87172. * * faceTiles sets the pattern, tile size and number of tiles for a face
  87173. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  87174. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  87175. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87176. * @returns the VertexData of the box
  87177. */
  87178. static CreateTiledBox(options: {
  87179. pattern?: number;
  87180. width?: number;
  87181. height?: number;
  87182. depth?: number;
  87183. tileSize?: number;
  87184. tileWidth?: number;
  87185. tileHeight?: number;
  87186. alignHorizontal?: number;
  87187. alignVertical?: number;
  87188. faceUV?: Vector4[];
  87189. faceColors?: Color4[];
  87190. sideOrientation?: number;
  87191. }): VertexData;
  87192. /**
  87193. * Creates the VertexData for a tiled plane
  87194. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87195. * * pattern a limited pattern arrangement depending on the number
  87196. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  87197. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  87198. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  87199. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87200. * * 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)
  87201. * * 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)
  87202. * @returns the VertexData of the tiled plane
  87203. */
  87204. static CreateTiledPlane(options: {
  87205. pattern?: number;
  87206. tileSize?: number;
  87207. tileWidth?: number;
  87208. tileHeight?: number;
  87209. size?: number;
  87210. width?: number;
  87211. height?: number;
  87212. alignHorizontal?: number;
  87213. alignVertical?: number;
  87214. sideOrientation?: number;
  87215. frontUVs?: Vector4;
  87216. backUVs?: Vector4;
  87217. }): VertexData;
  87218. /**
  87219. * Creates the VertexData for an ellipsoid, defaults to a sphere
  87220. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87221. * * segments sets the number of horizontal strips optional, default 32
  87222. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  87223. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  87224. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  87225. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  87226. * * 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
  87227. * * 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
  87228. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87229. * * 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)
  87230. * * 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)
  87231. * @returns the VertexData of the ellipsoid
  87232. */
  87233. static CreateSphere(options: {
  87234. segments?: number;
  87235. diameter?: number;
  87236. diameterX?: number;
  87237. diameterY?: number;
  87238. diameterZ?: number;
  87239. arc?: number;
  87240. slice?: number;
  87241. sideOrientation?: number;
  87242. frontUVs?: Vector4;
  87243. backUVs?: Vector4;
  87244. }): VertexData;
  87245. /**
  87246. * Creates the VertexData for a cylinder, cone or prism
  87247. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87248. * * height sets the height (y direction) of the cylinder, optional, default 2
  87249. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  87250. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  87251. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  87252. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87253. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  87254. * * 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
  87255. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87256. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87257. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  87258. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  87259. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87260. * * 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)
  87261. * * 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)
  87262. * @returns the VertexData of the cylinder, cone or prism
  87263. */
  87264. static CreateCylinder(options: {
  87265. height?: number;
  87266. diameterTop?: number;
  87267. diameterBottom?: number;
  87268. diameter?: number;
  87269. tessellation?: number;
  87270. subdivisions?: number;
  87271. arc?: number;
  87272. faceColors?: Color4[];
  87273. faceUV?: Vector4[];
  87274. hasRings?: boolean;
  87275. enclose?: boolean;
  87276. sideOrientation?: number;
  87277. frontUVs?: Vector4;
  87278. backUVs?: Vector4;
  87279. }): VertexData;
  87280. /**
  87281. * Creates the VertexData for a torus
  87282. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87283. * * diameter the diameter of the torus, optional default 1
  87284. * * thickness the diameter of the tube forming the torus, optional default 0.5
  87285. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87286. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87287. * * 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)
  87288. * * 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)
  87289. * @returns the VertexData of the torus
  87290. */
  87291. static CreateTorus(options: {
  87292. diameter?: number;
  87293. thickness?: number;
  87294. tessellation?: number;
  87295. sideOrientation?: number;
  87296. frontUVs?: Vector4;
  87297. backUVs?: Vector4;
  87298. }): VertexData;
  87299. /**
  87300. * Creates the VertexData of the LineSystem
  87301. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  87302. * - lines an array of lines, each line being an array of successive Vector3
  87303. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  87304. * @returns the VertexData of the LineSystem
  87305. */
  87306. static CreateLineSystem(options: {
  87307. lines: Vector3[][];
  87308. colors?: Nullable<Color4[][]>;
  87309. }): VertexData;
  87310. /**
  87311. * Create the VertexData for a DashedLines
  87312. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  87313. * - points an array successive Vector3
  87314. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  87315. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  87316. * - dashNb the intended total number of dashes, optional, default 200
  87317. * @returns the VertexData for the DashedLines
  87318. */
  87319. static CreateDashedLines(options: {
  87320. points: Vector3[];
  87321. dashSize?: number;
  87322. gapSize?: number;
  87323. dashNb?: number;
  87324. }): VertexData;
  87325. /**
  87326. * Creates the VertexData for a Ground
  87327. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87328. * - width the width (x direction) of the ground, optional, default 1
  87329. * - height the height (z direction) of the ground, optional, default 1
  87330. * - subdivisions the number of subdivisions per side, optional, default 1
  87331. * @returns the VertexData of the Ground
  87332. */
  87333. static CreateGround(options: {
  87334. width?: number;
  87335. height?: number;
  87336. subdivisions?: number;
  87337. subdivisionsX?: number;
  87338. subdivisionsY?: number;
  87339. }): VertexData;
  87340. /**
  87341. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  87342. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87343. * * xmin the ground minimum X coordinate, optional, default -1
  87344. * * zmin the ground minimum Z coordinate, optional, default -1
  87345. * * xmax the ground maximum X coordinate, optional, default 1
  87346. * * zmax the ground maximum Z coordinate, optional, default 1
  87347. * * 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}
  87348. * * 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}
  87349. * @returns the VertexData of the TiledGround
  87350. */
  87351. static CreateTiledGround(options: {
  87352. xmin: number;
  87353. zmin: number;
  87354. xmax: number;
  87355. zmax: number;
  87356. subdivisions?: {
  87357. w: number;
  87358. h: number;
  87359. };
  87360. precision?: {
  87361. w: number;
  87362. h: number;
  87363. };
  87364. }): VertexData;
  87365. /**
  87366. * Creates the VertexData of the Ground designed from a heightmap
  87367. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  87368. * * width the width (x direction) of the ground
  87369. * * height the height (z direction) of the ground
  87370. * * subdivisions the number of subdivisions per side
  87371. * * minHeight the minimum altitude on the ground, optional, default 0
  87372. * * maxHeight the maximum altitude on the ground, optional default 1
  87373. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  87374. * * buffer the array holding the image color data
  87375. * * bufferWidth the width of image
  87376. * * bufferHeight the height of image
  87377. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  87378. * @returns the VertexData of the Ground designed from a heightmap
  87379. */
  87380. static CreateGroundFromHeightMap(options: {
  87381. width: number;
  87382. height: number;
  87383. subdivisions: number;
  87384. minHeight: number;
  87385. maxHeight: number;
  87386. colorFilter: Color3;
  87387. buffer: Uint8Array;
  87388. bufferWidth: number;
  87389. bufferHeight: number;
  87390. alphaFilter: number;
  87391. }): VertexData;
  87392. /**
  87393. * Creates the VertexData for a Plane
  87394. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  87395. * * size sets the width and height of the plane to the value of size, optional default 1
  87396. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  87397. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  87398. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87399. * * 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)
  87400. * * 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)
  87401. * @returns the VertexData of the box
  87402. */
  87403. static CreatePlane(options: {
  87404. size?: number;
  87405. width?: number;
  87406. height?: number;
  87407. sideOrientation?: number;
  87408. frontUVs?: Vector4;
  87409. backUVs?: Vector4;
  87410. }): VertexData;
  87411. /**
  87412. * Creates the VertexData of the Disc or regular Polygon
  87413. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  87414. * * radius the radius of the disc, optional default 0.5
  87415. * * tessellation the number of polygon sides, optional, default 64
  87416. * * 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
  87417. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87418. * * 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)
  87419. * * 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)
  87420. * @returns the VertexData of the box
  87421. */
  87422. static CreateDisc(options: {
  87423. radius?: number;
  87424. tessellation?: number;
  87425. arc?: number;
  87426. sideOrientation?: number;
  87427. frontUVs?: Vector4;
  87428. backUVs?: Vector4;
  87429. }): VertexData;
  87430. /**
  87431. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  87432. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  87433. * @param polygon a mesh built from polygonTriangulation.build()
  87434. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87435. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87436. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87437. * @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)
  87438. * @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)
  87439. * @returns the VertexData of the Polygon
  87440. */
  87441. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  87442. /**
  87443. * Creates the VertexData of the IcoSphere
  87444. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  87445. * * radius the radius of the IcoSphere, optional default 1
  87446. * * radiusX allows stretching in the x direction, optional, default radius
  87447. * * radiusY allows stretching in the y direction, optional, default radius
  87448. * * radiusZ allows stretching in the z direction, optional, default radius
  87449. * * flat when true creates a flat shaded mesh, optional, default true
  87450. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87451. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87452. * * 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)
  87453. * * 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)
  87454. * @returns the VertexData of the IcoSphere
  87455. */
  87456. static CreateIcoSphere(options: {
  87457. radius?: number;
  87458. radiusX?: number;
  87459. radiusY?: number;
  87460. radiusZ?: number;
  87461. flat?: boolean;
  87462. subdivisions?: number;
  87463. sideOrientation?: number;
  87464. frontUVs?: Vector4;
  87465. backUVs?: Vector4;
  87466. }): VertexData;
  87467. /**
  87468. * Creates the VertexData for a Polyhedron
  87469. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  87470. * * type provided types are:
  87471. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  87472. * * 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)
  87473. * * size the size of the IcoSphere, optional default 1
  87474. * * sizeX allows stretching in the x direction, optional, default size
  87475. * * sizeY allows stretching in the y direction, optional, default size
  87476. * * sizeZ allows stretching in the z direction, optional, default size
  87477. * * 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
  87478. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87479. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87480. * * flat when true creates a flat shaded mesh, optional, default true
  87481. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87482. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87483. * * 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)
  87484. * * 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)
  87485. * @returns the VertexData of the Polyhedron
  87486. */
  87487. static CreatePolyhedron(options: {
  87488. type?: number;
  87489. size?: number;
  87490. sizeX?: number;
  87491. sizeY?: number;
  87492. sizeZ?: number;
  87493. custom?: any;
  87494. faceUV?: Vector4[];
  87495. faceColors?: Color4[];
  87496. flat?: boolean;
  87497. sideOrientation?: number;
  87498. frontUVs?: Vector4;
  87499. backUVs?: Vector4;
  87500. }): VertexData;
  87501. /**
  87502. * Creates the VertexData for a TorusKnot
  87503. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  87504. * * radius the radius of the torus knot, optional, default 2
  87505. * * tube the thickness of the tube, optional, default 0.5
  87506. * * radialSegments the number of sides on each tube segments, optional, default 32
  87507. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  87508. * * p the number of windings around the z axis, optional, default 2
  87509. * * q the number of windings around the x axis, optional, default 3
  87510. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87511. * * 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)
  87512. * * 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)
  87513. * @returns the VertexData of the Torus Knot
  87514. */
  87515. static CreateTorusKnot(options: {
  87516. radius?: number;
  87517. tube?: number;
  87518. radialSegments?: number;
  87519. tubularSegments?: number;
  87520. p?: number;
  87521. q?: number;
  87522. sideOrientation?: number;
  87523. frontUVs?: Vector4;
  87524. backUVs?: Vector4;
  87525. }): VertexData;
  87526. /**
  87527. * Compute normals for given positions and indices
  87528. * @param positions an array of vertex positions, [...., x, y, z, ......]
  87529. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  87530. * @param normals an array of vertex normals, [...., x, y, z, ......]
  87531. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  87532. * * facetNormals : optional array of facet normals (vector3)
  87533. * * facetPositions : optional array of facet positions (vector3)
  87534. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  87535. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  87536. * * bInfo : optional bounding info, required for facetPartitioning computation
  87537. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  87538. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  87539. * * useRightHandedSystem: optional boolean to for right handed system computation
  87540. * * depthSort : optional boolean to enable the facet depth sort computation
  87541. * * distanceTo : optional Vector3 to compute the facet depth from this location
  87542. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  87543. */
  87544. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  87545. facetNormals?: any;
  87546. facetPositions?: any;
  87547. facetPartitioning?: any;
  87548. ratio?: number;
  87549. bInfo?: any;
  87550. bbSize?: Vector3;
  87551. subDiv?: any;
  87552. useRightHandedSystem?: boolean;
  87553. depthSort?: boolean;
  87554. distanceTo?: Vector3;
  87555. depthSortedFacets?: any;
  87556. }): void;
  87557. /** @hidden */
  87558. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  87559. /**
  87560. * Applies VertexData created from the imported parameters to the geometry
  87561. * @param parsedVertexData the parsed data from an imported file
  87562. * @param geometry the geometry to apply the VertexData to
  87563. */
  87564. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  87565. }
  87566. }
  87567. declare module BABYLON {
  87568. /**
  87569. * Defines a target to use with MorphTargetManager
  87570. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87571. */
  87572. export class MorphTarget implements IAnimatable {
  87573. /** defines the name of the target */
  87574. name: string;
  87575. /**
  87576. * Gets or sets the list of animations
  87577. */
  87578. animations: Animation[];
  87579. private _scene;
  87580. private _positions;
  87581. private _normals;
  87582. private _tangents;
  87583. private _uvs;
  87584. private _influence;
  87585. /**
  87586. * Observable raised when the influence changes
  87587. */
  87588. onInfluenceChanged: Observable<boolean>;
  87589. /** @hidden */
  87590. _onDataLayoutChanged: Observable<void>;
  87591. /**
  87592. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  87593. */
  87594. influence: number;
  87595. /**
  87596. * Gets or sets the id of the morph Target
  87597. */
  87598. id: string;
  87599. private _animationPropertiesOverride;
  87600. /**
  87601. * Gets or sets the animation properties override
  87602. */
  87603. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  87604. /**
  87605. * Creates a new MorphTarget
  87606. * @param name defines the name of the target
  87607. * @param influence defines the influence to use
  87608. * @param scene defines the scene the morphtarget belongs to
  87609. */
  87610. constructor(
  87611. /** defines the name of the target */
  87612. name: string, influence?: number, scene?: Nullable<Scene>);
  87613. /**
  87614. * Gets a boolean defining if the target contains position data
  87615. */
  87616. readonly hasPositions: boolean;
  87617. /**
  87618. * Gets a boolean defining if the target contains normal data
  87619. */
  87620. readonly hasNormals: boolean;
  87621. /**
  87622. * Gets a boolean defining if the target contains tangent data
  87623. */
  87624. readonly hasTangents: boolean;
  87625. /**
  87626. * Gets a boolean defining if the target contains texture coordinates data
  87627. */
  87628. readonly hasUVs: boolean;
  87629. /**
  87630. * Affects position data to this target
  87631. * @param data defines the position data to use
  87632. */
  87633. setPositions(data: Nullable<FloatArray>): void;
  87634. /**
  87635. * Gets the position data stored in this target
  87636. * @returns a FloatArray containing the position data (or null if not present)
  87637. */
  87638. getPositions(): Nullable<FloatArray>;
  87639. /**
  87640. * Affects normal data to this target
  87641. * @param data defines the normal data to use
  87642. */
  87643. setNormals(data: Nullable<FloatArray>): void;
  87644. /**
  87645. * Gets the normal data stored in this target
  87646. * @returns a FloatArray containing the normal data (or null if not present)
  87647. */
  87648. getNormals(): Nullable<FloatArray>;
  87649. /**
  87650. * Affects tangent data to this target
  87651. * @param data defines the tangent data to use
  87652. */
  87653. setTangents(data: Nullable<FloatArray>): void;
  87654. /**
  87655. * Gets the tangent data stored in this target
  87656. * @returns a FloatArray containing the tangent data (or null if not present)
  87657. */
  87658. getTangents(): Nullable<FloatArray>;
  87659. /**
  87660. * Affects texture coordinates data to this target
  87661. * @param data defines the texture coordinates data to use
  87662. */
  87663. setUVs(data: Nullable<FloatArray>): void;
  87664. /**
  87665. * Gets the texture coordinates data stored in this target
  87666. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  87667. */
  87668. getUVs(): Nullable<FloatArray>;
  87669. /**
  87670. * Serializes the current target into a Serialization object
  87671. * @returns the serialized object
  87672. */
  87673. serialize(): any;
  87674. /**
  87675. * Returns the string "MorphTarget"
  87676. * @returns "MorphTarget"
  87677. */
  87678. getClassName(): string;
  87679. /**
  87680. * Creates a new target from serialized data
  87681. * @param serializationObject defines the serialized data to use
  87682. * @returns a new MorphTarget
  87683. */
  87684. static Parse(serializationObject: any): MorphTarget;
  87685. /**
  87686. * Creates a MorphTarget from mesh data
  87687. * @param mesh defines the source mesh
  87688. * @param name defines the name to use for the new target
  87689. * @param influence defines the influence to attach to the target
  87690. * @returns a new MorphTarget
  87691. */
  87692. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  87693. }
  87694. }
  87695. declare module BABYLON {
  87696. /**
  87697. * This class is used to deform meshes using morphing between different targets
  87698. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87699. */
  87700. export class MorphTargetManager {
  87701. private _targets;
  87702. private _targetInfluenceChangedObservers;
  87703. private _targetDataLayoutChangedObservers;
  87704. private _activeTargets;
  87705. private _scene;
  87706. private _influences;
  87707. private _supportsNormals;
  87708. private _supportsTangents;
  87709. private _supportsUVs;
  87710. private _vertexCount;
  87711. private _uniqueId;
  87712. private _tempInfluences;
  87713. /**
  87714. * Gets or sets a boolean indicating if normals must be morphed
  87715. */
  87716. enableNormalMorphing: boolean;
  87717. /**
  87718. * Gets or sets a boolean indicating if tangents must be morphed
  87719. */
  87720. enableTangentMorphing: boolean;
  87721. /**
  87722. * Gets or sets a boolean indicating if UV must be morphed
  87723. */
  87724. enableUVMorphing: boolean;
  87725. /**
  87726. * Creates a new MorphTargetManager
  87727. * @param scene defines the current scene
  87728. */
  87729. constructor(scene?: Nullable<Scene>);
  87730. /**
  87731. * Gets the unique ID of this manager
  87732. */
  87733. readonly uniqueId: number;
  87734. /**
  87735. * Gets the number of vertices handled by this manager
  87736. */
  87737. readonly vertexCount: number;
  87738. /**
  87739. * Gets a boolean indicating if this manager supports morphing of normals
  87740. */
  87741. readonly supportsNormals: boolean;
  87742. /**
  87743. * Gets a boolean indicating if this manager supports morphing of tangents
  87744. */
  87745. readonly supportsTangents: boolean;
  87746. /**
  87747. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  87748. */
  87749. readonly supportsUVs: boolean;
  87750. /**
  87751. * Gets the number of targets stored in this manager
  87752. */
  87753. readonly numTargets: number;
  87754. /**
  87755. * Gets the number of influencers (ie. the number of targets with influences > 0)
  87756. */
  87757. readonly numInfluencers: number;
  87758. /**
  87759. * Gets the list of influences (one per target)
  87760. */
  87761. readonly influences: Float32Array;
  87762. /**
  87763. * Gets the active target at specified index. An active target is a target with an influence > 0
  87764. * @param index defines the index to check
  87765. * @returns the requested target
  87766. */
  87767. getActiveTarget(index: number): MorphTarget;
  87768. /**
  87769. * Gets the target at specified index
  87770. * @param index defines the index to check
  87771. * @returns the requested target
  87772. */
  87773. getTarget(index: number): MorphTarget;
  87774. /**
  87775. * Add a new target to this manager
  87776. * @param target defines the target to add
  87777. */
  87778. addTarget(target: MorphTarget): void;
  87779. /**
  87780. * Removes a target from the manager
  87781. * @param target defines the target to remove
  87782. */
  87783. removeTarget(target: MorphTarget): void;
  87784. /**
  87785. * Serializes the current manager into a Serialization object
  87786. * @returns the serialized object
  87787. */
  87788. serialize(): any;
  87789. private _syncActiveTargets;
  87790. /**
  87791. * Syncrhonize the targets with all the meshes using this morph target manager
  87792. */
  87793. synchronize(): void;
  87794. /**
  87795. * Creates a new MorphTargetManager from serialized data
  87796. * @param serializationObject defines the serialized data
  87797. * @param scene defines the hosting scene
  87798. * @returns the new MorphTargetManager
  87799. */
  87800. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  87801. }
  87802. }
  87803. declare module BABYLON {
  87804. /**
  87805. * Class used to represent a specific level of detail of a mesh
  87806. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  87807. */
  87808. export class MeshLODLevel {
  87809. /** Defines the distance where this level should start being displayed */
  87810. distance: number;
  87811. /** Defines the mesh to use to render this level */
  87812. mesh: Nullable<Mesh>;
  87813. /**
  87814. * Creates a new LOD level
  87815. * @param distance defines the distance where this level should star being displayed
  87816. * @param mesh defines the mesh to use to render this level
  87817. */
  87818. constructor(
  87819. /** Defines the distance where this level should start being displayed */
  87820. distance: number,
  87821. /** Defines the mesh to use to render this level */
  87822. mesh: Nullable<Mesh>);
  87823. }
  87824. }
  87825. declare module BABYLON {
  87826. /**
  87827. * Mesh representing the gorund
  87828. */
  87829. export class GroundMesh extends Mesh {
  87830. /** If octree should be generated */
  87831. generateOctree: boolean;
  87832. private _heightQuads;
  87833. /** @hidden */
  87834. _subdivisionsX: number;
  87835. /** @hidden */
  87836. _subdivisionsY: number;
  87837. /** @hidden */
  87838. _width: number;
  87839. /** @hidden */
  87840. _height: number;
  87841. /** @hidden */
  87842. _minX: number;
  87843. /** @hidden */
  87844. _maxX: number;
  87845. /** @hidden */
  87846. _minZ: number;
  87847. /** @hidden */
  87848. _maxZ: number;
  87849. constructor(name: string, scene: Scene);
  87850. /**
  87851. * "GroundMesh"
  87852. * @returns "GroundMesh"
  87853. */
  87854. getClassName(): string;
  87855. /**
  87856. * The minimum of x and y subdivisions
  87857. */
  87858. readonly subdivisions: number;
  87859. /**
  87860. * X subdivisions
  87861. */
  87862. readonly subdivisionsX: number;
  87863. /**
  87864. * Y subdivisions
  87865. */
  87866. readonly subdivisionsY: number;
  87867. /**
  87868. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  87869. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  87870. * @param chunksCount the number of subdivisions for x and y
  87871. * @param octreeBlocksSize (Default: 32)
  87872. */
  87873. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  87874. /**
  87875. * Returns a height (y) value in the Worl system :
  87876. * the ground altitude at the coordinates (x, z) expressed in the World system.
  87877. * @param x x coordinate
  87878. * @param z z coordinate
  87879. * @returns the ground y position if (x, z) are outside the ground surface.
  87880. */
  87881. getHeightAtCoordinates(x: number, z: number): number;
  87882. /**
  87883. * Returns a normalized vector (Vector3) orthogonal to the ground
  87884. * at the ground coordinates (x, z) expressed in the World system.
  87885. * @param x x coordinate
  87886. * @param z z coordinate
  87887. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  87888. */
  87889. getNormalAtCoordinates(x: number, z: number): Vector3;
  87890. /**
  87891. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  87892. * at the ground coordinates (x, z) expressed in the World system.
  87893. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  87894. * @param x x coordinate
  87895. * @param z z coordinate
  87896. * @param ref vector to store the result
  87897. * @returns the GroundMesh.
  87898. */
  87899. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  87900. /**
  87901. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  87902. * if the ground has been updated.
  87903. * This can be used in the render loop.
  87904. * @returns the GroundMesh.
  87905. */
  87906. updateCoordinateHeights(): GroundMesh;
  87907. private _getFacetAt;
  87908. private _initHeightQuads;
  87909. private _computeHeightQuads;
  87910. /**
  87911. * Serializes this ground mesh
  87912. * @param serializationObject object to write serialization to
  87913. */
  87914. serialize(serializationObject: any): void;
  87915. /**
  87916. * Parses a serialized ground mesh
  87917. * @param parsedMesh the serialized mesh
  87918. * @param scene the scene to create the ground mesh in
  87919. * @returns the created ground mesh
  87920. */
  87921. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  87922. }
  87923. }
  87924. declare module BABYLON {
  87925. /**
  87926. * Interface for Physics-Joint data
  87927. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87928. */
  87929. export interface PhysicsJointData {
  87930. /**
  87931. * The main pivot of the joint
  87932. */
  87933. mainPivot?: Vector3;
  87934. /**
  87935. * The connected pivot of the joint
  87936. */
  87937. connectedPivot?: Vector3;
  87938. /**
  87939. * The main axis of the joint
  87940. */
  87941. mainAxis?: Vector3;
  87942. /**
  87943. * The connected axis of the joint
  87944. */
  87945. connectedAxis?: Vector3;
  87946. /**
  87947. * The collision of the joint
  87948. */
  87949. collision?: boolean;
  87950. /**
  87951. * Native Oimo/Cannon/Energy data
  87952. */
  87953. nativeParams?: any;
  87954. }
  87955. /**
  87956. * This is a holder class for the physics joint created by the physics plugin
  87957. * It holds a set of functions to control the underlying joint
  87958. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87959. */
  87960. export class PhysicsJoint {
  87961. /**
  87962. * The type of the physics joint
  87963. */
  87964. type: number;
  87965. /**
  87966. * The data for the physics joint
  87967. */
  87968. jointData: PhysicsJointData;
  87969. private _physicsJoint;
  87970. protected _physicsPlugin: IPhysicsEnginePlugin;
  87971. /**
  87972. * Initializes the physics joint
  87973. * @param type The type of the physics joint
  87974. * @param jointData The data for the physics joint
  87975. */
  87976. constructor(
  87977. /**
  87978. * The type of the physics joint
  87979. */
  87980. type: number,
  87981. /**
  87982. * The data for the physics joint
  87983. */
  87984. jointData: PhysicsJointData);
  87985. /**
  87986. * Gets the physics joint
  87987. */
  87988. /**
  87989. * Sets the physics joint
  87990. */
  87991. physicsJoint: any;
  87992. /**
  87993. * Sets the physics plugin
  87994. */
  87995. physicsPlugin: IPhysicsEnginePlugin;
  87996. /**
  87997. * Execute a function that is physics-plugin specific.
  87998. * @param {Function} func the function that will be executed.
  87999. * It accepts two parameters: the physics world and the physics joint
  88000. */
  88001. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  88002. /**
  88003. * Distance-Joint type
  88004. */
  88005. static DistanceJoint: number;
  88006. /**
  88007. * Hinge-Joint type
  88008. */
  88009. static HingeJoint: number;
  88010. /**
  88011. * Ball-and-Socket joint type
  88012. */
  88013. static BallAndSocketJoint: number;
  88014. /**
  88015. * Wheel-Joint type
  88016. */
  88017. static WheelJoint: number;
  88018. /**
  88019. * Slider-Joint type
  88020. */
  88021. static SliderJoint: number;
  88022. /**
  88023. * Prismatic-Joint type
  88024. */
  88025. static PrismaticJoint: number;
  88026. /**
  88027. * Universal-Joint type
  88028. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  88029. */
  88030. static UniversalJoint: number;
  88031. /**
  88032. * Hinge-Joint 2 type
  88033. */
  88034. static Hinge2Joint: number;
  88035. /**
  88036. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  88037. */
  88038. static PointToPointJoint: number;
  88039. /**
  88040. * Spring-Joint type
  88041. */
  88042. static SpringJoint: number;
  88043. /**
  88044. * Lock-Joint type
  88045. */
  88046. static LockJoint: number;
  88047. }
  88048. /**
  88049. * A class representing a physics distance joint
  88050. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88051. */
  88052. export class DistanceJoint extends PhysicsJoint {
  88053. /**
  88054. *
  88055. * @param jointData The data for the Distance-Joint
  88056. */
  88057. constructor(jointData: DistanceJointData);
  88058. /**
  88059. * Update the predefined distance.
  88060. * @param maxDistance The maximum preferred distance
  88061. * @param minDistance The minimum preferred distance
  88062. */
  88063. updateDistance(maxDistance: number, minDistance?: number): void;
  88064. }
  88065. /**
  88066. * Represents a Motor-Enabled Joint
  88067. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88068. */
  88069. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  88070. /**
  88071. * Initializes the Motor-Enabled Joint
  88072. * @param type The type of the joint
  88073. * @param jointData The physica joint data for the joint
  88074. */
  88075. constructor(type: number, jointData: PhysicsJointData);
  88076. /**
  88077. * Set the motor values.
  88078. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88079. * @param force the force to apply
  88080. * @param maxForce max force for this motor.
  88081. */
  88082. setMotor(force?: number, maxForce?: number): void;
  88083. /**
  88084. * Set the motor's limits.
  88085. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88086. * @param upperLimit The upper limit of the motor
  88087. * @param lowerLimit The lower limit of the motor
  88088. */
  88089. setLimit(upperLimit: number, lowerLimit?: number): void;
  88090. }
  88091. /**
  88092. * This class represents a single physics Hinge-Joint
  88093. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88094. */
  88095. export class HingeJoint extends MotorEnabledJoint {
  88096. /**
  88097. * Initializes the Hinge-Joint
  88098. * @param jointData The joint data for the Hinge-Joint
  88099. */
  88100. constructor(jointData: PhysicsJointData);
  88101. /**
  88102. * Set the motor values.
  88103. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88104. * @param {number} force the force to apply
  88105. * @param {number} maxForce max force for this motor.
  88106. */
  88107. setMotor(force?: number, maxForce?: number): void;
  88108. /**
  88109. * Set the motor's limits.
  88110. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88111. * @param upperLimit The upper limit of the motor
  88112. * @param lowerLimit The lower limit of the motor
  88113. */
  88114. setLimit(upperLimit: number, lowerLimit?: number): void;
  88115. }
  88116. /**
  88117. * This class represents a dual hinge physics joint (same as wheel joint)
  88118. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88119. */
  88120. export class Hinge2Joint extends MotorEnabledJoint {
  88121. /**
  88122. * Initializes the Hinge2-Joint
  88123. * @param jointData The joint data for the Hinge2-Joint
  88124. */
  88125. constructor(jointData: PhysicsJointData);
  88126. /**
  88127. * Set the motor values.
  88128. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88129. * @param {number} targetSpeed the speed the motor is to reach
  88130. * @param {number} maxForce max force for this motor.
  88131. * @param {motorIndex} the motor's index, 0 or 1.
  88132. */
  88133. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  88134. /**
  88135. * Set the motor limits.
  88136. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88137. * @param {number} upperLimit the upper limit
  88138. * @param {number} lowerLimit lower limit
  88139. * @param {motorIndex} the motor's index, 0 or 1.
  88140. */
  88141. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88142. }
  88143. /**
  88144. * Interface for a motor enabled joint
  88145. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88146. */
  88147. export interface IMotorEnabledJoint {
  88148. /**
  88149. * Physics joint
  88150. */
  88151. physicsJoint: any;
  88152. /**
  88153. * Sets the motor of the motor-enabled joint
  88154. * @param force The force of the motor
  88155. * @param maxForce The maximum force of the motor
  88156. * @param motorIndex The index of the motor
  88157. */
  88158. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  88159. /**
  88160. * Sets the limit of the motor
  88161. * @param upperLimit The upper limit of the motor
  88162. * @param lowerLimit The lower limit of the motor
  88163. * @param motorIndex The index of the motor
  88164. */
  88165. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88166. }
  88167. /**
  88168. * Joint data for a Distance-Joint
  88169. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88170. */
  88171. export interface DistanceJointData extends PhysicsJointData {
  88172. /**
  88173. * Max distance the 2 joint objects can be apart
  88174. */
  88175. maxDistance: number;
  88176. }
  88177. /**
  88178. * Joint data from a spring joint
  88179. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88180. */
  88181. export interface SpringJointData extends PhysicsJointData {
  88182. /**
  88183. * Length of the spring
  88184. */
  88185. length: number;
  88186. /**
  88187. * Stiffness of the spring
  88188. */
  88189. stiffness: number;
  88190. /**
  88191. * Damping of the spring
  88192. */
  88193. damping: number;
  88194. /** this callback will be called when applying the force to the impostors. */
  88195. forceApplicationCallback: () => void;
  88196. }
  88197. }
  88198. declare module BABYLON {
  88199. /**
  88200. * Holds the data for the raycast result
  88201. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88202. */
  88203. export class PhysicsRaycastResult {
  88204. private _hasHit;
  88205. private _hitDistance;
  88206. private _hitNormalWorld;
  88207. private _hitPointWorld;
  88208. private _rayFromWorld;
  88209. private _rayToWorld;
  88210. /**
  88211. * Gets if there was a hit
  88212. */
  88213. readonly hasHit: boolean;
  88214. /**
  88215. * Gets the distance from the hit
  88216. */
  88217. readonly hitDistance: number;
  88218. /**
  88219. * Gets the hit normal/direction in the world
  88220. */
  88221. readonly hitNormalWorld: Vector3;
  88222. /**
  88223. * Gets the hit point in the world
  88224. */
  88225. readonly hitPointWorld: Vector3;
  88226. /**
  88227. * Gets the ray "start point" of the ray in the world
  88228. */
  88229. readonly rayFromWorld: Vector3;
  88230. /**
  88231. * Gets the ray "end point" of the ray in the world
  88232. */
  88233. readonly rayToWorld: Vector3;
  88234. /**
  88235. * Sets the hit data (normal & point in world space)
  88236. * @param hitNormalWorld defines the normal in world space
  88237. * @param hitPointWorld defines the point in world space
  88238. */
  88239. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  88240. /**
  88241. * Sets the distance from the start point to the hit point
  88242. * @param distance
  88243. */
  88244. setHitDistance(distance: number): void;
  88245. /**
  88246. * Calculates the distance manually
  88247. */
  88248. calculateHitDistance(): void;
  88249. /**
  88250. * Resets all the values to default
  88251. * @param from The from point on world space
  88252. * @param to The to point on world space
  88253. */
  88254. reset(from?: Vector3, to?: Vector3): void;
  88255. }
  88256. /**
  88257. * Interface for the size containing width and height
  88258. */
  88259. interface IXYZ {
  88260. /**
  88261. * X
  88262. */
  88263. x: number;
  88264. /**
  88265. * Y
  88266. */
  88267. y: number;
  88268. /**
  88269. * Z
  88270. */
  88271. z: number;
  88272. }
  88273. }
  88274. declare module BABYLON {
  88275. /**
  88276. * Interface used to describe a physics joint
  88277. */
  88278. export interface PhysicsImpostorJoint {
  88279. /** Defines the main impostor to which the joint is linked */
  88280. mainImpostor: PhysicsImpostor;
  88281. /** Defines the impostor that is connected to the main impostor using this joint */
  88282. connectedImpostor: PhysicsImpostor;
  88283. /** Defines the joint itself */
  88284. joint: PhysicsJoint;
  88285. }
  88286. /** @hidden */
  88287. export interface IPhysicsEnginePlugin {
  88288. world: any;
  88289. name: string;
  88290. setGravity(gravity: Vector3): void;
  88291. setTimeStep(timeStep: number): void;
  88292. getTimeStep(): number;
  88293. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  88294. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  88295. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  88296. generatePhysicsBody(impostor: PhysicsImpostor): void;
  88297. removePhysicsBody(impostor: PhysicsImpostor): void;
  88298. generateJoint(joint: PhysicsImpostorJoint): void;
  88299. removeJoint(joint: PhysicsImpostorJoint): void;
  88300. isSupported(): boolean;
  88301. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  88302. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  88303. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  88304. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  88305. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  88306. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  88307. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  88308. getBodyMass(impostor: PhysicsImpostor): number;
  88309. getBodyFriction(impostor: PhysicsImpostor): number;
  88310. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  88311. getBodyRestitution(impostor: PhysicsImpostor): number;
  88312. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  88313. getBodyPressure?(impostor: PhysicsImpostor): number;
  88314. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  88315. getBodyStiffness?(impostor: PhysicsImpostor): number;
  88316. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  88317. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  88318. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  88319. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  88320. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  88321. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  88322. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  88323. sleepBody(impostor: PhysicsImpostor): void;
  88324. wakeUpBody(impostor: PhysicsImpostor): void;
  88325. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  88326. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  88327. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  88328. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88329. getRadius(impostor: PhysicsImpostor): number;
  88330. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  88331. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  88332. dispose(): void;
  88333. }
  88334. /**
  88335. * Interface used to define a physics engine
  88336. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  88337. */
  88338. export interface IPhysicsEngine {
  88339. /**
  88340. * Gets the gravity vector used by the simulation
  88341. */
  88342. gravity: Vector3;
  88343. /**
  88344. * Sets the gravity vector used by the simulation
  88345. * @param gravity defines the gravity vector to use
  88346. */
  88347. setGravity(gravity: Vector3): void;
  88348. /**
  88349. * Set the time step of the physics engine.
  88350. * Default is 1/60.
  88351. * To slow it down, enter 1/600 for example.
  88352. * To speed it up, 1/30
  88353. * @param newTimeStep the new timestep to apply to this world.
  88354. */
  88355. setTimeStep(newTimeStep: number): void;
  88356. /**
  88357. * Get the time step of the physics engine.
  88358. * @returns the current time step
  88359. */
  88360. getTimeStep(): number;
  88361. /**
  88362. * Release all resources
  88363. */
  88364. dispose(): void;
  88365. /**
  88366. * Gets the name of the current physics plugin
  88367. * @returns the name of the plugin
  88368. */
  88369. getPhysicsPluginName(): string;
  88370. /**
  88371. * Adding a new impostor for the impostor tracking.
  88372. * This will be done by the impostor itself.
  88373. * @param impostor the impostor to add
  88374. */
  88375. addImpostor(impostor: PhysicsImpostor): void;
  88376. /**
  88377. * Remove an impostor from the engine.
  88378. * This impostor and its mesh will not longer be updated by the physics engine.
  88379. * @param impostor the impostor to remove
  88380. */
  88381. removeImpostor(impostor: PhysicsImpostor): void;
  88382. /**
  88383. * Add a joint to the physics engine
  88384. * @param mainImpostor defines the main impostor to which the joint is added.
  88385. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  88386. * @param joint defines the joint that will connect both impostors.
  88387. */
  88388. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  88389. /**
  88390. * Removes a joint from the simulation
  88391. * @param mainImpostor defines the impostor used with the joint
  88392. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  88393. * @param joint defines the joint to remove
  88394. */
  88395. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  88396. /**
  88397. * Gets the current plugin used to run the simulation
  88398. * @returns current plugin
  88399. */
  88400. getPhysicsPlugin(): IPhysicsEnginePlugin;
  88401. /**
  88402. * Gets the list of physic impostors
  88403. * @returns an array of PhysicsImpostor
  88404. */
  88405. getImpostors(): Array<PhysicsImpostor>;
  88406. /**
  88407. * Gets the impostor for a physics enabled object
  88408. * @param object defines the object impersonated by the impostor
  88409. * @returns the PhysicsImpostor or null if not found
  88410. */
  88411. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  88412. /**
  88413. * Gets the impostor for a physics body object
  88414. * @param body defines physics body used by the impostor
  88415. * @returns the PhysicsImpostor or null if not found
  88416. */
  88417. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  88418. /**
  88419. * Does a raycast in the physics world
  88420. * @param from when should the ray start?
  88421. * @param to when should the ray end?
  88422. * @returns PhysicsRaycastResult
  88423. */
  88424. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  88425. /**
  88426. * Called by the scene. No need to call it.
  88427. * @param delta defines the timespam between frames
  88428. */
  88429. _step(delta: number): void;
  88430. }
  88431. }
  88432. declare module BABYLON {
  88433. /**
  88434. * The interface for the physics imposter parameters
  88435. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88436. */
  88437. export interface PhysicsImpostorParameters {
  88438. /**
  88439. * The mass of the physics imposter
  88440. */
  88441. mass: number;
  88442. /**
  88443. * The friction of the physics imposter
  88444. */
  88445. friction?: number;
  88446. /**
  88447. * The coefficient of restitution of the physics imposter
  88448. */
  88449. restitution?: number;
  88450. /**
  88451. * The native options of the physics imposter
  88452. */
  88453. nativeOptions?: any;
  88454. /**
  88455. * Specifies if the parent should be ignored
  88456. */
  88457. ignoreParent?: boolean;
  88458. /**
  88459. * Specifies if bi-directional transformations should be disabled
  88460. */
  88461. disableBidirectionalTransformation?: boolean;
  88462. /**
  88463. * The pressure inside the physics imposter, soft object only
  88464. */
  88465. pressure?: number;
  88466. /**
  88467. * The stiffness the physics imposter, soft object only
  88468. */
  88469. stiffness?: number;
  88470. /**
  88471. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  88472. */
  88473. velocityIterations?: number;
  88474. /**
  88475. * The number of iterations used in maintaining consistent vertex positions, soft object only
  88476. */
  88477. positionIterations?: number;
  88478. /**
  88479. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  88480. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  88481. * Add to fix multiple points
  88482. */
  88483. fixedPoints?: number;
  88484. /**
  88485. * The collision margin around a soft object
  88486. */
  88487. margin?: number;
  88488. /**
  88489. * The collision margin around a soft object
  88490. */
  88491. damping?: number;
  88492. /**
  88493. * The path for a rope based on an extrusion
  88494. */
  88495. path?: any;
  88496. /**
  88497. * The shape of an extrusion used for a rope based on an extrusion
  88498. */
  88499. shape?: any;
  88500. }
  88501. /**
  88502. * Interface for a physics-enabled object
  88503. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88504. */
  88505. export interface IPhysicsEnabledObject {
  88506. /**
  88507. * The position of the physics-enabled object
  88508. */
  88509. position: Vector3;
  88510. /**
  88511. * The rotation of the physics-enabled object
  88512. */
  88513. rotationQuaternion: Nullable<Quaternion>;
  88514. /**
  88515. * The scale of the physics-enabled object
  88516. */
  88517. scaling: Vector3;
  88518. /**
  88519. * The rotation of the physics-enabled object
  88520. */
  88521. rotation?: Vector3;
  88522. /**
  88523. * The parent of the physics-enabled object
  88524. */
  88525. parent?: any;
  88526. /**
  88527. * The bounding info of the physics-enabled object
  88528. * @returns The bounding info of the physics-enabled object
  88529. */
  88530. getBoundingInfo(): BoundingInfo;
  88531. /**
  88532. * Computes the world matrix
  88533. * @param force Specifies if the world matrix should be computed by force
  88534. * @returns A world matrix
  88535. */
  88536. computeWorldMatrix(force: boolean): Matrix;
  88537. /**
  88538. * Gets the world matrix
  88539. * @returns A world matrix
  88540. */
  88541. getWorldMatrix?(): Matrix;
  88542. /**
  88543. * Gets the child meshes
  88544. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  88545. * @returns An array of abstract meshes
  88546. */
  88547. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  88548. /**
  88549. * Gets the vertex data
  88550. * @param kind The type of vertex data
  88551. * @returns A nullable array of numbers, or a float32 array
  88552. */
  88553. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  88554. /**
  88555. * Gets the indices from the mesh
  88556. * @returns A nullable array of index arrays
  88557. */
  88558. getIndices?(): Nullable<IndicesArray>;
  88559. /**
  88560. * Gets the scene from the mesh
  88561. * @returns the indices array or null
  88562. */
  88563. getScene?(): Scene;
  88564. /**
  88565. * Gets the absolute position from the mesh
  88566. * @returns the absolute position
  88567. */
  88568. getAbsolutePosition(): Vector3;
  88569. /**
  88570. * Gets the absolute pivot point from the mesh
  88571. * @returns the absolute pivot point
  88572. */
  88573. getAbsolutePivotPoint(): Vector3;
  88574. /**
  88575. * Rotates the mesh
  88576. * @param axis The axis of rotation
  88577. * @param amount The amount of rotation
  88578. * @param space The space of the rotation
  88579. * @returns The rotation transform node
  88580. */
  88581. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  88582. /**
  88583. * Translates the mesh
  88584. * @param axis The axis of translation
  88585. * @param distance The distance of translation
  88586. * @param space The space of the translation
  88587. * @returns The transform node
  88588. */
  88589. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  88590. /**
  88591. * Sets the absolute position of the mesh
  88592. * @param absolutePosition The absolute position of the mesh
  88593. * @returns The transform node
  88594. */
  88595. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  88596. /**
  88597. * Gets the class name of the mesh
  88598. * @returns The class name
  88599. */
  88600. getClassName(): string;
  88601. }
  88602. /**
  88603. * Represents a physics imposter
  88604. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88605. */
  88606. export class PhysicsImpostor {
  88607. /**
  88608. * The physics-enabled object used as the physics imposter
  88609. */
  88610. object: IPhysicsEnabledObject;
  88611. /**
  88612. * The type of the physics imposter
  88613. */
  88614. type: number;
  88615. private _options;
  88616. private _scene?;
  88617. /**
  88618. * The default object size of the imposter
  88619. */
  88620. static DEFAULT_OBJECT_SIZE: Vector3;
  88621. /**
  88622. * The identity quaternion of the imposter
  88623. */
  88624. static IDENTITY_QUATERNION: Quaternion;
  88625. /** @hidden */
  88626. _pluginData: any;
  88627. private _physicsEngine;
  88628. private _physicsBody;
  88629. private _bodyUpdateRequired;
  88630. private _onBeforePhysicsStepCallbacks;
  88631. private _onAfterPhysicsStepCallbacks;
  88632. /** @hidden */
  88633. _onPhysicsCollideCallbacks: Array<{
  88634. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  88635. otherImpostors: Array<PhysicsImpostor>;
  88636. }>;
  88637. private _deltaPosition;
  88638. private _deltaRotation;
  88639. private _deltaRotationConjugated;
  88640. /** @hidden */
  88641. _isFromLine: boolean;
  88642. private _parent;
  88643. private _isDisposed;
  88644. private static _tmpVecs;
  88645. private static _tmpQuat;
  88646. /**
  88647. * Specifies if the physics imposter is disposed
  88648. */
  88649. readonly isDisposed: boolean;
  88650. /**
  88651. * Gets the mass of the physics imposter
  88652. */
  88653. mass: number;
  88654. /**
  88655. * Gets the coefficient of friction
  88656. */
  88657. /**
  88658. * Sets the coefficient of friction
  88659. */
  88660. friction: number;
  88661. /**
  88662. * Gets the coefficient of restitution
  88663. */
  88664. /**
  88665. * Sets the coefficient of restitution
  88666. */
  88667. restitution: number;
  88668. /**
  88669. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  88670. */
  88671. /**
  88672. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  88673. */
  88674. pressure: number;
  88675. /**
  88676. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  88677. */
  88678. /**
  88679. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  88680. */
  88681. stiffness: number;
  88682. /**
  88683. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  88684. */
  88685. /**
  88686. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  88687. */
  88688. velocityIterations: number;
  88689. /**
  88690. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  88691. */
  88692. /**
  88693. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  88694. */
  88695. positionIterations: number;
  88696. /**
  88697. * The unique id of the physics imposter
  88698. * set by the physics engine when adding this impostor to the array
  88699. */
  88700. uniqueId: number;
  88701. /**
  88702. * @hidden
  88703. */
  88704. soft: boolean;
  88705. /**
  88706. * @hidden
  88707. */
  88708. segments: number;
  88709. private _joints;
  88710. /**
  88711. * Initializes the physics imposter
  88712. * @param object The physics-enabled object used as the physics imposter
  88713. * @param type The type of the physics imposter
  88714. * @param _options The options for the physics imposter
  88715. * @param _scene The Babylon scene
  88716. */
  88717. constructor(
  88718. /**
  88719. * The physics-enabled object used as the physics imposter
  88720. */
  88721. object: IPhysicsEnabledObject,
  88722. /**
  88723. * The type of the physics imposter
  88724. */
  88725. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  88726. /**
  88727. * This function will completly initialize this impostor.
  88728. * It will create a new body - but only if this mesh has no parent.
  88729. * If it has, this impostor will not be used other than to define the impostor
  88730. * of the child mesh.
  88731. * @hidden
  88732. */
  88733. _init(): void;
  88734. private _getPhysicsParent;
  88735. /**
  88736. * Should a new body be generated.
  88737. * @returns boolean specifying if body initialization is required
  88738. */
  88739. isBodyInitRequired(): boolean;
  88740. /**
  88741. * Sets the updated scaling
  88742. * @param updated Specifies if the scaling is updated
  88743. */
  88744. setScalingUpdated(): void;
  88745. /**
  88746. * Force a regeneration of this or the parent's impostor's body.
  88747. * Use under cautious - This will remove all joints already implemented.
  88748. */
  88749. forceUpdate(): void;
  88750. /**
  88751. * Gets the body that holds this impostor. Either its own, or its parent.
  88752. */
  88753. /**
  88754. * Set the physics body. Used mainly by the physics engine/plugin
  88755. */
  88756. physicsBody: any;
  88757. /**
  88758. * Get the parent of the physics imposter
  88759. * @returns Physics imposter or null
  88760. */
  88761. /**
  88762. * Sets the parent of the physics imposter
  88763. */
  88764. parent: Nullable<PhysicsImpostor>;
  88765. /**
  88766. * Resets the update flags
  88767. */
  88768. resetUpdateFlags(): void;
  88769. /**
  88770. * Gets the object extend size
  88771. * @returns the object extend size
  88772. */
  88773. getObjectExtendSize(): Vector3;
  88774. /**
  88775. * Gets the object center
  88776. * @returns The object center
  88777. */
  88778. getObjectCenter(): Vector3;
  88779. /**
  88780. * Get a specific parametes from the options parameter
  88781. * @param paramName The object parameter name
  88782. * @returns The object parameter
  88783. */
  88784. getParam(paramName: string): any;
  88785. /**
  88786. * Sets a specific parameter in the options given to the physics plugin
  88787. * @param paramName The parameter name
  88788. * @param value The value of the parameter
  88789. */
  88790. setParam(paramName: string, value: number): void;
  88791. /**
  88792. * Specifically change the body's mass option. Won't recreate the physics body object
  88793. * @param mass The mass of the physics imposter
  88794. */
  88795. setMass(mass: number): void;
  88796. /**
  88797. * Gets the linear velocity
  88798. * @returns linear velocity or null
  88799. */
  88800. getLinearVelocity(): Nullable<Vector3>;
  88801. /**
  88802. * Sets the linear velocity
  88803. * @param velocity linear velocity or null
  88804. */
  88805. setLinearVelocity(velocity: Nullable<Vector3>): void;
  88806. /**
  88807. * Gets the angular velocity
  88808. * @returns angular velocity or null
  88809. */
  88810. getAngularVelocity(): Nullable<Vector3>;
  88811. /**
  88812. * Sets the angular velocity
  88813. * @param velocity The velocity or null
  88814. */
  88815. setAngularVelocity(velocity: Nullable<Vector3>): void;
  88816. /**
  88817. * Execute a function with the physics plugin native code
  88818. * Provide a function the will have two variables - the world object and the physics body object
  88819. * @param func The function to execute with the physics plugin native code
  88820. */
  88821. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  88822. /**
  88823. * Register a function that will be executed before the physics world is stepping forward
  88824. * @param func The function to execute before the physics world is stepped forward
  88825. */
  88826. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88827. /**
  88828. * Unregister a function that will be executed before the physics world is stepping forward
  88829. * @param func The function to execute before the physics world is stepped forward
  88830. */
  88831. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88832. /**
  88833. * Register a function that will be executed after the physics step
  88834. * @param func The function to execute after physics step
  88835. */
  88836. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88837. /**
  88838. * Unregisters a function that will be executed after the physics step
  88839. * @param func The function to execute after physics step
  88840. */
  88841. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88842. /**
  88843. * register a function that will be executed when this impostor collides against a different body
  88844. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  88845. * @param func Callback that is executed on collision
  88846. */
  88847. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  88848. /**
  88849. * Unregisters the physics imposter on contact
  88850. * @param collideAgainst The physics object to collide against
  88851. * @param func Callback to execute on collision
  88852. */
  88853. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  88854. private _tmpQuat;
  88855. private _tmpQuat2;
  88856. /**
  88857. * Get the parent rotation
  88858. * @returns The parent rotation
  88859. */
  88860. getParentsRotation(): Quaternion;
  88861. /**
  88862. * this function is executed by the physics engine.
  88863. */
  88864. beforeStep: () => void;
  88865. /**
  88866. * this function is executed by the physics engine
  88867. */
  88868. afterStep: () => void;
  88869. /**
  88870. * Legacy collision detection event support
  88871. */
  88872. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  88873. /**
  88874. * event and body object due to cannon's event-based architecture.
  88875. */
  88876. onCollide: (e: {
  88877. body: any;
  88878. }) => void;
  88879. /**
  88880. * Apply a force
  88881. * @param force The force to apply
  88882. * @param contactPoint The contact point for the force
  88883. * @returns The physics imposter
  88884. */
  88885. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  88886. /**
  88887. * Apply an impulse
  88888. * @param force The impulse force
  88889. * @param contactPoint The contact point for the impulse force
  88890. * @returns The physics imposter
  88891. */
  88892. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  88893. /**
  88894. * A help function to create a joint
  88895. * @param otherImpostor A physics imposter used to create a joint
  88896. * @param jointType The type of joint
  88897. * @param jointData The data for the joint
  88898. * @returns The physics imposter
  88899. */
  88900. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  88901. /**
  88902. * Add a joint to this impostor with a different impostor
  88903. * @param otherImpostor A physics imposter used to add a joint
  88904. * @param joint The joint to add
  88905. * @returns The physics imposter
  88906. */
  88907. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  88908. /**
  88909. * Add an anchor to a cloth impostor
  88910. * @param otherImpostor rigid impostor to anchor to
  88911. * @param width ratio across width from 0 to 1
  88912. * @param height ratio up height from 0 to 1
  88913. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  88914. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  88915. * @returns impostor the soft imposter
  88916. */
  88917. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  88918. /**
  88919. * Add a hook to a rope impostor
  88920. * @param otherImpostor rigid impostor to anchor to
  88921. * @param length ratio across rope from 0 to 1
  88922. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  88923. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  88924. * @returns impostor the rope imposter
  88925. */
  88926. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  88927. /**
  88928. * Will keep this body still, in a sleep mode.
  88929. * @returns the physics imposter
  88930. */
  88931. sleep(): PhysicsImpostor;
  88932. /**
  88933. * Wake the body up.
  88934. * @returns The physics imposter
  88935. */
  88936. wakeUp(): PhysicsImpostor;
  88937. /**
  88938. * Clones the physics imposter
  88939. * @param newObject The physics imposter clones to this physics-enabled object
  88940. * @returns A nullable physics imposter
  88941. */
  88942. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  88943. /**
  88944. * Disposes the physics imposter
  88945. */
  88946. dispose(): void;
  88947. /**
  88948. * Sets the delta position
  88949. * @param position The delta position amount
  88950. */
  88951. setDeltaPosition(position: Vector3): void;
  88952. /**
  88953. * Sets the delta rotation
  88954. * @param rotation The delta rotation amount
  88955. */
  88956. setDeltaRotation(rotation: Quaternion): void;
  88957. /**
  88958. * Gets the box size of the physics imposter and stores the result in the input parameter
  88959. * @param result Stores the box size
  88960. * @returns The physics imposter
  88961. */
  88962. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  88963. /**
  88964. * Gets the radius of the physics imposter
  88965. * @returns Radius of the physics imposter
  88966. */
  88967. getRadius(): number;
  88968. /**
  88969. * Sync a bone with this impostor
  88970. * @param bone The bone to sync to the impostor.
  88971. * @param boneMesh The mesh that the bone is influencing.
  88972. * @param jointPivot The pivot of the joint / bone in local space.
  88973. * @param distToJoint Optional distance from the impostor to the joint.
  88974. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  88975. */
  88976. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  88977. /**
  88978. * Sync impostor to a bone
  88979. * @param bone The bone that the impostor will be synced to.
  88980. * @param boneMesh The mesh that the bone is influencing.
  88981. * @param jointPivot The pivot of the joint / bone in local space.
  88982. * @param distToJoint Optional distance from the impostor to the joint.
  88983. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  88984. * @param boneAxis Optional vector3 axis the bone is aligned with
  88985. */
  88986. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  88987. /**
  88988. * No-Imposter type
  88989. */
  88990. static NoImpostor: number;
  88991. /**
  88992. * Sphere-Imposter type
  88993. */
  88994. static SphereImpostor: number;
  88995. /**
  88996. * Box-Imposter type
  88997. */
  88998. static BoxImpostor: number;
  88999. /**
  89000. * Plane-Imposter type
  89001. */
  89002. static PlaneImpostor: number;
  89003. /**
  89004. * Mesh-imposter type
  89005. */
  89006. static MeshImpostor: number;
  89007. /**
  89008. * Capsule-Impostor type (Ammo.js plugin only)
  89009. */
  89010. static CapsuleImpostor: number;
  89011. /**
  89012. * Cylinder-Imposter type
  89013. */
  89014. static CylinderImpostor: number;
  89015. /**
  89016. * Particle-Imposter type
  89017. */
  89018. static ParticleImpostor: number;
  89019. /**
  89020. * Heightmap-Imposter type
  89021. */
  89022. static HeightmapImpostor: number;
  89023. /**
  89024. * ConvexHull-Impostor type (Ammo.js plugin only)
  89025. */
  89026. static ConvexHullImpostor: number;
  89027. /**
  89028. * Rope-Imposter type
  89029. */
  89030. static RopeImpostor: number;
  89031. /**
  89032. * Cloth-Imposter type
  89033. */
  89034. static ClothImpostor: number;
  89035. /**
  89036. * Softbody-Imposter type
  89037. */
  89038. static SoftbodyImpostor: number;
  89039. }
  89040. }
  89041. declare module BABYLON {
  89042. /**
  89043. * @hidden
  89044. **/
  89045. export class _CreationDataStorage {
  89046. closePath?: boolean;
  89047. closeArray?: boolean;
  89048. idx: number[];
  89049. dashSize: number;
  89050. gapSize: number;
  89051. path3D: Path3D;
  89052. pathArray: Vector3[][];
  89053. arc: number;
  89054. radius: number;
  89055. cap: number;
  89056. tessellation: number;
  89057. }
  89058. /**
  89059. * @hidden
  89060. **/
  89061. class _InstanceDataStorage {
  89062. visibleInstances: any;
  89063. batchCache: _InstancesBatch;
  89064. instancesBufferSize: number;
  89065. instancesBuffer: Nullable<Buffer>;
  89066. instancesData: Float32Array;
  89067. overridenInstanceCount: number;
  89068. isFrozen: boolean;
  89069. previousBatch: Nullable<_InstancesBatch>;
  89070. hardwareInstancedRendering: boolean;
  89071. sideOrientation: number;
  89072. }
  89073. /**
  89074. * @hidden
  89075. **/
  89076. export class _InstancesBatch {
  89077. mustReturn: boolean;
  89078. visibleInstances: Nullable<InstancedMesh[]>[];
  89079. renderSelf: boolean[];
  89080. hardwareInstancedRendering: boolean[];
  89081. }
  89082. /**
  89083. * Class used to represent renderable models
  89084. */
  89085. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  89086. /**
  89087. * Mesh side orientation : usually the external or front surface
  89088. */
  89089. static readonly FRONTSIDE: number;
  89090. /**
  89091. * Mesh side orientation : usually the internal or back surface
  89092. */
  89093. static readonly BACKSIDE: number;
  89094. /**
  89095. * Mesh side orientation : both internal and external or front and back surfaces
  89096. */
  89097. static readonly DOUBLESIDE: number;
  89098. /**
  89099. * Mesh side orientation : by default, `FRONTSIDE`
  89100. */
  89101. static readonly DEFAULTSIDE: number;
  89102. /**
  89103. * Mesh cap setting : no cap
  89104. */
  89105. static readonly NO_CAP: number;
  89106. /**
  89107. * Mesh cap setting : one cap at the beginning of the mesh
  89108. */
  89109. static readonly CAP_START: number;
  89110. /**
  89111. * Mesh cap setting : one cap at the end of the mesh
  89112. */
  89113. static readonly CAP_END: number;
  89114. /**
  89115. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  89116. */
  89117. static readonly CAP_ALL: number;
  89118. /**
  89119. * Mesh pattern setting : no flip or rotate
  89120. */
  89121. static readonly NO_FLIP: number;
  89122. /**
  89123. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  89124. */
  89125. static readonly FLIP_TILE: number;
  89126. /**
  89127. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  89128. */
  89129. static readonly ROTATE_TILE: number;
  89130. /**
  89131. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  89132. */
  89133. static readonly FLIP_ROW: number;
  89134. /**
  89135. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  89136. */
  89137. static readonly ROTATE_ROW: number;
  89138. /**
  89139. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  89140. */
  89141. static readonly FLIP_N_ROTATE_TILE: number;
  89142. /**
  89143. * Mesh pattern setting : rotate pattern and rotate
  89144. */
  89145. static readonly FLIP_N_ROTATE_ROW: number;
  89146. /**
  89147. * Mesh tile positioning : part tiles same on left/right or top/bottom
  89148. */
  89149. static readonly CENTER: number;
  89150. /**
  89151. * Mesh tile positioning : part tiles on left
  89152. */
  89153. static readonly LEFT: number;
  89154. /**
  89155. * Mesh tile positioning : part tiles on right
  89156. */
  89157. static readonly RIGHT: number;
  89158. /**
  89159. * Mesh tile positioning : part tiles on top
  89160. */
  89161. static readonly TOP: number;
  89162. /**
  89163. * Mesh tile positioning : part tiles on bottom
  89164. */
  89165. static readonly BOTTOM: number;
  89166. /**
  89167. * Gets the default side orientation.
  89168. * @param orientation the orientation to value to attempt to get
  89169. * @returns the default orientation
  89170. * @hidden
  89171. */
  89172. static _GetDefaultSideOrientation(orientation?: number): number;
  89173. private _internalMeshDataInfo;
  89174. /**
  89175. * An event triggered before rendering the mesh
  89176. */
  89177. readonly onBeforeRenderObservable: Observable<Mesh>;
  89178. /**
  89179. * An event triggered before binding the mesh
  89180. */
  89181. readonly onBeforeBindObservable: Observable<Mesh>;
  89182. /**
  89183. * An event triggered after rendering the mesh
  89184. */
  89185. readonly onAfterRenderObservable: Observable<Mesh>;
  89186. /**
  89187. * An event triggered before drawing the mesh
  89188. */
  89189. readonly onBeforeDrawObservable: Observable<Mesh>;
  89190. private _onBeforeDrawObserver;
  89191. /**
  89192. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  89193. */
  89194. onBeforeDraw: () => void;
  89195. readonly hasInstances: boolean;
  89196. /**
  89197. * Gets the delay loading state of the mesh (when delay loading is turned on)
  89198. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  89199. */
  89200. delayLoadState: number;
  89201. /**
  89202. * Gets the list of instances created from this mesh
  89203. * it is not supposed to be modified manually.
  89204. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  89205. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89206. */
  89207. instances: InstancedMesh[];
  89208. /**
  89209. * Gets the file containing delay loading data for this mesh
  89210. */
  89211. delayLoadingFile: string;
  89212. /** @hidden */
  89213. _binaryInfo: any;
  89214. /**
  89215. * User defined function used to change how LOD level selection is done
  89216. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  89217. */
  89218. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  89219. /**
  89220. * Gets or sets the morph target manager
  89221. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  89222. */
  89223. morphTargetManager: Nullable<MorphTargetManager>;
  89224. /** @hidden */
  89225. _creationDataStorage: Nullable<_CreationDataStorage>;
  89226. /** @hidden */
  89227. _geometry: Nullable<Geometry>;
  89228. /** @hidden */
  89229. _delayInfo: Array<string>;
  89230. /** @hidden */
  89231. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  89232. /** @hidden */
  89233. _instanceDataStorage: _InstanceDataStorage;
  89234. private _effectiveMaterial;
  89235. /** @hidden */
  89236. _shouldGenerateFlatShading: boolean;
  89237. /** @hidden */
  89238. _originalBuilderSideOrientation: number;
  89239. /**
  89240. * Use this property to change the original side orientation defined at construction time
  89241. */
  89242. overrideMaterialSideOrientation: Nullable<number>;
  89243. /**
  89244. * Gets the source mesh (the one used to clone this one from)
  89245. */
  89246. readonly source: Nullable<Mesh>;
  89247. /**
  89248. * Gets or sets a boolean indicating that this mesh does not use index buffer
  89249. */
  89250. isUnIndexed: boolean;
  89251. /**
  89252. * @constructor
  89253. * @param name The value used by scene.getMeshByName() to do a lookup.
  89254. * @param scene The scene to add this mesh to.
  89255. * @param parent The parent of this mesh, if it has one
  89256. * @param source An optional Mesh from which geometry is shared, cloned.
  89257. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  89258. * When false, achieved by calling a clone(), also passing False.
  89259. * This will make creation of children, recursive.
  89260. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  89261. */
  89262. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  89263. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  89264. /**
  89265. * Gets the class name
  89266. * @returns the string "Mesh".
  89267. */
  89268. getClassName(): string;
  89269. /** @hidden */
  89270. readonly _isMesh: boolean;
  89271. /**
  89272. * Returns a description of this mesh
  89273. * @param fullDetails define if full details about this mesh must be used
  89274. * @returns a descriptive string representing this mesh
  89275. */
  89276. toString(fullDetails?: boolean): string;
  89277. /** @hidden */
  89278. _unBindEffect(): void;
  89279. /**
  89280. * Gets a boolean indicating if this mesh has LOD
  89281. */
  89282. readonly hasLODLevels: boolean;
  89283. /**
  89284. * Gets the list of MeshLODLevel associated with the current mesh
  89285. * @returns an array of MeshLODLevel
  89286. */
  89287. getLODLevels(): MeshLODLevel[];
  89288. private _sortLODLevels;
  89289. /**
  89290. * Add a mesh as LOD level triggered at the given distance.
  89291. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89292. * @param distance The distance from the center of the object to show this level
  89293. * @param mesh The mesh to be added as LOD level (can be null)
  89294. * @return This mesh (for chaining)
  89295. */
  89296. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  89297. /**
  89298. * Returns the LOD level mesh at the passed distance or null if not found.
  89299. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89300. * @param distance The distance from the center of the object to show this level
  89301. * @returns a Mesh or `null`
  89302. */
  89303. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  89304. /**
  89305. * Remove a mesh from the LOD array
  89306. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89307. * @param mesh defines the mesh to be removed
  89308. * @return This mesh (for chaining)
  89309. */
  89310. removeLODLevel(mesh: Mesh): Mesh;
  89311. /**
  89312. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  89313. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89314. * @param camera defines the camera to use to compute distance
  89315. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  89316. * @return This mesh (for chaining)
  89317. */
  89318. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  89319. /**
  89320. * Gets the mesh internal Geometry object
  89321. */
  89322. readonly geometry: Nullable<Geometry>;
  89323. /**
  89324. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  89325. * @returns the total number of vertices
  89326. */
  89327. getTotalVertices(): number;
  89328. /**
  89329. * Returns the content of an associated vertex buffer
  89330. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89331. * - VertexBuffer.PositionKind
  89332. * - VertexBuffer.UVKind
  89333. * - VertexBuffer.UV2Kind
  89334. * - VertexBuffer.UV3Kind
  89335. * - VertexBuffer.UV4Kind
  89336. * - VertexBuffer.UV5Kind
  89337. * - VertexBuffer.UV6Kind
  89338. * - VertexBuffer.ColorKind
  89339. * - VertexBuffer.MatricesIndicesKind
  89340. * - VertexBuffer.MatricesIndicesExtraKind
  89341. * - VertexBuffer.MatricesWeightsKind
  89342. * - VertexBuffer.MatricesWeightsExtraKind
  89343. * @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
  89344. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  89345. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  89346. */
  89347. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89348. /**
  89349. * Returns the mesh VertexBuffer object from the requested `kind`
  89350. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89351. * - VertexBuffer.PositionKind
  89352. * - VertexBuffer.NormalKind
  89353. * - VertexBuffer.UVKind
  89354. * - VertexBuffer.UV2Kind
  89355. * - VertexBuffer.UV3Kind
  89356. * - VertexBuffer.UV4Kind
  89357. * - VertexBuffer.UV5Kind
  89358. * - VertexBuffer.UV6Kind
  89359. * - VertexBuffer.ColorKind
  89360. * - VertexBuffer.MatricesIndicesKind
  89361. * - VertexBuffer.MatricesIndicesExtraKind
  89362. * - VertexBuffer.MatricesWeightsKind
  89363. * - VertexBuffer.MatricesWeightsExtraKind
  89364. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  89365. */
  89366. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  89367. /**
  89368. * Tests if a specific vertex buffer is associated with this mesh
  89369. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  89370. * - VertexBuffer.PositionKind
  89371. * - VertexBuffer.NormalKind
  89372. * - VertexBuffer.UVKind
  89373. * - VertexBuffer.UV2Kind
  89374. * - VertexBuffer.UV3Kind
  89375. * - VertexBuffer.UV4Kind
  89376. * - VertexBuffer.UV5Kind
  89377. * - VertexBuffer.UV6Kind
  89378. * - VertexBuffer.ColorKind
  89379. * - VertexBuffer.MatricesIndicesKind
  89380. * - VertexBuffer.MatricesIndicesExtraKind
  89381. * - VertexBuffer.MatricesWeightsKind
  89382. * - VertexBuffer.MatricesWeightsExtraKind
  89383. * @returns a boolean
  89384. */
  89385. isVerticesDataPresent(kind: string): boolean;
  89386. /**
  89387. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  89388. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  89389. * - VertexBuffer.PositionKind
  89390. * - VertexBuffer.UVKind
  89391. * - VertexBuffer.UV2Kind
  89392. * - VertexBuffer.UV3Kind
  89393. * - VertexBuffer.UV4Kind
  89394. * - VertexBuffer.UV5Kind
  89395. * - VertexBuffer.UV6Kind
  89396. * - VertexBuffer.ColorKind
  89397. * - VertexBuffer.MatricesIndicesKind
  89398. * - VertexBuffer.MatricesIndicesExtraKind
  89399. * - VertexBuffer.MatricesWeightsKind
  89400. * - VertexBuffer.MatricesWeightsExtraKind
  89401. * @returns a boolean
  89402. */
  89403. isVertexBufferUpdatable(kind: string): boolean;
  89404. /**
  89405. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  89406. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89407. * - VertexBuffer.PositionKind
  89408. * - VertexBuffer.NormalKind
  89409. * - VertexBuffer.UVKind
  89410. * - VertexBuffer.UV2Kind
  89411. * - VertexBuffer.UV3Kind
  89412. * - VertexBuffer.UV4Kind
  89413. * - VertexBuffer.UV5Kind
  89414. * - VertexBuffer.UV6Kind
  89415. * - VertexBuffer.ColorKind
  89416. * - VertexBuffer.MatricesIndicesKind
  89417. * - VertexBuffer.MatricesIndicesExtraKind
  89418. * - VertexBuffer.MatricesWeightsKind
  89419. * - VertexBuffer.MatricesWeightsExtraKind
  89420. * @returns an array of strings
  89421. */
  89422. getVerticesDataKinds(): string[];
  89423. /**
  89424. * Returns a positive integer : the total number of indices in this mesh geometry.
  89425. * @returns the numner of indices or zero if the mesh has no geometry.
  89426. */
  89427. getTotalIndices(): number;
  89428. /**
  89429. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89430. * @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.
  89431. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89432. * @returns the indices array or an empty array if the mesh has no geometry
  89433. */
  89434. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89435. readonly isBlocked: boolean;
  89436. /**
  89437. * Determine if the current mesh is ready to be rendered
  89438. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89439. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  89440. * @returns true if all associated assets are ready (material, textures, shaders)
  89441. */
  89442. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  89443. /**
  89444. * 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.
  89445. */
  89446. readonly areNormalsFrozen: boolean;
  89447. /**
  89448. * 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.
  89449. * @returns the current mesh
  89450. */
  89451. freezeNormals(): Mesh;
  89452. /**
  89453. * 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
  89454. * @returns the current mesh
  89455. */
  89456. unfreezeNormals(): Mesh;
  89457. /**
  89458. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  89459. */
  89460. overridenInstanceCount: number;
  89461. /** @hidden */
  89462. _preActivate(): Mesh;
  89463. /** @hidden */
  89464. _preActivateForIntermediateRendering(renderId: number): Mesh;
  89465. /** @hidden */
  89466. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  89467. /**
  89468. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89469. * This means the mesh underlying bounding box and sphere are recomputed.
  89470. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89471. * @returns the current mesh
  89472. */
  89473. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  89474. /** @hidden */
  89475. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  89476. /**
  89477. * This function will subdivide the mesh into multiple submeshes
  89478. * @param count defines the expected number of submeshes
  89479. */
  89480. subdivide(count: number): void;
  89481. /**
  89482. * Copy a FloatArray into a specific associated vertex buffer
  89483. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89484. * - VertexBuffer.PositionKind
  89485. * - VertexBuffer.UVKind
  89486. * - VertexBuffer.UV2Kind
  89487. * - VertexBuffer.UV3Kind
  89488. * - VertexBuffer.UV4Kind
  89489. * - VertexBuffer.UV5Kind
  89490. * - VertexBuffer.UV6Kind
  89491. * - VertexBuffer.ColorKind
  89492. * - VertexBuffer.MatricesIndicesKind
  89493. * - VertexBuffer.MatricesIndicesExtraKind
  89494. * - VertexBuffer.MatricesWeightsKind
  89495. * - VertexBuffer.MatricesWeightsExtraKind
  89496. * @param data defines the data source
  89497. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  89498. * @param stride defines the data stride size (can be null)
  89499. * @returns the current mesh
  89500. */
  89501. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89502. /**
  89503. * Flags an associated vertex buffer as updatable
  89504. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  89505. * - VertexBuffer.PositionKind
  89506. * - VertexBuffer.UVKind
  89507. * - VertexBuffer.UV2Kind
  89508. * - VertexBuffer.UV3Kind
  89509. * - VertexBuffer.UV4Kind
  89510. * - VertexBuffer.UV5Kind
  89511. * - VertexBuffer.UV6Kind
  89512. * - VertexBuffer.ColorKind
  89513. * - VertexBuffer.MatricesIndicesKind
  89514. * - VertexBuffer.MatricesIndicesExtraKind
  89515. * - VertexBuffer.MatricesWeightsKind
  89516. * - VertexBuffer.MatricesWeightsExtraKind
  89517. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  89518. */
  89519. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  89520. /**
  89521. * Sets the mesh global Vertex Buffer
  89522. * @param buffer defines the buffer to use
  89523. * @returns the current mesh
  89524. */
  89525. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  89526. /**
  89527. * Update a specific associated vertex buffer
  89528. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89529. * - VertexBuffer.PositionKind
  89530. * - VertexBuffer.UVKind
  89531. * - VertexBuffer.UV2Kind
  89532. * - VertexBuffer.UV3Kind
  89533. * - VertexBuffer.UV4Kind
  89534. * - VertexBuffer.UV5Kind
  89535. * - VertexBuffer.UV6Kind
  89536. * - VertexBuffer.ColorKind
  89537. * - VertexBuffer.MatricesIndicesKind
  89538. * - VertexBuffer.MatricesIndicesExtraKind
  89539. * - VertexBuffer.MatricesWeightsKind
  89540. * - VertexBuffer.MatricesWeightsExtraKind
  89541. * @param data defines the data source
  89542. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  89543. * @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)
  89544. * @returns the current mesh
  89545. */
  89546. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  89547. /**
  89548. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  89549. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  89550. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  89551. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  89552. * @returns the current mesh
  89553. */
  89554. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  89555. /**
  89556. * Creates a un-shared specific occurence of the geometry for the mesh.
  89557. * @returns the current mesh
  89558. */
  89559. makeGeometryUnique(): Mesh;
  89560. /**
  89561. * Set the index buffer of this mesh
  89562. * @param indices defines the source data
  89563. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  89564. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  89565. * @returns the current mesh
  89566. */
  89567. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  89568. /**
  89569. * Update the current index buffer
  89570. * @param indices defines the source data
  89571. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  89572. * @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)
  89573. * @returns the current mesh
  89574. */
  89575. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  89576. /**
  89577. * Invert the geometry to move from a right handed system to a left handed one.
  89578. * @returns the current mesh
  89579. */
  89580. toLeftHanded(): Mesh;
  89581. /** @hidden */
  89582. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  89583. /** @hidden */
  89584. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  89585. /**
  89586. * Registers for this mesh a javascript function called just before the rendering process
  89587. * @param func defines the function to call before rendering this mesh
  89588. * @returns the current mesh
  89589. */
  89590. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  89591. /**
  89592. * Disposes a previously registered javascript function called before the rendering
  89593. * @param func defines the function to remove
  89594. * @returns the current mesh
  89595. */
  89596. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  89597. /**
  89598. * Registers for this mesh a javascript function called just after the rendering is complete
  89599. * @param func defines the function to call after rendering this mesh
  89600. * @returns the current mesh
  89601. */
  89602. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  89603. /**
  89604. * Disposes a previously registered javascript function called after the rendering.
  89605. * @param func defines the function to remove
  89606. * @returns the current mesh
  89607. */
  89608. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  89609. /** @hidden */
  89610. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  89611. /** @hidden */
  89612. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  89613. /** @hidden */
  89614. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  89615. /** @hidden */
  89616. _rebuild(): void;
  89617. /** @hidden */
  89618. _freeze(): void;
  89619. /** @hidden */
  89620. _unFreeze(): void;
  89621. /**
  89622. * 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
  89623. * @param subMesh defines the subMesh to render
  89624. * @param enableAlphaMode defines if alpha mode can be changed
  89625. * @returns the current mesh
  89626. */
  89627. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  89628. private _onBeforeDraw;
  89629. /**
  89630. * Renormalize the mesh and patch it up if there are no weights
  89631. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  89632. * However in the case of zero weights then we set just a single influence to 1.
  89633. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  89634. */
  89635. cleanMatrixWeights(): void;
  89636. private normalizeSkinFourWeights;
  89637. private normalizeSkinWeightsAndExtra;
  89638. /**
  89639. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  89640. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  89641. * the user know there was an issue with importing the mesh
  89642. * @returns a validation object with skinned, valid and report string
  89643. */
  89644. validateSkinning(): {
  89645. skinned: boolean;
  89646. valid: boolean;
  89647. report: string;
  89648. };
  89649. /** @hidden */
  89650. _checkDelayState(): Mesh;
  89651. private _queueLoad;
  89652. /**
  89653. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  89654. * A mesh is in the frustum if its bounding box intersects the frustum
  89655. * @param frustumPlanes defines the frustum to test
  89656. * @returns true if the mesh is in the frustum planes
  89657. */
  89658. isInFrustum(frustumPlanes: Plane[]): boolean;
  89659. /**
  89660. * Sets the mesh material by the material or multiMaterial `id` property
  89661. * @param id is a string identifying the material or the multiMaterial
  89662. * @returns the current mesh
  89663. */
  89664. setMaterialByID(id: string): Mesh;
  89665. /**
  89666. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  89667. * @returns an array of IAnimatable
  89668. */
  89669. getAnimatables(): IAnimatable[];
  89670. /**
  89671. * Modifies the mesh geometry according to the passed transformation matrix.
  89672. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  89673. * The mesh normals are modified using the same transformation.
  89674. * Note that, under the hood, this method sets a new VertexBuffer each call.
  89675. * @param transform defines the transform matrix to use
  89676. * @see http://doc.babylonjs.com/resources/baking_transformations
  89677. * @returns the current mesh
  89678. */
  89679. bakeTransformIntoVertices(transform: Matrix): Mesh;
  89680. /**
  89681. * Modifies the mesh geometry according to its own current World Matrix.
  89682. * The mesh World Matrix is then reset.
  89683. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  89684. * Note that, under the hood, this method sets a new VertexBuffer each call.
  89685. * @see http://doc.babylonjs.com/resources/baking_transformations
  89686. * @returns the current mesh
  89687. */
  89688. bakeCurrentTransformIntoVertices(): Mesh;
  89689. /** @hidden */
  89690. readonly _positions: Nullable<Vector3[]>;
  89691. /** @hidden */
  89692. _resetPointsArrayCache(): Mesh;
  89693. /** @hidden */
  89694. _generatePointsArray(): boolean;
  89695. /**
  89696. * Returns a new Mesh object generated from the current mesh properties.
  89697. * This method must not get confused with createInstance()
  89698. * @param name is a string, the name given to the new mesh
  89699. * @param newParent can be any Node object (default `null`)
  89700. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  89701. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  89702. * @returns a new mesh
  89703. */
  89704. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  89705. /**
  89706. * Releases resources associated with this mesh.
  89707. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89708. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89709. */
  89710. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89711. /**
  89712. * Modifies the mesh geometry according to a displacement map.
  89713. * 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.
  89714. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89715. * @param url is a string, the URL from the image file is to be downloaded.
  89716. * @param minHeight is the lower limit of the displacement.
  89717. * @param maxHeight is the upper limit of the displacement.
  89718. * @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.
  89719. * @param uvOffset is an optional vector2 used to offset UV.
  89720. * @param uvScale is an optional vector2 used to scale UV.
  89721. * @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.
  89722. * @returns the Mesh.
  89723. */
  89724. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  89725. /**
  89726. * Modifies the mesh geometry according to a displacementMap buffer.
  89727. * 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.
  89728. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89729. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  89730. * @param heightMapWidth is the width of the buffer image.
  89731. * @param heightMapHeight is the height of the buffer image.
  89732. * @param minHeight is the lower limit of the displacement.
  89733. * @param maxHeight is the upper limit of the displacement.
  89734. * @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.
  89735. * @param uvOffset is an optional vector2 used to offset UV.
  89736. * @param uvScale is an optional vector2 used to scale UV.
  89737. * @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.
  89738. * @returns the Mesh.
  89739. */
  89740. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  89741. /**
  89742. * Modify the mesh to get a flat shading rendering.
  89743. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  89744. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  89745. * @returns current mesh
  89746. */
  89747. convertToFlatShadedMesh(): Mesh;
  89748. /**
  89749. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  89750. * In other words, more vertices, no more indices and a single bigger VBO.
  89751. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  89752. * @returns current mesh
  89753. */
  89754. convertToUnIndexedMesh(): Mesh;
  89755. /**
  89756. * Inverses facet orientations.
  89757. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89758. * @param flipNormals will also inverts the normals
  89759. * @returns current mesh
  89760. */
  89761. flipFaces(flipNormals?: boolean): Mesh;
  89762. /**
  89763. * Increase the number of facets and hence vertices in a mesh
  89764. * Vertex normals are interpolated from existing vertex normals
  89765. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89766. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  89767. */
  89768. increaseVertices(numberPerEdge: number): void;
  89769. /**
  89770. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  89771. * This will undo any application of covertToFlatShadedMesh
  89772. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89773. */
  89774. forceSharedVertices(): void;
  89775. /** @hidden */
  89776. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  89777. /** @hidden */
  89778. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  89779. /**
  89780. * Creates a new InstancedMesh object from the mesh model.
  89781. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89782. * @param name defines the name of the new instance
  89783. * @returns a new InstancedMesh
  89784. */
  89785. createInstance(name: string): InstancedMesh;
  89786. /**
  89787. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  89788. * After this call, all the mesh instances have the same submeshes than the current mesh.
  89789. * @returns the current mesh
  89790. */
  89791. synchronizeInstances(): Mesh;
  89792. /**
  89793. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  89794. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  89795. * This should be used together with the simplification to avoid disappearing triangles.
  89796. * @param successCallback an optional success callback to be called after the optimization finished.
  89797. * @returns the current mesh
  89798. */
  89799. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  89800. /**
  89801. * Serialize current mesh
  89802. * @param serializationObject defines the object which will receive the serialization data
  89803. */
  89804. serialize(serializationObject: any): void;
  89805. /** @hidden */
  89806. _syncGeometryWithMorphTargetManager(): void;
  89807. /** @hidden */
  89808. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  89809. /**
  89810. * Returns a new Mesh object parsed from the source provided.
  89811. * @param parsedMesh is the source
  89812. * @param scene defines the hosting scene
  89813. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  89814. * @returns a new Mesh
  89815. */
  89816. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  89817. /**
  89818. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  89819. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89820. * @param name defines the name of the mesh to create
  89821. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  89822. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  89823. * @param closePath creates a seam between the first and the last points of each path of the path array
  89824. * @param offset is taken in account only if the `pathArray` is containing a single path
  89825. * @param scene defines the hosting scene
  89826. * @param updatable defines if the mesh must be flagged as updatable
  89827. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89828. * @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)
  89829. * @returns a new Mesh
  89830. */
  89831. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  89832. /**
  89833. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  89834. * @param name defines the name of the mesh to create
  89835. * @param radius sets the radius size (float) of the polygon (default 0.5)
  89836. * @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
  89837. * @param scene defines the hosting scene
  89838. * @param updatable defines if the mesh must be flagged as updatable
  89839. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89840. * @returns a new Mesh
  89841. */
  89842. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  89843. /**
  89844. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  89845. * @param name defines the name of the mesh to create
  89846. * @param size sets the size (float) of each box side (default 1)
  89847. * @param scene defines the hosting scene
  89848. * @param updatable defines if the mesh must be flagged as updatable
  89849. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89850. * @returns a new Mesh
  89851. */
  89852. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  89853. /**
  89854. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  89855. * @param name defines the name of the mesh to create
  89856. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  89857. * @param diameter sets the diameter size (float) of the sphere (default 1)
  89858. * @param scene defines the hosting scene
  89859. * @param updatable defines if the mesh must be flagged as updatable
  89860. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89861. * @returns a new Mesh
  89862. */
  89863. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89864. /**
  89865. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  89866. * @param name defines the name of the mesh to create
  89867. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  89868. * @param diameter sets the diameter size (float) of the sphere (default 1)
  89869. * @param scene defines the hosting scene
  89870. * @returns a new Mesh
  89871. */
  89872. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  89873. /**
  89874. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  89875. * @param name defines the name of the mesh to create
  89876. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  89877. * @param diameterTop set the top cap diameter (floats, default 1)
  89878. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  89879. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  89880. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  89881. * @param scene defines the hosting scene
  89882. * @param updatable defines if the mesh must be flagged as updatable
  89883. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89884. * @returns a new Mesh
  89885. */
  89886. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  89887. /**
  89888. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  89889. * @param name defines the name of the mesh to create
  89890. * @param diameter sets the diameter size (float) of the torus (default 1)
  89891. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  89892. * @param tessellation sets the number of torus sides (postive integer, default 16)
  89893. * @param scene defines the hosting scene
  89894. * @param updatable defines if the mesh must be flagged as updatable
  89895. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89896. * @returns a new Mesh
  89897. */
  89898. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89899. /**
  89900. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  89901. * @param name defines the name of the mesh to create
  89902. * @param radius sets the global radius size (float) of the torus knot (default 2)
  89903. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  89904. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  89905. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  89906. * @param p the number of windings on X axis (positive integers, default 2)
  89907. * @param q the number of windings on Y axis (positive integers, default 3)
  89908. * @param scene defines the hosting scene
  89909. * @param updatable defines if the mesh must be flagged as updatable
  89910. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89911. * @returns a new Mesh
  89912. */
  89913. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89914. /**
  89915. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  89916. * @param name defines the name of the mesh to create
  89917. * @param points is an array successive Vector3
  89918. * @param scene defines the hosting scene
  89919. * @param updatable defines if the mesh must be flagged as updatable
  89920. * @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).
  89921. * @returns a new Mesh
  89922. */
  89923. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  89924. /**
  89925. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  89926. * @param name defines the name of the mesh to create
  89927. * @param points is an array successive Vector3
  89928. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  89929. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  89930. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  89931. * @param scene defines the hosting scene
  89932. * @param updatable defines if the mesh must be flagged as updatable
  89933. * @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)
  89934. * @returns a new Mesh
  89935. */
  89936. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  89937. /**
  89938. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  89939. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  89940. * 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.
  89941. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89942. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  89943. * Remember you can only change the shape positions, not their number when updating a polygon.
  89944. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  89945. * @param name defines the name of the mesh to create
  89946. * @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
  89947. * @param scene defines the hosting scene
  89948. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  89949. * @param updatable defines if the mesh must be flagged as updatable
  89950. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89951. * @param earcutInjection can be used to inject your own earcut reference
  89952. * @returns a new Mesh
  89953. */
  89954. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  89955. /**
  89956. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  89957. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  89958. * @param name defines the name of the mesh to create
  89959. * @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
  89960. * @param depth defines the height of extrusion
  89961. * @param scene defines the hosting scene
  89962. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  89963. * @param updatable defines if the mesh must be flagged as updatable
  89964. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89965. * @param earcutInjection can be used to inject your own earcut reference
  89966. * @returns a new Mesh
  89967. */
  89968. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  89969. /**
  89970. * Creates an extruded shape mesh.
  89971. * 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
  89972. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89973. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  89974. * @param name defines the name of the mesh to create
  89975. * @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
  89976. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  89977. * @param scale is the value to scale the shape
  89978. * @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
  89979. * @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
  89980. * @param scene defines the hosting scene
  89981. * @param updatable defines if the mesh must be flagged as updatable
  89982. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89983. * @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)
  89984. * @returns a new Mesh
  89985. */
  89986. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  89987. /**
  89988. * Creates an custom extruded shape mesh.
  89989. * The custom extrusion is a parametric shape.
  89990. * It has no predefined shape. Its final shape will depend on the input parameters.
  89991. * Please consider using the same method from the MeshBuilder class instead
  89992. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  89993. * @param name defines the name of the mesh to create
  89994. * @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
  89995. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  89996. * @param scaleFunction is a custom Javascript function called on each path point
  89997. * @param rotationFunction is a custom Javascript function called on each path point
  89998. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  89999. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  90000. * @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
  90001. * @param scene defines the hosting scene
  90002. * @param updatable defines if the mesh must be flagged as updatable
  90003. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90004. * @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)
  90005. * @returns a new Mesh
  90006. */
  90007. 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;
  90008. /**
  90009. * Creates lathe mesh.
  90010. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  90011. * Please consider using the same method from the MeshBuilder class instead
  90012. * @param name defines the name of the mesh to create
  90013. * @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
  90014. * @param radius is the radius value of the lathe
  90015. * @param tessellation is the side number of the lathe.
  90016. * @param scene defines the hosting scene
  90017. * @param updatable defines if the mesh must be flagged as updatable
  90018. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90019. * @returns a new Mesh
  90020. */
  90021. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90022. /**
  90023. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  90024. * @param name defines the name of the mesh to create
  90025. * @param size sets the size (float) of both sides of the plane at once (default 1)
  90026. * @param scene defines the hosting scene
  90027. * @param updatable defines if the mesh must be flagged as updatable
  90028. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90029. * @returns a new Mesh
  90030. */
  90031. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90032. /**
  90033. * Creates a ground mesh.
  90034. * Please consider using the same method from the MeshBuilder class instead
  90035. * @param name defines the name of the mesh to create
  90036. * @param width set the width of the ground
  90037. * @param height set the height of the ground
  90038. * @param subdivisions sets the number of subdivisions per side
  90039. * @param scene defines the hosting scene
  90040. * @param updatable defines if the mesh must be flagged as updatable
  90041. * @returns a new Mesh
  90042. */
  90043. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  90044. /**
  90045. * Creates a tiled ground mesh.
  90046. * Please consider using the same method from the MeshBuilder class instead
  90047. * @param name defines the name of the mesh to create
  90048. * @param xmin set the ground minimum X coordinate
  90049. * @param zmin set the ground minimum Y coordinate
  90050. * @param xmax set the ground maximum X coordinate
  90051. * @param zmax set the ground maximum Z coordinate
  90052. * @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
  90053. * @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
  90054. * @param scene defines the hosting scene
  90055. * @param updatable defines if the mesh must be flagged as updatable
  90056. * @returns a new Mesh
  90057. */
  90058. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  90059. w: number;
  90060. h: number;
  90061. }, precision: {
  90062. w: number;
  90063. h: number;
  90064. }, scene: Scene, updatable?: boolean): Mesh;
  90065. /**
  90066. * Creates a ground mesh from a height map.
  90067. * Please consider using the same method from the MeshBuilder class instead
  90068. * @see http://doc.babylonjs.com/babylon101/height_map
  90069. * @param name defines the name of the mesh to create
  90070. * @param url sets the URL of the height map image resource
  90071. * @param width set the ground width size
  90072. * @param height set the ground height size
  90073. * @param subdivisions sets the number of subdivision per side
  90074. * @param minHeight is the minimum altitude on the ground
  90075. * @param maxHeight is the maximum altitude on the ground
  90076. * @param scene defines the hosting scene
  90077. * @param updatable defines if the mesh must be flagged as updatable
  90078. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  90079. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  90080. * @returns a new Mesh
  90081. */
  90082. 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;
  90083. /**
  90084. * Creates a tube mesh.
  90085. * The tube is a parametric shape.
  90086. * It has no predefined shape. Its final shape will depend on the input parameters.
  90087. * Please consider using the same method from the MeshBuilder class instead
  90088. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90089. * @param name defines the name of the mesh to create
  90090. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  90091. * @param radius sets the tube radius size
  90092. * @param tessellation is the number of sides on the tubular surface
  90093. * @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
  90094. * @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
  90095. * @param scene defines the hosting scene
  90096. * @param updatable defines if the mesh must be flagged as updatable
  90097. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90098. * @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)
  90099. * @returns a new Mesh
  90100. */
  90101. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  90102. (i: number, distance: number): number;
  90103. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90104. /**
  90105. * Creates a polyhedron mesh.
  90106. * Please consider using the same method from the MeshBuilder class instead.
  90107. * * 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
  90108. * * The parameter `size` (positive float, default 1) sets the polygon size
  90109. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  90110. * * 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`
  90111. * * 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
  90112. * * 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)`)
  90113. * * 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
  90114. * * 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
  90115. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90116. * * If you create a double-sided mesh, you can choose what parts of 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
  90117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90118. * @param name defines the name of the mesh to create
  90119. * @param options defines the options used to create the mesh
  90120. * @param scene defines the hosting scene
  90121. * @returns a new Mesh
  90122. */
  90123. static CreatePolyhedron(name: string, options: {
  90124. type?: number;
  90125. size?: number;
  90126. sizeX?: number;
  90127. sizeY?: number;
  90128. sizeZ?: number;
  90129. custom?: any;
  90130. faceUV?: Vector4[];
  90131. faceColors?: Color4[];
  90132. updatable?: boolean;
  90133. sideOrientation?: number;
  90134. }, scene: Scene): Mesh;
  90135. /**
  90136. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  90137. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  90138. * * 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`)
  90139. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  90140. * * 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
  90141. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90142. * * If you create a double-sided mesh, you can choose what parts of 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
  90143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90144. * @param name defines the name of the mesh
  90145. * @param options defines the options used to create the mesh
  90146. * @param scene defines the hosting scene
  90147. * @returns a new Mesh
  90148. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  90149. */
  90150. static CreateIcoSphere(name: string, options: {
  90151. radius?: number;
  90152. flat?: boolean;
  90153. subdivisions?: number;
  90154. sideOrientation?: number;
  90155. updatable?: boolean;
  90156. }, scene: Scene): Mesh;
  90157. /**
  90158. * Creates a decal mesh.
  90159. * Please consider using the same method from the MeshBuilder class instead.
  90160. * A decal is a mesh usually applied as a model onto the surface of another mesh
  90161. * @param name defines the name of the mesh
  90162. * @param sourceMesh defines the mesh receiving the decal
  90163. * @param position sets the position of the decal in world coordinates
  90164. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  90165. * @param size sets the decal scaling
  90166. * @param angle sets the angle to rotate the decal
  90167. * @returns a new Mesh
  90168. */
  90169. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  90170. /**
  90171. * Prepare internal position array for software CPU skinning
  90172. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  90173. */
  90174. setPositionsForCPUSkinning(): Float32Array;
  90175. /**
  90176. * Prepare internal normal array for software CPU skinning
  90177. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  90178. */
  90179. setNormalsForCPUSkinning(): Float32Array;
  90180. /**
  90181. * Updates the vertex buffer by applying transformation from the bones
  90182. * @param skeleton defines the skeleton to apply to current mesh
  90183. * @returns the current mesh
  90184. */
  90185. applySkeleton(skeleton: Skeleton): Mesh;
  90186. /**
  90187. * 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
  90188. * @param meshes defines the list of meshes to scan
  90189. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  90190. */
  90191. static MinMax(meshes: AbstractMesh[]): {
  90192. min: Vector3;
  90193. max: Vector3;
  90194. };
  90195. /**
  90196. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  90197. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  90198. * @returns a vector3
  90199. */
  90200. static Center(meshesOrMinMaxVector: {
  90201. min: Vector3;
  90202. max: Vector3;
  90203. } | AbstractMesh[]): Vector3;
  90204. /**
  90205. * Merge the array of meshes into a single mesh for performance reasons.
  90206. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  90207. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  90208. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  90209. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  90210. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  90211. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  90212. * @returns a new mesh
  90213. */
  90214. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  90215. /** @hidden */
  90216. addInstance(instance: InstancedMesh): void;
  90217. /** @hidden */
  90218. removeInstance(instance: InstancedMesh): void;
  90219. }
  90220. }
  90221. declare module BABYLON {
  90222. /**
  90223. * This is the base class of all the camera used in the application.
  90224. * @see http://doc.babylonjs.com/features/cameras
  90225. */
  90226. export class Camera extends Node {
  90227. /** @hidden */
  90228. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  90229. /**
  90230. * This is the default projection mode used by the cameras.
  90231. * It helps recreating a feeling of perspective and better appreciate depth.
  90232. * This is the best way to simulate real life cameras.
  90233. */
  90234. static readonly PERSPECTIVE_CAMERA: number;
  90235. /**
  90236. * This helps creating camera with an orthographic mode.
  90237. * 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.
  90238. */
  90239. static readonly ORTHOGRAPHIC_CAMERA: number;
  90240. /**
  90241. * This is the default FOV mode for perspective cameras.
  90242. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  90243. */
  90244. static readonly FOVMODE_VERTICAL_FIXED: number;
  90245. /**
  90246. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  90247. */
  90248. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  90249. /**
  90250. * This specifies ther is no need for a camera rig.
  90251. * Basically only one eye is rendered corresponding to the camera.
  90252. */
  90253. static readonly RIG_MODE_NONE: number;
  90254. /**
  90255. * Simulates a camera Rig with one blue eye and one red eye.
  90256. * This can be use with 3d blue and red glasses.
  90257. */
  90258. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  90259. /**
  90260. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  90261. */
  90262. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  90263. /**
  90264. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  90265. */
  90266. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  90267. /**
  90268. * Defines that both eyes of the camera will be rendered over under each other.
  90269. */
  90270. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  90271. /**
  90272. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  90273. */
  90274. static readonly RIG_MODE_VR: number;
  90275. /**
  90276. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  90277. */
  90278. static readonly RIG_MODE_WEBVR: number;
  90279. /**
  90280. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  90281. */
  90282. static readonly RIG_MODE_CUSTOM: number;
  90283. /**
  90284. * Defines if by default attaching controls should prevent the default javascript event to continue.
  90285. */
  90286. static ForceAttachControlToAlwaysPreventDefault: boolean;
  90287. /**
  90288. * Define the input manager associated with the camera.
  90289. */
  90290. inputs: CameraInputsManager<Camera>;
  90291. /** @hidden */
  90292. _position: Vector3;
  90293. /**
  90294. * Define the current local position of the camera in the scene
  90295. */
  90296. position: Vector3;
  90297. /**
  90298. * The vector the camera should consider as up.
  90299. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  90300. */
  90301. upVector: Vector3;
  90302. /**
  90303. * Define the current limit on the left side for an orthographic camera
  90304. * In scene unit
  90305. */
  90306. orthoLeft: Nullable<number>;
  90307. /**
  90308. * Define the current limit on the right side for an orthographic camera
  90309. * In scene unit
  90310. */
  90311. orthoRight: Nullable<number>;
  90312. /**
  90313. * Define the current limit on the bottom side for an orthographic camera
  90314. * In scene unit
  90315. */
  90316. orthoBottom: Nullable<number>;
  90317. /**
  90318. * Define the current limit on the top side for an orthographic camera
  90319. * In scene unit
  90320. */
  90321. orthoTop: Nullable<number>;
  90322. /**
  90323. * Field Of View is set in Radians. (default is 0.8)
  90324. */
  90325. fov: number;
  90326. /**
  90327. * Define the minimum distance the camera can see from.
  90328. * This is important to note that the depth buffer are not infinite and the closer it starts
  90329. * the more your scene might encounter depth fighting issue.
  90330. */
  90331. minZ: number;
  90332. /**
  90333. * Define the maximum distance the camera can see to.
  90334. * This is important to note that the depth buffer are not infinite and the further it end
  90335. * the more your scene might encounter depth fighting issue.
  90336. */
  90337. maxZ: number;
  90338. /**
  90339. * Define the default inertia of the camera.
  90340. * This helps giving a smooth feeling to the camera movement.
  90341. */
  90342. inertia: number;
  90343. /**
  90344. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  90345. */
  90346. mode: number;
  90347. /**
  90348. * Define wether the camera is intermediate.
  90349. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  90350. */
  90351. isIntermediate: boolean;
  90352. /**
  90353. * Define the viewport of the camera.
  90354. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  90355. */
  90356. viewport: Viewport;
  90357. /**
  90358. * Restricts the camera to viewing objects with the same layerMask.
  90359. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  90360. */
  90361. layerMask: number;
  90362. /**
  90363. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  90364. */
  90365. fovMode: number;
  90366. /**
  90367. * Rig mode of the camera.
  90368. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  90369. * This is normally controlled byt the camera themselves as internal use.
  90370. */
  90371. cameraRigMode: number;
  90372. /**
  90373. * Defines the distance between both "eyes" in case of a RIG
  90374. */
  90375. interaxialDistance: number;
  90376. /**
  90377. * Defines if stereoscopic rendering is done side by side or over under.
  90378. */
  90379. isStereoscopicSideBySide: boolean;
  90380. /**
  90381. * 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
  90382. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  90383. * else in the scene. (Eg. security camera)
  90384. *
  90385. * 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)
  90386. */
  90387. customRenderTargets: RenderTargetTexture[];
  90388. /**
  90389. * When set, the camera will render to this render target instead of the default canvas
  90390. *
  90391. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  90392. */
  90393. outputRenderTarget: Nullable<RenderTargetTexture>;
  90394. /**
  90395. * Observable triggered when the camera view matrix has changed.
  90396. */
  90397. onViewMatrixChangedObservable: Observable<Camera>;
  90398. /**
  90399. * Observable triggered when the camera Projection matrix has changed.
  90400. */
  90401. onProjectionMatrixChangedObservable: Observable<Camera>;
  90402. /**
  90403. * Observable triggered when the inputs have been processed.
  90404. */
  90405. onAfterCheckInputsObservable: Observable<Camera>;
  90406. /**
  90407. * Observable triggered when reset has been called and applied to the camera.
  90408. */
  90409. onRestoreStateObservable: Observable<Camera>;
  90410. /** @hidden */
  90411. _cameraRigParams: any;
  90412. /** @hidden */
  90413. _rigCameras: Camera[];
  90414. /** @hidden */
  90415. _rigPostProcess: Nullable<PostProcess>;
  90416. protected _webvrViewMatrix: Matrix;
  90417. /** @hidden */
  90418. _skipRendering: boolean;
  90419. /** @hidden */
  90420. _projectionMatrix: Matrix;
  90421. /** @hidden */
  90422. _postProcesses: Nullable<PostProcess>[];
  90423. /** @hidden */
  90424. _activeMeshes: SmartArray<AbstractMesh>;
  90425. protected _globalPosition: Vector3;
  90426. /** @hidden */
  90427. _computedViewMatrix: Matrix;
  90428. private _doNotComputeProjectionMatrix;
  90429. private _transformMatrix;
  90430. private _frustumPlanes;
  90431. private _refreshFrustumPlanes;
  90432. private _storedFov;
  90433. private _stateStored;
  90434. /**
  90435. * Instantiates a new camera object.
  90436. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  90437. * @see http://doc.babylonjs.com/features/cameras
  90438. * @param name Defines the name of the camera in the scene
  90439. * @param position Defines the position of the camera
  90440. * @param scene Defines the scene the camera belongs too
  90441. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  90442. */
  90443. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90444. /**
  90445. * Store current camera state (fov, position, etc..)
  90446. * @returns the camera
  90447. */
  90448. storeState(): Camera;
  90449. /**
  90450. * Restores the camera state values if it has been stored. You must call storeState() first
  90451. */
  90452. protected _restoreStateValues(): boolean;
  90453. /**
  90454. * Restored camera state. You must call storeState() first.
  90455. * @returns true if restored and false otherwise
  90456. */
  90457. restoreState(): boolean;
  90458. /**
  90459. * Gets the class name of the camera.
  90460. * @returns the class name
  90461. */
  90462. getClassName(): string;
  90463. /** @hidden */
  90464. readonly _isCamera: boolean;
  90465. /**
  90466. * Gets a string representation of the camera useful for debug purpose.
  90467. * @param fullDetails Defines that a more verboe level of logging is required
  90468. * @returns the string representation
  90469. */
  90470. toString(fullDetails?: boolean): string;
  90471. /**
  90472. * Gets the current world space position of the camera.
  90473. */
  90474. readonly globalPosition: Vector3;
  90475. /**
  90476. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  90477. * @returns the active meshe list
  90478. */
  90479. getActiveMeshes(): SmartArray<AbstractMesh>;
  90480. /**
  90481. * Check wether a mesh is part of the current active mesh list of the camera
  90482. * @param mesh Defines the mesh to check
  90483. * @returns true if active, false otherwise
  90484. */
  90485. isActiveMesh(mesh: Mesh): boolean;
  90486. /**
  90487. * Is this camera ready to be used/rendered
  90488. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  90489. * @return true if the camera is ready
  90490. */
  90491. isReady(completeCheck?: boolean): boolean;
  90492. /** @hidden */
  90493. _initCache(): void;
  90494. /** @hidden */
  90495. _updateCache(ignoreParentClass?: boolean): void;
  90496. /** @hidden */
  90497. _isSynchronized(): boolean;
  90498. /** @hidden */
  90499. _isSynchronizedViewMatrix(): boolean;
  90500. /** @hidden */
  90501. _isSynchronizedProjectionMatrix(): boolean;
  90502. /**
  90503. * Attach the input controls to a specific dom element to get the input from.
  90504. * @param element Defines the element the controls should be listened from
  90505. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90506. */
  90507. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90508. /**
  90509. * Detach the current controls from the specified dom element.
  90510. * @param element Defines the element to stop listening the inputs from
  90511. */
  90512. detachControl(element: HTMLElement): void;
  90513. /**
  90514. * Update the camera state according to the different inputs gathered during the frame.
  90515. */
  90516. update(): void;
  90517. /** @hidden */
  90518. _checkInputs(): void;
  90519. /** @hidden */
  90520. readonly rigCameras: Camera[];
  90521. /**
  90522. * Gets the post process used by the rig cameras
  90523. */
  90524. readonly rigPostProcess: Nullable<PostProcess>;
  90525. /**
  90526. * Internal, gets the first post proces.
  90527. * @returns the first post process to be run on this camera.
  90528. */
  90529. _getFirstPostProcess(): Nullable<PostProcess>;
  90530. private _cascadePostProcessesToRigCams;
  90531. /**
  90532. * Attach a post process to the camera.
  90533. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90534. * @param postProcess The post process to attach to the camera
  90535. * @param insertAt The position of the post process in case several of them are in use in the scene
  90536. * @returns the position the post process has been inserted at
  90537. */
  90538. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  90539. /**
  90540. * Detach a post process to the camera.
  90541. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90542. * @param postProcess The post process to detach from the camera
  90543. */
  90544. detachPostProcess(postProcess: PostProcess): void;
  90545. /**
  90546. * Gets the current world matrix of the camera
  90547. */
  90548. getWorldMatrix(): Matrix;
  90549. /** @hidden */
  90550. _getViewMatrix(): Matrix;
  90551. /**
  90552. * Gets the current view matrix of the camera.
  90553. * @param force forces the camera to recompute the matrix without looking at the cached state
  90554. * @returns the view matrix
  90555. */
  90556. getViewMatrix(force?: boolean): Matrix;
  90557. /**
  90558. * Freeze the projection matrix.
  90559. * It will prevent the cache check of the camera projection compute and can speed up perf
  90560. * if no parameter of the camera are meant to change
  90561. * @param projection Defines manually a projection if necessary
  90562. */
  90563. freezeProjectionMatrix(projection?: Matrix): void;
  90564. /**
  90565. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  90566. */
  90567. unfreezeProjectionMatrix(): void;
  90568. /**
  90569. * Gets the current projection matrix of the camera.
  90570. * @param force forces the camera to recompute the matrix without looking at the cached state
  90571. * @returns the projection matrix
  90572. */
  90573. getProjectionMatrix(force?: boolean): Matrix;
  90574. /**
  90575. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  90576. * @returns a Matrix
  90577. */
  90578. getTransformationMatrix(): Matrix;
  90579. private _updateFrustumPlanes;
  90580. /**
  90581. * Checks if a cullable object (mesh...) is in the camera frustum
  90582. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  90583. * @param target The object to check
  90584. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  90585. * @returns true if the object is in frustum otherwise false
  90586. */
  90587. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  90588. /**
  90589. * Checks if a cullable object (mesh...) is in the camera frustum
  90590. * Unlike isInFrustum this cheks the full bounding box
  90591. * @param target The object to check
  90592. * @returns true if the object is in frustum otherwise false
  90593. */
  90594. isCompletelyInFrustum(target: ICullable): boolean;
  90595. /**
  90596. * Gets a ray in the forward direction from the camera.
  90597. * @param length Defines the length of the ray to create
  90598. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  90599. * @param origin Defines the start point of the ray which defaults to the camera position
  90600. * @returns the forward ray
  90601. */
  90602. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  90603. /**
  90604. * Releases resources associated with this node.
  90605. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90606. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90607. */
  90608. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90609. /** @hidden */
  90610. _isLeftCamera: boolean;
  90611. /**
  90612. * Gets the left camera of a rig setup in case of Rigged Camera
  90613. */
  90614. readonly isLeftCamera: boolean;
  90615. /** @hidden */
  90616. _isRightCamera: boolean;
  90617. /**
  90618. * Gets the right camera of a rig setup in case of Rigged Camera
  90619. */
  90620. readonly isRightCamera: boolean;
  90621. /**
  90622. * Gets the left camera of a rig setup in case of Rigged Camera
  90623. */
  90624. readonly leftCamera: Nullable<FreeCamera>;
  90625. /**
  90626. * Gets the right camera of a rig setup in case of Rigged Camera
  90627. */
  90628. readonly rightCamera: Nullable<FreeCamera>;
  90629. /**
  90630. * Gets the left camera target of a rig setup in case of Rigged Camera
  90631. * @returns the target position
  90632. */
  90633. getLeftTarget(): Nullable<Vector3>;
  90634. /**
  90635. * Gets the right camera target of a rig setup in case of Rigged Camera
  90636. * @returns the target position
  90637. */
  90638. getRightTarget(): Nullable<Vector3>;
  90639. /**
  90640. * @hidden
  90641. */
  90642. setCameraRigMode(mode: number, rigParams: any): void;
  90643. /** @hidden */
  90644. static _setStereoscopicRigMode(camera: Camera): void;
  90645. /** @hidden */
  90646. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  90647. /** @hidden */
  90648. static _setVRRigMode(camera: Camera, rigParams: any): void;
  90649. /** @hidden */
  90650. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  90651. /** @hidden */
  90652. _getVRProjectionMatrix(): Matrix;
  90653. protected _updateCameraRotationMatrix(): void;
  90654. protected _updateWebVRCameraRotationMatrix(): void;
  90655. /**
  90656. * This function MUST be overwritten by the different WebVR cameras available.
  90657. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90658. * @hidden
  90659. */
  90660. _getWebVRProjectionMatrix(): Matrix;
  90661. /**
  90662. * This function MUST be overwritten by the different WebVR cameras available.
  90663. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90664. * @hidden
  90665. */
  90666. _getWebVRViewMatrix(): Matrix;
  90667. /** @hidden */
  90668. setCameraRigParameter(name: string, value: any): void;
  90669. /**
  90670. * needs to be overridden by children so sub has required properties to be copied
  90671. * @hidden
  90672. */
  90673. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90674. /**
  90675. * May need to be overridden by children
  90676. * @hidden
  90677. */
  90678. _updateRigCameras(): void;
  90679. /** @hidden */
  90680. _setupInputs(): void;
  90681. /**
  90682. * Serialiaze the camera setup to a json represention
  90683. * @returns the JSON representation
  90684. */
  90685. serialize(): any;
  90686. /**
  90687. * Clones the current camera.
  90688. * @param name The cloned camera name
  90689. * @returns the cloned camera
  90690. */
  90691. clone(name: string): Camera;
  90692. /**
  90693. * Gets the direction of the camera relative to a given local axis.
  90694. * @param localAxis Defines the reference axis to provide a relative direction.
  90695. * @return the direction
  90696. */
  90697. getDirection(localAxis: Vector3): Vector3;
  90698. /**
  90699. * Returns the current camera absolute rotation
  90700. */
  90701. readonly absoluteRotation: Quaternion;
  90702. /**
  90703. * Gets the direction of the camera relative to a given local axis into a passed vector.
  90704. * @param localAxis Defines the reference axis to provide a relative direction.
  90705. * @param result Defines the vector to store the result in
  90706. */
  90707. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  90708. /**
  90709. * Gets a camera constructor for a given camera type
  90710. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  90711. * @param name The name of the camera the result will be able to instantiate
  90712. * @param scene The scene the result will construct the camera in
  90713. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  90714. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  90715. * @returns a factory method to construc the camera
  90716. */
  90717. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  90718. /**
  90719. * Compute the world matrix of the camera.
  90720. * @returns the camera workd matrix
  90721. */
  90722. computeWorldMatrix(): Matrix;
  90723. /**
  90724. * Parse a JSON and creates the camera from the parsed information
  90725. * @param parsedCamera The JSON to parse
  90726. * @param scene The scene to instantiate the camera in
  90727. * @returns the newly constructed camera
  90728. */
  90729. static Parse(parsedCamera: any, scene: Scene): Camera;
  90730. }
  90731. }
  90732. declare module BABYLON {
  90733. /**
  90734. * Class containing static functions to help procedurally build meshes
  90735. */
  90736. export class DiscBuilder {
  90737. /**
  90738. * Creates a plane polygonal mesh. By default, this is a disc
  90739. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  90740. * * 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
  90741. * * 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
  90742. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90743. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  90744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90745. * @param name defines the name of the mesh
  90746. * @param options defines the options used to create the mesh
  90747. * @param scene defines the hosting scene
  90748. * @returns the plane polygonal mesh
  90749. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  90750. */
  90751. static CreateDisc(name: string, options: {
  90752. radius?: number;
  90753. tessellation?: number;
  90754. arc?: number;
  90755. updatable?: boolean;
  90756. sideOrientation?: number;
  90757. frontUVs?: Vector4;
  90758. backUVs?: Vector4;
  90759. }, scene?: Nullable<Scene>): Mesh;
  90760. }
  90761. }
  90762. declare module BABYLON {
  90763. /**
  90764. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  90765. *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.
  90766. * The SPS is also a particle system. It provides some methods to manage the particles.
  90767. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  90768. *
  90769. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  90770. */
  90771. export class SolidParticleSystem implements IDisposable {
  90772. /**
  90773. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  90774. * Example : var p = SPS.particles[i];
  90775. */
  90776. particles: SolidParticle[];
  90777. /**
  90778. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  90779. */
  90780. nbParticles: number;
  90781. /**
  90782. * If the particles must ever face the camera (default false). Useful for planar particles.
  90783. */
  90784. billboard: boolean;
  90785. /**
  90786. * Recompute normals when adding a shape
  90787. */
  90788. recomputeNormals: boolean;
  90789. /**
  90790. * This a counter ofr your own usage. It's not set by any SPS functions.
  90791. */
  90792. counter: number;
  90793. /**
  90794. * The SPS name. This name is also given to the underlying mesh.
  90795. */
  90796. name: string;
  90797. /**
  90798. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  90799. */
  90800. mesh: Mesh;
  90801. /**
  90802. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  90803. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  90804. */
  90805. vars: any;
  90806. /**
  90807. * This array is populated when the SPS is set as 'pickable'.
  90808. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  90809. * Each element of this array is an object `{idx: int, faceId: int}`.
  90810. * `idx` is the picked particle index in the `SPS.particles` array
  90811. * `faceId` is the picked face index counted within this particle.
  90812. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  90813. */
  90814. pickedParticles: {
  90815. idx: number;
  90816. faceId: number;
  90817. }[];
  90818. /**
  90819. * This array is populated when `enableDepthSort` is set to true.
  90820. * Each element of this array is an instance of the class DepthSortedParticle.
  90821. */
  90822. depthSortedParticles: DepthSortedParticle[];
  90823. /**
  90824. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  90825. * @hidden
  90826. */
  90827. _bSphereOnly: boolean;
  90828. /**
  90829. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  90830. * @hidden
  90831. */
  90832. _bSphereRadiusFactor: number;
  90833. private _scene;
  90834. private _positions;
  90835. private _indices;
  90836. private _normals;
  90837. private _colors;
  90838. private _uvs;
  90839. private _indices32;
  90840. private _positions32;
  90841. private _normals32;
  90842. private _fixedNormal32;
  90843. private _colors32;
  90844. private _uvs32;
  90845. private _index;
  90846. private _updatable;
  90847. private _pickable;
  90848. private _isVisibilityBoxLocked;
  90849. private _alwaysVisible;
  90850. private _depthSort;
  90851. private _shapeCounter;
  90852. private _copy;
  90853. private _color;
  90854. private _computeParticleColor;
  90855. private _computeParticleTexture;
  90856. private _computeParticleRotation;
  90857. private _computeParticleVertex;
  90858. private _computeBoundingBox;
  90859. private _depthSortParticles;
  90860. private _camera;
  90861. private _mustUnrotateFixedNormals;
  90862. private _particlesIntersect;
  90863. private _needs32Bits;
  90864. /**
  90865. * Creates a SPS (Solid Particle System) object.
  90866. * @param name (String) is the SPS name, this will be the underlying mesh name.
  90867. * @param scene (Scene) is the scene in which the SPS is added.
  90868. * @param options defines the options of the sps e.g.
  90869. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  90870. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  90871. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  90872. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  90873. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  90874. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  90875. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  90876. */
  90877. constructor(name: string, scene: Scene, options?: {
  90878. updatable?: boolean;
  90879. isPickable?: boolean;
  90880. enableDepthSort?: boolean;
  90881. particleIntersection?: boolean;
  90882. boundingSphereOnly?: boolean;
  90883. bSphereRadiusFactor?: number;
  90884. });
  90885. /**
  90886. * Builds the SPS underlying mesh. Returns a standard Mesh.
  90887. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  90888. * @returns the created mesh
  90889. */
  90890. buildMesh(): Mesh;
  90891. /**
  90892. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  90893. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  90894. * Thus the particles generated from `digest()` have their property `position` set yet.
  90895. * @param mesh ( Mesh ) is the mesh to be digested
  90896. * @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
  90897. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  90898. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  90899. * @returns the current SPS
  90900. */
  90901. digest(mesh: Mesh, options?: {
  90902. facetNb?: number;
  90903. number?: number;
  90904. delta?: number;
  90905. }): SolidParticleSystem;
  90906. private _unrotateFixedNormals;
  90907. private _resetCopy;
  90908. private _meshBuilder;
  90909. private _posToShape;
  90910. private _uvsToShapeUV;
  90911. private _addParticle;
  90912. /**
  90913. * Adds some particles to the SPS from the model shape. Returns the shape id.
  90914. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  90915. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  90916. * @param nb (positive integer) the number of particles to be created from this model
  90917. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  90918. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  90919. * @returns the number of shapes in the system
  90920. */
  90921. addShape(mesh: Mesh, nb: number, options?: {
  90922. positionFunction?: any;
  90923. vertexFunction?: any;
  90924. }): number;
  90925. private _rebuildParticle;
  90926. /**
  90927. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  90928. * @returns the SPS.
  90929. */
  90930. rebuildMesh(): SolidParticleSystem;
  90931. /**
  90932. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  90933. * This method calls `updateParticle()` for each particle of the SPS.
  90934. * For an animated SPS, it is usually called within the render loop.
  90935. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  90936. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  90937. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  90938. * @returns the SPS.
  90939. */
  90940. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  90941. /**
  90942. * Disposes the SPS.
  90943. */
  90944. dispose(): void;
  90945. /**
  90946. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  90947. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90948. * @returns the SPS.
  90949. */
  90950. refreshVisibleSize(): SolidParticleSystem;
  90951. /**
  90952. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  90953. * @param size the size (float) of the visibility box
  90954. * note : this doesn't lock the SPS mesh bounding box.
  90955. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90956. */
  90957. setVisibilityBox(size: number): void;
  90958. /**
  90959. * Gets whether the SPS as always visible or not
  90960. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90961. */
  90962. /**
  90963. * Sets the SPS as always visible or not
  90964. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90965. */
  90966. isAlwaysVisible: boolean;
  90967. /**
  90968. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  90969. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90970. */
  90971. /**
  90972. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  90973. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90974. */
  90975. isVisibilityBoxLocked: boolean;
  90976. /**
  90977. * Tells to `setParticles()` to compute the particle rotations or not.
  90978. * Default value : true. The SPS is faster when it's set to false.
  90979. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  90980. */
  90981. /**
  90982. * Gets if `setParticles()` computes the particle rotations or not.
  90983. * Default value : true. The SPS is faster when it's set to false.
  90984. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  90985. */
  90986. computeParticleRotation: boolean;
  90987. /**
  90988. * Tells to `setParticles()` to compute the particle colors or not.
  90989. * Default value : true. The SPS is faster when it's set to false.
  90990. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  90991. */
  90992. /**
  90993. * Gets if `setParticles()` computes the particle colors or not.
  90994. * Default value : true. The SPS is faster when it's set to false.
  90995. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  90996. */
  90997. computeParticleColor: boolean;
  90998. /**
  90999. * Gets if `setParticles()` computes the particle textures or not.
  91000. * Default value : true. The SPS is faster when it's set to false.
  91001. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  91002. */
  91003. computeParticleTexture: boolean;
  91004. /**
  91005. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  91006. * Default value : false. The SPS is faster when it's set to false.
  91007. * Note : the particle custom vertex positions aren't stored values.
  91008. */
  91009. /**
  91010. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  91011. * Default value : false. The SPS is faster when it's set to false.
  91012. * Note : the particle custom vertex positions aren't stored values.
  91013. */
  91014. computeParticleVertex: boolean;
  91015. /**
  91016. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  91017. */
  91018. /**
  91019. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  91020. */
  91021. computeBoundingBox: boolean;
  91022. /**
  91023. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  91024. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  91025. * Default : `true`
  91026. */
  91027. /**
  91028. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  91029. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  91030. * Default : `true`
  91031. */
  91032. depthSortParticles: boolean;
  91033. /**
  91034. * This function does nothing. It may be overwritten to set all the particle first values.
  91035. * The SPS doesn't call this function, you may have to call it by your own.
  91036. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91037. */
  91038. initParticles(): void;
  91039. /**
  91040. * This function does nothing. It may be overwritten to recycle a particle.
  91041. * The SPS doesn't call this function, you may have to call it by your own.
  91042. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91043. * @param particle The particle to recycle
  91044. * @returns the recycled particle
  91045. */
  91046. recycleParticle(particle: SolidParticle): SolidParticle;
  91047. /**
  91048. * Updates a particle : this function should be overwritten by the user.
  91049. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  91050. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91051. * @example : just set a particle position or velocity and recycle conditions
  91052. * @param particle The particle to update
  91053. * @returns the updated particle
  91054. */
  91055. updateParticle(particle: SolidParticle): SolidParticle;
  91056. /**
  91057. * Updates a vertex of a particle : it can be overwritten by the user.
  91058. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  91059. * @param particle the current particle
  91060. * @param vertex the current index of the current particle
  91061. * @param pt the index of the current vertex in the particle shape
  91062. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  91063. * @example : just set a vertex particle position
  91064. * @returns the updated vertex
  91065. */
  91066. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  91067. /**
  91068. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  91069. * This does nothing and may be overwritten by the user.
  91070. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91071. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91072. * @param update the boolean update value actually passed to setParticles()
  91073. */
  91074. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  91075. /**
  91076. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  91077. * This will be passed three parameters.
  91078. * This does nothing and may be overwritten by the user.
  91079. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91080. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91081. * @param update the boolean update value actually passed to setParticles()
  91082. */
  91083. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  91084. }
  91085. }
  91086. declare module BABYLON {
  91087. /**
  91088. * Represents one particle of a solid particle system.
  91089. */
  91090. export class SolidParticle {
  91091. /**
  91092. * particle global index
  91093. */
  91094. idx: number;
  91095. /**
  91096. * The color of the particle
  91097. */
  91098. color: Nullable<Color4>;
  91099. /**
  91100. * The world space position of the particle.
  91101. */
  91102. position: Vector3;
  91103. /**
  91104. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  91105. */
  91106. rotation: Vector3;
  91107. /**
  91108. * The world space rotation quaternion of the particle.
  91109. */
  91110. rotationQuaternion: Nullable<Quaternion>;
  91111. /**
  91112. * The scaling of the particle.
  91113. */
  91114. scaling: Vector3;
  91115. /**
  91116. * The uvs of the particle.
  91117. */
  91118. uvs: Vector4;
  91119. /**
  91120. * The current speed of the particle.
  91121. */
  91122. velocity: Vector3;
  91123. /**
  91124. * The pivot point in the particle local space.
  91125. */
  91126. pivot: Vector3;
  91127. /**
  91128. * Must the particle be translated from its pivot point in its local space ?
  91129. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  91130. * Default : false
  91131. */
  91132. translateFromPivot: boolean;
  91133. /**
  91134. * Is the particle active or not ?
  91135. */
  91136. alive: boolean;
  91137. /**
  91138. * Is the particle visible or not ?
  91139. */
  91140. isVisible: boolean;
  91141. /**
  91142. * Index of this particle in the global "positions" array (Internal use)
  91143. * @hidden
  91144. */
  91145. _pos: number;
  91146. /**
  91147. * @hidden Index of this particle in the global "indices" array (Internal use)
  91148. */
  91149. _ind: number;
  91150. /**
  91151. * @hidden ModelShape of this particle (Internal use)
  91152. */
  91153. _model: ModelShape;
  91154. /**
  91155. * ModelShape id of this particle
  91156. */
  91157. shapeId: number;
  91158. /**
  91159. * Index of the particle in its shape id
  91160. */
  91161. idxInShape: number;
  91162. /**
  91163. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  91164. */
  91165. _modelBoundingInfo: BoundingInfo;
  91166. /**
  91167. * @hidden Particle BoundingInfo object (Internal use)
  91168. */
  91169. _boundingInfo: BoundingInfo;
  91170. /**
  91171. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  91172. */
  91173. _sps: SolidParticleSystem;
  91174. /**
  91175. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  91176. */
  91177. _stillInvisible: boolean;
  91178. /**
  91179. * @hidden Last computed particle rotation matrix
  91180. */
  91181. _rotationMatrix: number[];
  91182. /**
  91183. * Parent particle Id, if any.
  91184. * Default null.
  91185. */
  91186. parentId: Nullable<number>;
  91187. /**
  91188. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  91189. * The possible values are :
  91190. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  91191. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91192. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  91193. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  91194. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91195. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  91196. * */
  91197. cullingStrategy: number;
  91198. /**
  91199. * @hidden Internal global position in the SPS.
  91200. */
  91201. _globalPosition: Vector3;
  91202. /**
  91203. * Creates a Solid Particle object.
  91204. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  91205. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  91206. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  91207. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  91208. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  91209. * @param shapeId (integer) is the model shape identifier in the SPS.
  91210. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  91211. * @param sps defines the sps it is associated to
  91212. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  91213. */
  91214. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  91215. /**
  91216. * Legacy support, changed scale to scaling
  91217. */
  91218. /**
  91219. * Legacy support, changed scale to scaling
  91220. */
  91221. scale: Vector3;
  91222. /**
  91223. * Legacy support, changed quaternion to rotationQuaternion
  91224. */
  91225. /**
  91226. * Legacy support, changed quaternion to rotationQuaternion
  91227. */
  91228. quaternion: Nullable<Quaternion>;
  91229. /**
  91230. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  91231. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  91232. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  91233. * @returns true if it intersects
  91234. */
  91235. intersectsMesh(target: Mesh | SolidParticle): boolean;
  91236. /**
  91237. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  91238. * A particle is in the frustum if its bounding box intersects the frustum
  91239. * @param frustumPlanes defines the frustum to test
  91240. * @returns true if the particle is in the frustum planes
  91241. */
  91242. isInFrustum(frustumPlanes: Plane[]): boolean;
  91243. /**
  91244. * get the rotation matrix of the particle
  91245. * @hidden
  91246. */
  91247. getRotationMatrix(m: Matrix): void;
  91248. }
  91249. /**
  91250. * Represents the shape of the model used by one particle of a solid particle system.
  91251. * SPS internal tool, don't use it manually.
  91252. */
  91253. export class ModelShape {
  91254. /**
  91255. * The shape id
  91256. * @hidden
  91257. */
  91258. shapeID: number;
  91259. /**
  91260. * flat array of model positions (internal use)
  91261. * @hidden
  91262. */
  91263. _shape: Vector3[];
  91264. /**
  91265. * flat array of model UVs (internal use)
  91266. * @hidden
  91267. */
  91268. _shapeUV: number[];
  91269. /**
  91270. * length of the shape in the model indices array (internal use)
  91271. * @hidden
  91272. */
  91273. _indicesLength: number;
  91274. /**
  91275. * Custom position function (internal use)
  91276. * @hidden
  91277. */
  91278. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  91279. /**
  91280. * Custom vertex function (internal use)
  91281. * @hidden
  91282. */
  91283. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  91284. /**
  91285. * 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.
  91286. * SPS internal tool, don't use it manually.
  91287. * @hidden
  91288. */
  91289. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  91290. }
  91291. /**
  91292. * Represents a Depth Sorted Particle in the solid particle system.
  91293. */
  91294. export class DepthSortedParticle {
  91295. /**
  91296. * Index of the particle in the "indices" array
  91297. */
  91298. ind: number;
  91299. /**
  91300. * Length of the particle shape in the "indices" array
  91301. */
  91302. indicesLength: number;
  91303. /**
  91304. * Squared distance from the particle to the camera
  91305. */
  91306. sqDistance: number;
  91307. }
  91308. }
  91309. declare module BABYLON {
  91310. /**
  91311. * @hidden
  91312. */
  91313. export class _MeshCollisionData {
  91314. _checkCollisions: boolean;
  91315. _collisionMask: number;
  91316. _collisionGroup: number;
  91317. _collider: Nullable<Collider>;
  91318. _oldPositionForCollisions: Vector3;
  91319. _diffPositionForCollisions: Vector3;
  91320. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  91321. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  91322. }
  91323. }
  91324. declare module BABYLON {
  91325. /** @hidden */
  91326. class _FacetDataStorage {
  91327. facetPositions: Vector3[];
  91328. facetNormals: Vector3[];
  91329. facetPartitioning: number[][];
  91330. facetNb: number;
  91331. partitioningSubdivisions: number;
  91332. partitioningBBoxRatio: number;
  91333. facetDataEnabled: boolean;
  91334. facetParameters: any;
  91335. bbSize: Vector3;
  91336. subDiv: {
  91337. max: number;
  91338. X: number;
  91339. Y: number;
  91340. Z: number;
  91341. };
  91342. facetDepthSort: boolean;
  91343. facetDepthSortEnabled: boolean;
  91344. depthSortedIndices: IndicesArray;
  91345. depthSortedFacets: {
  91346. ind: number;
  91347. sqDistance: number;
  91348. }[];
  91349. facetDepthSortFunction: (f1: {
  91350. ind: number;
  91351. sqDistance: number;
  91352. }, f2: {
  91353. ind: number;
  91354. sqDistance: number;
  91355. }) => number;
  91356. facetDepthSortFrom: Vector3;
  91357. facetDepthSortOrigin: Vector3;
  91358. invertedMatrix: Matrix;
  91359. }
  91360. /**
  91361. * @hidden
  91362. **/
  91363. class _InternalAbstractMeshDataInfo {
  91364. _hasVertexAlpha: boolean;
  91365. _useVertexColors: boolean;
  91366. _numBoneInfluencers: number;
  91367. _applyFog: boolean;
  91368. _receiveShadows: boolean;
  91369. _facetData: _FacetDataStorage;
  91370. _visibility: number;
  91371. _skeleton: Nullable<Skeleton>;
  91372. _layerMask: number;
  91373. _computeBonesUsingShaders: boolean;
  91374. _isActive: boolean;
  91375. _onlyForInstances: boolean;
  91376. _isActiveIntermediate: boolean;
  91377. _onlyForInstancesIntermediate: boolean;
  91378. }
  91379. /**
  91380. * Class used to store all common mesh properties
  91381. */
  91382. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  91383. /** No occlusion */
  91384. static OCCLUSION_TYPE_NONE: number;
  91385. /** Occlusion set to optimisitic */
  91386. static OCCLUSION_TYPE_OPTIMISTIC: number;
  91387. /** Occlusion set to strict */
  91388. static OCCLUSION_TYPE_STRICT: number;
  91389. /** Use an accurante occlusion algorithm */
  91390. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  91391. /** Use a conservative occlusion algorithm */
  91392. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  91393. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  91394. * Test order :
  91395. * Is the bounding sphere outside the frustum ?
  91396. * If not, are the bounding box vertices outside the frustum ?
  91397. * It not, then the cullable object is in the frustum.
  91398. */
  91399. static readonly CULLINGSTRATEGY_STANDARD: number;
  91400. /** Culling strategy : Bounding Sphere Only.
  91401. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  91402. * It's also less accurate than the standard because some not visible objects can still be selected.
  91403. * Test : is the bounding sphere outside the frustum ?
  91404. * If not, then the cullable object is in the frustum.
  91405. */
  91406. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  91407. /** Culling strategy : Optimistic Inclusion.
  91408. * This in an inclusion test first, then the standard exclusion test.
  91409. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  91410. * 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.
  91411. * Anyway, it's as accurate as the standard strategy.
  91412. * Test :
  91413. * Is the cullable object bounding sphere center in the frustum ?
  91414. * If not, apply the default culling strategy.
  91415. */
  91416. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  91417. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  91418. * This in an inclusion test first, then the bounding sphere only exclusion test.
  91419. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  91420. * 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.
  91421. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  91422. * Test :
  91423. * Is the cullable object bounding sphere center in the frustum ?
  91424. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  91425. */
  91426. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  91427. /**
  91428. * No billboard
  91429. */
  91430. static readonly BILLBOARDMODE_NONE: number;
  91431. /** Billboard on X axis */
  91432. static readonly BILLBOARDMODE_X: number;
  91433. /** Billboard on Y axis */
  91434. static readonly BILLBOARDMODE_Y: number;
  91435. /** Billboard on Z axis */
  91436. static readonly BILLBOARDMODE_Z: number;
  91437. /** Billboard on all axes */
  91438. static readonly BILLBOARDMODE_ALL: number;
  91439. /** Billboard on using position instead of orientation */
  91440. static readonly BILLBOARDMODE_USE_POSITION: number;
  91441. /** @hidden */
  91442. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  91443. /**
  91444. * The culling strategy to use to check whether the mesh must be rendered or not.
  91445. * This value can be changed at any time and will be used on the next render mesh selection.
  91446. * The possible values are :
  91447. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  91448. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91449. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  91450. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  91451. * Please read each static variable documentation to get details about the culling process.
  91452. * */
  91453. cullingStrategy: number;
  91454. /**
  91455. * Gets the number of facets in the mesh
  91456. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  91457. */
  91458. readonly facetNb: number;
  91459. /**
  91460. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  91461. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  91462. */
  91463. partitioningSubdivisions: number;
  91464. /**
  91465. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  91466. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  91467. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  91468. */
  91469. partitioningBBoxRatio: number;
  91470. /**
  91471. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  91472. * Works only for updatable meshes.
  91473. * Doesn't work with multi-materials
  91474. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  91475. */
  91476. mustDepthSortFacets: boolean;
  91477. /**
  91478. * The location (Vector3) where the facet depth sort must be computed from.
  91479. * By default, the active camera position.
  91480. * Used only when facet depth sort is enabled
  91481. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  91482. */
  91483. facetDepthSortFrom: Vector3;
  91484. /**
  91485. * gets a boolean indicating if facetData is enabled
  91486. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  91487. */
  91488. readonly isFacetDataEnabled: boolean;
  91489. /** @hidden */
  91490. _updateNonUniformScalingState(value: boolean): boolean;
  91491. /**
  91492. * An event triggered when this mesh collides with another one
  91493. */
  91494. onCollideObservable: Observable<AbstractMesh>;
  91495. /** Set a function to call when this mesh collides with another one */
  91496. onCollide: () => void;
  91497. /**
  91498. * An event triggered when the collision's position changes
  91499. */
  91500. onCollisionPositionChangeObservable: Observable<Vector3>;
  91501. /** Set a function to call when the collision's position changes */
  91502. onCollisionPositionChange: () => void;
  91503. /**
  91504. * An event triggered when material is changed
  91505. */
  91506. onMaterialChangedObservable: Observable<AbstractMesh>;
  91507. /**
  91508. * Gets or sets the orientation for POV movement & rotation
  91509. */
  91510. definedFacingForward: boolean;
  91511. /** @hidden */
  91512. _occlusionQuery: Nullable<WebGLQuery>;
  91513. /** @hidden */
  91514. _renderingGroup: Nullable<RenderingGroup>;
  91515. /**
  91516. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  91517. */
  91518. /**
  91519. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  91520. */
  91521. visibility: number;
  91522. /** Gets or sets the alpha index used to sort transparent meshes
  91523. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  91524. */
  91525. alphaIndex: number;
  91526. /**
  91527. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  91528. */
  91529. isVisible: boolean;
  91530. /**
  91531. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  91532. */
  91533. isPickable: boolean;
  91534. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  91535. showSubMeshesBoundingBox: boolean;
  91536. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  91537. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  91538. */
  91539. isBlocker: boolean;
  91540. /**
  91541. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  91542. */
  91543. enablePointerMoveEvents: boolean;
  91544. /**
  91545. * Specifies the rendering group id for this mesh (0 by default)
  91546. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  91547. */
  91548. renderingGroupId: number;
  91549. private _material;
  91550. /** Gets or sets current material */
  91551. material: Nullable<Material>;
  91552. /**
  91553. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  91554. * @see http://doc.babylonjs.com/babylon101/shadows
  91555. */
  91556. receiveShadows: boolean;
  91557. /** Defines color to use when rendering outline */
  91558. outlineColor: Color3;
  91559. /** Define width to use when rendering outline */
  91560. outlineWidth: number;
  91561. /** Defines color to use when rendering overlay */
  91562. overlayColor: Color3;
  91563. /** Defines alpha to use when rendering overlay */
  91564. overlayAlpha: number;
  91565. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  91566. hasVertexAlpha: boolean;
  91567. /** 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) */
  91568. useVertexColors: boolean;
  91569. /**
  91570. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  91571. */
  91572. computeBonesUsingShaders: boolean;
  91573. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  91574. numBoneInfluencers: number;
  91575. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  91576. applyFog: boolean;
  91577. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  91578. useOctreeForRenderingSelection: boolean;
  91579. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  91580. useOctreeForPicking: boolean;
  91581. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  91582. useOctreeForCollisions: boolean;
  91583. /**
  91584. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  91585. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  91586. */
  91587. layerMask: number;
  91588. /**
  91589. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  91590. */
  91591. alwaysSelectAsActiveMesh: boolean;
  91592. /**
  91593. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  91594. */
  91595. doNotSyncBoundingInfo: boolean;
  91596. /**
  91597. * Gets or sets the current action manager
  91598. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91599. */
  91600. actionManager: Nullable<AbstractActionManager>;
  91601. private _meshCollisionData;
  91602. /**
  91603. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  91604. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91605. */
  91606. ellipsoid: Vector3;
  91607. /**
  91608. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  91609. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91610. */
  91611. ellipsoidOffset: Vector3;
  91612. /**
  91613. * Gets or sets a collision mask used to mask collisions (default is -1).
  91614. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  91615. */
  91616. collisionMask: number;
  91617. /**
  91618. * Gets or sets the current collision group mask (-1 by default).
  91619. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  91620. */
  91621. collisionGroup: number;
  91622. /**
  91623. * Defines edge width used when edgesRenderer is enabled
  91624. * @see https://www.babylonjs-playground.com/#10OJSG#13
  91625. */
  91626. edgesWidth: number;
  91627. /**
  91628. * Defines edge color used when edgesRenderer is enabled
  91629. * @see https://www.babylonjs-playground.com/#10OJSG#13
  91630. */
  91631. edgesColor: Color4;
  91632. /** @hidden */
  91633. _edgesRenderer: Nullable<IEdgesRenderer>;
  91634. /** @hidden */
  91635. _masterMesh: Nullable<AbstractMesh>;
  91636. /** @hidden */
  91637. _boundingInfo: Nullable<BoundingInfo>;
  91638. /** @hidden */
  91639. _renderId: number;
  91640. /**
  91641. * Gets or sets the list of subMeshes
  91642. * @see http://doc.babylonjs.com/how_to/multi_materials
  91643. */
  91644. subMeshes: SubMesh[];
  91645. /** @hidden */
  91646. _intersectionsInProgress: AbstractMesh[];
  91647. /** @hidden */
  91648. _unIndexed: boolean;
  91649. /** @hidden */
  91650. _lightSources: Light[];
  91651. /** Gets the list of lights affecting that mesh */
  91652. readonly lightSources: Light[];
  91653. /** @hidden */
  91654. readonly _positions: Nullable<Vector3[]>;
  91655. /** @hidden */
  91656. _waitingData: {
  91657. lods: Nullable<any>;
  91658. actions: Nullable<any>;
  91659. freezeWorldMatrix: Nullable<boolean>;
  91660. };
  91661. /** @hidden */
  91662. _bonesTransformMatrices: Nullable<Float32Array>;
  91663. /** @hidden */
  91664. _transformMatrixTexture: Nullable<RawTexture>;
  91665. /**
  91666. * Gets or sets a skeleton to apply skining transformations
  91667. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  91668. */
  91669. skeleton: Nullable<Skeleton>;
  91670. /**
  91671. * An event triggered when the mesh is rebuilt.
  91672. */
  91673. onRebuildObservable: Observable<AbstractMesh>;
  91674. /**
  91675. * Creates a new AbstractMesh
  91676. * @param name defines the name of the mesh
  91677. * @param scene defines the hosting scene
  91678. */
  91679. constructor(name: string, scene?: Nullable<Scene>);
  91680. /**
  91681. * Returns the string "AbstractMesh"
  91682. * @returns "AbstractMesh"
  91683. */
  91684. getClassName(): string;
  91685. /**
  91686. * Gets a string representation of the current mesh
  91687. * @param fullDetails defines a boolean indicating if full details must be included
  91688. * @returns a string representation of the current mesh
  91689. */
  91690. toString(fullDetails?: boolean): string;
  91691. /**
  91692. * @hidden
  91693. */
  91694. protected _getEffectiveParent(): Nullable<Node>;
  91695. /** @hidden */
  91696. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  91697. /** @hidden */
  91698. _rebuild(): void;
  91699. /** @hidden */
  91700. _resyncLightSources(): void;
  91701. /** @hidden */
  91702. _resyncLighSource(light: Light): void;
  91703. /** @hidden */
  91704. _unBindEffect(): void;
  91705. /** @hidden */
  91706. _removeLightSource(light: Light, dispose: boolean): void;
  91707. private _markSubMeshesAsDirty;
  91708. /** @hidden */
  91709. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  91710. /** @hidden */
  91711. _markSubMeshesAsAttributesDirty(): void;
  91712. /** @hidden */
  91713. _markSubMeshesAsMiscDirty(): void;
  91714. /**
  91715. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  91716. */
  91717. scaling: Vector3;
  91718. /**
  91719. * Returns true if the mesh is blocked. Implemented by child classes
  91720. */
  91721. readonly isBlocked: boolean;
  91722. /**
  91723. * Returns the mesh itself by default. Implemented by child classes
  91724. * @param camera defines the camera to use to pick the right LOD level
  91725. * @returns the currentAbstractMesh
  91726. */
  91727. getLOD(camera: Camera): Nullable<AbstractMesh>;
  91728. /**
  91729. * Returns 0 by default. Implemented by child classes
  91730. * @returns an integer
  91731. */
  91732. getTotalVertices(): number;
  91733. /**
  91734. * Returns a positive integer : the total number of indices in this mesh geometry.
  91735. * @returns the numner of indices or zero if the mesh has no geometry.
  91736. */
  91737. getTotalIndices(): number;
  91738. /**
  91739. * Returns null by default. Implemented by child classes
  91740. * @returns null
  91741. */
  91742. getIndices(): Nullable<IndicesArray>;
  91743. /**
  91744. * Returns the array of the requested vertex data kind. Implemented by child classes
  91745. * @param kind defines the vertex data kind to use
  91746. * @returns null
  91747. */
  91748. getVerticesData(kind: string): Nullable<FloatArray>;
  91749. /**
  91750. * Sets the vertex data of the mesh geometry for the requested `kind`.
  91751. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  91752. * Note that a new underlying VertexBuffer object is created each call.
  91753. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  91754. * @param kind defines vertex data kind:
  91755. * * VertexBuffer.PositionKind
  91756. * * VertexBuffer.UVKind
  91757. * * VertexBuffer.UV2Kind
  91758. * * VertexBuffer.UV3Kind
  91759. * * VertexBuffer.UV4Kind
  91760. * * VertexBuffer.UV5Kind
  91761. * * VertexBuffer.UV6Kind
  91762. * * VertexBuffer.ColorKind
  91763. * * VertexBuffer.MatricesIndicesKind
  91764. * * VertexBuffer.MatricesIndicesExtraKind
  91765. * * VertexBuffer.MatricesWeightsKind
  91766. * * VertexBuffer.MatricesWeightsExtraKind
  91767. * @param data defines the data source
  91768. * @param updatable defines if the data must be flagged as updatable (or static)
  91769. * @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
  91770. * @returns the current mesh
  91771. */
  91772. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  91773. /**
  91774. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  91775. * If the mesh has no geometry, it is simply returned as it is.
  91776. * @param kind defines vertex data kind:
  91777. * * VertexBuffer.PositionKind
  91778. * * VertexBuffer.UVKind
  91779. * * VertexBuffer.UV2Kind
  91780. * * VertexBuffer.UV3Kind
  91781. * * VertexBuffer.UV4Kind
  91782. * * VertexBuffer.UV5Kind
  91783. * * VertexBuffer.UV6Kind
  91784. * * VertexBuffer.ColorKind
  91785. * * VertexBuffer.MatricesIndicesKind
  91786. * * VertexBuffer.MatricesIndicesExtraKind
  91787. * * VertexBuffer.MatricesWeightsKind
  91788. * * VertexBuffer.MatricesWeightsExtraKind
  91789. * @param data defines the data source
  91790. * @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
  91791. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  91792. * @returns the current mesh
  91793. */
  91794. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  91795. /**
  91796. * Sets the mesh indices,
  91797. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  91798. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  91799. * @param totalVertices Defines the total number of vertices
  91800. * @returns the current mesh
  91801. */
  91802. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  91803. /**
  91804. * Gets a boolean indicating if specific vertex data is present
  91805. * @param kind defines the vertex data kind to use
  91806. * @returns true is data kind is present
  91807. */
  91808. isVerticesDataPresent(kind: string): boolean;
  91809. /**
  91810. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  91811. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  91812. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  91813. * @returns a BoundingInfo
  91814. */
  91815. getBoundingInfo(): BoundingInfo;
  91816. /**
  91817. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  91818. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  91819. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  91820. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  91821. * @returns the current mesh
  91822. */
  91823. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  91824. /**
  91825. * Overwrite the current bounding info
  91826. * @param boundingInfo defines the new bounding info
  91827. * @returns the current mesh
  91828. */
  91829. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  91830. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  91831. readonly useBones: boolean;
  91832. /** @hidden */
  91833. _preActivate(): void;
  91834. /** @hidden */
  91835. _preActivateForIntermediateRendering(renderId: number): void;
  91836. /** @hidden */
  91837. _activate(renderId: number, intermediateRendering: boolean): boolean;
  91838. /** @hidden */
  91839. _postActivate(): void;
  91840. /** @hidden */
  91841. _freeze(): void;
  91842. /** @hidden */
  91843. _unFreeze(): void;
  91844. /**
  91845. * Gets the current world matrix
  91846. * @returns a Matrix
  91847. */
  91848. getWorldMatrix(): Matrix;
  91849. /** @hidden */
  91850. _getWorldMatrixDeterminant(): number;
  91851. /**
  91852. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  91853. */
  91854. readonly isAnInstance: boolean;
  91855. /**
  91856. * Gets a boolean indicating if this mesh has instances
  91857. */
  91858. readonly hasInstances: boolean;
  91859. /**
  91860. * Perform relative position change from the point of view of behind the front of the mesh.
  91861. * This is performed taking into account the meshes current rotation, so you do not have to care.
  91862. * Supports definition of mesh facing forward or backward
  91863. * @param amountRight defines the distance on the right axis
  91864. * @param amountUp defines the distance on the up axis
  91865. * @param amountForward defines the distance on the forward axis
  91866. * @returns the current mesh
  91867. */
  91868. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  91869. /**
  91870. * Calculate relative position change from the point of view of behind the front of the mesh.
  91871. * This is performed taking into account the meshes current rotation, so you do not have to care.
  91872. * Supports definition of mesh facing forward or backward
  91873. * @param amountRight defines the distance on the right axis
  91874. * @param amountUp defines the distance on the up axis
  91875. * @param amountForward defines the distance on the forward axis
  91876. * @returns the new displacement vector
  91877. */
  91878. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  91879. /**
  91880. * Perform relative rotation change from the point of view of behind the front of the mesh.
  91881. * Supports definition of mesh facing forward or backward
  91882. * @param flipBack defines the flip
  91883. * @param twirlClockwise defines the twirl
  91884. * @param tiltRight defines the tilt
  91885. * @returns the current mesh
  91886. */
  91887. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  91888. /**
  91889. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  91890. * Supports definition of mesh facing forward or backward.
  91891. * @param flipBack defines the flip
  91892. * @param twirlClockwise defines the twirl
  91893. * @param tiltRight defines the tilt
  91894. * @returns the new rotation vector
  91895. */
  91896. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  91897. /**
  91898. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  91899. * This means the mesh underlying bounding box and sphere are recomputed.
  91900. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  91901. * @returns the current mesh
  91902. */
  91903. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  91904. /** @hidden */
  91905. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  91906. /** @hidden */
  91907. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  91908. /** @hidden */
  91909. _updateBoundingInfo(): AbstractMesh;
  91910. /** @hidden */
  91911. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  91912. /** @hidden */
  91913. protected _afterComputeWorldMatrix(): void;
  91914. /** @hidden */
  91915. readonly _effectiveMesh: AbstractMesh;
  91916. /**
  91917. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  91918. * A mesh is in the frustum if its bounding box intersects the frustum
  91919. * @param frustumPlanes defines the frustum to test
  91920. * @returns true if the mesh is in the frustum planes
  91921. */
  91922. isInFrustum(frustumPlanes: Plane[]): boolean;
  91923. /**
  91924. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  91925. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  91926. * @param frustumPlanes defines the frustum to test
  91927. * @returns true if the mesh is completely in the frustum planes
  91928. */
  91929. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  91930. /**
  91931. * True if the mesh intersects another mesh or a SolidParticle object
  91932. * @param mesh defines a target mesh or SolidParticle to test
  91933. * @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)
  91934. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  91935. * @returns true if there is an intersection
  91936. */
  91937. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  91938. /**
  91939. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  91940. * @param point defines the point to test
  91941. * @returns true if there is an intersection
  91942. */
  91943. intersectsPoint(point: Vector3): boolean;
  91944. /**
  91945. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  91946. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91947. */
  91948. checkCollisions: boolean;
  91949. /**
  91950. * Gets Collider object used to compute collisions (not physics)
  91951. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91952. */
  91953. readonly collider: Nullable<Collider>;
  91954. /**
  91955. * Move the mesh using collision engine
  91956. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91957. * @param displacement defines the requested displacement vector
  91958. * @returns the current mesh
  91959. */
  91960. moveWithCollisions(displacement: Vector3): AbstractMesh;
  91961. private _onCollisionPositionChange;
  91962. /** @hidden */
  91963. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  91964. /** @hidden */
  91965. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  91966. /** @hidden */
  91967. _checkCollision(collider: Collider): AbstractMesh;
  91968. /** @hidden */
  91969. _generatePointsArray(): boolean;
  91970. /**
  91971. * Checks if the passed Ray intersects with the mesh
  91972. * @param ray defines the ray to use
  91973. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  91974. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91975. * @returns the picking info
  91976. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  91977. */
  91978. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  91979. /**
  91980. * Clones the current mesh
  91981. * @param name defines the mesh name
  91982. * @param newParent defines the new mesh parent
  91983. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  91984. * @returns the new mesh
  91985. */
  91986. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  91987. /**
  91988. * Disposes all the submeshes of the current meshnp
  91989. * @returns the current mesh
  91990. */
  91991. releaseSubMeshes(): AbstractMesh;
  91992. /**
  91993. * Releases resources associated with this abstract mesh.
  91994. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91995. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91996. */
  91997. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91998. /**
  91999. * Adds the passed mesh as a child to the current mesh
  92000. * @param mesh defines the child mesh
  92001. * @returns the current mesh
  92002. */
  92003. addChild(mesh: AbstractMesh): AbstractMesh;
  92004. /**
  92005. * Removes the passed mesh from the current mesh children list
  92006. * @param mesh defines the child mesh
  92007. * @returns the current mesh
  92008. */
  92009. removeChild(mesh: AbstractMesh): AbstractMesh;
  92010. /** @hidden */
  92011. private _initFacetData;
  92012. /**
  92013. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  92014. * This method can be called within the render loop.
  92015. * 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
  92016. * @returns the current mesh
  92017. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92018. */
  92019. updateFacetData(): AbstractMesh;
  92020. /**
  92021. * Returns the facetLocalNormals array.
  92022. * The normals are expressed in the mesh local spac
  92023. * @returns an array of Vector3
  92024. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92025. */
  92026. getFacetLocalNormals(): Vector3[];
  92027. /**
  92028. * Returns the facetLocalPositions array.
  92029. * The facet positions are expressed in the mesh local space
  92030. * @returns an array of Vector3
  92031. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92032. */
  92033. getFacetLocalPositions(): Vector3[];
  92034. /**
  92035. * Returns the facetLocalPartioning array
  92036. * @returns an array of array of numbers
  92037. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92038. */
  92039. getFacetLocalPartitioning(): number[][];
  92040. /**
  92041. * Returns the i-th facet position in the world system.
  92042. * This method allocates a new Vector3 per call
  92043. * @param i defines the facet index
  92044. * @returns a new Vector3
  92045. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92046. */
  92047. getFacetPosition(i: number): Vector3;
  92048. /**
  92049. * Sets the reference Vector3 with the i-th facet position in the world system
  92050. * @param i defines the facet index
  92051. * @param ref defines the target vector
  92052. * @returns the current mesh
  92053. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92054. */
  92055. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  92056. /**
  92057. * Returns the i-th facet normal in the world system.
  92058. * This method allocates a new Vector3 per call
  92059. * @param i defines the facet index
  92060. * @returns a new Vector3
  92061. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92062. */
  92063. getFacetNormal(i: number): Vector3;
  92064. /**
  92065. * Sets the reference Vector3 with the i-th facet normal in the world system
  92066. * @param i defines the facet index
  92067. * @param ref defines the target vector
  92068. * @returns the current mesh
  92069. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92070. */
  92071. getFacetNormalToRef(i: number, ref: Vector3): this;
  92072. /**
  92073. * 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)
  92074. * @param x defines x coordinate
  92075. * @param y defines y coordinate
  92076. * @param z defines z coordinate
  92077. * @returns the array of facet indexes
  92078. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92079. */
  92080. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  92081. /**
  92082. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  92083. * @param projected sets as the (x,y,z) world projection on the facet
  92084. * @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
  92085. * @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
  92086. * @param x defines x coordinate
  92087. * @param y defines y coordinate
  92088. * @param z defines z coordinate
  92089. * @returns the face index if found (or null instead)
  92090. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92091. */
  92092. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  92093. /**
  92094. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  92095. * @param projected sets as the (x,y,z) local projection on the facet
  92096. * @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
  92097. * @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
  92098. * @param x defines x coordinate
  92099. * @param y defines y coordinate
  92100. * @param z defines z coordinate
  92101. * @returns the face index if found (or null instead)
  92102. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92103. */
  92104. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  92105. /**
  92106. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  92107. * @returns the parameters
  92108. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92109. */
  92110. getFacetDataParameters(): any;
  92111. /**
  92112. * Disables the feature FacetData and frees the related memory
  92113. * @returns the current mesh
  92114. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92115. */
  92116. disableFacetData(): AbstractMesh;
  92117. /**
  92118. * Updates the AbstractMesh indices array
  92119. * @param indices defines the data source
  92120. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  92121. * @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)
  92122. * @returns the current mesh
  92123. */
  92124. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  92125. /**
  92126. * Creates new normals data for the mesh
  92127. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  92128. * @returns the current mesh
  92129. */
  92130. createNormals(updatable: boolean): AbstractMesh;
  92131. /**
  92132. * Align the mesh with a normal
  92133. * @param normal defines the normal to use
  92134. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  92135. * @returns the current mesh
  92136. */
  92137. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  92138. /** @hidden */
  92139. _checkOcclusionQuery(): boolean;
  92140. /**
  92141. * Disables the mesh edge rendering mode
  92142. * @returns the currentAbstractMesh
  92143. */
  92144. disableEdgesRendering(): AbstractMesh;
  92145. /**
  92146. * Enables the edge rendering mode on the mesh.
  92147. * This mode makes the mesh edges visible
  92148. * @param epsilon defines the maximal distance between two angles to detect a face
  92149. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  92150. * @returns the currentAbstractMesh
  92151. * @see https://www.babylonjs-playground.com/#19O9TU#0
  92152. */
  92153. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  92154. }
  92155. }
  92156. declare module BABYLON {
  92157. /**
  92158. * Interface used to define ActionEvent
  92159. */
  92160. export interface IActionEvent {
  92161. /** The mesh or sprite that triggered the action */
  92162. source: any;
  92163. /** The X mouse cursor position at the time of the event */
  92164. pointerX: number;
  92165. /** The Y mouse cursor position at the time of the event */
  92166. pointerY: number;
  92167. /** The mesh that is currently pointed at (can be null) */
  92168. meshUnderPointer: Nullable<AbstractMesh>;
  92169. /** the original (browser) event that triggered the ActionEvent */
  92170. sourceEvent?: any;
  92171. /** additional data for the event */
  92172. additionalData?: any;
  92173. }
  92174. /**
  92175. * ActionEvent is the event being sent when an action is triggered.
  92176. */
  92177. export class ActionEvent implements IActionEvent {
  92178. /** The mesh or sprite that triggered the action */
  92179. source: any;
  92180. /** The X mouse cursor position at the time of the event */
  92181. pointerX: number;
  92182. /** The Y mouse cursor position at the time of the event */
  92183. pointerY: number;
  92184. /** The mesh that is currently pointed at (can be null) */
  92185. meshUnderPointer: Nullable<AbstractMesh>;
  92186. /** the original (browser) event that triggered the ActionEvent */
  92187. sourceEvent?: any;
  92188. /** additional data for the event */
  92189. additionalData?: any;
  92190. /**
  92191. * Creates a new ActionEvent
  92192. * @param source The mesh or sprite that triggered the action
  92193. * @param pointerX The X mouse cursor position at the time of the event
  92194. * @param pointerY The Y mouse cursor position at the time of the event
  92195. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  92196. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  92197. * @param additionalData additional data for the event
  92198. */
  92199. constructor(
  92200. /** The mesh or sprite that triggered the action */
  92201. source: any,
  92202. /** The X mouse cursor position at the time of the event */
  92203. pointerX: number,
  92204. /** The Y mouse cursor position at the time of the event */
  92205. pointerY: number,
  92206. /** The mesh that is currently pointed at (can be null) */
  92207. meshUnderPointer: Nullable<AbstractMesh>,
  92208. /** the original (browser) event that triggered the ActionEvent */
  92209. sourceEvent?: any,
  92210. /** additional data for the event */
  92211. additionalData?: any);
  92212. /**
  92213. * Helper function to auto-create an ActionEvent from a source mesh.
  92214. * @param source The source mesh that triggered the event
  92215. * @param evt The original (browser) event
  92216. * @param additionalData additional data for the event
  92217. * @returns the new ActionEvent
  92218. */
  92219. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  92220. /**
  92221. * Helper function to auto-create an ActionEvent from a source sprite
  92222. * @param source The source sprite that triggered the event
  92223. * @param scene Scene associated with the sprite
  92224. * @param evt The original (browser) event
  92225. * @param additionalData additional data for the event
  92226. * @returns the new ActionEvent
  92227. */
  92228. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  92229. /**
  92230. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  92231. * @param scene the scene where the event occurred
  92232. * @param evt The original (browser) event
  92233. * @returns the new ActionEvent
  92234. */
  92235. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  92236. /**
  92237. * Helper function to auto-create an ActionEvent from a primitive
  92238. * @param prim defines the target primitive
  92239. * @param pointerPos defines the pointer position
  92240. * @param evt The original (browser) event
  92241. * @param additionalData additional data for the event
  92242. * @returns the new ActionEvent
  92243. */
  92244. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  92245. }
  92246. }
  92247. declare module BABYLON {
  92248. /**
  92249. * Abstract class used to decouple action Manager from scene and meshes.
  92250. * Do not instantiate.
  92251. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92252. */
  92253. export abstract class AbstractActionManager implements IDisposable {
  92254. /** Gets the list of active triggers */
  92255. static Triggers: {
  92256. [key: string]: number;
  92257. };
  92258. /** Gets the cursor to use when hovering items */
  92259. hoverCursor: string;
  92260. /** Gets the list of actions */
  92261. actions: IAction[];
  92262. /**
  92263. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  92264. */
  92265. isRecursive: boolean;
  92266. /**
  92267. * Releases all associated resources
  92268. */
  92269. abstract dispose(): void;
  92270. /**
  92271. * Does this action manager has pointer triggers
  92272. */
  92273. abstract readonly hasPointerTriggers: boolean;
  92274. /**
  92275. * Does this action manager has pick triggers
  92276. */
  92277. abstract readonly hasPickTriggers: boolean;
  92278. /**
  92279. * Process a specific trigger
  92280. * @param trigger defines the trigger to process
  92281. * @param evt defines the event details to be processed
  92282. */
  92283. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  92284. /**
  92285. * Does this action manager handles actions of any of the given triggers
  92286. * @param triggers defines the triggers to be tested
  92287. * @return a boolean indicating whether one (or more) of the triggers is handled
  92288. */
  92289. abstract hasSpecificTriggers(triggers: number[]): boolean;
  92290. /**
  92291. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  92292. * speed.
  92293. * @param triggerA defines the trigger to be tested
  92294. * @param triggerB defines the trigger to be tested
  92295. * @return a boolean indicating whether one (or more) of the triggers is handled
  92296. */
  92297. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  92298. /**
  92299. * Does this action manager handles actions of a given trigger
  92300. * @param trigger defines the trigger to be tested
  92301. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  92302. * @return whether the trigger is handled
  92303. */
  92304. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  92305. /**
  92306. * Serialize this manager to a JSON object
  92307. * @param name defines the property name to store this manager
  92308. * @returns a JSON representation of this manager
  92309. */
  92310. abstract serialize(name: string): any;
  92311. /**
  92312. * Registers an action to this action manager
  92313. * @param action defines the action to be registered
  92314. * @return the action amended (prepared) after registration
  92315. */
  92316. abstract registerAction(action: IAction): Nullable<IAction>;
  92317. /**
  92318. * Unregisters an action to this action manager
  92319. * @param action defines the action to be unregistered
  92320. * @return a boolean indicating whether the action has been unregistered
  92321. */
  92322. abstract unregisterAction(action: IAction): Boolean;
  92323. /**
  92324. * Does exist one action manager with at least one trigger
  92325. **/
  92326. static readonly HasTriggers: boolean;
  92327. /**
  92328. * Does exist one action manager with at least one pick trigger
  92329. **/
  92330. static readonly HasPickTriggers: boolean;
  92331. /**
  92332. * Does exist one action manager that handles actions of a given trigger
  92333. * @param trigger defines the trigger to be tested
  92334. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  92335. **/
  92336. static HasSpecificTrigger(trigger: number): boolean;
  92337. }
  92338. }
  92339. declare module BABYLON {
  92340. /**
  92341. * Defines how a node can be built from a string name.
  92342. */
  92343. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  92344. /**
  92345. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  92346. */
  92347. export class Node implements IBehaviorAware<Node> {
  92348. /** @hidden */
  92349. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  92350. private static _NodeConstructors;
  92351. /**
  92352. * Add a new node constructor
  92353. * @param type defines the type name of the node to construct
  92354. * @param constructorFunc defines the constructor function
  92355. */
  92356. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  92357. /**
  92358. * Returns a node constructor based on type name
  92359. * @param type defines the type name
  92360. * @param name defines the new node name
  92361. * @param scene defines the hosting scene
  92362. * @param options defines optional options to transmit to constructors
  92363. * @returns the new constructor or null
  92364. */
  92365. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  92366. /**
  92367. * Gets or sets the name of the node
  92368. */
  92369. name: string;
  92370. /**
  92371. * Gets or sets the id of the node
  92372. */
  92373. id: string;
  92374. /**
  92375. * Gets or sets the unique id of the node
  92376. */
  92377. uniqueId: number;
  92378. /**
  92379. * Gets or sets a string used to store user defined state for the node
  92380. */
  92381. state: string;
  92382. /**
  92383. * Gets or sets an object used to store user defined information for the node
  92384. */
  92385. metadata: any;
  92386. /**
  92387. * For internal use only. Please do not use.
  92388. */
  92389. reservedDataStore: any;
  92390. /**
  92391. * List of inspectable custom properties (used by the Inspector)
  92392. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  92393. */
  92394. inspectableCustomProperties: IInspectable[];
  92395. /**
  92396. * Gets or sets a boolean used to define if the node must be serialized
  92397. */
  92398. doNotSerialize: boolean;
  92399. /** @hidden */
  92400. _isDisposed: boolean;
  92401. /**
  92402. * Gets a list of Animations associated with the node
  92403. */
  92404. animations: Animation[];
  92405. protected _ranges: {
  92406. [name: string]: Nullable<AnimationRange>;
  92407. };
  92408. /**
  92409. * Callback raised when the node is ready to be used
  92410. */
  92411. onReady: Nullable<(node: Node) => void>;
  92412. private _isEnabled;
  92413. private _isParentEnabled;
  92414. private _isReady;
  92415. /** @hidden */
  92416. _currentRenderId: number;
  92417. private _parentUpdateId;
  92418. /** @hidden */
  92419. _childUpdateId: number;
  92420. /** @hidden */
  92421. _waitingParentId: Nullable<string>;
  92422. /** @hidden */
  92423. _scene: Scene;
  92424. /** @hidden */
  92425. _cache: any;
  92426. private _parentNode;
  92427. private _children;
  92428. /** @hidden */
  92429. _worldMatrix: Matrix;
  92430. /** @hidden */
  92431. _worldMatrixDeterminant: number;
  92432. /** @hidden */
  92433. _worldMatrixDeterminantIsDirty: boolean;
  92434. /** @hidden */
  92435. private _sceneRootNodesIndex;
  92436. /**
  92437. * Gets a boolean indicating if the node has been disposed
  92438. * @returns true if the node was disposed
  92439. */
  92440. isDisposed(): boolean;
  92441. /**
  92442. * Gets or sets the parent of the node (without keeping the current position in the scene)
  92443. * @see https://doc.babylonjs.com/how_to/parenting
  92444. */
  92445. parent: Nullable<Node>;
  92446. private addToSceneRootNodes;
  92447. private removeFromSceneRootNodes;
  92448. private _animationPropertiesOverride;
  92449. /**
  92450. * Gets or sets the animation properties override
  92451. */
  92452. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  92453. /**
  92454. * Gets a string idenfifying the name of the class
  92455. * @returns "Node" string
  92456. */
  92457. getClassName(): string;
  92458. /** @hidden */
  92459. readonly _isNode: boolean;
  92460. /**
  92461. * An event triggered when the mesh is disposed
  92462. */
  92463. onDisposeObservable: Observable<Node>;
  92464. private _onDisposeObserver;
  92465. /**
  92466. * Sets a callback that will be raised when the node will be disposed
  92467. */
  92468. onDispose: () => void;
  92469. /**
  92470. * Creates a new Node
  92471. * @param name the name and id to be given to this node
  92472. * @param scene the scene this node will be added to
  92473. * @param addToRootNodes the node will be added to scene.rootNodes
  92474. */
  92475. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  92476. /**
  92477. * Gets the scene of the node
  92478. * @returns a scene
  92479. */
  92480. getScene(): Scene;
  92481. /**
  92482. * Gets the engine of the node
  92483. * @returns a Engine
  92484. */
  92485. getEngine(): Engine;
  92486. private _behaviors;
  92487. /**
  92488. * Attach a behavior to the node
  92489. * @see http://doc.babylonjs.com/features/behaviour
  92490. * @param behavior defines the behavior to attach
  92491. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  92492. * @returns the current Node
  92493. */
  92494. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  92495. /**
  92496. * Remove an attached behavior
  92497. * @see http://doc.babylonjs.com/features/behaviour
  92498. * @param behavior defines the behavior to attach
  92499. * @returns the current Node
  92500. */
  92501. removeBehavior(behavior: Behavior<Node>): Node;
  92502. /**
  92503. * Gets the list of attached behaviors
  92504. * @see http://doc.babylonjs.com/features/behaviour
  92505. */
  92506. readonly behaviors: Behavior<Node>[];
  92507. /**
  92508. * Gets an attached behavior by name
  92509. * @param name defines the name of the behavior to look for
  92510. * @see http://doc.babylonjs.com/features/behaviour
  92511. * @returns null if behavior was not found else the requested behavior
  92512. */
  92513. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  92514. /**
  92515. * Returns the latest update of the World matrix
  92516. * @returns a Matrix
  92517. */
  92518. getWorldMatrix(): Matrix;
  92519. /** @hidden */
  92520. _getWorldMatrixDeterminant(): number;
  92521. /**
  92522. * Returns directly the latest state of the mesh World matrix.
  92523. * A Matrix is returned.
  92524. */
  92525. readonly worldMatrixFromCache: Matrix;
  92526. /** @hidden */
  92527. _initCache(): void;
  92528. /** @hidden */
  92529. updateCache(force?: boolean): void;
  92530. /** @hidden */
  92531. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  92532. /** @hidden */
  92533. _updateCache(ignoreParentClass?: boolean): void;
  92534. /** @hidden */
  92535. _isSynchronized(): boolean;
  92536. /** @hidden */
  92537. _markSyncedWithParent(): void;
  92538. /** @hidden */
  92539. isSynchronizedWithParent(): boolean;
  92540. /** @hidden */
  92541. isSynchronized(): boolean;
  92542. /**
  92543. * Is this node ready to be used/rendered
  92544. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  92545. * @return true if the node is ready
  92546. */
  92547. isReady(completeCheck?: boolean): boolean;
  92548. /**
  92549. * Is this node enabled?
  92550. * 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
  92551. * @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
  92552. * @return whether this node (and its parent) is enabled
  92553. */
  92554. isEnabled(checkAncestors?: boolean): boolean;
  92555. /** @hidden */
  92556. protected _syncParentEnabledState(): void;
  92557. /**
  92558. * Set the enabled state of this node
  92559. * @param value defines the new enabled state
  92560. */
  92561. setEnabled(value: boolean): void;
  92562. /**
  92563. * Is this node a descendant of the given node?
  92564. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  92565. * @param ancestor defines the parent node to inspect
  92566. * @returns a boolean indicating if this node is a descendant of the given node
  92567. */
  92568. isDescendantOf(ancestor: Node): boolean;
  92569. /** @hidden */
  92570. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  92571. /**
  92572. * Will return all nodes that have this node as ascendant
  92573. * @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
  92574. * @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
  92575. * @return all children nodes of all types
  92576. */
  92577. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  92578. /**
  92579. * Get all child-meshes of this node
  92580. * @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)
  92581. * @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
  92582. * @returns an array of AbstractMesh
  92583. */
  92584. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  92585. /**
  92586. * Get all direct children of this node
  92587. * @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
  92588. * @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)
  92589. * @returns an array of Node
  92590. */
  92591. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  92592. /** @hidden */
  92593. _setReady(state: boolean): void;
  92594. /**
  92595. * Get an animation by name
  92596. * @param name defines the name of the animation to look for
  92597. * @returns null if not found else the requested animation
  92598. */
  92599. getAnimationByName(name: string): Nullable<Animation>;
  92600. /**
  92601. * Creates an animation range for this node
  92602. * @param name defines the name of the range
  92603. * @param from defines the starting key
  92604. * @param to defines the end key
  92605. */
  92606. createAnimationRange(name: string, from: number, to: number): void;
  92607. /**
  92608. * Delete a specific animation range
  92609. * @param name defines the name of the range to delete
  92610. * @param deleteFrames defines if animation frames from the range must be deleted as well
  92611. */
  92612. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  92613. /**
  92614. * Get an animation range by name
  92615. * @param name defines the name of the animation range to look for
  92616. * @returns null if not found else the requested animation range
  92617. */
  92618. getAnimationRange(name: string): Nullable<AnimationRange>;
  92619. /**
  92620. * Gets the list of all animation ranges defined on this node
  92621. * @returns an array
  92622. */
  92623. getAnimationRanges(): Nullable<AnimationRange>[];
  92624. /**
  92625. * Will start the animation sequence
  92626. * @param name defines the range frames for animation sequence
  92627. * @param loop defines if the animation should loop (false by default)
  92628. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  92629. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  92630. * @returns the object created for this animation. If range does not exist, it will return null
  92631. */
  92632. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  92633. /**
  92634. * Serialize animation ranges into a JSON compatible object
  92635. * @returns serialization object
  92636. */
  92637. serializeAnimationRanges(): any;
  92638. /**
  92639. * Computes the world matrix of the node
  92640. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92641. * @returns the world matrix
  92642. */
  92643. computeWorldMatrix(force?: boolean): Matrix;
  92644. /**
  92645. * Releases resources associated with this node.
  92646. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92647. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92648. */
  92649. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92650. /**
  92651. * Parse animation range data from a serialization object and store them into a given node
  92652. * @param node defines where to store the animation ranges
  92653. * @param parsedNode defines the serialization object to read data from
  92654. * @param scene defines the hosting scene
  92655. */
  92656. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  92657. /**
  92658. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  92659. * @param includeDescendants Include bounding info from descendants as well (true by default)
  92660. * @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
  92661. * @returns the new bounding vectors
  92662. */
  92663. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  92664. min: Vector3;
  92665. max: Vector3;
  92666. };
  92667. }
  92668. }
  92669. declare module BABYLON {
  92670. /**
  92671. * @hidden
  92672. */
  92673. export class _IAnimationState {
  92674. key: number;
  92675. repeatCount: number;
  92676. workValue?: any;
  92677. loopMode?: number;
  92678. offsetValue?: any;
  92679. highLimitValue?: any;
  92680. }
  92681. /**
  92682. * Class used to store any kind of animation
  92683. */
  92684. export class Animation {
  92685. /**Name of the animation */
  92686. name: string;
  92687. /**Property to animate */
  92688. targetProperty: string;
  92689. /**The frames per second of the animation */
  92690. framePerSecond: number;
  92691. /**The data type of the animation */
  92692. dataType: number;
  92693. /**The loop mode of the animation */
  92694. loopMode?: number | undefined;
  92695. /**Specifies if blending should be enabled */
  92696. enableBlending?: boolean | undefined;
  92697. /**
  92698. * Use matrix interpolation instead of using direct key value when animating matrices
  92699. */
  92700. static AllowMatricesInterpolation: boolean;
  92701. /**
  92702. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  92703. */
  92704. static AllowMatrixDecomposeForInterpolation: boolean;
  92705. /**
  92706. * Stores the key frames of the animation
  92707. */
  92708. private _keys;
  92709. /**
  92710. * Stores the easing function of the animation
  92711. */
  92712. private _easingFunction;
  92713. /**
  92714. * @hidden Internal use only
  92715. */
  92716. _runtimeAnimations: RuntimeAnimation[];
  92717. /**
  92718. * The set of event that will be linked to this animation
  92719. */
  92720. private _events;
  92721. /**
  92722. * Stores an array of target property paths
  92723. */
  92724. targetPropertyPath: string[];
  92725. /**
  92726. * Stores the blending speed of the animation
  92727. */
  92728. blendingSpeed: number;
  92729. /**
  92730. * Stores the animation ranges for the animation
  92731. */
  92732. private _ranges;
  92733. /**
  92734. * @hidden Internal use
  92735. */
  92736. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  92737. /**
  92738. * Sets up an animation
  92739. * @param property The property to animate
  92740. * @param animationType The animation type to apply
  92741. * @param framePerSecond The frames per second of the animation
  92742. * @param easingFunction The easing function used in the animation
  92743. * @returns The created animation
  92744. */
  92745. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  92746. /**
  92747. * Create and start an animation on a node
  92748. * @param name defines the name of the global animation that will be run on all nodes
  92749. * @param node defines the root node where the animation will take place
  92750. * @param targetProperty defines property to animate
  92751. * @param framePerSecond defines the number of frame per second yo use
  92752. * @param totalFrame defines the number of frames in total
  92753. * @param from defines the initial value
  92754. * @param to defines the final value
  92755. * @param loopMode defines which loop mode you want to use (off by default)
  92756. * @param easingFunction defines the easing function to use (linear by default)
  92757. * @param onAnimationEnd defines the callback to call when animation end
  92758. * @returns the animatable created for this animation
  92759. */
  92760. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  92761. /**
  92762. * Create and start an animation on a node and its descendants
  92763. * @param name defines the name of the global animation that will be run on all nodes
  92764. * @param node defines the root node where the animation will take place
  92765. * @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
  92766. * @param targetProperty defines property to animate
  92767. * @param framePerSecond defines the number of frame per second to use
  92768. * @param totalFrame defines the number of frames in total
  92769. * @param from defines the initial value
  92770. * @param to defines the final value
  92771. * @param loopMode defines which loop mode you want to use (off by default)
  92772. * @param easingFunction defines the easing function to use (linear by default)
  92773. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  92774. * @returns the list of animatables created for all nodes
  92775. * @example https://www.babylonjs-playground.com/#MH0VLI
  92776. */
  92777. 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[]>;
  92778. /**
  92779. * Creates a new animation, merges it with the existing animations and starts it
  92780. * @param name Name of the animation
  92781. * @param node Node which contains the scene that begins the animations
  92782. * @param targetProperty Specifies which property to animate
  92783. * @param framePerSecond The frames per second of the animation
  92784. * @param totalFrame The total number of frames
  92785. * @param from The frame at the beginning of the animation
  92786. * @param to The frame at the end of the animation
  92787. * @param loopMode Specifies the loop mode of the animation
  92788. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  92789. * @param onAnimationEnd Callback to run once the animation is complete
  92790. * @returns Nullable animation
  92791. */
  92792. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  92793. /**
  92794. * Transition property of an host to the target Value
  92795. * @param property The property to transition
  92796. * @param targetValue The target Value of the property
  92797. * @param host The object where the property to animate belongs
  92798. * @param scene Scene used to run the animation
  92799. * @param frameRate Framerate (in frame/s) to use
  92800. * @param transition The transition type we want to use
  92801. * @param duration The duration of the animation, in milliseconds
  92802. * @param onAnimationEnd Callback trigger at the end of the animation
  92803. * @returns Nullable animation
  92804. */
  92805. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  92806. /**
  92807. * Return the array of runtime animations currently using this animation
  92808. */
  92809. readonly runtimeAnimations: RuntimeAnimation[];
  92810. /**
  92811. * Specifies if any of the runtime animations are currently running
  92812. */
  92813. readonly hasRunningRuntimeAnimations: boolean;
  92814. /**
  92815. * Initializes the animation
  92816. * @param name Name of the animation
  92817. * @param targetProperty Property to animate
  92818. * @param framePerSecond The frames per second of the animation
  92819. * @param dataType The data type of the animation
  92820. * @param loopMode The loop mode of the animation
  92821. * @param enableBlending Specifies if blending should be enabled
  92822. */
  92823. constructor(
  92824. /**Name of the animation */
  92825. name: string,
  92826. /**Property to animate */
  92827. targetProperty: string,
  92828. /**The frames per second of the animation */
  92829. framePerSecond: number,
  92830. /**The data type of the animation */
  92831. dataType: number,
  92832. /**The loop mode of the animation */
  92833. loopMode?: number | undefined,
  92834. /**Specifies if blending should be enabled */
  92835. enableBlending?: boolean | undefined);
  92836. /**
  92837. * Converts the animation to a string
  92838. * @param fullDetails support for multiple levels of logging within scene loading
  92839. * @returns String form of the animation
  92840. */
  92841. toString(fullDetails?: boolean): string;
  92842. /**
  92843. * Add an event to this animation
  92844. * @param event Event to add
  92845. */
  92846. addEvent(event: AnimationEvent): void;
  92847. /**
  92848. * Remove all events found at the given frame
  92849. * @param frame The frame to remove events from
  92850. */
  92851. removeEvents(frame: number): void;
  92852. /**
  92853. * Retrieves all the events from the animation
  92854. * @returns Events from the animation
  92855. */
  92856. getEvents(): AnimationEvent[];
  92857. /**
  92858. * Creates an animation range
  92859. * @param name Name of the animation range
  92860. * @param from Starting frame of the animation range
  92861. * @param to Ending frame of the animation
  92862. */
  92863. createRange(name: string, from: number, to: number): void;
  92864. /**
  92865. * Deletes an animation range by name
  92866. * @param name Name of the animation range to delete
  92867. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  92868. */
  92869. deleteRange(name: string, deleteFrames?: boolean): void;
  92870. /**
  92871. * Gets the animation range by name, or null if not defined
  92872. * @param name Name of the animation range
  92873. * @returns Nullable animation range
  92874. */
  92875. getRange(name: string): Nullable<AnimationRange>;
  92876. /**
  92877. * Gets the key frames from the animation
  92878. * @returns The key frames of the animation
  92879. */
  92880. getKeys(): Array<IAnimationKey>;
  92881. /**
  92882. * Gets the highest frame rate of the animation
  92883. * @returns Highest frame rate of the animation
  92884. */
  92885. getHighestFrame(): number;
  92886. /**
  92887. * Gets the easing function of the animation
  92888. * @returns Easing function of the animation
  92889. */
  92890. getEasingFunction(): IEasingFunction;
  92891. /**
  92892. * Sets the easing function of the animation
  92893. * @param easingFunction A custom mathematical formula for animation
  92894. */
  92895. setEasingFunction(easingFunction: EasingFunction): void;
  92896. /**
  92897. * Interpolates a scalar linearly
  92898. * @param startValue Start value of the animation curve
  92899. * @param endValue End value of the animation curve
  92900. * @param gradient Scalar amount to interpolate
  92901. * @returns Interpolated scalar value
  92902. */
  92903. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  92904. /**
  92905. * Interpolates a scalar cubically
  92906. * @param startValue Start value of the animation curve
  92907. * @param outTangent End tangent of the animation
  92908. * @param endValue End value of the animation curve
  92909. * @param inTangent Start tangent of the animation curve
  92910. * @param gradient Scalar amount to interpolate
  92911. * @returns Interpolated scalar value
  92912. */
  92913. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  92914. /**
  92915. * Interpolates a quaternion using a spherical linear interpolation
  92916. * @param startValue Start value of the animation curve
  92917. * @param endValue End value of the animation curve
  92918. * @param gradient Scalar amount to interpolate
  92919. * @returns Interpolated quaternion value
  92920. */
  92921. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  92922. /**
  92923. * Interpolates a quaternion cubically
  92924. * @param startValue Start value of the animation curve
  92925. * @param outTangent End tangent of the animation curve
  92926. * @param endValue End value of the animation curve
  92927. * @param inTangent Start tangent of the animation curve
  92928. * @param gradient Scalar amount to interpolate
  92929. * @returns Interpolated quaternion value
  92930. */
  92931. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  92932. /**
  92933. * Interpolates a Vector3 linearl
  92934. * @param startValue Start value of the animation curve
  92935. * @param endValue End value of the animation curve
  92936. * @param gradient Scalar amount to interpolate
  92937. * @returns Interpolated scalar value
  92938. */
  92939. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  92940. /**
  92941. * Interpolates a Vector3 cubically
  92942. * @param startValue Start value of the animation curve
  92943. * @param outTangent End tangent of the animation
  92944. * @param endValue End value of the animation curve
  92945. * @param inTangent Start tangent of the animation curve
  92946. * @param gradient Scalar amount to interpolate
  92947. * @returns InterpolatedVector3 value
  92948. */
  92949. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  92950. /**
  92951. * Interpolates a Vector2 linearly
  92952. * @param startValue Start value of the animation curve
  92953. * @param endValue End value of the animation curve
  92954. * @param gradient Scalar amount to interpolate
  92955. * @returns Interpolated Vector2 value
  92956. */
  92957. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  92958. /**
  92959. * Interpolates a Vector2 cubically
  92960. * @param startValue Start value of the animation curve
  92961. * @param outTangent End tangent of the animation
  92962. * @param endValue End value of the animation curve
  92963. * @param inTangent Start tangent of the animation curve
  92964. * @param gradient Scalar amount to interpolate
  92965. * @returns Interpolated Vector2 value
  92966. */
  92967. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  92968. /**
  92969. * Interpolates a size linearly
  92970. * @param startValue Start value of the animation curve
  92971. * @param endValue End value of the animation curve
  92972. * @param gradient Scalar amount to interpolate
  92973. * @returns Interpolated Size value
  92974. */
  92975. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  92976. /**
  92977. * Interpolates a Color3 linearly
  92978. * @param startValue Start value of the animation curve
  92979. * @param endValue End value of the animation curve
  92980. * @param gradient Scalar amount to interpolate
  92981. * @returns Interpolated Color3 value
  92982. */
  92983. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  92984. /**
  92985. * @hidden Internal use only
  92986. */
  92987. _getKeyValue(value: any): any;
  92988. /**
  92989. * @hidden Internal use only
  92990. */
  92991. _interpolate(currentFrame: number, state: _IAnimationState): any;
  92992. /**
  92993. * Defines the function to use to interpolate matrices
  92994. * @param startValue defines the start matrix
  92995. * @param endValue defines the end matrix
  92996. * @param gradient defines the gradient between both matrices
  92997. * @param result defines an optional target matrix where to store the interpolation
  92998. * @returns the interpolated matrix
  92999. */
  93000. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  93001. /**
  93002. * Makes a copy of the animation
  93003. * @returns Cloned animation
  93004. */
  93005. clone(): Animation;
  93006. /**
  93007. * Sets the key frames of the animation
  93008. * @param values The animation key frames to set
  93009. */
  93010. setKeys(values: Array<IAnimationKey>): void;
  93011. /**
  93012. * Serializes the animation to an object
  93013. * @returns Serialized object
  93014. */
  93015. serialize(): any;
  93016. /**
  93017. * Float animation type
  93018. */
  93019. private static _ANIMATIONTYPE_FLOAT;
  93020. /**
  93021. * Vector3 animation type
  93022. */
  93023. private static _ANIMATIONTYPE_VECTOR3;
  93024. /**
  93025. * Quaternion animation type
  93026. */
  93027. private static _ANIMATIONTYPE_QUATERNION;
  93028. /**
  93029. * Matrix animation type
  93030. */
  93031. private static _ANIMATIONTYPE_MATRIX;
  93032. /**
  93033. * Color3 animation type
  93034. */
  93035. private static _ANIMATIONTYPE_COLOR3;
  93036. /**
  93037. * Vector2 animation type
  93038. */
  93039. private static _ANIMATIONTYPE_VECTOR2;
  93040. /**
  93041. * Size animation type
  93042. */
  93043. private static _ANIMATIONTYPE_SIZE;
  93044. /**
  93045. * Relative Loop Mode
  93046. */
  93047. private static _ANIMATIONLOOPMODE_RELATIVE;
  93048. /**
  93049. * Cycle Loop Mode
  93050. */
  93051. private static _ANIMATIONLOOPMODE_CYCLE;
  93052. /**
  93053. * Constant Loop Mode
  93054. */
  93055. private static _ANIMATIONLOOPMODE_CONSTANT;
  93056. /**
  93057. * Get the float animation type
  93058. */
  93059. static readonly ANIMATIONTYPE_FLOAT: number;
  93060. /**
  93061. * Get the Vector3 animation type
  93062. */
  93063. static readonly ANIMATIONTYPE_VECTOR3: number;
  93064. /**
  93065. * Get the Vector2 animation type
  93066. */
  93067. static readonly ANIMATIONTYPE_VECTOR2: number;
  93068. /**
  93069. * Get the Size animation type
  93070. */
  93071. static readonly ANIMATIONTYPE_SIZE: number;
  93072. /**
  93073. * Get the Quaternion animation type
  93074. */
  93075. static readonly ANIMATIONTYPE_QUATERNION: number;
  93076. /**
  93077. * Get the Matrix animation type
  93078. */
  93079. static readonly ANIMATIONTYPE_MATRIX: number;
  93080. /**
  93081. * Get the Color3 animation type
  93082. */
  93083. static readonly ANIMATIONTYPE_COLOR3: number;
  93084. /**
  93085. * Get the Relative Loop Mode
  93086. */
  93087. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  93088. /**
  93089. * Get the Cycle Loop Mode
  93090. */
  93091. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  93092. /**
  93093. * Get the Constant Loop Mode
  93094. */
  93095. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  93096. /** @hidden */
  93097. static _UniversalLerp(left: any, right: any, amount: number): any;
  93098. /**
  93099. * Parses an animation object and creates an animation
  93100. * @param parsedAnimation Parsed animation object
  93101. * @returns Animation object
  93102. */
  93103. static Parse(parsedAnimation: any): Animation;
  93104. /**
  93105. * Appends the serialized animations from the source animations
  93106. * @param source Source containing the animations
  93107. * @param destination Target to store the animations
  93108. */
  93109. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93110. }
  93111. }
  93112. declare module BABYLON {
  93113. /**
  93114. * Interface containing an array of animations
  93115. */
  93116. export interface IAnimatable {
  93117. /**
  93118. * Array of animations
  93119. */
  93120. animations: Nullable<Array<Animation>>;
  93121. }
  93122. }
  93123. declare module BABYLON {
  93124. /**
  93125. * This represents all the required information to add a fresnel effect on a material:
  93126. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93127. */
  93128. export class FresnelParameters {
  93129. private _isEnabled;
  93130. /**
  93131. * Define if the fresnel effect is enable or not.
  93132. */
  93133. isEnabled: boolean;
  93134. /**
  93135. * Define the color used on edges (grazing angle)
  93136. */
  93137. leftColor: Color3;
  93138. /**
  93139. * Define the color used on center
  93140. */
  93141. rightColor: Color3;
  93142. /**
  93143. * Define bias applied to computed fresnel term
  93144. */
  93145. bias: number;
  93146. /**
  93147. * Defined the power exponent applied to fresnel term
  93148. */
  93149. power: number;
  93150. /**
  93151. * Clones the current fresnel and its valuues
  93152. * @returns a clone fresnel configuration
  93153. */
  93154. clone(): FresnelParameters;
  93155. /**
  93156. * Serializes the current fresnel parameters to a JSON representation.
  93157. * @return the JSON serialization
  93158. */
  93159. serialize(): any;
  93160. /**
  93161. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  93162. * @param parsedFresnelParameters Define the JSON representation
  93163. * @returns the parsed parameters
  93164. */
  93165. static Parse(parsedFresnelParameters: any): FresnelParameters;
  93166. }
  93167. }
  93168. declare module BABYLON {
  93169. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  93170. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93171. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93172. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93173. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93174. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93175. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93176. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93177. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93178. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93179. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93180. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93181. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93182. /**
  93183. * Decorator used to define property that can be serialized as reference to a camera
  93184. * @param sourceName defines the name of the property to decorate
  93185. */
  93186. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93187. /**
  93188. * Class used to help serialization objects
  93189. */
  93190. export class SerializationHelper {
  93191. /** @hidden */
  93192. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  93193. /** @hidden */
  93194. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  93195. /** @hidden */
  93196. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  93197. /** @hidden */
  93198. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  93199. /**
  93200. * Appends the serialized animations from the source animations
  93201. * @param source Source containing the animations
  93202. * @param destination Target to store the animations
  93203. */
  93204. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93205. /**
  93206. * Static function used to serialized a specific entity
  93207. * @param entity defines the entity to serialize
  93208. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  93209. * @returns a JSON compatible object representing the serialization of the entity
  93210. */
  93211. static Serialize<T>(entity: T, serializationObject?: any): any;
  93212. /**
  93213. * Creates a new entity from a serialization data object
  93214. * @param creationFunction defines a function used to instanciated the new entity
  93215. * @param source defines the source serialization data
  93216. * @param scene defines the hosting scene
  93217. * @param rootUrl defines the root url for resources
  93218. * @returns a new entity
  93219. */
  93220. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  93221. /**
  93222. * Clones an object
  93223. * @param creationFunction defines the function used to instanciate the new object
  93224. * @param source defines the source object
  93225. * @returns the cloned object
  93226. */
  93227. static Clone<T>(creationFunction: () => T, source: T): T;
  93228. /**
  93229. * Instanciates a new object based on a source one (some data will be shared between both object)
  93230. * @param creationFunction defines the function used to instanciate the new object
  93231. * @param source defines the source object
  93232. * @returns the new object
  93233. */
  93234. static Instanciate<T>(creationFunction: () => T, source: T): T;
  93235. }
  93236. }
  93237. declare module BABYLON {
  93238. /**
  93239. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  93240. */
  93241. export interface CubeMapInfo {
  93242. /**
  93243. * The pixel array for the front face.
  93244. * This is stored in format, left to right, up to down format.
  93245. */
  93246. front: Nullable<ArrayBufferView>;
  93247. /**
  93248. * The pixel array for the back face.
  93249. * This is stored in format, left to right, up to down format.
  93250. */
  93251. back: Nullable<ArrayBufferView>;
  93252. /**
  93253. * The pixel array for the left face.
  93254. * This is stored in format, left to right, up to down format.
  93255. */
  93256. left: Nullable<ArrayBufferView>;
  93257. /**
  93258. * The pixel array for the right face.
  93259. * This is stored in format, left to right, up to down format.
  93260. */
  93261. right: Nullable<ArrayBufferView>;
  93262. /**
  93263. * The pixel array for the up face.
  93264. * This is stored in format, left to right, up to down format.
  93265. */
  93266. up: Nullable<ArrayBufferView>;
  93267. /**
  93268. * The pixel array for the down face.
  93269. * This is stored in format, left to right, up to down format.
  93270. */
  93271. down: Nullable<ArrayBufferView>;
  93272. /**
  93273. * The size of the cubemap stored.
  93274. *
  93275. * Each faces will be size * size pixels.
  93276. */
  93277. size: number;
  93278. /**
  93279. * The format of the texture.
  93280. *
  93281. * RGBA, RGB.
  93282. */
  93283. format: number;
  93284. /**
  93285. * The type of the texture data.
  93286. *
  93287. * UNSIGNED_INT, FLOAT.
  93288. */
  93289. type: number;
  93290. /**
  93291. * Specifies whether the texture is in gamma space.
  93292. */
  93293. gammaSpace: boolean;
  93294. }
  93295. /**
  93296. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  93297. */
  93298. export class PanoramaToCubeMapTools {
  93299. private static FACE_FRONT;
  93300. private static FACE_BACK;
  93301. private static FACE_RIGHT;
  93302. private static FACE_LEFT;
  93303. private static FACE_DOWN;
  93304. private static FACE_UP;
  93305. /**
  93306. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  93307. *
  93308. * @param float32Array The source data.
  93309. * @param inputWidth The width of the input panorama.
  93310. * @param inputHeight The height of the input panorama.
  93311. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  93312. * @return The cubemap data
  93313. */
  93314. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  93315. private static CreateCubemapTexture;
  93316. private static CalcProjectionSpherical;
  93317. }
  93318. }
  93319. declare module BABYLON {
  93320. /**
  93321. * Helper class dealing with the extraction of spherical polynomial dataArray
  93322. * from a cube map.
  93323. */
  93324. export class CubeMapToSphericalPolynomialTools {
  93325. private static FileFaces;
  93326. /**
  93327. * Converts a texture to the according Spherical Polynomial data.
  93328. * This extracts the first 3 orders only as they are the only one used in the lighting.
  93329. *
  93330. * @param texture The texture to extract the information from.
  93331. * @return The Spherical Polynomial data.
  93332. */
  93333. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  93334. /**
  93335. * Converts a cubemap to the according Spherical Polynomial data.
  93336. * This extracts the first 3 orders only as they are the only one used in the lighting.
  93337. *
  93338. * @param cubeInfo The Cube map to extract the information from.
  93339. * @return The Spherical Polynomial data.
  93340. */
  93341. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  93342. }
  93343. }
  93344. declare module BABYLON {
  93345. /**
  93346. * Class used to manipulate GUIDs
  93347. */
  93348. export class GUID {
  93349. /**
  93350. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  93351. * Be aware Math.random() could cause collisions, but:
  93352. * "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"
  93353. * @returns a pseudo random id
  93354. */
  93355. static RandomId(): string;
  93356. }
  93357. }
  93358. declare module BABYLON {
  93359. /**
  93360. * Base class of all the textures in babylon.
  93361. * It groups all the common properties the materials, post process, lights... might need
  93362. * in order to make a correct use of the texture.
  93363. */
  93364. export class BaseTexture implements IAnimatable {
  93365. /**
  93366. * Default anisotropic filtering level for the application.
  93367. * It is set to 4 as a good tradeoff between perf and quality.
  93368. */
  93369. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  93370. /**
  93371. * Gets or sets the unique id of the texture
  93372. */
  93373. uniqueId: number;
  93374. /**
  93375. * Define the name of the texture.
  93376. */
  93377. name: string;
  93378. /**
  93379. * Gets or sets an object used to store user defined information.
  93380. */
  93381. metadata: any;
  93382. /**
  93383. * For internal use only. Please do not use.
  93384. */
  93385. reservedDataStore: any;
  93386. private _hasAlpha;
  93387. /**
  93388. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  93389. */
  93390. hasAlpha: boolean;
  93391. /**
  93392. * Defines if the alpha value should be determined via the rgb values.
  93393. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  93394. */
  93395. getAlphaFromRGB: boolean;
  93396. /**
  93397. * Intensity or strength of the texture.
  93398. * It is commonly used by materials to fine tune the intensity of the texture
  93399. */
  93400. level: number;
  93401. /**
  93402. * Define the UV chanel to use starting from 0 and defaulting to 0.
  93403. * This is part of the texture as textures usually maps to one uv set.
  93404. */
  93405. coordinatesIndex: number;
  93406. private _coordinatesMode;
  93407. /**
  93408. * How a texture is mapped.
  93409. *
  93410. * | Value | Type | Description |
  93411. * | ----- | ----------------------------------- | ----------- |
  93412. * | 0 | EXPLICIT_MODE | |
  93413. * | 1 | SPHERICAL_MODE | |
  93414. * | 2 | PLANAR_MODE | |
  93415. * | 3 | CUBIC_MODE | |
  93416. * | 4 | PROJECTION_MODE | |
  93417. * | 5 | SKYBOX_MODE | |
  93418. * | 6 | INVCUBIC_MODE | |
  93419. * | 7 | EQUIRECTANGULAR_MODE | |
  93420. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  93421. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  93422. */
  93423. coordinatesMode: number;
  93424. /**
  93425. * | Value | Type | Description |
  93426. * | ----- | ------------------ | ----------- |
  93427. * | 0 | CLAMP_ADDRESSMODE | |
  93428. * | 1 | WRAP_ADDRESSMODE | |
  93429. * | 2 | MIRROR_ADDRESSMODE | |
  93430. */
  93431. wrapU: number;
  93432. /**
  93433. * | Value | Type | Description |
  93434. * | ----- | ------------------ | ----------- |
  93435. * | 0 | CLAMP_ADDRESSMODE | |
  93436. * | 1 | WRAP_ADDRESSMODE | |
  93437. * | 2 | MIRROR_ADDRESSMODE | |
  93438. */
  93439. wrapV: number;
  93440. /**
  93441. * | Value | Type | Description |
  93442. * | ----- | ------------------ | ----------- |
  93443. * | 0 | CLAMP_ADDRESSMODE | |
  93444. * | 1 | WRAP_ADDRESSMODE | |
  93445. * | 2 | MIRROR_ADDRESSMODE | |
  93446. */
  93447. wrapR: number;
  93448. /**
  93449. * With compliant hardware and browser (supporting anisotropic filtering)
  93450. * this defines the level of anisotropic filtering in the texture.
  93451. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  93452. */
  93453. anisotropicFilteringLevel: number;
  93454. /**
  93455. * Define if the texture is a cube texture or if false a 2d texture.
  93456. */
  93457. isCube: boolean;
  93458. /**
  93459. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  93460. */
  93461. is3D: boolean;
  93462. /**
  93463. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  93464. * HDR texture are usually stored in linear space.
  93465. * This only impacts the PBR and Background materials
  93466. */
  93467. gammaSpace: boolean;
  93468. /**
  93469. * Gets or sets whether or not the texture contains RGBD data.
  93470. */
  93471. isRGBD: boolean;
  93472. /**
  93473. * Is Z inverted in the texture (useful in a cube texture).
  93474. */
  93475. invertZ: boolean;
  93476. /**
  93477. * Are mip maps generated for this texture or not.
  93478. */
  93479. readonly noMipmap: boolean;
  93480. /**
  93481. * @hidden
  93482. */
  93483. lodLevelInAlpha: boolean;
  93484. /**
  93485. * With prefiltered texture, defined the offset used during the prefiltering steps.
  93486. */
  93487. lodGenerationOffset: number;
  93488. /**
  93489. * With prefiltered texture, defined the scale used during the prefiltering steps.
  93490. */
  93491. lodGenerationScale: number;
  93492. /**
  93493. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  93494. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  93495. * average roughness values.
  93496. */
  93497. linearSpecularLOD: boolean;
  93498. /**
  93499. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  93500. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  93501. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  93502. */
  93503. irradianceTexture: Nullable<BaseTexture>;
  93504. /**
  93505. * Define if the texture is a render target.
  93506. */
  93507. isRenderTarget: boolean;
  93508. /**
  93509. * Define the unique id of the texture in the scene.
  93510. */
  93511. readonly uid: string;
  93512. /**
  93513. * Return a string representation of the texture.
  93514. * @returns the texture as a string
  93515. */
  93516. toString(): string;
  93517. /**
  93518. * Get the class name of the texture.
  93519. * @returns "BaseTexture"
  93520. */
  93521. getClassName(): string;
  93522. /**
  93523. * Define the list of animation attached to the texture.
  93524. */
  93525. animations: Animation[];
  93526. /**
  93527. * An event triggered when the texture is disposed.
  93528. */
  93529. onDisposeObservable: Observable<BaseTexture>;
  93530. private _onDisposeObserver;
  93531. /**
  93532. * Callback triggered when the texture has been disposed.
  93533. * Kept for back compatibility, you can use the onDisposeObservable instead.
  93534. */
  93535. onDispose: () => void;
  93536. /**
  93537. * Define the current state of the loading sequence when in delayed load mode.
  93538. */
  93539. delayLoadState: number;
  93540. private _scene;
  93541. /** @hidden */
  93542. _texture: Nullable<InternalTexture>;
  93543. private _uid;
  93544. /**
  93545. * Define if the texture is preventinga material to render or not.
  93546. * If not and the texture is not ready, the engine will use a default black texture instead.
  93547. */
  93548. readonly isBlocking: boolean;
  93549. /**
  93550. * Instantiates a new BaseTexture.
  93551. * Base class of all the textures in babylon.
  93552. * It groups all the common properties the materials, post process, lights... might need
  93553. * in order to make a correct use of the texture.
  93554. * @param scene Define the scene the texture blongs to
  93555. */
  93556. constructor(scene: Nullable<Scene>);
  93557. /**
  93558. * Get the scene the texture belongs to.
  93559. * @returns the scene or null if undefined
  93560. */
  93561. getScene(): Nullable<Scene>;
  93562. /**
  93563. * Get the texture transform matrix used to offset tile the texture for istance.
  93564. * @returns the transformation matrix
  93565. */
  93566. getTextureMatrix(): Matrix;
  93567. /**
  93568. * Get the texture reflection matrix used to rotate/transform the reflection.
  93569. * @returns the reflection matrix
  93570. */
  93571. getReflectionTextureMatrix(): Matrix;
  93572. /**
  93573. * Get the underlying lower level texture from Babylon.
  93574. * @returns the insternal texture
  93575. */
  93576. getInternalTexture(): Nullable<InternalTexture>;
  93577. /**
  93578. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  93579. * @returns true if ready or not blocking
  93580. */
  93581. isReadyOrNotBlocking(): boolean;
  93582. /**
  93583. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  93584. * @returns true if fully ready
  93585. */
  93586. isReady(): boolean;
  93587. private _cachedSize;
  93588. /**
  93589. * Get the size of the texture.
  93590. * @returns the texture size.
  93591. */
  93592. getSize(): ISize;
  93593. /**
  93594. * Get the base size of the texture.
  93595. * It can be different from the size if the texture has been resized for POT for instance
  93596. * @returns the base size
  93597. */
  93598. getBaseSize(): ISize;
  93599. /**
  93600. * Update the sampling mode of the texture.
  93601. * Default is Trilinear mode.
  93602. *
  93603. * | Value | Type | Description |
  93604. * | ----- | ------------------ | ----------- |
  93605. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  93606. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  93607. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  93608. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  93609. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  93610. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  93611. * | 7 | NEAREST_LINEAR | |
  93612. * | 8 | NEAREST_NEAREST | |
  93613. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  93614. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  93615. * | 11 | LINEAR_LINEAR | |
  93616. * | 12 | LINEAR_NEAREST | |
  93617. *
  93618. * > _mag_: magnification filter (close to the viewer)
  93619. * > _min_: minification filter (far from the viewer)
  93620. * > _mip_: filter used between mip map levels
  93621. *@param samplingMode Define the new sampling mode of the texture
  93622. */
  93623. updateSamplingMode(samplingMode: number): void;
  93624. /**
  93625. * Scales the texture if is `canRescale()`
  93626. * @param ratio the resize factor we want to use to rescale
  93627. */
  93628. scale(ratio: number): void;
  93629. /**
  93630. * Get if the texture can rescale.
  93631. */
  93632. readonly canRescale: boolean;
  93633. /** @hidden */
  93634. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  93635. /** @hidden */
  93636. _rebuild(): void;
  93637. /**
  93638. * Triggers the load sequence in delayed load mode.
  93639. */
  93640. delayLoad(): void;
  93641. /**
  93642. * Clones the texture.
  93643. * @returns the cloned texture
  93644. */
  93645. clone(): Nullable<BaseTexture>;
  93646. /**
  93647. * Get the texture underlying type (INT, FLOAT...)
  93648. */
  93649. readonly textureType: number;
  93650. /**
  93651. * Get the texture underlying format (RGB, RGBA...)
  93652. */
  93653. readonly textureFormat: number;
  93654. /**
  93655. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  93656. * This will returns an RGBA array buffer containing either in values (0-255) or
  93657. * float values (0-1) depending of the underlying buffer type.
  93658. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  93659. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  93660. * @param buffer defines a user defined buffer to fill with data (can be null)
  93661. * @returns The Array buffer containing the pixels data.
  93662. */
  93663. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  93664. /**
  93665. * Release and destroy the underlying lower level texture aka internalTexture.
  93666. */
  93667. releaseInternalTexture(): void;
  93668. /**
  93669. * Get the polynomial representation of the texture data.
  93670. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  93671. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  93672. */
  93673. sphericalPolynomial: Nullable<SphericalPolynomial>;
  93674. /** @hidden */
  93675. readonly _lodTextureHigh: Nullable<BaseTexture>;
  93676. /** @hidden */
  93677. readonly _lodTextureMid: Nullable<BaseTexture>;
  93678. /** @hidden */
  93679. readonly _lodTextureLow: Nullable<BaseTexture>;
  93680. /**
  93681. * Dispose the texture and release its associated resources.
  93682. */
  93683. dispose(): void;
  93684. /**
  93685. * Serialize the texture into a JSON representation that can be parsed later on.
  93686. * @returns the JSON representation of the texture
  93687. */
  93688. serialize(): any;
  93689. /**
  93690. * Helper function to be called back once a list of texture contains only ready textures.
  93691. * @param textures Define the list of textures to wait for
  93692. * @param callback Define the callback triggered once the entire list will be ready
  93693. */
  93694. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  93695. }
  93696. }
  93697. declare module BABYLON {
  93698. /**
  93699. * Class used to store data associated with WebGL texture data for the engine
  93700. * This class should not be used directly
  93701. */
  93702. export class InternalTexture {
  93703. /** @hidden */
  93704. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  93705. /**
  93706. * The source of the texture data is unknown
  93707. */
  93708. static DATASOURCE_UNKNOWN: number;
  93709. /**
  93710. * Texture data comes from an URL
  93711. */
  93712. static DATASOURCE_URL: number;
  93713. /**
  93714. * Texture data is only used for temporary storage
  93715. */
  93716. static DATASOURCE_TEMP: number;
  93717. /**
  93718. * Texture data comes from raw data (ArrayBuffer)
  93719. */
  93720. static DATASOURCE_RAW: number;
  93721. /**
  93722. * Texture content is dynamic (video or dynamic texture)
  93723. */
  93724. static DATASOURCE_DYNAMIC: number;
  93725. /**
  93726. * Texture content is generated by rendering to it
  93727. */
  93728. static DATASOURCE_RENDERTARGET: number;
  93729. /**
  93730. * Texture content is part of a multi render target process
  93731. */
  93732. static DATASOURCE_MULTIRENDERTARGET: number;
  93733. /**
  93734. * Texture data comes from a cube data file
  93735. */
  93736. static DATASOURCE_CUBE: number;
  93737. /**
  93738. * Texture data comes from a raw cube data
  93739. */
  93740. static DATASOURCE_CUBERAW: number;
  93741. /**
  93742. * Texture data come from a prefiltered cube data file
  93743. */
  93744. static DATASOURCE_CUBEPREFILTERED: number;
  93745. /**
  93746. * Texture content is raw 3D data
  93747. */
  93748. static DATASOURCE_RAW3D: number;
  93749. /**
  93750. * Texture content is a depth texture
  93751. */
  93752. static DATASOURCE_DEPTHTEXTURE: number;
  93753. /**
  93754. * Texture data comes from a raw cube data encoded with RGBD
  93755. */
  93756. static DATASOURCE_CUBERAW_RGBD: number;
  93757. /**
  93758. * Defines if the texture is ready
  93759. */
  93760. isReady: boolean;
  93761. /**
  93762. * Defines if the texture is a cube texture
  93763. */
  93764. isCube: boolean;
  93765. /**
  93766. * Defines if the texture contains 3D data
  93767. */
  93768. is3D: boolean;
  93769. /**
  93770. * Defines if the texture contains multiview data
  93771. */
  93772. isMultiview: boolean;
  93773. /**
  93774. * Gets the URL used to load this texture
  93775. */
  93776. url: string;
  93777. /**
  93778. * Gets the sampling mode of the texture
  93779. */
  93780. samplingMode: number;
  93781. /**
  93782. * Gets a boolean indicating if the texture needs mipmaps generation
  93783. */
  93784. generateMipMaps: boolean;
  93785. /**
  93786. * Gets the number of samples used by the texture (WebGL2+ only)
  93787. */
  93788. samples: number;
  93789. /**
  93790. * Gets the type of the texture (int, float...)
  93791. */
  93792. type: number;
  93793. /**
  93794. * Gets the format of the texture (RGB, RGBA...)
  93795. */
  93796. format: number;
  93797. /**
  93798. * Observable called when the texture is loaded
  93799. */
  93800. onLoadedObservable: Observable<InternalTexture>;
  93801. /**
  93802. * Gets the width of the texture
  93803. */
  93804. width: number;
  93805. /**
  93806. * Gets the height of the texture
  93807. */
  93808. height: number;
  93809. /**
  93810. * Gets the depth of the texture
  93811. */
  93812. depth: number;
  93813. /**
  93814. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  93815. */
  93816. baseWidth: number;
  93817. /**
  93818. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  93819. */
  93820. baseHeight: number;
  93821. /**
  93822. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  93823. */
  93824. baseDepth: number;
  93825. /**
  93826. * Gets a boolean indicating if the texture is inverted on Y axis
  93827. */
  93828. invertY: boolean;
  93829. /** @hidden */
  93830. _invertVScale: boolean;
  93831. /** @hidden */
  93832. _associatedChannel: number;
  93833. /** @hidden */
  93834. _dataSource: number;
  93835. /** @hidden */
  93836. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  93837. /** @hidden */
  93838. _bufferView: Nullable<ArrayBufferView>;
  93839. /** @hidden */
  93840. _bufferViewArray: Nullable<ArrayBufferView[]>;
  93841. /** @hidden */
  93842. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  93843. /** @hidden */
  93844. _size: number;
  93845. /** @hidden */
  93846. _extension: string;
  93847. /** @hidden */
  93848. _files: Nullable<string[]>;
  93849. /** @hidden */
  93850. _workingCanvas: Nullable<HTMLCanvasElement>;
  93851. /** @hidden */
  93852. _workingContext: Nullable<CanvasRenderingContext2D>;
  93853. /** @hidden */
  93854. _framebuffer: Nullable<WebGLFramebuffer>;
  93855. /** @hidden */
  93856. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  93857. /** @hidden */
  93858. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  93859. /** @hidden */
  93860. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  93861. /** @hidden */
  93862. _attachments: Nullable<number[]>;
  93863. /** @hidden */
  93864. _cachedCoordinatesMode: Nullable<number>;
  93865. /** @hidden */
  93866. _cachedWrapU: Nullable<number>;
  93867. /** @hidden */
  93868. _cachedWrapV: Nullable<number>;
  93869. /** @hidden */
  93870. _cachedWrapR: Nullable<number>;
  93871. /** @hidden */
  93872. _cachedAnisotropicFilteringLevel: Nullable<number>;
  93873. /** @hidden */
  93874. _isDisabled: boolean;
  93875. /** @hidden */
  93876. _compression: Nullable<string>;
  93877. /** @hidden */
  93878. _generateStencilBuffer: boolean;
  93879. /** @hidden */
  93880. _generateDepthBuffer: boolean;
  93881. /** @hidden */
  93882. _comparisonFunction: number;
  93883. /** @hidden */
  93884. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  93885. /** @hidden */
  93886. _lodGenerationScale: number;
  93887. /** @hidden */
  93888. _lodGenerationOffset: number;
  93889. /** @hidden */
  93890. _colorTextureArray: Nullable<WebGLTexture>;
  93891. /** @hidden */
  93892. _depthStencilTextureArray: Nullable<WebGLTexture>;
  93893. /** @hidden */
  93894. _lodTextureHigh: Nullable<BaseTexture>;
  93895. /** @hidden */
  93896. _lodTextureMid: Nullable<BaseTexture>;
  93897. /** @hidden */
  93898. _lodTextureLow: Nullable<BaseTexture>;
  93899. /** @hidden */
  93900. _isRGBD: boolean;
  93901. /** @hidden */
  93902. _linearSpecularLOD: boolean;
  93903. /** @hidden */
  93904. _irradianceTexture: Nullable<BaseTexture>;
  93905. /** @hidden */
  93906. _webGLTexture: Nullable<WebGLTexture>;
  93907. /** @hidden */
  93908. _references: number;
  93909. private _engine;
  93910. /**
  93911. * Gets the Engine the texture belongs to.
  93912. * @returns The babylon engine
  93913. */
  93914. getEngine(): Engine;
  93915. /**
  93916. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  93917. */
  93918. readonly dataSource: number;
  93919. /**
  93920. * Creates a new InternalTexture
  93921. * @param engine defines the engine to use
  93922. * @param dataSource defines the type of data that will be used
  93923. * @param delayAllocation if the texture allocation should be delayed (default: false)
  93924. */
  93925. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  93926. /**
  93927. * Increments the number of references (ie. the number of Texture that point to it)
  93928. */
  93929. incrementReferences(): void;
  93930. /**
  93931. * Change the size of the texture (not the size of the content)
  93932. * @param width defines the new width
  93933. * @param height defines the new height
  93934. * @param depth defines the new depth (1 by default)
  93935. */
  93936. updateSize(width: int, height: int, depth?: int): void;
  93937. /** @hidden */
  93938. _rebuild(): void;
  93939. /** @hidden */
  93940. _swapAndDie(target: InternalTexture): void;
  93941. /**
  93942. * Dispose the current allocated resources
  93943. */
  93944. dispose(): void;
  93945. }
  93946. }
  93947. declare module BABYLON {
  93948. /**
  93949. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  93950. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  93951. */
  93952. export class EffectFallbacks {
  93953. private _defines;
  93954. private _currentRank;
  93955. private _maxRank;
  93956. private _mesh;
  93957. /**
  93958. * Removes the fallback from the bound mesh.
  93959. */
  93960. unBindMesh(): void;
  93961. /**
  93962. * Adds a fallback on the specified property.
  93963. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  93964. * @param define The name of the define in the shader
  93965. */
  93966. addFallback(rank: number, define: string): void;
  93967. /**
  93968. * Sets the mesh to use CPU skinning when needing to fallback.
  93969. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  93970. * @param mesh The mesh to use the fallbacks.
  93971. */
  93972. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  93973. /**
  93974. * Checks to see if more fallbacks are still availible.
  93975. */
  93976. readonly hasMoreFallbacks: boolean;
  93977. /**
  93978. * Removes the defines that should be removed when falling back.
  93979. * @param currentDefines defines the current define statements for the shader.
  93980. * @param effect defines the current effect we try to compile
  93981. * @returns The resulting defines with defines of the current rank removed.
  93982. */
  93983. reduce(currentDefines: string, effect: Effect): string;
  93984. }
  93985. /**
  93986. * Options to be used when creating an effect.
  93987. */
  93988. export class EffectCreationOptions {
  93989. /**
  93990. * Atrributes that will be used in the shader.
  93991. */
  93992. attributes: string[];
  93993. /**
  93994. * Uniform varible names that will be set in the shader.
  93995. */
  93996. uniformsNames: string[];
  93997. /**
  93998. * Uniform buffer varible names that will be set in the shader.
  93999. */
  94000. uniformBuffersNames: string[];
  94001. /**
  94002. * Sampler texture variable names that will be set in the shader.
  94003. */
  94004. samplers: string[];
  94005. /**
  94006. * Define statements that will be set in the shader.
  94007. */
  94008. defines: any;
  94009. /**
  94010. * Possible fallbacks for this effect to improve performance when needed.
  94011. */
  94012. fallbacks: Nullable<EffectFallbacks>;
  94013. /**
  94014. * Callback that will be called when the shader is compiled.
  94015. */
  94016. onCompiled: Nullable<(effect: Effect) => void>;
  94017. /**
  94018. * Callback that will be called if an error occurs during shader compilation.
  94019. */
  94020. onError: Nullable<(effect: Effect, errors: string) => void>;
  94021. /**
  94022. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94023. */
  94024. indexParameters: any;
  94025. /**
  94026. * Max number of lights that can be used in the shader.
  94027. */
  94028. maxSimultaneousLights: number;
  94029. /**
  94030. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  94031. */
  94032. transformFeedbackVaryings: Nullable<string[]>;
  94033. }
  94034. /**
  94035. * Effect containing vertex and fragment shader that can be executed on an object.
  94036. */
  94037. export class Effect implements IDisposable {
  94038. /**
  94039. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  94040. */
  94041. static ShadersRepository: string;
  94042. /**
  94043. * Name of the effect.
  94044. */
  94045. name: any;
  94046. /**
  94047. * String container all the define statements that should be set on the shader.
  94048. */
  94049. defines: string;
  94050. /**
  94051. * Callback that will be called when the shader is compiled.
  94052. */
  94053. onCompiled: Nullable<(effect: Effect) => void>;
  94054. /**
  94055. * Callback that will be called if an error occurs during shader compilation.
  94056. */
  94057. onError: Nullable<(effect: Effect, errors: string) => void>;
  94058. /**
  94059. * Callback that will be called when effect is bound.
  94060. */
  94061. onBind: Nullable<(effect: Effect) => void>;
  94062. /**
  94063. * Unique ID of the effect.
  94064. */
  94065. uniqueId: number;
  94066. /**
  94067. * Observable that will be called when the shader is compiled.
  94068. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  94069. */
  94070. onCompileObservable: Observable<Effect>;
  94071. /**
  94072. * Observable that will be called if an error occurs during shader compilation.
  94073. */
  94074. onErrorObservable: Observable<Effect>;
  94075. /** @hidden */
  94076. _onBindObservable: Nullable<Observable<Effect>>;
  94077. /**
  94078. * Observable that will be called when effect is bound.
  94079. */
  94080. readonly onBindObservable: Observable<Effect>;
  94081. /** @hidden */
  94082. _bonesComputationForcedToCPU: boolean;
  94083. private static _uniqueIdSeed;
  94084. private _engine;
  94085. private _uniformBuffersNames;
  94086. private _uniformsNames;
  94087. private _samplerList;
  94088. private _samplers;
  94089. private _isReady;
  94090. private _compilationError;
  94091. private _attributesNames;
  94092. private _attributes;
  94093. private _uniforms;
  94094. /**
  94095. * Key for the effect.
  94096. * @hidden
  94097. */
  94098. _key: string;
  94099. private _indexParameters;
  94100. private _fallbacks;
  94101. private _vertexSourceCode;
  94102. private _fragmentSourceCode;
  94103. private _vertexSourceCodeOverride;
  94104. private _fragmentSourceCodeOverride;
  94105. private _transformFeedbackVaryings;
  94106. /**
  94107. * Compiled shader to webGL program.
  94108. * @hidden
  94109. */
  94110. _pipelineContext: Nullable<IPipelineContext>;
  94111. private _valueCache;
  94112. private static _baseCache;
  94113. /**
  94114. * Instantiates an effect.
  94115. * An effect can be used to create/manage/execute vertex and fragment shaders.
  94116. * @param baseName Name of the effect.
  94117. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  94118. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  94119. * @param samplers List of sampler variables that will be passed to the shader.
  94120. * @param engine Engine to be used to render the effect
  94121. * @param defines Define statements to be added to the shader.
  94122. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  94123. * @param onCompiled Callback that will be called when the shader is compiled.
  94124. * @param onError Callback that will be called if an error occurs during shader compilation.
  94125. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94126. */
  94127. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  94128. private _useFinalCode;
  94129. /**
  94130. * Unique key for this effect
  94131. */
  94132. readonly key: string;
  94133. /**
  94134. * If the effect has been compiled and prepared.
  94135. * @returns if the effect is compiled and prepared.
  94136. */
  94137. isReady(): boolean;
  94138. private _isReadyInternal;
  94139. /**
  94140. * The engine the effect was initialized with.
  94141. * @returns the engine.
  94142. */
  94143. getEngine(): Engine;
  94144. /**
  94145. * The pipeline context for this effect
  94146. * @returns the associated pipeline context
  94147. */
  94148. getPipelineContext(): Nullable<IPipelineContext>;
  94149. /**
  94150. * The set of names of attribute variables for the shader.
  94151. * @returns An array of attribute names.
  94152. */
  94153. getAttributesNames(): string[];
  94154. /**
  94155. * Returns the attribute at the given index.
  94156. * @param index The index of the attribute.
  94157. * @returns The location of the attribute.
  94158. */
  94159. getAttributeLocation(index: number): number;
  94160. /**
  94161. * Returns the attribute based on the name of the variable.
  94162. * @param name of the attribute to look up.
  94163. * @returns the attribute location.
  94164. */
  94165. getAttributeLocationByName(name: string): number;
  94166. /**
  94167. * The number of attributes.
  94168. * @returns the numnber of attributes.
  94169. */
  94170. getAttributesCount(): number;
  94171. /**
  94172. * Gets the index of a uniform variable.
  94173. * @param uniformName of the uniform to look up.
  94174. * @returns the index.
  94175. */
  94176. getUniformIndex(uniformName: string): number;
  94177. /**
  94178. * Returns the attribute based on the name of the variable.
  94179. * @param uniformName of the uniform to look up.
  94180. * @returns the location of the uniform.
  94181. */
  94182. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  94183. /**
  94184. * Returns an array of sampler variable names
  94185. * @returns The array of sampler variable neames.
  94186. */
  94187. getSamplers(): string[];
  94188. /**
  94189. * The error from the last compilation.
  94190. * @returns the error string.
  94191. */
  94192. getCompilationError(): string;
  94193. /**
  94194. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  94195. * @param func The callback to be used.
  94196. */
  94197. executeWhenCompiled(func: (effect: Effect) => void): void;
  94198. private _checkIsReady;
  94199. /** @hidden */
  94200. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  94201. /** @hidden */
  94202. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  94203. /** @hidden */
  94204. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  94205. /**
  94206. * Recompiles the webGL program
  94207. * @param vertexSourceCode The source code for the vertex shader.
  94208. * @param fragmentSourceCode The source code for the fragment shader.
  94209. * @param onCompiled Callback called when completed.
  94210. * @param onError Callback called on error.
  94211. * @hidden
  94212. */
  94213. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  94214. /**
  94215. * Prepares the effect
  94216. * @hidden
  94217. */
  94218. _prepareEffect(): void;
  94219. private _processCompilationErrors;
  94220. /**
  94221. * Checks if the effect is supported. (Must be called after compilation)
  94222. */
  94223. readonly isSupported: boolean;
  94224. /**
  94225. * Binds a texture to the engine to be used as output of the shader.
  94226. * @param channel Name of the output variable.
  94227. * @param texture Texture to bind.
  94228. * @hidden
  94229. */
  94230. _bindTexture(channel: string, texture: InternalTexture): void;
  94231. /**
  94232. * Sets a texture on the engine to be used in the shader.
  94233. * @param channel Name of the sampler variable.
  94234. * @param texture Texture to set.
  94235. */
  94236. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  94237. /**
  94238. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  94239. * @param channel Name of the sampler variable.
  94240. * @param texture Texture to set.
  94241. */
  94242. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  94243. /**
  94244. * Sets an array of textures on the engine to be used in the shader.
  94245. * @param channel Name of the variable.
  94246. * @param textures Textures to set.
  94247. */
  94248. setTextureArray(channel: string, textures: BaseTexture[]): void;
  94249. /**
  94250. * 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)
  94251. * @param channel Name of the sampler variable.
  94252. * @param postProcess Post process to get the input texture from.
  94253. */
  94254. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  94255. /**
  94256. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  94257. * 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)
  94258. * @param channel Name of the sampler variable.
  94259. * @param postProcess Post process to get the output texture from.
  94260. */
  94261. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  94262. /** @hidden */
  94263. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  94264. /** @hidden */
  94265. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  94266. /** @hidden */
  94267. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  94268. /** @hidden */
  94269. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  94270. /**
  94271. * Binds a buffer to a uniform.
  94272. * @param buffer Buffer to bind.
  94273. * @param name Name of the uniform variable to bind to.
  94274. */
  94275. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  94276. /**
  94277. * Binds block to a uniform.
  94278. * @param blockName Name of the block to bind.
  94279. * @param index Index to bind.
  94280. */
  94281. bindUniformBlock(blockName: string, index: number): void;
  94282. /**
  94283. * Sets an interger value on a uniform variable.
  94284. * @param uniformName Name of the variable.
  94285. * @param value Value to be set.
  94286. * @returns this effect.
  94287. */
  94288. setInt(uniformName: string, value: number): Effect;
  94289. /**
  94290. * Sets an int array on a uniform variable.
  94291. * @param uniformName Name of the variable.
  94292. * @param array array to be set.
  94293. * @returns this effect.
  94294. */
  94295. setIntArray(uniformName: string, array: Int32Array): Effect;
  94296. /**
  94297. * 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)
  94298. * @param uniformName Name of the variable.
  94299. * @param array array to be set.
  94300. * @returns this effect.
  94301. */
  94302. setIntArray2(uniformName: string, array: Int32Array): Effect;
  94303. /**
  94304. * 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)
  94305. * @param uniformName Name of the variable.
  94306. * @param array array to be set.
  94307. * @returns this effect.
  94308. */
  94309. setIntArray3(uniformName: string, array: Int32Array): Effect;
  94310. /**
  94311. * 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)
  94312. * @param uniformName Name of the variable.
  94313. * @param array array to be set.
  94314. * @returns this effect.
  94315. */
  94316. setIntArray4(uniformName: string, array: Int32Array): Effect;
  94317. /**
  94318. * Sets an float array on a uniform variable.
  94319. * @param uniformName Name of the variable.
  94320. * @param array array to be set.
  94321. * @returns this effect.
  94322. */
  94323. setFloatArray(uniformName: string, array: Float32Array): Effect;
  94324. /**
  94325. * 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)
  94326. * @param uniformName Name of the variable.
  94327. * @param array array to be set.
  94328. * @returns this effect.
  94329. */
  94330. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  94331. /**
  94332. * 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)
  94333. * @param uniformName Name of the variable.
  94334. * @param array array to be set.
  94335. * @returns this effect.
  94336. */
  94337. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  94338. /**
  94339. * 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)
  94340. * @param uniformName Name of the variable.
  94341. * @param array array to be set.
  94342. * @returns this effect.
  94343. */
  94344. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  94345. /**
  94346. * Sets an array on a uniform variable.
  94347. * @param uniformName Name of the variable.
  94348. * @param array array to be set.
  94349. * @returns this effect.
  94350. */
  94351. setArray(uniformName: string, array: number[]): Effect;
  94352. /**
  94353. * 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)
  94354. * @param uniformName Name of the variable.
  94355. * @param array array to be set.
  94356. * @returns this effect.
  94357. */
  94358. setArray2(uniformName: string, array: number[]): Effect;
  94359. /**
  94360. * 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)
  94361. * @param uniformName Name of the variable.
  94362. * @param array array to be set.
  94363. * @returns this effect.
  94364. */
  94365. setArray3(uniformName: string, array: number[]): Effect;
  94366. /**
  94367. * 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)
  94368. * @param uniformName Name of the variable.
  94369. * @param array array to be set.
  94370. * @returns this effect.
  94371. */
  94372. setArray4(uniformName: string, array: number[]): Effect;
  94373. /**
  94374. * Sets matrices on a uniform variable.
  94375. * @param uniformName Name of the variable.
  94376. * @param matrices matrices to be set.
  94377. * @returns this effect.
  94378. */
  94379. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  94380. /**
  94381. * Sets matrix on a uniform variable.
  94382. * @param uniformName Name of the variable.
  94383. * @param matrix matrix to be set.
  94384. * @returns this effect.
  94385. */
  94386. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  94387. /**
  94388. * 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)
  94389. * @param uniformName Name of the variable.
  94390. * @param matrix matrix to be set.
  94391. * @returns this effect.
  94392. */
  94393. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  94394. /**
  94395. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  94396. * @param uniformName Name of the variable.
  94397. * @param matrix matrix to be set.
  94398. * @returns this effect.
  94399. */
  94400. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  94401. /**
  94402. * Sets a float on a uniform variable.
  94403. * @param uniformName Name of the variable.
  94404. * @param value value to be set.
  94405. * @returns this effect.
  94406. */
  94407. setFloat(uniformName: string, value: number): Effect;
  94408. /**
  94409. * Sets a boolean on a uniform variable.
  94410. * @param uniformName Name of the variable.
  94411. * @param bool value to be set.
  94412. * @returns this effect.
  94413. */
  94414. setBool(uniformName: string, bool: boolean): Effect;
  94415. /**
  94416. * Sets a Vector2 on a uniform variable.
  94417. * @param uniformName Name of the variable.
  94418. * @param vector2 vector2 to be set.
  94419. * @returns this effect.
  94420. */
  94421. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  94422. /**
  94423. * Sets a float2 on a uniform variable.
  94424. * @param uniformName Name of the variable.
  94425. * @param x First float in float2.
  94426. * @param y Second float in float2.
  94427. * @returns this effect.
  94428. */
  94429. setFloat2(uniformName: string, x: number, y: number): Effect;
  94430. /**
  94431. * Sets a Vector3 on a uniform variable.
  94432. * @param uniformName Name of the variable.
  94433. * @param vector3 Value to be set.
  94434. * @returns this effect.
  94435. */
  94436. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  94437. /**
  94438. * Sets a float3 on a uniform variable.
  94439. * @param uniformName Name of the variable.
  94440. * @param x First float in float3.
  94441. * @param y Second float in float3.
  94442. * @param z Third float in float3.
  94443. * @returns this effect.
  94444. */
  94445. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  94446. /**
  94447. * Sets a Vector4 on a uniform variable.
  94448. * @param uniformName Name of the variable.
  94449. * @param vector4 Value to be set.
  94450. * @returns this effect.
  94451. */
  94452. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  94453. /**
  94454. * Sets a float4 on a uniform variable.
  94455. * @param uniformName Name of the variable.
  94456. * @param x First float in float4.
  94457. * @param y Second float in float4.
  94458. * @param z Third float in float4.
  94459. * @param w Fourth float in float4.
  94460. * @returns this effect.
  94461. */
  94462. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  94463. /**
  94464. * Sets a Color3 on a uniform variable.
  94465. * @param uniformName Name of the variable.
  94466. * @param color3 Value to be set.
  94467. * @returns this effect.
  94468. */
  94469. setColor3(uniformName: string, color3: IColor3Like): Effect;
  94470. /**
  94471. * Sets a Color4 on a uniform variable.
  94472. * @param uniformName Name of the variable.
  94473. * @param color3 Value to be set.
  94474. * @param alpha Alpha value to be set.
  94475. * @returns this effect.
  94476. */
  94477. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  94478. /**
  94479. * Sets a Color4 on a uniform variable
  94480. * @param uniformName defines the name of the variable
  94481. * @param color4 defines the value to be set
  94482. * @returns this effect.
  94483. */
  94484. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  94485. /** Release all associated resources */
  94486. dispose(): void;
  94487. /**
  94488. * This function will add a new shader to the shader store
  94489. * @param name the name of the shader
  94490. * @param pixelShader optional pixel shader content
  94491. * @param vertexShader optional vertex shader content
  94492. */
  94493. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  94494. /**
  94495. * Store of each shader (The can be looked up using effect.key)
  94496. */
  94497. static ShadersStore: {
  94498. [key: string]: string;
  94499. };
  94500. /**
  94501. * Store of each included file for a shader (The can be looked up using effect.key)
  94502. */
  94503. static IncludesShadersStore: {
  94504. [key: string]: string;
  94505. };
  94506. /**
  94507. * Resets the cache of effects.
  94508. */
  94509. static ResetCache(): void;
  94510. }
  94511. }
  94512. declare module BABYLON {
  94513. /**
  94514. * Uniform buffer objects.
  94515. *
  94516. * Handles blocks of uniform on the GPU.
  94517. *
  94518. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  94519. *
  94520. * For more information, please refer to :
  94521. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  94522. */
  94523. export class UniformBuffer {
  94524. private _engine;
  94525. private _buffer;
  94526. private _data;
  94527. private _bufferData;
  94528. private _dynamic?;
  94529. private _uniformLocations;
  94530. private _uniformSizes;
  94531. private _uniformLocationPointer;
  94532. private _needSync;
  94533. private _noUBO;
  94534. private _currentEffect;
  94535. private static _MAX_UNIFORM_SIZE;
  94536. private static _tempBuffer;
  94537. /**
  94538. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  94539. * This is dynamic to allow compat with webgl 1 and 2.
  94540. * You will need to pass the name of the uniform as well as the value.
  94541. */
  94542. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  94543. /**
  94544. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  94545. * This is dynamic to allow compat with webgl 1 and 2.
  94546. * You will need to pass the name of the uniform as well as the value.
  94547. */
  94548. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  94549. /**
  94550. * Lambda to Update a single float in a uniform buffer.
  94551. * This is dynamic to allow compat with webgl 1 and 2.
  94552. * You will need to pass the name of the uniform as well as the value.
  94553. */
  94554. updateFloat: (name: string, x: number) => void;
  94555. /**
  94556. * Lambda to Update a vec2 of float in a uniform buffer.
  94557. * This is dynamic to allow compat with webgl 1 and 2.
  94558. * You will need to pass the name of the uniform as well as the value.
  94559. */
  94560. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  94561. /**
  94562. * Lambda to Update a vec3 of float in a uniform buffer.
  94563. * This is dynamic to allow compat with webgl 1 and 2.
  94564. * You will need to pass the name of the uniform as well as the value.
  94565. */
  94566. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  94567. /**
  94568. * Lambda to Update a vec4 of float in a uniform buffer.
  94569. * This is dynamic to allow compat with webgl 1 and 2.
  94570. * You will need to pass the name of the uniform as well as the value.
  94571. */
  94572. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  94573. /**
  94574. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  94575. * This is dynamic to allow compat with webgl 1 and 2.
  94576. * You will need to pass the name of the uniform as well as the value.
  94577. */
  94578. updateMatrix: (name: string, mat: Matrix) => void;
  94579. /**
  94580. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  94581. * This is dynamic to allow compat with webgl 1 and 2.
  94582. * You will need to pass the name of the uniform as well as the value.
  94583. */
  94584. updateVector3: (name: string, vector: Vector3) => void;
  94585. /**
  94586. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  94587. * This is dynamic to allow compat with webgl 1 and 2.
  94588. * You will need to pass the name of the uniform as well as the value.
  94589. */
  94590. updateVector4: (name: string, vector: Vector4) => void;
  94591. /**
  94592. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  94593. * This is dynamic to allow compat with webgl 1 and 2.
  94594. * You will need to pass the name of the uniform as well as the value.
  94595. */
  94596. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  94597. /**
  94598. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  94599. * This is dynamic to allow compat with webgl 1 and 2.
  94600. * You will need to pass the name of the uniform as well as the value.
  94601. */
  94602. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  94603. /**
  94604. * Instantiates a new Uniform buffer objects.
  94605. *
  94606. * Handles blocks of uniform on the GPU.
  94607. *
  94608. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  94609. *
  94610. * For more information, please refer to :
  94611. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  94612. * @param engine Define the engine the buffer is associated with
  94613. * @param data Define the data contained in the buffer
  94614. * @param dynamic Define if the buffer is updatable
  94615. */
  94616. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  94617. /**
  94618. * Indicates if the buffer is using the WebGL2 UBO implementation,
  94619. * or just falling back on setUniformXXX calls.
  94620. */
  94621. readonly useUbo: boolean;
  94622. /**
  94623. * Indicates if the WebGL underlying uniform buffer is in sync
  94624. * with the javascript cache data.
  94625. */
  94626. readonly isSync: boolean;
  94627. /**
  94628. * Indicates if the WebGL underlying uniform buffer is dynamic.
  94629. * Also, a dynamic UniformBuffer will disable cache verification and always
  94630. * update the underlying WebGL uniform buffer to the GPU.
  94631. * @returns if Dynamic, otherwise false
  94632. */
  94633. isDynamic(): boolean;
  94634. /**
  94635. * The data cache on JS side.
  94636. * @returns the underlying data as a float array
  94637. */
  94638. getData(): Float32Array;
  94639. /**
  94640. * The underlying WebGL Uniform buffer.
  94641. * @returns the webgl buffer
  94642. */
  94643. getBuffer(): Nullable<DataBuffer>;
  94644. /**
  94645. * std140 layout specifies how to align data within an UBO structure.
  94646. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  94647. * for specs.
  94648. */
  94649. private _fillAlignment;
  94650. /**
  94651. * Adds an uniform in the buffer.
  94652. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  94653. * for the layout to be correct !
  94654. * @param name Name of the uniform, as used in the uniform block in the shader.
  94655. * @param size Data size, or data directly.
  94656. */
  94657. addUniform(name: string, size: number | number[]): void;
  94658. /**
  94659. * Adds a Matrix 4x4 to the uniform buffer.
  94660. * @param name Name of the uniform, as used in the uniform block in the shader.
  94661. * @param mat A 4x4 matrix.
  94662. */
  94663. addMatrix(name: string, mat: Matrix): void;
  94664. /**
  94665. * Adds a vec2 to the uniform buffer.
  94666. * @param name Name of the uniform, as used in the uniform block in the shader.
  94667. * @param x Define the x component value of the vec2
  94668. * @param y Define the y component value of the vec2
  94669. */
  94670. addFloat2(name: string, x: number, y: number): void;
  94671. /**
  94672. * Adds a vec3 to the uniform buffer.
  94673. * @param name Name of the uniform, as used in the uniform block in the shader.
  94674. * @param x Define the x component value of the vec3
  94675. * @param y Define the y component value of the vec3
  94676. * @param z Define the z component value of the vec3
  94677. */
  94678. addFloat3(name: string, x: number, y: number, z: number): void;
  94679. /**
  94680. * Adds a vec3 to the uniform buffer.
  94681. * @param name Name of the uniform, as used in the uniform block in the shader.
  94682. * @param color Define the vec3 from a Color
  94683. */
  94684. addColor3(name: string, color: Color3): void;
  94685. /**
  94686. * Adds a vec4 to the uniform buffer.
  94687. * @param name Name of the uniform, as used in the uniform block in the shader.
  94688. * @param color Define the rgb components from a Color
  94689. * @param alpha Define the a component of the vec4
  94690. */
  94691. addColor4(name: string, color: Color3, alpha: number): void;
  94692. /**
  94693. * Adds a vec3 to the uniform buffer.
  94694. * @param name Name of the uniform, as used in the uniform block in the shader.
  94695. * @param vector Define the vec3 components from a Vector
  94696. */
  94697. addVector3(name: string, vector: Vector3): void;
  94698. /**
  94699. * Adds a Matrix 3x3 to the uniform buffer.
  94700. * @param name Name of the uniform, as used in the uniform block in the shader.
  94701. */
  94702. addMatrix3x3(name: string): void;
  94703. /**
  94704. * Adds a Matrix 2x2 to the uniform buffer.
  94705. * @param name Name of the uniform, as used in the uniform block in the shader.
  94706. */
  94707. addMatrix2x2(name: string): void;
  94708. /**
  94709. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  94710. */
  94711. create(): void;
  94712. /** @hidden */
  94713. _rebuild(): void;
  94714. /**
  94715. * Updates the WebGL Uniform Buffer on the GPU.
  94716. * If the `dynamic` flag is set to true, no cache comparison is done.
  94717. * Otherwise, the buffer will be updated only if the cache differs.
  94718. */
  94719. update(): void;
  94720. /**
  94721. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  94722. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  94723. * @param data Define the flattened data
  94724. * @param size Define the size of the data.
  94725. */
  94726. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  94727. private _valueCache;
  94728. private _cacheMatrix;
  94729. private _updateMatrix3x3ForUniform;
  94730. private _updateMatrix3x3ForEffect;
  94731. private _updateMatrix2x2ForEffect;
  94732. private _updateMatrix2x2ForUniform;
  94733. private _updateFloatForEffect;
  94734. private _updateFloatForUniform;
  94735. private _updateFloat2ForEffect;
  94736. private _updateFloat2ForUniform;
  94737. private _updateFloat3ForEffect;
  94738. private _updateFloat3ForUniform;
  94739. private _updateFloat4ForEffect;
  94740. private _updateFloat4ForUniform;
  94741. private _updateMatrixForEffect;
  94742. private _updateMatrixForUniform;
  94743. private _updateVector3ForEffect;
  94744. private _updateVector3ForUniform;
  94745. private _updateVector4ForEffect;
  94746. private _updateVector4ForUniform;
  94747. private _updateColor3ForEffect;
  94748. private _updateColor3ForUniform;
  94749. private _updateColor4ForEffect;
  94750. private _updateColor4ForUniform;
  94751. /**
  94752. * Sets a sampler uniform on the effect.
  94753. * @param name Define the name of the sampler.
  94754. * @param texture Define the texture to set in the sampler
  94755. */
  94756. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  94757. /**
  94758. * Directly updates the value of the uniform in the cache AND on the GPU.
  94759. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  94760. * @param data Define the flattened data
  94761. */
  94762. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  94763. /**
  94764. * Binds this uniform buffer to an effect.
  94765. * @param effect Define the effect to bind the buffer to
  94766. * @param name Name of the uniform block in the shader.
  94767. */
  94768. bindToEffect(effect: Effect, name: string): void;
  94769. /**
  94770. * Disposes the uniform buffer.
  94771. */
  94772. dispose(): void;
  94773. }
  94774. }
  94775. declare module BABYLON {
  94776. /**
  94777. * Class used to work with sound analyzer using fast fourier transform (FFT)
  94778. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94779. */
  94780. export class Analyser {
  94781. /**
  94782. * Gets or sets the smoothing
  94783. * @ignorenaming
  94784. */
  94785. SMOOTHING: number;
  94786. /**
  94787. * Gets or sets the FFT table size
  94788. * @ignorenaming
  94789. */
  94790. FFT_SIZE: number;
  94791. /**
  94792. * Gets or sets the bar graph amplitude
  94793. * @ignorenaming
  94794. */
  94795. BARGRAPHAMPLITUDE: number;
  94796. /**
  94797. * Gets or sets the position of the debug canvas
  94798. * @ignorenaming
  94799. */
  94800. DEBUGCANVASPOS: {
  94801. x: number;
  94802. y: number;
  94803. };
  94804. /**
  94805. * Gets or sets the debug canvas size
  94806. * @ignorenaming
  94807. */
  94808. DEBUGCANVASSIZE: {
  94809. width: number;
  94810. height: number;
  94811. };
  94812. private _byteFreqs;
  94813. private _byteTime;
  94814. private _floatFreqs;
  94815. private _webAudioAnalyser;
  94816. private _debugCanvas;
  94817. private _debugCanvasContext;
  94818. private _scene;
  94819. private _registerFunc;
  94820. private _audioEngine;
  94821. /**
  94822. * Creates a new analyser
  94823. * @param scene defines hosting scene
  94824. */
  94825. constructor(scene: Scene);
  94826. /**
  94827. * Get the number of data values you will have to play with for the visualization
  94828. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  94829. * @returns a number
  94830. */
  94831. getFrequencyBinCount(): number;
  94832. /**
  94833. * Gets the current frequency data as a byte array
  94834. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  94835. * @returns a Uint8Array
  94836. */
  94837. getByteFrequencyData(): Uint8Array;
  94838. /**
  94839. * Gets the current waveform as a byte array
  94840. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  94841. * @returns a Uint8Array
  94842. */
  94843. getByteTimeDomainData(): Uint8Array;
  94844. /**
  94845. * Gets the current frequency data as a float array
  94846. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  94847. * @returns a Float32Array
  94848. */
  94849. getFloatFrequencyData(): Float32Array;
  94850. /**
  94851. * Renders the debug canvas
  94852. */
  94853. drawDebugCanvas(): void;
  94854. /**
  94855. * Stops rendering the debug canvas and removes it
  94856. */
  94857. stopDebugCanvas(): void;
  94858. /**
  94859. * Connects two audio nodes
  94860. * @param inputAudioNode defines first node to connect
  94861. * @param outputAudioNode defines second node to connect
  94862. */
  94863. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  94864. /**
  94865. * Releases all associated resources
  94866. */
  94867. dispose(): void;
  94868. }
  94869. }
  94870. declare module BABYLON {
  94871. /**
  94872. * This represents an audio engine and it is responsible
  94873. * to play, synchronize and analyse sounds throughout the application.
  94874. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94875. */
  94876. export interface IAudioEngine extends IDisposable {
  94877. /**
  94878. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  94879. */
  94880. readonly canUseWebAudio: boolean;
  94881. /**
  94882. * Gets the current AudioContext if available.
  94883. */
  94884. readonly audioContext: Nullable<AudioContext>;
  94885. /**
  94886. * The master gain node defines the global audio volume of your audio engine.
  94887. */
  94888. readonly masterGain: GainNode;
  94889. /**
  94890. * Gets whether or not mp3 are supported by your browser.
  94891. */
  94892. readonly isMP3supported: boolean;
  94893. /**
  94894. * Gets whether or not ogg are supported by your browser.
  94895. */
  94896. readonly isOGGsupported: boolean;
  94897. /**
  94898. * Defines if Babylon should emit a warning if WebAudio is not supported.
  94899. * @ignoreNaming
  94900. */
  94901. WarnedWebAudioUnsupported: boolean;
  94902. /**
  94903. * Defines if the audio engine relies on a custom unlocked button.
  94904. * In this case, the embedded button will not be displayed.
  94905. */
  94906. useCustomUnlockedButton: boolean;
  94907. /**
  94908. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  94909. */
  94910. readonly unlocked: boolean;
  94911. /**
  94912. * Event raised when audio has been unlocked on the browser.
  94913. */
  94914. onAudioUnlockedObservable: Observable<AudioEngine>;
  94915. /**
  94916. * Event raised when audio has been locked on the browser.
  94917. */
  94918. onAudioLockedObservable: Observable<AudioEngine>;
  94919. /**
  94920. * Flags the audio engine in Locked state.
  94921. * This happens due to new browser policies preventing audio to autoplay.
  94922. */
  94923. lock(): void;
  94924. /**
  94925. * Unlocks the audio engine once a user action has been done on the dom.
  94926. * This is helpful to resume play once browser policies have been satisfied.
  94927. */
  94928. unlock(): void;
  94929. }
  94930. /**
  94931. * This represents the default audio engine used in babylon.
  94932. * It is responsible to play, synchronize and analyse sounds throughout the application.
  94933. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94934. */
  94935. export class AudioEngine implements IAudioEngine {
  94936. private _audioContext;
  94937. private _audioContextInitialized;
  94938. private _muteButton;
  94939. private _hostElement;
  94940. /**
  94941. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  94942. */
  94943. canUseWebAudio: boolean;
  94944. /**
  94945. * The master gain node defines the global audio volume of your audio engine.
  94946. */
  94947. masterGain: GainNode;
  94948. /**
  94949. * Defines if Babylon should emit a warning if WebAudio is not supported.
  94950. * @ignoreNaming
  94951. */
  94952. WarnedWebAudioUnsupported: boolean;
  94953. /**
  94954. * Gets whether or not mp3 are supported by your browser.
  94955. */
  94956. isMP3supported: boolean;
  94957. /**
  94958. * Gets whether or not ogg are supported by your browser.
  94959. */
  94960. isOGGsupported: boolean;
  94961. /**
  94962. * Gets whether audio has been unlocked on the device.
  94963. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  94964. * a user interaction has happened.
  94965. */
  94966. unlocked: boolean;
  94967. /**
  94968. * Defines if the audio engine relies on a custom unlocked button.
  94969. * In this case, the embedded button will not be displayed.
  94970. */
  94971. useCustomUnlockedButton: boolean;
  94972. /**
  94973. * Event raised when audio has been unlocked on the browser.
  94974. */
  94975. onAudioUnlockedObservable: Observable<AudioEngine>;
  94976. /**
  94977. * Event raised when audio has been locked on the browser.
  94978. */
  94979. onAudioLockedObservable: Observable<AudioEngine>;
  94980. /**
  94981. * Gets the current AudioContext if available.
  94982. */
  94983. readonly audioContext: Nullable<AudioContext>;
  94984. private _connectedAnalyser;
  94985. /**
  94986. * Instantiates a new audio engine.
  94987. *
  94988. * There should be only one per page as some browsers restrict the number
  94989. * of audio contexts you can create.
  94990. * @param hostElement defines the host element where to display the mute icon if necessary
  94991. */
  94992. constructor(hostElement?: Nullable<HTMLElement>);
  94993. /**
  94994. * Flags the audio engine in Locked state.
  94995. * This happens due to new browser policies preventing audio to autoplay.
  94996. */
  94997. lock(): void;
  94998. /**
  94999. * Unlocks the audio engine once a user action has been done on the dom.
  95000. * This is helpful to resume play once browser policies have been satisfied.
  95001. */
  95002. unlock(): void;
  95003. private _resumeAudioContext;
  95004. private _initializeAudioContext;
  95005. private _tryToRun;
  95006. private _triggerRunningState;
  95007. private _triggerSuspendedState;
  95008. private _displayMuteButton;
  95009. private _moveButtonToTopLeft;
  95010. private _onResize;
  95011. private _hideMuteButton;
  95012. /**
  95013. * Destroy and release the resources associated with the audio ccontext.
  95014. */
  95015. dispose(): void;
  95016. /**
  95017. * Gets the global volume sets on the master gain.
  95018. * @returns the global volume if set or -1 otherwise
  95019. */
  95020. getGlobalVolume(): number;
  95021. /**
  95022. * Sets the global volume of your experience (sets on the master gain).
  95023. * @param newVolume Defines the new global volume of the application
  95024. */
  95025. setGlobalVolume(newVolume: number): void;
  95026. /**
  95027. * Connect the audio engine to an audio analyser allowing some amazing
  95028. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  95029. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  95030. * @param analyser The analyser to connect to the engine
  95031. */
  95032. connectToAnalyser(analyser: Analyser): void;
  95033. }
  95034. }
  95035. declare module BABYLON {
  95036. /**
  95037. * Interface used to present a loading screen while loading a scene
  95038. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95039. */
  95040. export interface ILoadingScreen {
  95041. /**
  95042. * Function called to display the loading screen
  95043. */
  95044. displayLoadingUI: () => void;
  95045. /**
  95046. * Function called to hide the loading screen
  95047. */
  95048. hideLoadingUI: () => void;
  95049. /**
  95050. * Gets or sets the color to use for the background
  95051. */
  95052. loadingUIBackgroundColor: string;
  95053. /**
  95054. * Gets or sets the text to display while loading
  95055. */
  95056. loadingUIText: string;
  95057. }
  95058. /**
  95059. * Class used for the default loading screen
  95060. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95061. */
  95062. export class DefaultLoadingScreen implements ILoadingScreen {
  95063. private _renderingCanvas;
  95064. private _loadingText;
  95065. private _loadingDivBackgroundColor;
  95066. private _loadingDiv;
  95067. private _loadingTextDiv;
  95068. /** Gets or sets the logo url to use for the default loading screen */
  95069. static DefaultLogoUrl: string;
  95070. /** Gets or sets the spinner url to use for the default loading screen */
  95071. static DefaultSpinnerUrl: string;
  95072. /**
  95073. * Creates a new default loading screen
  95074. * @param _renderingCanvas defines the canvas used to render the scene
  95075. * @param _loadingText defines the default text to display
  95076. * @param _loadingDivBackgroundColor defines the default background color
  95077. */
  95078. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  95079. /**
  95080. * Function called to display the loading screen
  95081. */
  95082. displayLoadingUI(): void;
  95083. /**
  95084. * Function called to hide the loading screen
  95085. */
  95086. hideLoadingUI(): void;
  95087. /**
  95088. * Gets or sets the text to display while loading
  95089. */
  95090. loadingUIText: string;
  95091. /**
  95092. * Gets or sets the color to use for the background
  95093. */
  95094. loadingUIBackgroundColor: string;
  95095. private _resizeLoadingUI;
  95096. }
  95097. }
  95098. declare module BABYLON {
  95099. /** @hidden */
  95100. export class WebGLPipelineContext implements IPipelineContext {
  95101. engine: Engine;
  95102. program: Nullable<WebGLProgram>;
  95103. context?: WebGLRenderingContext;
  95104. vertexShader?: WebGLShader;
  95105. fragmentShader?: WebGLShader;
  95106. isParallelCompiled: boolean;
  95107. onCompiled?: () => void;
  95108. transformFeedback?: WebGLTransformFeedback | null;
  95109. readonly isAsync: boolean;
  95110. readonly isReady: boolean;
  95111. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  95112. }
  95113. }
  95114. declare module BABYLON {
  95115. /** @hidden */
  95116. export class WebGLDataBuffer extends DataBuffer {
  95117. private _buffer;
  95118. constructor(resource: WebGLBuffer);
  95119. readonly underlyingResource: any;
  95120. }
  95121. }
  95122. declare module BABYLON {
  95123. /** @hidden */
  95124. export class WebGL2ShaderProcessor implements IShaderProcessor {
  95125. attributeProcessor(attribute: string): string;
  95126. varyingProcessor(varying: string, isFragment: boolean): string;
  95127. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  95128. }
  95129. }
  95130. declare module BABYLON {
  95131. /**
  95132. * This class is used to track a performance counter which is number based.
  95133. * The user has access to many properties which give statistics of different nature.
  95134. *
  95135. * The implementer can track two kinds of Performance Counter: time and count.
  95136. * 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.
  95137. * 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.
  95138. */
  95139. export class PerfCounter {
  95140. /**
  95141. * Gets or sets a global boolean to turn on and off all the counters
  95142. */
  95143. static Enabled: boolean;
  95144. /**
  95145. * Returns the smallest value ever
  95146. */
  95147. readonly min: number;
  95148. /**
  95149. * Returns the biggest value ever
  95150. */
  95151. readonly max: number;
  95152. /**
  95153. * Returns the average value since the performance counter is running
  95154. */
  95155. readonly average: number;
  95156. /**
  95157. * Returns the average value of the last second the counter was monitored
  95158. */
  95159. readonly lastSecAverage: number;
  95160. /**
  95161. * Returns the current value
  95162. */
  95163. readonly current: number;
  95164. /**
  95165. * Gets the accumulated total
  95166. */
  95167. readonly total: number;
  95168. /**
  95169. * Gets the total value count
  95170. */
  95171. readonly count: number;
  95172. /**
  95173. * Creates a new counter
  95174. */
  95175. constructor();
  95176. /**
  95177. * Call this method to start monitoring a new frame.
  95178. * 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.
  95179. */
  95180. fetchNewFrame(): void;
  95181. /**
  95182. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  95183. * @param newCount the count value to add to the monitored count
  95184. * @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.
  95185. */
  95186. addCount(newCount: number, fetchResult: boolean): void;
  95187. /**
  95188. * Start monitoring this performance counter
  95189. */
  95190. beginMonitoring(): void;
  95191. /**
  95192. * Compute the time lapsed since the previous beginMonitoring() call.
  95193. * @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
  95194. */
  95195. endMonitoring(newFrame?: boolean): void;
  95196. private _fetchResult;
  95197. private _startMonitoringTime;
  95198. private _min;
  95199. private _max;
  95200. private _average;
  95201. private _current;
  95202. private _totalValueCount;
  95203. private _totalAccumulated;
  95204. private _lastSecAverage;
  95205. private _lastSecAccumulated;
  95206. private _lastSecTime;
  95207. private _lastSecValueCount;
  95208. }
  95209. }
  95210. declare module BABYLON {
  95211. /**
  95212. * Interface for any object that can request an animation frame
  95213. */
  95214. export interface ICustomAnimationFrameRequester {
  95215. /**
  95216. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  95217. */
  95218. renderFunction?: Function;
  95219. /**
  95220. * Called to request the next frame to render to
  95221. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  95222. */
  95223. requestAnimationFrame: Function;
  95224. /**
  95225. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  95226. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  95227. */
  95228. requestID?: number;
  95229. }
  95230. }
  95231. declare module BABYLON {
  95232. /**
  95233. * Settings for finer control over video usage
  95234. */
  95235. export interface VideoTextureSettings {
  95236. /**
  95237. * Applies `autoplay` to video, if specified
  95238. */
  95239. autoPlay?: boolean;
  95240. /**
  95241. * Applies `loop` to video, if specified
  95242. */
  95243. loop?: boolean;
  95244. /**
  95245. * Automatically updates internal texture from video at every frame in the render loop
  95246. */
  95247. autoUpdateTexture: boolean;
  95248. /**
  95249. * Image src displayed during the video loading or until the user interacts with the video.
  95250. */
  95251. poster?: string;
  95252. }
  95253. /**
  95254. * If you want to display a video in your scene, this is the special texture for that.
  95255. * This special texture works similar to other textures, with the exception of a few parameters.
  95256. * @see https://doc.babylonjs.com/how_to/video_texture
  95257. */
  95258. export class VideoTexture extends Texture {
  95259. /**
  95260. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  95261. */
  95262. readonly autoUpdateTexture: boolean;
  95263. /**
  95264. * The video instance used by the texture internally
  95265. */
  95266. readonly video: HTMLVideoElement;
  95267. private _onUserActionRequestedObservable;
  95268. /**
  95269. * Event triggerd when a dom action is required by the user to play the video.
  95270. * This happens due to recent changes in browser policies preventing video to auto start.
  95271. */
  95272. readonly onUserActionRequestedObservable: Observable<Texture>;
  95273. private _generateMipMaps;
  95274. private _engine;
  95275. private _stillImageCaptured;
  95276. private _displayingPosterTexture;
  95277. private _settings;
  95278. private _createInternalTextureOnEvent;
  95279. private _frameId;
  95280. /**
  95281. * Creates a video texture.
  95282. * If you want to display a video in your scene, this is the special texture for that.
  95283. * This special texture works similar to other textures, with the exception of a few parameters.
  95284. * @see https://doc.babylonjs.com/how_to/video_texture
  95285. * @param name optional name, will detect from video source, if not defined
  95286. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  95287. * @param scene is obviously the current scene.
  95288. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  95289. * @param invertY is false by default but can be used to invert video on Y axis
  95290. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  95291. * @param settings allows finer control over video usage
  95292. */
  95293. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  95294. private _getName;
  95295. private _getVideo;
  95296. private _createInternalTexture;
  95297. private reset;
  95298. /**
  95299. * @hidden Internal method to initiate `update`.
  95300. */
  95301. _rebuild(): void;
  95302. /**
  95303. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  95304. */
  95305. update(): void;
  95306. /**
  95307. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  95308. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  95309. */
  95310. updateTexture(isVisible: boolean): void;
  95311. protected _updateInternalTexture: () => void;
  95312. /**
  95313. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  95314. * @param url New url.
  95315. */
  95316. updateURL(url: string): void;
  95317. /**
  95318. * Dispose the texture and release its associated resources.
  95319. */
  95320. dispose(): void;
  95321. /**
  95322. * Creates a video texture straight from a stream.
  95323. * @param scene Define the scene the texture should be created in
  95324. * @param stream Define the stream the texture should be created from
  95325. * @returns The created video texture as a promise
  95326. */
  95327. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  95328. /**
  95329. * Creates a video texture straight from your WebCam video feed.
  95330. * @param scene Define the scene the texture should be created in
  95331. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95332. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95333. * @returns The created video texture as a promise
  95334. */
  95335. static CreateFromWebCamAsync(scene: Scene, constraints: {
  95336. minWidth: number;
  95337. maxWidth: number;
  95338. minHeight: number;
  95339. maxHeight: number;
  95340. deviceId: string;
  95341. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  95342. /**
  95343. * Creates a video texture straight from your WebCam video feed.
  95344. * @param scene Define the scene the texture should be created in
  95345. * @param onReady Define a callback to triggered once the texture will be ready
  95346. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95347. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95348. */
  95349. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  95350. minWidth: number;
  95351. maxWidth: number;
  95352. minHeight: number;
  95353. maxHeight: number;
  95354. deviceId: string;
  95355. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  95356. }
  95357. }
  95358. declare module BABYLON {
  95359. /**
  95360. * Defines the interface used by objects containing a viewport (like a camera)
  95361. */
  95362. interface IViewportOwnerLike {
  95363. /**
  95364. * Gets or sets the viewport
  95365. */
  95366. viewport: IViewportLike;
  95367. }
  95368. /**
  95369. * Interface for attribute information associated with buffer instanciation
  95370. */
  95371. export class InstancingAttributeInfo {
  95372. /**
  95373. * Index/offset of the attribute in the vertex shader
  95374. */
  95375. index: number;
  95376. /**
  95377. * size of the attribute, 1, 2, 3 or 4
  95378. */
  95379. attributeSize: number;
  95380. /**
  95381. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  95382. * default is FLOAT
  95383. */
  95384. attribyteType: number;
  95385. /**
  95386. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  95387. */
  95388. normalized: boolean;
  95389. /**
  95390. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  95391. */
  95392. offset: number;
  95393. /**
  95394. * Name of the GLSL attribute, for debugging purpose only
  95395. */
  95396. attributeName: string;
  95397. }
  95398. /**
  95399. * Define options used to create a depth texture
  95400. */
  95401. export class DepthTextureCreationOptions {
  95402. /** Specifies whether or not a stencil should be allocated in the texture */
  95403. generateStencil?: boolean;
  95404. /** Specifies whether or not bilinear filtering is enable on the texture */
  95405. bilinearFiltering?: boolean;
  95406. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  95407. comparisonFunction?: number;
  95408. /** Specifies if the created texture is a cube texture */
  95409. isCube?: boolean;
  95410. }
  95411. /**
  95412. * Class used to describe the capabilities of the engine relatively to the current browser
  95413. */
  95414. export class EngineCapabilities {
  95415. /** Maximum textures units per fragment shader */
  95416. maxTexturesImageUnits: number;
  95417. /** Maximum texture units per vertex shader */
  95418. maxVertexTextureImageUnits: number;
  95419. /** Maximum textures units in the entire pipeline */
  95420. maxCombinedTexturesImageUnits: number;
  95421. /** Maximum texture size */
  95422. maxTextureSize: number;
  95423. /** Maximum cube texture size */
  95424. maxCubemapTextureSize: number;
  95425. /** Maximum render texture size */
  95426. maxRenderTextureSize: number;
  95427. /** Maximum number of vertex attributes */
  95428. maxVertexAttribs: number;
  95429. /** Maximum number of varyings */
  95430. maxVaryingVectors: number;
  95431. /** Maximum number of uniforms per vertex shader */
  95432. maxVertexUniformVectors: number;
  95433. /** Maximum number of uniforms per fragment shader */
  95434. maxFragmentUniformVectors: number;
  95435. /** Defines if standard derivates (dx/dy) are supported */
  95436. standardDerivatives: boolean;
  95437. /** Defines if s3tc texture compression is supported */
  95438. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  95439. /** Defines if pvrtc texture compression is supported */
  95440. pvrtc: any;
  95441. /** Defines if etc1 texture compression is supported */
  95442. etc1: any;
  95443. /** Defines if etc2 texture compression is supported */
  95444. etc2: any;
  95445. /** Defines if astc texture compression is supported */
  95446. astc: any;
  95447. /** Defines if float textures are supported */
  95448. textureFloat: boolean;
  95449. /** Defines if vertex array objects are supported */
  95450. vertexArrayObject: boolean;
  95451. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  95452. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  95453. /** Gets the maximum level of anisotropy supported */
  95454. maxAnisotropy: number;
  95455. /** Defines if instancing is supported */
  95456. instancedArrays: boolean;
  95457. /** Defines if 32 bits indices are supported */
  95458. uintIndices: boolean;
  95459. /** Defines if high precision shaders are supported */
  95460. highPrecisionShaderSupported: boolean;
  95461. /** Defines if depth reading in the fragment shader is supported */
  95462. fragmentDepthSupported: boolean;
  95463. /** Defines if float texture linear filtering is supported*/
  95464. textureFloatLinearFiltering: boolean;
  95465. /** Defines if rendering to float textures is supported */
  95466. textureFloatRender: boolean;
  95467. /** Defines if half float textures are supported*/
  95468. textureHalfFloat: boolean;
  95469. /** Defines if half float texture linear filtering is supported*/
  95470. textureHalfFloatLinearFiltering: boolean;
  95471. /** Defines if rendering to half float textures is supported */
  95472. textureHalfFloatRender: boolean;
  95473. /** Defines if textureLOD shader command is supported */
  95474. textureLOD: boolean;
  95475. /** Defines if draw buffers extension is supported */
  95476. drawBuffersExtension: boolean;
  95477. /** Defines if depth textures are supported */
  95478. depthTextureExtension: boolean;
  95479. /** Defines if float color buffer are supported */
  95480. colorBufferFloat: boolean;
  95481. /** Gets disjoint timer query extension (null if not supported) */
  95482. timerQuery: EXT_disjoint_timer_query;
  95483. /** Defines if timestamp can be used with timer query */
  95484. canUseTimestampForTimerQuery: boolean;
  95485. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  95486. multiview: any;
  95487. /** Function used to let the system compiles shaders in background */
  95488. parallelShaderCompile: {
  95489. COMPLETION_STATUS_KHR: number;
  95490. };
  95491. /** Max number of texture samples for MSAA */
  95492. maxMSAASamples: number;
  95493. }
  95494. /** Interface defining initialization parameters for Engine class */
  95495. export interface EngineOptions extends WebGLContextAttributes {
  95496. /**
  95497. * Defines if the engine should no exceed a specified device ratio
  95498. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  95499. */
  95500. limitDeviceRatio?: number;
  95501. /**
  95502. * Defines if webvr should be enabled automatically
  95503. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95504. */
  95505. autoEnableWebVR?: boolean;
  95506. /**
  95507. * Defines if webgl2 should be turned off even if supported
  95508. * @see http://doc.babylonjs.com/features/webgl2
  95509. */
  95510. disableWebGL2Support?: boolean;
  95511. /**
  95512. * Defines if webaudio should be initialized as well
  95513. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95514. */
  95515. audioEngine?: boolean;
  95516. /**
  95517. * Defines if animations should run using a deterministic lock step
  95518. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95519. */
  95520. deterministicLockstep?: boolean;
  95521. /** Defines the maximum steps to use with deterministic lock step mode */
  95522. lockstepMaxSteps?: number;
  95523. /**
  95524. * Defines that engine should ignore context lost events
  95525. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  95526. */
  95527. doNotHandleContextLost?: boolean;
  95528. /**
  95529. * Defines that engine should ignore modifying touch action attribute and style
  95530. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  95531. */
  95532. doNotHandleTouchAction?: boolean;
  95533. /**
  95534. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  95535. */
  95536. useHighPrecisionFloats?: boolean;
  95537. }
  95538. /**
  95539. * Defines the interface used by display changed events
  95540. */
  95541. export interface IDisplayChangedEventArgs {
  95542. /** Gets the vrDisplay object (if any) */
  95543. vrDisplay: Nullable<any>;
  95544. /** Gets a boolean indicating if webVR is supported */
  95545. vrSupported: boolean;
  95546. }
  95547. /**
  95548. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  95549. */
  95550. export class Engine {
  95551. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  95552. static ExceptionList: ({
  95553. key: string;
  95554. capture: string;
  95555. captureConstraint: number;
  95556. targets: string[];
  95557. } | {
  95558. key: string;
  95559. capture: null;
  95560. captureConstraint: null;
  95561. targets: string[];
  95562. })[];
  95563. /** Gets the list of created engines */
  95564. static readonly Instances: Engine[];
  95565. /**
  95566. * Gets the latest created engine
  95567. */
  95568. static readonly LastCreatedEngine: Nullable<Engine>;
  95569. /**
  95570. * Gets the latest created scene
  95571. */
  95572. static readonly LastCreatedScene: Nullable<Scene>;
  95573. /**
  95574. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  95575. * @param flag defines which part of the materials must be marked as dirty
  95576. * @param predicate defines a predicate used to filter which materials should be affected
  95577. */
  95578. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  95579. /** @hidden */
  95580. static _TextureLoaders: IInternalTextureLoader[];
  95581. /** Defines that alpha blending is disabled */
  95582. static readonly ALPHA_DISABLE: number;
  95583. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  95584. static readonly ALPHA_ADD: number;
  95585. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  95586. static readonly ALPHA_COMBINE: number;
  95587. /** Defines that alpha blending to DEST - SRC * DEST */
  95588. static readonly ALPHA_SUBTRACT: number;
  95589. /** Defines that alpha blending to SRC * DEST */
  95590. static readonly ALPHA_MULTIPLY: number;
  95591. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  95592. static readonly ALPHA_MAXIMIZED: number;
  95593. /** Defines that alpha blending to SRC + DEST */
  95594. static readonly ALPHA_ONEONE: number;
  95595. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  95596. static readonly ALPHA_PREMULTIPLIED: number;
  95597. /**
  95598. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  95599. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  95600. */
  95601. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  95602. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  95603. static readonly ALPHA_INTERPOLATE: number;
  95604. /**
  95605. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  95606. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  95607. */
  95608. static readonly ALPHA_SCREENMODE: number;
  95609. /** Defines that the ressource is not delayed*/
  95610. static readonly DELAYLOADSTATE_NONE: number;
  95611. /** Defines that the ressource was successfully delay loaded */
  95612. static readonly DELAYLOADSTATE_LOADED: number;
  95613. /** Defines that the ressource is currently delay loading */
  95614. static readonly DELAYLOADSTATE_LOADING: number;
  95615. /** Defines that the ressource is delayed and has not started loading */
  95616. static readonly DELAYLOADSTATE_NOTLOADED: number;
  95617. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  95618. static readonly NEVER: number;
  95619. /** 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 */
  95620. static readonly ALWAYS: number;
  95621. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  95622. static readonly LESS: number;
  95623. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  95624. static readonly EQUAL: number;
  95625. /** 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 */
  95626. static readonly LEQUAL: number;
  95627. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  95628. static readonly GREATER: number;
  95629. /** 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 */
  95630. static readonly GEQUAL: number;
  95631. /** 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 */
  95632. static readonly NOTEQUAL: number;
  95633. /** Passed to stencilOperation to specify that stencil value must be kept */
  95634. static readonly KEEP: number;
  95635. /** Passed to stencilOperation to specify that stencil value must be replaced */
  95636. static readonly REPLACE: number;
  95637. /** Passed to stencilOperation to specify that stencil value must be incremented */
  95638. static readonly INCR: number;
  95639. /** Passed to stencilOperation to specify that stencil value must be decremented */
  95640. static readonly DECR: number;
  95641. /** Passed to stencilOperation to specify that stencil value must be inverted */
  95642. static readonly INVERT: number;
  95643. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  95644. static readonly INCR_WRAP: number;
  95645. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  95646. static readonly DECR_WRAP: number;
  95647. /** Texture is not repeating outside of 0..1 UVs */
  95648. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  95649. /** Texture is repeating outside of 0..1 UVs */
  95650. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  95651. /** Texture is repeating and mirrored */
  95652. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  95653. /** ALPHA */
  95654. static readonly TEXTUREFORMAT_ALPHA: number;
  95655. /** LUMINANCE */
  95656. static readonly TEXTUREFORMAT_LUMINANCE: number;
  95657. /** LUMINANCE_ALPHA */
  95658. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  95659. /** RGB */
  95660. static readonly TEXTUREFORMAT_RGB: number;
  95661. /** RGBA */
  95662. static readonly TEXTUREFORMAT_RGBA: number;
  95663. /** RED */
  95664. static readonly TEXTUREFORMAT_RED: number;
  95665. /** RED (2nd reference) */
  95666. static readonly TEXTUREFORMAT_R: number;
  95667. /** RG */
  95668. static readonly TEXTUREFORMAT_RG: number;
  95669. /** RED_INTEGER */
  95670. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  95671. /** RED_INTEGER (2nd reference) */
  95672. static readonly TEXTUREFORMAT_R_INTEGER: number;
  95673. /** RG_INTEGER */
  95674. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  95675. /** RGB_INTEGER */
  95676. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  95677. /** RGBA_INTEGER */
  95678. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  95679. /** UNSIGNED_BYTE */
  95680. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  95681. /** UNSIGNED_BYTE (2nd reference) */
  95682. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  95683. /** FLOAT */
  95684. static readonly TEXTURETYPE_FLOAT: number;
  95685. /** HALF_FLOAT */
  95686. static readonly TEXTURETYPE_HALF_FLOAT: number;
  95687. /** BYTE */
  95688. static readonly TEXTURETYPE_BYTE: number;
  95689. /** SHORT */
  95690. static readonly TEXTURETYPE_SHORT: number;
  95691. /** UNSIGNED_SHORT */
  95692. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  95693. /** INT */
  95694. static readonly TEXTURETYPE_INT: number;
  95695. /** UNSIGNED_INT */
  95696. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  95697. /** UNSIGNED_SHORT_4_4_4_4 */
  95698. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  95699. /** UNSIGNED_SHORT_5_5_5_1 */
  95700. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  95701. /** UNSIGNED_SHORT_5_6_5 */
  95702. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  95703. /** UNSIGNED_INT_2_10_10_10_REV */
  95704. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  95705. /** UNSIGNED_INT_24_8 */
  95706. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  95707. /** UNSIGNED_INT_10F_11F_11F_REV */
  95708. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  95709. /** UNSIGNED_INT_5_9_9_9_REV */
  95710. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  95711. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  95712. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  95713. /** nearest is mag = nearest and min = nearest and mip = linear */
  95714. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  95715. /** Bilinear is mag = linear and min = linear and mip = nearest */
  95716. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  95717. /** Trilinear is mag = linear and min = linear and mip = linear */
  95718. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  95719. /** nearest is mag = nearest and min = nearest and mip = linear */
  95720. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  95721. /** Bilinear is mag = linear and min = linear and mip = nearest */
  95722. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  95723. /** Trilinear is mag = linear and min = linear and mip = linear */
  95724. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  95725. /** mag = nearest and min = nearest and mip = nearest */
  95726. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  95727. /** mag = nearest and min = linear and mip = nearest */
  95728. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  95729. /** mag = nearest and min = linear and mip = linear */
  95730. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  95731. /** mag = nearest and min = linear and mip = none */
  95732. static readonly TEXTURE_NEAREST_LINEAR: number;
  95733. /** mag = nearest and min = nearest and mip = none */
  95734. static readonly TEXTURE_NEAREST_NEAREST: number;
  95735. /** mag = linear and min = nearest and mip = nearest */
  95736. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  95737. /** mag = linear and min = nearest and mip = linear */
  95738. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  95739. /** mag = linear and min = linear and mip = none */
  95740. static readonly TEXTURE_LINEAR_LINEAR: number;
  95741. /** mag = linear and min = nearest and mip = none */
  95742. static readonly TEXTURE_LINEAR_NEAREST: number;
  95743. /** Explicit coordinates mode */
  95744. static readonly TEXTURE_EXPLICIT_MODE: number;
  95745. /** Spherical coordinates mode */
  95746. static readonly TEXTURE_SPHERICAL_MODE: number;
  95747. /** Planar coordinates mode */
  95748. static readonly TEXTURE_PLANAR_MODE: number;
  95749. /** Cubic coordinates mode */
  95750. static readonly TEXTURE_CUBIC_MODE: number;
  95751. /** Projection coordinates mode */
  95752. static readonly TEXTURE_PROJECTION_MODE: number;
  95753. /** Skybox coordinates mode */
  95754. static readonly TEXTURE_SKYBOX_MODE: number;
  95755. /** Inverse Cubic coordinates mode */
  95756. static readonly TEXTURE_INVCUBIC_MODE: number;
  95757. /** Equirectangular coordinates mode */
  95758. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  95759. /** Equirectangular Fixed coordinates mode */
  95760. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  95761. /** Equirectangular Fixed Mirrored coordinates mode */
  95762. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  95763. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  95764. static readonly SCALEMODE_FLOOR: number;
  95765. /** Defines that texture rescaling will look for the nearest power of 2 size */
  95766. static readonly SCALEMODE_NEAREST: number;
  95767. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  95768. static readonly SCALEMODE_CEILING: number;
  95769. /**
  95770. * Returns the current npm package of the sdk
  95771. */
  95772. static readonly NpmPackage: string;
  95773. /**
  95774. * Returns the current version of the framework
  95775. */
  95776. static readonly Version: string;
  95777. /**
  95778. * Returns a string describing the current engine
  95779. */
  95780. readonly description: string;
  95781. /**
  95782. * Gets or sets the epsilon value used by collision engine
  95783. */
  95784. static CollisionsEpsilon: number;
  95785. /**
  95786. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95787. */
  95788. static ShadersRepository: string;
  95789. /**
  95790. * Method called to create the default loading screen.
  95791. * This can be overriden in your own app.
  95792. * @param canvas The rendering canvas element
  95793. * @returns The loading screen
  95794. */
  95795. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  95796. /**
  95797. * Method called to create the default rescale post process on each engine.
  95798. */
  95799. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  95800. /** @hidden */
  95801. _shaderProcessor: IShaderProcessor;
  95802. /**
  95803. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  95804. */
  95805. forcePOTTextures: boolean;
  95806. /**
  95807. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  95808. */
  95809. isFullscreen: boolean;
  95810. /**
  95811. * Gets a boolean indicating if the pointer is currently locked
  95812. */
  95813. isPointerLock: boolean;
  95814. /**
  95815. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  95816. */
  95817. cullBackFaces: boolean;
  95818. /**
  95819. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  95820. */
  95821. renderEvenInBackground: boolean;
  95822. /**
  95823. * Gets or sets a boolean indicating that cache can be kept between frames
  95824. */
  95825. preventCacheWipeBetweenFrames: boolean;
  95826. /**
  95827. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  95828. **/
  95829. enableOfflineSupport: boolean;
  95830. /**
  95831. * 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)
  95832. **/
  95833. disableManifestCheck: boolean;
  95834. /**
  95835. * Gets the list of created scenes
  95836. */
  95837. scenes: Scene[];
  95838. /**
  95839. * Event raised when a new scene is created
  95840. */
  95841. onNewSceneAddedObservable: Observable<Scene>;
  95842. /**
  95843. * Gets the list of created postprocesses
  95844. */
  95845. postProcesses: PostProcess[];
  95846. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  95847. validateShaderPrograms: boolean;
  95848. /**
  95849. * Observable event triggered each time the rendering canvas is resized
  95850. */
  95851. onResizeObservable: Observable<Engine>;
  95852. /**
  95853. * Observable event triggered each time the canvas loses focus
  95854. */
  95855. onCanvasBlurObservable: Observable<Engine>;
  95856. /**
  95857. * Observable event triggered each time the canvas gains focus
  95858. */
  95859. onCanvasFocusObservable: Observable<Engine>;
  95860. /**
  95861. * Observable event triggered each time the canvas receives pointerout event
  95862. */
  95863. onCanvasPointerOutObservable: Observable<PointerEvent>;
  95864. /**
  95865. * Observable event triggered before each texture is initialized
  95866. */
  95867. onBeforeTextureInitObservable: Observable<Texture>;
  95868. /**
  95869. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  95870. */
  95871. disableUniformBuffers: boolean;
  95872. /** @hidden */
  95873. _uniformBuffers: UniformBuffer[];
  95874. /**
  95875. * Gets a boolean indicating that the engine supports uniform buffers
  95876. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95877. */
  95878. readonly supportsUniformBuffers: boolean;
  95879. /**
  95880. * Observable raised when the engine begins a new frame
  95881. */
  95882. onBeginFrameObservable: Observable<Engine>;
  95883. /**
  95884. * If set, will be used to request the next animation frame for the render loop
  95885. */
  95886. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  95887. /**
  95888. * Observable raised when the engine ends the current frame
  95889. */
  95890. onEndFrameObservable: Observable<Engine>;
  95891. /**
  95892. * Observable raised when the engine is about to compile a shader
  95893. */
  95894. onBeforeShaderCompilationObservable: Observable<Engine>;
  95895. /**
  95896. * Observable raised when the engine has jsut compiled a shader
  95897. */
  95898. onAfterShaderCompilationObservable: Observable<Engine>;
  95899. /** @hidden */
  95900. _gl: WebGLRenderingContext;
  95901. private _renderingCanvas;
  95902. private _windowIsBackground;
  95903. protected _webGLVersion: number;
  95904. protected _highPrecisionShadersAllowed: boolean;
  95905. /** @hidden */
  95906. readonly _shouldUseHighPrecisionShader: boolean;
  95907. /**
  95908. * Gets a boolean indicating that only power of 2 textures are supported
  95909. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  95910. */
  95911. readonly needPOTTextures: boolean;
  95912. /** @hidden */
  95913. _badOS: boolean;
  95914. /** @hidden */
  95915. _badDesktopOS: boolean;
  95916. /**
  95917. * Gets the audio engine
  95918. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95919. * @ignorenaming
  95920. */
  95921. static audioEngine: IAudioEngine;
  95922. /**
  95923. * Default AudioEngine factory responsible of creating the Audio Engine.
  95924. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  95925. */
  95926. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  95927. /**
  95928. * Default offline support factory responsible of creating a tool used to store data locally.
  95929. * By default, this will create a Database object if the workload has been embedded.
  95930. */
  95931. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  95932. private _onFocus;
  95933. private _onBlur;
  95934. private _onCanvasPointerOut;
  95935. private _onCanvasBlur;
  95936. private _onCanvasFocus;
  95937. private _onFullscreenChange;
  95938. private _onPointerLockChange;
  95939. private _hardwareScalingLevel;
  95940. /** @hidden */
  95941. _caps: EngineCapabilities;
  95942. private _pointerLockRequested;
  95943. private _isStencilEnable;
  95944. protected _colorWrite: boolean;
  95945. private _loadingScreen;
  95946. /** @hidden */
  95947. _drawCalls: PerfCounter;
  95948. private _glVersion;
  95949. private _glRenderer;
  95950. private _glVendor;
  95951. private _videoTextureSupported;
  95952. private _renderingQueueLaunched;
  95953. private _activeRenderLoops;
  95954. private _deterministicLockstep;
  95955. private _lockstepMaxSteps;
  95956. /**
  95957. * Observable signaled when a context lost event is raised
  95958. */
  95959. onContextLostObservable: Observable<Engine>;
  95960. /**
  95961. * Observable signaled when a context restored event is raised
  95962. */
  95963. onContextRestoredObservable: Observable<Engine>;
  95964. private _onContextLost;
  95965. private _onContextRestored;
  95966. private _contextWasLost;
  95967. /** @hidden */
  95968. _doNotHandleContextLost: boolean;
  95969. /**
  95970. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  95971. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  95972. */
  95973. doNotHandleContextLost: boolean;
  95974. private _performanceMonitor;
  95975. private _fps;
  95976. private _deltaTime;
  95977. /**
  95978. * Turn this value on if you want to pause FPS computation when in background
  95979. */
  95980. disablePerformanceMonitorInBackground: boolean;
  95981. /**
  95982. * Gets the performance monitor attached to this engine
  95983. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  95984. */
  95985. readonly performanceMonitor: PerformanceMonitor;
  95986. /**
  95987. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  95988. */
  95989. disableVertexArrayObjects: boolean;
  95990. /** @hidden */
  95991. protected _depthCullingState: _DepthCullingState;
  95992. /** @hidden */
  95993. protected _stencilState: _StencilState;
  95994. /** @hidden */
  95995. protected _alphaState: _AlphaState;
  95996. /** @hidden */
  95997. protected _alphaMode: number;
  95998. /** @hidden */
  95999. _internalTexturesCache: InternalTexture[];
  96000. /** @hidden */
  96001. protected _activeChannel: number;
  96002. private _currentTextureChannel;
  96003. /** @hidden */
  96004. protected _boundTexturesCache: {
  96005. [key: string]: Nullable<InternalTexture>;
  96006. };
  96007. /** @hidden */
  96008. protected _currentEffect: Nullable<Effect>;
  96009. /** @hidden */
  96010. protected _currentProgram: Nullable<WebGLProgram>;
  96011. private _compiledEffects;
  96012. private _vertexAttribArraysEnabled;
  96013. /** @hidden */
  96014. protected _cachedViewport: Nullable<IViewportLike>;
  96015. private _cachedVertexArrayObject;
  96016. /** @hidden */
  96017. protected _cachedVertexBuffers: any;
  96018. /** @hidden */
  96019. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  96020. /** @hidden */
  96021. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  96022. /** @hidden */
  96023. _currentRenderTarget: Nullable<InternalTexture>;
  96024. private _uintIndicesCurrentlySet;
  96025. private _currentBoundBuffer;
  96026. /** @hidden */
  96027. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  96028. private _currentBufferPointers;
  96029. private _currentInstanceLocations;
  96030. private _currentInstanceBuffers;
  96031. private _textureUnits;
  96032. /** @hidden */
  96033. _workingCanvas: Nullable<HTMLCanvasElement>;
  96034. /** @hidden */
  96035. _workingContext: Nullable<CanvasRenderingContext2D>;
  96036. private _rescalePostProcess;
  96037. private _dummyFramebuffer;
  96038. private _externalData;
  96039. /** @hidden */
  96040. _bindedRenderFunction: any;
  96041. private _vaoRecordInProgress;
  96042. private _mustWipeVertexAttributes;
  96043. private _emptyTexture;
  96044. private _emptyCubeTexture;
  96045. private _emptyTexture3D;
  96046. /** @hidden */
  96047. _frameHandler: number;
  96048. private _nextFreeTextureSlots;
  96049. private _maxSimultaneousTextures;
  96050. private _activeRequests;
  96051. private _texturesSupported;
  96052. /** @hidden */
  96053. _textureFormatInUse: Nullable<string>;
  96054. /**
  96055. * Gets the list of texture formats supported
  96056. */
  96057. readonly texturesSupported: Array<string>;
  96058. /**
  96059. * Gets the list of texture formats in use
  96060. */
  96061. readonly textureFormatInUse: Nullable<string>;
  96062. /**
  96063. * Gets the current viewport
  96064. */
  96065. readonly currentViewport: Nullable<IViewportLike>;
  96066. /**
  96067. * Gets the default empty texture
  96068. */
  96069. readonly emptyTexture: InternalTexture;
  96070. /**
  96071. * Gets the default empty 3D texture
  96072. */
  96073. readonly emptyTexture3D: InternalTexture;
  96074. /**
  96075. * Gets the default empty cube texture
  96076. */
  96077. readonly emptyCubeTexture: InternalTexture;
  96078. /**
  96079. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  96080. */
  96081. readonly premultipliedAlpha: boolean;
  96082. /**
  96083. * Creates a new engine
  96084. * @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
  96085. * @param antialias defines enable antialiasing (default: false)
  96086. * @param options defines further options to be sent to the getContext() function
  96087. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  96088. */
  96089. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  96090. /**
  96091. * Initializes a webVR display and starts listening to display change events
  96092. * The onVRDisplayChangedObservable will be notified upon these changes
  96093. * @returns The onVRDisplayChangedObservable
  96094. */
  96095. initWebVR(): Observable<IDisplayChangedEventArgs>;
  96096. /** @hidden */
  96097. _prepareVRComponent(): void;
  96098. /** @hidden */
  96099. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  96100. /** @hidden */
  96101. _submitVRFrame(): void;
  96102. /**
  96103. * Call this function to leave webVR mode
  96104. * Will do nothing if webVR is not supported or if there is no webVR device
  96105. * @see http://doc.babylonjs.com/how_to/webvr_camera
  96106. */
  96107. disableVR(): void;
  96108. /**
  96109. * Gets a boolean indicating that the system is in VR mode and is presenting
  96110. * @returns true if VR mode is engaged
  96111. */
  96112. isVRPresenting(): boolean;
  96113. /** @hidden */
  96114. _requestVRFrame(): void;
  96115. private _disableTouchAction;
  96116. private _rebuildInternalTextures;
  96117. private _rebuildEffects;
  96118. /**
  96119. * Gets a boolean indicating if all created effects are ready
  96120. * @returns true if all effects are ready
  96121. */
  96122. areAllEffectsReady(): boolean;
  96123. private _rebuildBuffers;
  96124. private _initGLContext;
  96125. /**
  96126. * Gets version of the current webGL context
  96127. */
  96128. readonly webGLVersion: number;
  96129. /**
  96130. * Gets a string idenfifying the name of the class
  96131. * @returns "Engine" string
  96132. */
  96133. getClassName(): string;
  96134. /**
  96135. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  96136. */
  96137. readonly isStencilEnable: boolean;
  96138. /** @hidden */
  96139. _prepareWorkingCanvas(): void;
  96140. /**
  96141. * Reset the texture cache to empty state
  96142. */
  96143. resetTextureCache(): void;
  96144. /**
  96145. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  96146. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96147. * @returns true if engine is in deterministic lock step mode
  96148. */
  96149. isDeterministicLockStep(): boolean;
  96150. /**
  96151. * Gets the max steps when engine is running in deterministic lock step
  96152. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96153. * @returns the max steps
  96154. */
  96155. getLockstepMaxSteps(): number;
  96156. /**
  96157. * Gets an object containing information about the current webGL context
  96158. * @returns an object containing the vender, the renderer and the version of the current webGL context
  96159. */
  96160. getGlInfo(): {
  96161. vendor: string;
  96162. renderer: string;
  96163. version: string;
  96164. };
  96165. /**
  96166. * Gets current aspect ratio
  96167. * @param viewportOwner defines the camera to use to get the aspect ratio
  96168. * @param useScreen defines if screen size must be used (or the current render target if any)
  96169. * @returns a number defining the aspect ratio
  96170. */
  96171. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  96172. /**
  96173. * Gets current screen aspect ratio
  96174. * @returns a number defining the aspect ratio
  96175. */
  96176. getScreenAspectRatio(): number;
  96177. /**
  96178. * Gets the current render width
  96179. * @param useScreen defines if screen size must be used (or the current render target if any)
  96180. * @returns a number defining the current render width
  96181. */
  96182. getRenderWidth(useScreen?: boolean): number;
  96183. /**
  96184. * Gets the current render height
  96185. * @param useScreen defines if screen size must be used (or the current render target if any)
  96186. * @returns a number defining the current render height
  96187. */
  96188. getRenderHeight(useScreen?: boolean): number;
  96189. /**
  96190. * Gets the HTML canvas attached with the current webGL context
  96191. * @returns a HTML canvas
  96192. */
  96193. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  96194. /**
  96195. * Gets host window
  96196. * @returns the host window object
  96197. */
  96198. getHostWindow(): Window;
  96199. /**
  96200. * Gets host document
  96201. * @returns the host document object
  96202. */
  96203. getHostDocument(): Document;
  96204. /**
  96205. * Gets the client rect of the HTML canvas attached with the current webGL context
  96206. * @returns a client rectanglee
  96207. */
  96208. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  96209. /**
  96210. * Defines the hardware scaling level.
  96211. * By default the hardware scaling level is computed from the window device ratio.
  96212. * 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.
  96213. * @param level defines the level to use
  96214. */
  96215. setHardwareScalingLevel(level: number): void;
  96216. /**
  96217. * Gets the current hardware scaling level.
  96218. * By default the hardware scaling level is computed from the window device ratio.
  96219. * 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.
  96220. * @returns a number indicating the current hardware scaling level
  96221. */
  96222. getHardwareScalingLevel(): number;
  96223. /**
  96224. * Gets the list of loaded textures
  96225. * @returns an array containing all loaded textures
  96226. */
  96227. getLoadedTexturesCache(): InternalTexture[];
  96228. /**
  96229. * Gets the object containing all engine capabilities
  96230. * @returns the EngineCapabilities object
  96231. */
  96232. getCaps(): EngineCapabilities;
  96233. /**
  96234. * Gets the current depth function
  96235. * @returns a number defining the depth function
  96236. */
  96237. getDepthFunction(): Nullable<number>;
  96238. /**
  96239. * Sets the current depth function
  96240. * @param depthFunc defines the function to use
  96241. */
  96242. setDepthFunction(depthFunc: number): void;
  96243. /**
  96244. * Sets the current depth function to GREATER
  96245. */
  96246. setDepthFunctionToGreater(): void;
  96247. /**
  96248. * Sets the current depth function to GEQUAL
  96249. */
  96250. setDepthFunctionToGreaterOrEqual(): void;
  96251. /**
  96252. * Sets the current depth function to LESS
  96253. */
  96254. setDepthFunctionToLess(): void;
  96255. private _cachedStencilBuffer;
  96256. private _cachedStencilFunction;
  96257. private _cachedStencilMask;
  96258. private _cachedStencilOperationPass;
  96259. private _cachedStencilOperationFail;
  96260. private _cachedStencilOperationDepthFail;
  96261. private _cachedStencilReference;
  96262. /**
  96263. * Caches the the state of the stencil buffer
  96264. */
  96265. cacheStencilState(): void;
  96266. /**
  96267. * Restores the state of the stencil buffer
  96268. */
  96269. restoreStencilState(): void;
  96270. /**
  96271. * Sets the current depth function to LEQUAL
  96272. */
  96273. setDepthFunctionToLessOrEqual(): void;
  96274. /**
  96275. * Gets a boolean indicating if stencil buffer is enabled
  96276. * @returns the current stencil buffer state
  96277. */
  96278. getStencilBuffer(): boolean;
  96279. /**
  96280. * Enable or disable the stencil buffer
  96281. * @param enable defines if the stencil buffer must be enabled or disabled
  96282. */
  96283. setStencilBuffer(enable: boolean): void;
  96284. /**
  96285. * Gets the current stencil mask
  96286. * @returns a number defining the new stencil mask to use
  96287. */
  96288. getStencilMask(): number;
  96289. /**
  96290. * Sets the current stencil mask
  96291. * @param mask defines the new stencil mask to use
  96292. */
  96293. setStencilMask(mask: number): void;
  96294. /**
  96295. * Gets the current stencil function
  96296. * @returns a number defining the stencil function to use
  96297. */
  96298. getStencilFunction(): number;
  96299. /**
  96300. * Gets the current stencil reference value
  96301. * @returns a number defining the stencil reference value to use
  96302. */
  96303. getStencilFunctionReference(): number;
  96304. /**
  96305. * Gets the current stencil mask
  96306. * @returns a number defining the stencil mask to use
  96307. */
  96308. getStencilFunctionMask(): number;
  96309. /**
  96310. * Sets the current stencil function
  96311. * @param stencilFunc defines the new stencil function to use
  96312. */
  96313. setStencilFunction(stencilFunc: number): void;
  96314. /**
  96315. * Sets the current stencil reference
  96316. * @param reference defines the new stencil reference to use
  96317. */
  96318. setStencilFunctionReference(reference: number): void;
  96319. /**
  96320. * Sets the current stencil mask
  96321. * @param mask defines the new stencil mask to use
  96322. */
  96323. setStencilFunctionMask(mask: number): void;
  96324. /**
  96325. * Gets the current stencil operation when stencil fails
  96326. * @returns a number defining stencil operation to use when stencil fails
  96327. */
  96328. getStencilOperationFail(): number;
  96329. /**
  96330. * Gets the current stencil operation when depth fails
  96331. * @returns a number defining stencil operation to use when depth fails
  96332. */
  96333. getStencilOperationDepthFail(): number;
  96334. /**
  96335. * Gets the current stencil operation when stencil passes
  96336. * @returns a number defining stencil operation to use when stencil passes
  96337. */
  96338. getStencilOperationPass(): number;
  96339. /**
  96340. * Sets the stencil operation to use when stencil fails
  96341. * @param operation defines the stencil operation to use when stencil fails
  96342. */
  96343. setStencilOperationFail(operation: number): void;
  96344. /**
  96345. * Sets the stencil operation to use when depth fails
  96346. * @param operation defines the stencil operation to use when depth fails
  96347. */
  96348. setStencilOperationDepthFail(operation: number): void;
  96349. /**
  96350. * Sets the stencil operation to use when stencil passes
  96351. * @param operation defines the stencil operation to use when stencil passes
  96352. */
  96353. setStencilOperationPass(operation: number): void;
  96354. /**
  96355. * Sets a boolean indicating if the dithering state is enabled or disabled
  96356. * @param value defines the dithering state
  96357. */
  96358. setDitheringState(value: boolean): void;
  96359. /**
  96360. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  96361. * @param value defines the rasterizer state
  96362. */
  96363. setRasterizerState(value: boolean): void;
  96364. /**
  96365. * stop executing a render loop function and remove it from the execution array
  96366. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  96367. */
  96368. stopRenderLoop(renderFunction?: () => void): void;
  96369. /** @hidden */
  96370. _renderLoop(): void;
  96371. /**
  96372. * Can be used to override the current requestAnimationFrame requester.
  96373. * @hidden
  96374. */
  96375. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96376. /**
  96377. * Register and execute a render loop. The engine can have more than one render function
  96378. * @param renderFunction defines the function to continuously execute
  96379. */
  96380. runRenderLoop(renderFunction: () => void): void;
  96381. /**
  96382. * Toggle full screen mode
  96383. * @param requestPointerLock defines if a pointer lock should be requested from the user
  96384. */
  96385. switchFullscreen(requestPointerLock: boolean): void;
  96386. /**
  96387. * Enters full screen mode
  96388. * @param requestPointerLock defines if a pointer lock should be requested from the user
  96389. */
  96390. enterFullscreen(requestPointerLock: boolean): void;
  96391. /**
  96392. * Exits full screen mode
  96393. */
  96394. exitFullscreen(): void;
  96395. /**
  96396. * Enters Pointerlock mode
  96397. */
  96398. enterPointerlock(): void;
  96399. /**
  96400. * Exits Pointerlock mode
  96401. */
  96402. exitPointerlock(): void;
  96403. /**
  96404. * Clear the current render buffer or the current render target (if any is set up)
  96405. * @param color defines the color to use
  96406. * @param backBuffer defines if the back buffer must be cleared
  96407. * @param depth defines if the depth buffer must be cleared
  96408. * @param stencil defines if the stencil buffer must be cleared
  96409. */
  96410. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96411. /**
  96412. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  96413. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  96414. * @param y defines the y-coordinate of the corner of the clear rectangle
  96415. * @param width defines the width of the clear rectangle
  96416. * @param height defines the height of the clear rectangle
  96417. * @param clearColor defines the clear color
  96418. */
  96419. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  96420. /**
  96421. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  96422. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  96423. * @param y defines the y-coordinate of the corner of the clear rectangle
  96424. * @param width defines the width of the clear rectangle
  96425. * @param height defines the height of the clear rectangle
  96426. */
  96427. enableScissor(x: number, y: number, width: number, height: number): void;
  96428. /**
  96429. * Disable previously set scissor test rectangle
  96430. */
  96431. disableScissor(): void;
  96432. private _viewportCached;
  96433. /** @hidden */
  96434. _viewport(x: number, y: number, width: number, height: number): void;
  96435. /**
  96436. * Set the WebGL's viewport
  96437. * @param viewport defines the viewport element to be used
  96438. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96439. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96440. */
  96441. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96442. /**
  96443. * Directly set the WebGL Viewport
  96444. * @param x defines the x coordinate of the viewport (in screen space)
  96445. * @param y defines the y coordinate of the viewport (in screen space)
  96446. * @param width defines the width of the viewport (in screen space)
  96447. * @param height defines the height of the viewport (in screen space)
  96448. * @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
  96449. */
  96450. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  96451. /**
  96452. * Begin a new frame
  96453. */
  96454. beginFrame(): void;
  96455. /**
  96456. * Enf the current frame
  96457. */
  96458. endFrame(): void;
  96459. /**
  96460. * Resize the view according to the canvas' size
  96461. */
  96462. resize(): void;
  96463. /**
  96464. * Force a specific size of the canvas
  96465. * @param width defines the new canvas' width
  96466. * @param height defines the new canvas' height
  96467. */
  96468. setSize(width: number, height: number): void;
  96469. /**
  96470. * Binds the frame buffer to the specified texture.
  96471. * @param texture The texture to render to or null for the default canvas
  96472. * @param faceIndex The face of the texture to render to in case of cube texture
  96473. * @param requiredWidth The width of the target to render to
  96474. * @param requiredHeight The height of the target to render to
  96475. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96476. * @param depthStencilTexture The depth stencil texture to use to render
  96477. * @param lodLevel defines le lod level to bind to the frame buffer
  96478. */
  96479. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96480. /** @hidden */
  96481. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96482. /**
  96483. * Unbind the current render target texture from the webGL context
  96484. * @param texture defines the render target texture to unbind
  96485. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96486. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96487. */
  96488. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96489. /**
  96490. * Force the mipmap generation for the given render target texture
  96491. * @param texture defines the render target texture to use
  96492. */
  96493. generateMipMapsForCubemap(texture: InternalTexture): void;
  96494. /**
  96495. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96496. */
  96497. flushFramebuffer(): void;
  96498. /**
  96499. * Unbind the current render target and bind the default framebuffer
  96500. */
  96501. restoreDefaultFramebuffer(): void;
  96502. /**
  96503. * Create an uniform buffer
  96504. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96505. * @param elements defines the content of the uniform buffer
  96506. * @returns the webGL uniform buffer
  96507. */
  96508. createUniformBuffer(elements: FloatArray): DataBuffer;
  96509. /**
  96510. * Create a dynamic uniform buffer
  96511. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96512. * @param elements defines the content of the uniform buffer
  96513. * @returns the webGL uniform buffer
  96514. */
  96515. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  96516. /**
  96517. * Update an existing uniform buffer
  96518. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96519. * @param uniformBuffer defines the target uniform buffer
  96520. * @param elements defines the content to update
  96521. * @param offset defines the offset in the uniform buffer where update should start
  96522. * @param count defines the size of the data to update
  96523. */
  96524. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  96525. private _resetVertexBufferBinding;
  96526. /**
  96527. * Creates a vertex buffer
  96528. * @param data the data for the vertex buffer
  96529. * @returns the new WebGL static buffer
  96530. */
  96531. createVertexBuffer(data: DataArray): DataBuffer;
  96532. /**
  96533. * Creates a dynamic vertex buffer
  96534. * @param data the data for the dynamic vertex buffer
  96535. * @returns the new WebGL dynamic buffer
  96536. */
  96537. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96538. /**
  96539. * Update a dynamic index buffer
  96540. * @param indexBuffer defines the target index buffer
  96541. * @param indices defines the data to update
  96542. * @param offset defines the offset in the target index buffer where update should start
  96543. */
  96544. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  96545. /**
  96546. * Updates a dynamic vertex buffer.
  96547. * @param vertexBuffer the vertex buffer to update
  96548. * @param data the data used to update the vertex buffer
  96549. * @param byteOffset the byte offset of the data
  96550. * @param byteLength the byte length of the data
  96551. */
  96552. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96553. private _resetIndexBufferBinding;
  96554. /**
  96555. * Creates a new index buffer
  96556. * @param indices defines the content of the index buffer
  96557. * @param updatable defines if the index buffer must be updatable
  96558. * @returns a new webGL buffer
  96559. */
  96560. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96561. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96562. /**
  96563. * Bind a webGL buffer to the webGL context
  96564. * @param buffer defines the buffer to bind
  96565. */
  96566. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96567. /**
  96568. * Bind an uniform buffer to the current webGL context
  96569. * @param buffer defines the buffer to bind
  96570. */
  96571. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  96572. /**
  96573. * Bind a buffer to the current webGL context at a given location
  96574. * @param buffer defines the buffer to bind
  96575. * @param location defines the index where to bind the buffer
  96576. */
  96577. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  96578. /**
  96579. * Bind a specific block at a given index in a specific shader program
  96580. * @param pipelineContext defines the pipeline context to use
  96581. * @param blockName defines the block name
  96582. * @param index defines the index where to bind the block
  96583. */
  96584. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  96585. private bindIndexBuffer;
  96586. private bindBuffer;
  96587. /**
  96588. * update the bound buffer with the given data
  96589. * @param data defines the data to update
  96590. */
  96591. updateArrayBuffer(data: Float32Array): void;
  96592. private _vertexAttribPointer;
  96593. private _bindIndexBufferWithCache;
  96594. private _bindVertexBuffersAttributes;
  96595. /**
  96596. * Records a vertex array object
  96597. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96598. * @param vertexBuffers defines the list of vertex buffers to store
  96599. * @param indexBuffer defines the index buffer to store
  96600. * @param effect defines the effect to store
  96601. * @returns the new vertex array object
  96602. */
  96603. recordVertexArrayObject(vertexBuffers: {
  96604. [key: string]: VertexBuffer;
  96605. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96606. /**
  96607. * Bind a specific vertex array object
  96608. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96609. * @param vertexArrayObject defines the vertex array object to bind
  96610. * @param indexBuffer defines the index buffer to bind
  96611. */
  96612. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96613. /**
  96614. * Bind webGl buffers directly to the webGL context
  96615. * @param vertexBuffer defines the vertex buffer to bind
  96616. * @param indexBuffer defines the index buffer to bind
  96617. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96618. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96619. * @param effect defines the effect associated with the vertex buffer
  96620. */
  96621. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96622. private _unbindVertexArrayObject;
  96623. /**
  96624. * Bind a list of vertex buffers to the webGL context
  96625. * @param vertexBuffers defines the list of vertex buffers to bind
  96626. * @param indexBuffer defines the index buffer to bind
  96627. * @param effect defines the effect associated with the vertex buffers
  96628. */
  96629. bindBuffers(vertexBuffers: {
  96630. [key: string]: Nullable<VertexBuffer>;
  96631. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96632. /**
  96633. * Unbind all instance attributes
  96634. */
  96635. unbindInstanceAttributes(): void;
  96636. /**
  96637. * Release and free the memory of a vertex array object
  96638. * @param vao defines the vertex array object to delete
  96639. */
  96640. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96641. /** @hidden */
  96642. _releaseBuffer(buffer: DataBuffer): boolean;
  96643. protected _deleteBuffer(buffer: DataBuffer): void;
  96644. /**
  96645. * Creates a webGL buffer to use with instanciation
  96646. * @param capacity defines the size of the buffer
  96647. * @returns the webGL buffer
  96648. */
  96649. createInstancesBuffer(capacity: number): DataBuffer;
  96650. /**
  96651. * Delete a webGL buffer used with instanciation
  96652. * @param buffer defines the webGL buffer to delete
  96653. */
  96654. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96655. /**
  96656. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96657. * @param instancesBuffer defines the webGL buffer to update and bind
  96658. * @param data defines the data to store in the buffer
  96659. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96660. */
  96661. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96662. /**
  96663. * Apply all cached states (depth, culling, stencil and alpha)
  96664. */
  96665. applyStates(): void;
  96666. /**
  96667. * Send a draw order
  96668. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96669. * @param indexStart defines the starting index
  96670. * @param indexCount defines the number of index to draw
  96671. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96672. */
  96673. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96674. /**
  96675. * Draw a list of points
  96676. * @param verticesStart defines the index of first vertex to draw
  96677. * @param verticesCount defines the count of vertices to draw
  96678. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96679. */
  96680. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96681. /**
  96682. * Draw a list of unindexed primitives
  96683. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96684. * @param verticesStart defines the index of first vertex to draw
  96685. * @param verticesCount defines the count of vertices to draw
  96686. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96687. */
  96688. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96689. /**
  96690. * Draw a list of indexed primitives
  96691. * @param fillMode defines the primitive to use
  96692. * @param indexStart defines the starting index
  96693. * @param indexCount defines the number of index to draw
  96694. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96695. */
  96696. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96697. /**
  96698. * Draw a list of unindexed primitives
  96699. * @param fillMode defines the primitive to use
  96700. * @param verticesStart defines the index of first vertex to draw
  96701. * @param verticesCount defines the count of vertices to draw
  96702. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96703. */
  96704. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96705. private _drawMode;
  96706. /** @hidden */
  96707. _releaseEffect(effect: Effect): void;
  96708. /** @hidden */
  96709. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96710. /**
  96711. * Create a new effect (used to store vertex/fragment shaders)
  96712. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96713. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  96714. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96715. * @param samplers defines an array of string used to represent textures
  96716. * @param defines defines the string containing the defines to use to compile the shaders
  96717. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  96718. * @param onCompiled defines a function to call when the effect creation is successful
  96719. * @param onError defines a function to call when the effect creation has failed
  96720. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  96721. * @returns the new Effect
  96722. */
  96723. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  96724. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  96725. private _compileShader;
  96726. private _compileRawShader;
  96727. /**
  96728. * Directly creates a webGL program
  96729. * @param pipelineContext defines the pipeline context to attach to
  96730. * @param vertexCode defines the vertex shader code to use
  96731. * @param fragmentCode defines the fragment shader code to use
  96732. * @param context defines the webGL context to use (if not set, the current one will be used)
  96733. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96734. * @returns the new webGL program
  96735. */
  96736. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96737. /**
  96738. * Creates a webGL program
  96739. * @param pipelineContext defines the pipeline context to attach to
  96740. * @param vertexCode defines the vertex shader code to use
  96741. * @param fragmentCode defines the fragment shader code to use
  96742. * @param defines defines the string containing the defines to use to compile the shaders
  96743. * @param context defines the webGL context to use (if not set, the current one will be used)
  96744. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96745. * @returns the new webGL program
  96746. */
  96747. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96748. /**
  96749. * Creates a new pipeline context
  96750. * @returns the new pipeline
  96751. */
  96752. createPipelineContext(): IPipelineContext;
  96753. private _createShaderProgram;
  96754. private _finalizePipelineContext;
  96755. /** @hidden */
  96756. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  96757. /** @hidden */
  96758. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  96759. /** @hidden */
  96760. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  96761. /**
  96762. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  96763. * @param pipelineContext defines the pipeline context to use
  96764. * @param uniformsNames defines the list of uniform names
  96765. * @returns an array of webGL uniform locations
  96766. */
  96767. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  96768. /**
  96769. * Gets the lsit of active attributes for a given webGL program
  96770. * @param pipelineContext defines the pipeline context to use
  96771. * @param attributesNames defines the list of attribute names to get
  96772. * @returns an array of indices indicating the offset of each attribute
  96773. */
  96774. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  96775. /**
  96776. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  96777. * @param effect defines the effect to activate
  96778. */
  96779. enableEffect(effect: Nullable<Effect>): void;
  96780. /**
  96781. * Set the value of an uniform to an array of int32
  96782. * @param uniform defines the webGL uniform location where to store the value
  96783. * @param array defines the array of int32 to store
  96784. */
  96785. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96786. /**
  96787. * Set the value of an uniform to an array of int32 (stored as vec2)
  96788. * @param uniform defines the webGL uniform location where to store the value
  96789. * @param array defines the array of int32 to store
  96790. */
  96791. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96792. /**
  96793. * Set the value of an uniform to an array of int32 (stored as vec3)
  96794. * @param uniform defines the webGL uniform location where to store the value
  96795. * @param array defines the array of int32 to store
  96796. */
  96797. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96798. /**
  96799. * Set the value of an uniform to an array of int32 (stored as vec4)
  96800. * @param uniform defines the webGL uniform location where to store the value
  96801. * @param array defines the array of int32 to store
  96802. */
  96803. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96804. /**
  96805. * Set the value of an uniform to an array of float32
  96806. * @param uniform defines the webGL uniform location where to store the value
  96807. * @param array defines the array of float32 to store
  96808. */
  96809. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96810. /**
  96811. * Set the value of an uniform to an array of float32 (stored as vec2)
  96812. * @param uniform defines the webGL uniform location where to store the value
  96813. * @param array defines the array of float32 to store
  96814. */
  96815. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96816. /**
  96817. * Set the value of an uniform to an array of float32 (stored as vec3)
  96818. * @param uniform defines the webGL uniform location where to store the value
  96819. * @param array defines the array of float32 to store
  96820. */
  96821. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96822. /**
  96823. * Set the value of an uniform to an array of float32 (stored as vec4)
  96824. * @param uniform defines the webGL uniform location where to store the value
  96825. * @param array defines the array of float32 to store
  96826. */
  96827. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96828. /**
  96829. * Set the value of an uniform to an array of number
  96830. * @param uniform defines the webGL uniform location where to store the value
  96831. * @param array defines the array of number to store
  96832. */
  96833. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96834. /**
  96835. * Set the value of an uniform to an array of number (stored as vec2)
  96836. * @param uniform defines the webGL uniform location where to store the value
  96837. * @param array defines the array of number to store
  96838. */
  96839. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96840. /**
  96841. * Set the value of an uniform to an array of number (stored as vec3)
  96842. * @param uniform defines the webGL uniform location where to store the value
  96843. * @param array defines the array of number to store
  96844. */
  96845. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96846. /**
  96847. * Set the value of an uniform to an array of number (stored as vec4)
  96848. * @param uniform defines the webGL uniform location where to store the value
  96849. * @param array defines the array of number to store
  96850. */
  96851. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96852. /**
  96853. * Set the value of an uniform to an array of float32 (stored as matrices)
  96854. * @param uniform defines the webGL uniform location where to store the value
  96855. * @param matrices defines the array of float32 to store
  96856. */
  96857. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  96858. /**
  96859. * Set the value of an uniform to a matrix (3x3)
  96860. * @param uniform defines the webGL uniform location where to store the value
  96861. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  96862. */
  96863. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96864. /**
  96865. * Set the value of an uniform to a matrix (2x2)
  96866. * @param uniform defines the webGL uniform location where to store the value
  96867. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  96868. */
  96869. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96870. /**
  96871. * Set the value of an uniform to a number (int)
  96872. * @param uniform defines the webGL uniform location where to store the value
  96873. * @param value defines the int number to store
  96874. */
  96875. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96876. /**
  96877. * Set the value of an uniform to a number (float)
  96878. * @param uniform defines the webGL uniform location where to store the value
  96879. * @param value defines the float number to store
  96880. */
  96881. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96882. /**
  96883. * Set the value of an uniform to a vec2
  96884. * @param uniform defines the webGL uniform location where to store the value
  96885. * @param x defines the 1st component of the value
  96886. * @param y defines the 2nd component of the value
  96887. */
  96888. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  96889. /**
  96890. * Set the value of an uniform to a vec3
  96891. * @param uniform defines the webGL uniform location where to store the value
  96892. * @param x defines the 1st component of the value
  96893. * @param y defines the 2nd component of the value
  96894. * @param z defines the 3rd component of the value
  96895. */
  96896. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  96897. /**
  96898. * Set the value of an uniform to a boolean
  96899. * @param uniform defines the webGL uniform location where to store the value
  96900. * @param bool defines the boolean to store
  96901. */
  96902. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  96903. /**
  96904. * Set the value of an uniform to a vec4
  96905. * @param uniform defines the webGL uniform location where to store the value
  96906. * @param x defines the 1st component of the value
  96907. * @param y defines the 2nd component of the value
  96908. * @param z defines the 3rd component of the value
  96909. * @param w defines the 4th component of the value
  96910. */
  96911. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  96912. /**
  96913. * Sets a Color4 on a uniform variable
  96914. * @param uniform defines the uniform location
  96915. * @param color4 defines the value to be set
  96916. */
  96917. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  96918. /**
  96919. * Set various states to the webGL context
  96920. * @param culling defines backface culling state
  96921. * @param zOffset defines the value to apply to zOffset (0 by default)
  96922. * @param force defines if states must be applied even if cache is up to date
  96923. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  96924. */
  96925. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  96926. /**
  96927. * Set the z offset to apply to current rendering
  96928. * @param value defines the offset to apply
  96929. */
  96930. setZOffset(value: number): void;
  96931. /**
  96932. * Gets the current value of the zOffset
  96933. * @returns the current zOffset state
  96934. */
  96935. getZOffset(): number;
  96936. /**
  96937. * Enable or disable depth buffering
  96938. * @param enable defines the state to set
  96939. */
  96940. setDepthBuffer(enable: boolean): void;
  96941. /**
  96942. * Gets a boolean indicating if depth writing is enabled
  96943. * @returns the current depth writing state
  96944. */
  96945. getDepthWrite(): boolean;
  96946. /**
  96947. * Enable or disable depth writing
  96948. * @param enable defines the state to set
  96949. */
  96950. setDepthWrite(enable: boolean): void;
  96951. /**
  96952. * Enable or disable color writing
  96953. * @param enable defines the state to set
  96954. */
  96955. setColorWrite(enable: boolean): void;
  96956. /**
  96957. * Gets a boolean indicating if color writing is enabled
  96958. * @returns the current color writing state
  96959. */
  96960. getColorWrite(): boolean;
  96961. /**
  96962. * Sets alpha constants used by some alpha blending modes
  96963. * @param r defines the red component
  96964. * @param g defines the green component
  96965. * @param b defines the blue component
  96966. * @param a defines the alpha component
  96967. */
  96968. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  96969. /**
  96970. * Sets the current alpha mode
  96971. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  96972. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  96973. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  96974. */
  96975. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  96976. /**
  96977. * Gets the current alpha mode
  96978. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  96979. * @returns the current alpha mode
  96980. */
  96981. getAlphaMode(): number;
  96982. /**
  96983. * Clears the list of texture accessible through engine.
  96984. * This can help preventing texture load conflict due to name collision.
  96985. */
  96986. clearInternalTexturesCache(): void;
  96987. /**
  96988. * Force the entire cache to be cleared
  96989. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  96990. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  96991. */
  96992. wipeCaches(bruteForce?: boolean): void;
  96993. /**
  96994. * Set the compressed texture format to use, based on the formats you have, and the formats
  96995. * supported by the hardware / browser.
  96996. *
  96997. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  96998. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  96999. * to API arguments needed to compressed textures. This puts the burden on the container
  97000. * generator to house the arcane code for determining these for current & future formats.
  97001. *
  97002. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  97003. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  97004. *
  97005. * Note: The result of this call is not taken into account when a texture is base64.
  97006. *
  97007. * @param formatsAvailable defines the list of those format families you have created
  97008. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  97009. *
  97010. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  97011. * @returns The extension selected.
  97012. */
  97013. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  97014. /** @hidden */
  97015. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  97016. min: number;
  97017. mag: number;
  97018. };
  97019. /** @hidden */
  97020. _createTexture(): WebGLTexture;
  97021. /**
  97022. * Usually called from Texture.ts.
  97023. * Passed information to create a WebGLTexture
  97024. * @param urlArg defines a value which contains one of the following:
  97025. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  97026. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  97027. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  97028. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  97029. * @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)
  97030. * @param scene needed for loading to the correct scene
  97031. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  97032. * @param onLoad optional callback to be called upon successful completion
  97033. * @param onError optional callback to be called upon failure
  97034. * @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
  97035. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  97036. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  97037. * @param forcedExtension defines the extension to use to pick the right loader
  97038. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  97039. * @returns a InternalTexture for assignment back into BABYLON.Texture
  97040. */
  97041. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  97042. /**
  97043. * @hidden
  97044. * Rescales a texture
  97045. * @param source input texutre
  97046. * @param destination destination texture
  97047. * @param scene scene to use to render the resize
  97048. * @param internalFormat format to use when resizing
  97049. * @param onComplete callback to be called when resize has completed
  97050. */
  97051. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  97052. private _unpackFlipYCached;
  97053. /**
  97054. * In case you are sharing the context with other applications, it might
  97055. * be interested to not cache the unpack flip y state to ensure a consistent
  97056. * value would be set.
  97057. */
  97058. enableUnpackFlipYCached: boolean;
  97059. /** @hidden */
  97060. _unpackFlipY(value: boolean): void;
  97061. /** @hidden */
  97062. _getUnpackAlignement(): number;
  97063. /**
  97064. * Creates a dynamic texture
  97065. * @param width defines the width of the texture
  97066. * @param height defines the height of the texture
  97067. * @param generateMipMaps defines if the engine should generate the mip levels
  97068. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  97069. * @returns the dynamic texture inside an InternalTexture
  97070. */
  97071. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  97072. /**
  97073. * Update the sampling mode of a given texture
  97074. * @param samplingMode defines the required sampling mode
  97075. * @param texture defines the texture to update
  97076. */
  97077. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  97078. /**
  97079. * Update the content of a dynamic texture
  97080. * @param texture defines the texture to update
  97081. * @param canvas defines the canvas containing the source
  97082. * @param invertY defines if data must be stored with Y axis inverted
  97083. * @param premulAlpha defines if alpha is stored as premultiplied
  97084. * @param format defines the format of the data
  97085. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  97086. */
  97087. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  97088. /**
  97089. * Update a video texture
  97090. * @param texture defines the texture to update
  97091. * @param video defines the video element to use
  97092. * @param invertY defines if data must be stored with Y axis inverted
  97093. */
  97094. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  97095. /**
  97096. * Updates a depth texture Comparison Mode and Function.
  97097. * If the comparison Function is equal to 0, the mode will be set to none.
  97098. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  97099. * @param texture The texture to set the comparison function for
  97100. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  97101. */
  97102. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  97103. /** @hidden */
  97104. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  97105. width: number;
  97106. height: number;
  97107. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  97108. /**
  97109. * Creates a depth stencil texture.
  97110. * This is only available in WebGL 2 or with the depth texture extension available.
  97111. * @param size The size of face edge in the texture.
  97112. * @param options The options defining the texture.
  97113. * @returns The texture
  97114. */
  97115. createDepthStencilTexture(size: number | {
  97116. width: number;
  97117. height: number;
  97118. }, options: DepthTextureCreationOptions): InternalTexture;
  97119. /**
  97120. * Creates a depth stencil texture.
  97121. * This is only available in WebGL 2 or with the depth texture extension available.
  97122. * @param size The size of face edge in the texture.
  97123. * @param options The options defining the texture.
  97124. * @returns The texture
  97125. */
  97126. private _createDepthStencilTexture;
  97127. /**
  97128. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  97129. * @param renderTarget The render target to set the frame buffer for
  97130. */
  97131. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  97132. /**
  97133. * Creates a new render target texture
  97134. * @param size defines the size of the texture
  97135. * @param options defines the options used to create the texture
  97136. * @returns a new render target texture stored in an InternalTexture
  97137. */
  97138. createRenderTargetTexture(size: number | {
  97139. width: number;
  97140. height: number;
  97141. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  97142. /** @hidden */
  97143. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  97144. /**
  97145. * Updates the sample count of a render target texture
  97146. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  97147. * @param texture defines the texture to update
  97148. * @param samples defines the sample count to set
  97149. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  97150. */
  97151. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  97152. /** @hidden */
  97153. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97154. /** @hidden */
  97155. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  97156. /** @hidden */
  97157. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97158. /** @hidden */
  97159. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  97160. /**
  97161. * @hidden
  97162. */
  97163. _setCubeMapTextureParams(loadMipmap: boolean): void;
  97164. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  97165. private _prepareWebGLTexture;
  97166. /** @hidden */
  97167. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  97168. /** @hidden */
  97169. _releaseFramebufferObjects(texture: InternalTexture): void;
  97170. /** @hidden */
  97171. _releaseTexture(texture: InternalTexture): void;
  97172. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  97173. protected _setProgram(program: WebGLProgram): void;
  97174. protected _boundUniforms: {
  97175. [key: number]: WebGLUniformLocation;
  97176. };
  97177. /**
  97178. * Binds an effect to the webGL context
  97179. * @param effect defines the effect to bind
  97180. */
  97181. bindSamplers(effect: Effect): void;
  97182. private _activateCurrentTexture;
  97183. /** @hidden */
  97184. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  97185. /** @hidden */
  97186. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  97187. /**
  97188. * Sets a texture to the webGL context from a postprocess
  97189. * @param channel defines the channel to use
  97190. * @param postProcess defines the source postprocess
  97191. */
  97192. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  97193. /**
  97194. * Binds the output of the passed in post process to the texture channel specified
  97195. * @param channel The channel the texture should be bound to
  97196. * @param postProcess The post process which's output should be bound
  97197. */
  97198. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  97199. /**
  97200. * Unbind all textures from the webGL context
  97201. */
  97202. unbindAllTextures(): void;
  97203. /**
  97204. * Sets a texture to the according uniform.
  97205. * @param channel The texture channel
  97206. * @param uniform The uniform to set
  97207. * @param texture The texture to apply
  97208. */
  97209. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  97210. /**
  97211. * Sets a depth stencil texture from a render target to the according uniform.
  97212. * @param channel The texture channel
  97213. * @param uniform The uniform to set
  97214. * @param texture The render target texture containing the depth stencil texture to apply
  97215. */
  97216. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  97217. private _bindSamplerUniformToChannel;
  97218. private _getTextureWrapMode;
  97219. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  97220. /**
  97221. * Sets an array of texture to the webGL context
  97222. * @param channel defines the channel where the texture array must be set
  97223. * @param uniform defines the associated uniform location
  97224. * @param textures defines the array of textures to bind
  97225. */
  97226. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  97227. /** @hidden */
  97228. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  97229. private _setTextureParameterFloat;
  97230. private _setTextureParameterInteger;
  97231. /**
  97232. * Reads pixels from the current frame buffer. Please note that this function can be slow
  97233. * @param x defines the x coordinate of the rectangle where pixels must be read
  97234. * @param y defines the y coordinate of the rectangle where pixels must be read
  97235. * @param width defines the width of the rectangle where pixels must be read
  97236. * @param height defines the height of the rectangle where pixels must be read
  97237. * @returns a Uint8Array containing RGBA colors
  97238. */
  97239. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  97240. /**
  97241. * Add an externaly attached data from its key.
  97242. * This method call will fail and return false, if such key already exists.
  97243. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  97244. * @param key the unique key that identifies the data
  97245. * @param data the data object to associate to the key for this Engine instance
  97246. * @return true if no such key were already present and the data was added successfully, false otherwise
  97247. */
  97248. addExternalData<T>(key: string, data: T): boolean;
  97249. /**
  97250. * Get an externaly attached data from its key
  97251. * @param key the unique key that identifies the data
  97252. * @return the associated data, if present (can be null), or undefined if not present
  97253. */
  97254. getExternalData<T>(key: string): T;
  97255. /**
  97256. * Get an externaly attached data from its key, create it using a factory if it's not already present
  97257. * @param key the unique key that identifies the data
  97258. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  97259. * @return the associated data, can be null if the factory returned null.
  97260. */
  97261. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  97262. /**
  97263. * Remove an externaly attached data from the Engine instance
  97264. * @param key the unique key that identifies the data
  97265. * @return true if the data was successfully removed, false if it doesn't exist
  97266. */
  97267. removeExternalData(key: string): boolean;
  97268. /**
  97269. * Unbind all vertex attributes from the webGL context
  97270. */
  97271. unbindAllAttributes(): void;
  97272. /**
  97273. * 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
  97274. */
  97275. releaseEffects(): void;
  97276. /**
  97277. * Dispose and release all associated resources
  97278. */
  97279. dispose(): void;
  97280. /**
  97281. * Display the loading screen
  97282. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97283. */
  97284. displayLoadingUI(): void;
  97285. /**
  97286. * Hide the loading screen
  97287. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97288. */
  97289. hideLoadingUI(): void;
  97290. /**
  97291. * Gets the current loading screen object
  97292. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97293. */
  97294. /**
  97295. * Sets the current loading screen object
  97296. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97297. */
  97298. loadingScreen: ILoadingScreen;
  97299. /**
  97300. * Sets the current loading screen text
  97301. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97302. */
  97303. loadingUIText: string;
  97304. /**
  97305. * Sets the current loading screen background color
  97306. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97307. */
  97308. loadingUIBackgroundColor: string;
  97309. /**
  97310. * Attach a new callback raised when context lost event is fired
  97311. * @param callback defines the callback to call
  97312. */
  97313. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97314. /**
  97315. * Attach a new callback raised when context restored event is fired
  97316. * @param callback defines the callback to call
  97317. */
  97318. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97319. /**
  97320. * Gets the source code of the vertex shader associated with a specific webGL program
  97321. * @param program defines the program to use
  97322. * @returns a string containing the source code of the vertex shader associated with the program
  97323. */
  97324. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  97325. /**
  97326. * Gets the source code of the fragment shader associated with a specific webGL program
  97327. * @param program defines the program to use
  97328. * @returns a string containing the source code of the fragment shader associated with the program
  97329. */
  97330. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  97331. /**
  97332. * Get the current error code of the webGL context
  97333. * @returns the error code
  97334. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  97335. */
  97336. getError(): number;
  97337. /**
  97338. * Gets the current framerate
  97339. * @returns a number representing the framerate
  97340. */
  97341. getFps(): number;
  97342. /**
  97343. * Gets the time spent between current and previous frame
  97344. * @returns a number representing the delta time in ms
  97345. */
  97346. getDeltaTime(): number;
  97347. private _measureFps;
  97348. /** @hidden */
  97349. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  97350. private _canRenderToFloatFramebuffer;
  97351. private _canRenderToHalfFloatFramebuffer;
  97352. private _canRenderToFramebuffer;
  97353. /** @hidden */
  97354. _getWebGLTextureType(type: number): number;
  97355. /** @hidden */
  97356. _getInternalFormat(format: number): number;
  97357. /** @hidden */
  97358. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  97359. /** @hidden */
  97360. _getRGBAMultiSampleBufferFormat(type: number): number;
  97361. /** @hidden */
  97362. _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;
  97363. /** @hidden */
  97364. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  97365. /**
  97366. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  97367. * @returns true if the engine can be created
  97368. * @ignorenaming
  97369. */
  97370. static isSupported(): boolean;
  97371. /**
  97372. * Find the next highest power of two.
  97373. * @param x Number to start search from.
  97374. * @return Next highest power of two.
  97375. */
  97376. static CeilingPOT(x: number): number;
  97377. /**
  97378. * Find the next lowest power of two.
  97379. * @param x Number to start search from.
  97380. * @return Next lowest power of two.
  97381. */
  97382. static FloorPOT(x: number): number;
  97383. /**
  97384. * Find the nearest power of two.
  97385. * @param x Number to start search from.
  97386. * @return Next nearest power of two.
  97387. */
  97388. static NearestPOT(x: number): number;
  97389. /**
  97390. * Get the closest exponent of two
  97391. * @param value defines the value to approximate
  97392. * @param max defines the maximum value to return
  97393. * @param mode defines how to define the closest value
  97394. * @returns closest exponent of two of the given value
  97395. */
  97396. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  97397. /**
  97398. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  97399. * @param func - the function to be called
  97400. * @param requester - the object that will request the next frame. Falls back to window.
  97401. * @returns frame number
  97402. */
  97403. static QueueNewFrame(func: () => void, requester?: any): number;
  97404. /**
  97405. * Ask the browser to promote the current element to pointerlock mode
  97406. * @param element defines the DOM element to promote
  97407. */
  97408. static _RequestPointerlock(element: HTMLElement): void;
  97409. /**
  97410. * Asks the browser to exit pointerlock mode
  97411. */
  97412. static _ExitPointerlock(): void;
  97413. /**
  97414. * Ask the browser to promote the current element to fullscreen rendering mode
  97415. * @param element defines the DOM element to promote
  97416. */
  97417. static _RequestFullscreen(element: HTMLElement): void;
  97418. /**
  97419. * Asks the browser to exit fullscreen mode
  97420. */
  97421. static _ExitFullscreen(): void;
  97422. }
  97423. }
  97424. declare module BABYLON {
  97425. /**
  97426. * The engine store class is responsible to hold all the instances of Engine and Scene created
  97427. * during the life time of the application.
  97428. */
  97429. export class EngineStore {
  97430. /** Gets the list of created engines */
  97431. static Instances: Engine[];
  97432. /** @hidden */
  97433. static _LastCreatedScene: Nullable<Scene>;
  97434. /**
  97435. * Gets the latest created engine
  97436. */
  97437. static readonly LastCreatedEngine: Nullable<Engine>;
  97438. /**
  97439. * Gets the latest created scene
  97440. */
  97441. static readonly LastCreatedScene: Nullable<Scene>;
  97442. /**
  97443. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  97444. * @ignorenaming
  97445. */
  97446. static UseFallbackTexture: boolean;
  97447. /**
  97448. * Texture content used if a texture cannot loaded
  97449. * @ignorenaming
  97450. */
  97451. static FallbackTexture: string;
  97452. }
  97453. }
  97454. declare module BABYLON {
  97455. /**
  97456. * Helper class that provides a small promise polyfill
  97457. */
  97458. export class PromisePolyfill {
  97459. /**
  97460. * Static function used to check if the polyfill is required
  97461. * If this is the case then the function will inject the polyfill to window.Promise
  97462. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  97463. */
  97464. static Apply(force?: boolean): void;
  97465. }
  97466. }
  97467. declare module BABYLON {
  97468. /**
  97469. * Interface for screenshot methods with describe argument called `size` as object with options
  97470. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  97471. */
  97472. export interface IScreenshotSize {
  97473. /**
  97474. * number in pixels for canvas height
  97475. */
  97476. height?: number;
  97477. /**
  97478. * multiplier allowing render at a higher or lower resolution
  97479. * If value is defined then height and width will be ignored and taken from camera
  97480. */
  97481. precision?: number;
  97482. /**
  97483. * number in pixels for canvas width
  97484. */
  97485. width?: number;
  97486. }
  97487. }
  97488. declare module BABYLON {
  97489. interface IColor4Like {
  97490. r: float;
  97491. g: float;
  97492. b: float;
  97493. a: float;
  97494. }
  97495. /**
  97496. * Class containing a set of static utilities functions
  97497. */
  97498. export class Tools {
  97499. /**
  97500. * Gets or sets the base URL to use to load assets
  97501. */
  97502. static BaseUrl: string;
  97503. /**
  97504. * Enable/Disable Custom HTTP Request Headers globally.
  97505. * default = false
  97506. * @see CustomRequestHeaders
  97507. */
  97508. static UseCustomRequestHeaders: boolean;
  97509. /**
  97510. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  97511. * i.e. when loading files, where the server/service expects an Authorization header
  97512. */
  97513. static CustomRequestHeaders: {
  97514. [key: string]: string;
  97515. };
  97516. /**
  97517. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  97518. */
  97519. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  97520. /**
  97521. * Default behaviour for cors in the application.
  97522. * It can be a string if the expected behavior is identical in the entire app.
  97523. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  97524. */
  97525. static CorsBehavior: string | ((url: string | string[]) => string);
  97526. /**
  97527. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  97528. * @ignorenaming
  97529. */
  97530. static UseFallbackTexture: boolean;
  97531. /**
  97532. * Use this object to register external classes like custom textures or material
  97533. * to allow the laoders to instantiate them
  97534. */
  97535. static RegisteredExternalClasses: {
  97536. [key: string]: Object;
  97537. };
  97538. /**
  97539. * Texture content used if a texture cannot loaded
  97540. * @ignorenaming
  97541. */
  97542. static fallbackTexture: string;
  97543. /**
  97544. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  97545. * @param u defines the coordinate on X axis
  97546. * @param v defines the coordinate on Y axis
  97547. * @param width defines the width of the source data
  97548. * @param height defines the height of the source data
  97549. * @param pixels defines the source byte array
  97550. * @param color defines the output color
  97551. */
  97552. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  97553. /**
  97554. * Interpolates between a and b via alpha
  97555. * @param a The lower value (returned when alpha = 0)
  97556. * @param b The upper value (returned when alpha = 1)
  97557. * @param alpha The interpolation-factor
  97558. * @return The mixed value
  97559. */
  97560. static Mix(a: number, b: number, alpha: number): number;
  97561. /**
  97562. * Tries to instantiate a new object from a given class name
  97563. * @param className defines the class name to instantiate
  97564. * @returns the new object or null if the system was not able to do the instantiation
  97565. */
  97566. static Instantiate(className: string): any;
  97567. /**
  97568. * Provides a slice function that will work even on IE
  97569. * @param data defines the array to slice
  97570. * @param start defines the start of the data (optional)
  97571. * @param end defines the end of the data (optional)
  97572. * @returns the new sliced array
  97573. */
  97574. static Slice<T>(data: T, start?: number, end?: number): T;
  97575. /**
  97576. * Polyfill for setImmediate
  97577. * @param action defines the action to execute after the current execution block
  97578. */
  97579. static SetImmediate(action: () => void): void;
  97580. /**
  97581. * Function indicating if a number is an exponent of 2
  97582. * @param value defines the value to test
  97583. * @returns true if the value is an exponent of 2
  97584. */
  97585. static IsExponentOfTwo(value: number): boolean;
  97586. private static _tmpFloatArray;
  97587. /**
  97588. * Returns the nearest 32-bit single precision float representation of a Number
  97589. * @param value A Number. If the parameter is of a different type, it will get converted
  97590. * to a number or to NaN if it cannot be converted
  97591. * @returns number
  97592. */
  97593. static FloatRound(value: number): number;
  97594. /**
  97595. * Extracts the filename from a path
  97596. * @param path defines the path to use
  97597. * @returns the filename
  97598. */
  97599. static GetFilename(path: string): string;
  97600. /**
  97601. * Extracts the "folder" part of a path (everything before the filename).
  97602. * @param uri The URI to extract the info from
  97603. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  97604. * @returns The "folder" part of the path
  97605. */
  97606. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  97607. /**
  97608. * Extracts text content from a DOM element hierarchy
  97609. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  97610. */
  97611. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  97612. /**
  97613. * Convert an angle in radians to degrees
  97614. * @param angle defines the angle to convert
  97615. * @returns the angle in degrees
  97616. */
  97617. static ToDegrees(angle: number): number;
  97618. /**
  97619. * Convert an angle in degrees to radians
  97620. * @param angle defines the angle to convert
  97621. * @returns the angle in radians
  97622. */
  97623. static ToRadians(angle: number): number;
  97624. /**
  97625. * Encode a buffer to a base64 string
  97626. * @param buffer defines the buffer to encode
  97627. * @returns the encoded string
  97628. */
  97629. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  97630. /**
  97631. * Returns an array if obj is not an array
  97632. * @param obj defines the object to evaluate as an array
  97633. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  97634. * @returns either obj directly if obj is an array or a new array containing obj
  97635. */
  97636. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  97637. /**
  97638. * Gets the pointer prefix to use
  97639. * @returns "pointer" if touch is enabled. Else returns "mouse"
  97640. */
  97641. static GetPointerPrefix(): string;
  97642. /**
  97643. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  97644. * @param url define the url we are trying
  97645. * @param element define the dom element where to configure the cors policy
  97646. */
  97647. static SetCorsBehavior(url: string | string[], element: {
  97648. crossOrigin: string | null;
  97649. }): void;
  97650. /**
  97651. * Removes unwanted characters from an url
  97652. * @param url defines the url to clean
  97653. * @returns the cleaned url
  97654. */
  97655. static CleanUrl(url: string): string;
  97656. /**
  97657. * Gets or sets a function used to pre-process url before using them to load assets
  97658. */
  97659. static PreprocessUrl: (url: string) => string;
  97660. /**
  97661. * Loads an image as an HTMLImageElement.
  97662. * @param input url string, ArrayBuffer, or Blob to load
  97663. * @param onLoad callback called when the image successfully loads
  97664. * @param onError callback called when the image fails to load
  97665. * @param offlineProvider offline provider for caching
  97666. * @returns the HTMLImageElement of the loaded image
  97667. */
  97668. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  97669. /**
  97670. * Loads a file
  97671. * @param url url string, ArrayBuffer, or Blob to load
  97672. * @param onSuccess callback called when the file successfully loads
  97673. * @param onProgress callback called while file is loading (if the server supports this mode)
  97674. * @param offlineProvider defines the offline provider for caching
  97675. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  97676. * @param onError callback called when the file fails to load
  97677. * @returns a file request object
  97678. */
  97679. 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;
  97680. /**
  97681. * Loads a file from a url
  97682. * @param url the file url to load
  97683. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  97684. */
  97685. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  97686. /**
  97687. * Load a script (identified by an url). When the url returns, the
  97688. * content of this file is added into a new script element, attached to the DOM (body element)
  97689. * @param scriptUrl defines the url of the script to laod
  97690. * @param onSuccess defines the callback called when the script is loaded
  97691. * @param onError defines the callback to call if an error occurs
  97692. * @param scriptId defines the id of the script element
  97693. */
  97694. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  97695. /**
  97696. * Load an asynchronous script (identified by an url). When the url returns, the
  97697. * content of this file is added into a new script element, attached to the DOM (body element)
  97698. * @param scriptUrl defines the url of the script to laod
  97699. * @param scriptId defines the id of the script element
  97700. * @returns a promise request object
  97701. */
  97702. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  97703. /**
  97704. * Loads a file from a blob
  97705. * @param fileToLoad defines the blob to use
  97706. * @param callback defines the callback to call when data is loaded
  97707. * @param progressCallback defines the callback to call during loading process
  97708. * @returns a file request object
  97709. */
  97710. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  97711. /**
  97712. * Loads a file
  97713. * @param fileToLoad defines the file to load
  97714. * @param callback defines the callback to call when data is loaded
  97715. * @param progressCallBack defines the callback to call during loading process
  97716. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  97717. * @returns a file request object
  97718. */
  97719. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  97720. /**
  97721. * Creates a data url from a given string content
  97722. * @param content defines the content to convert
  97723. * @returns the new data url link
  97724. */
  97725. static FileAsURL(content: string): string;
  97726. /**
  97727. * Format the given number to a specific decimal format
  97728. * @param value defines the number to format
  97729. * @param decimals defines the number of decimals to use
  97730. * @returns the formatted string
  97731. */
  97732. static Format(value: number, decimals?: number): string;
  97733. /**
  97734. * Tries to copy an object by duplicating every property
  97735. * @param source defines the source object
  97736. * @param destination defines the target object
  97737. * @param doNotCopyList defines a list of properties to avoid
  97738. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  97739. */
  97740. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  97741. /**
  97742. * Gets a boolean indicating if the given object has no own property
  97743. * @param obj defines the object to test
  97744. * @returns true if object has no own property
  97745. */
  97746. static IsEmpty(obj: any): boolean;
  97747. /**
  97748. * Function used to register events at window level
  97749. * @param windowElement defines the Window object to use
  97750. * @param events defines the events to register
  97751. */
  97752. static RegisterTopRootEvents(windowElement: Window, events: {
  97753. name: string;
  97754. handler: Nullable<(e: FocusEvent) => any>;
  97755. }[]): void;
  97756. /**
  97757. * Function used to unregister events from window level
  97758. * @param windowElement defines the Window object to use
  97759. * @param events defines the events to unregister
  97760. */
  97761. static UnregisterTopRootEvents(windowElement: Window, events: {
  97762. name: string;
  97763. handler: Nullable<(e: FocusEvent) => any>;
  97764. }[]): void;
  97765. /**
  97766. * @ignore
  97767. */
  97768. static _ScreenshotCanvas: HTMLCanvasElement;
  97769. /**
  97770. * Dumps the current bound framebuffer
  97771. * @param width defines the rendering width
  97772. * @param height defines the rendering height
  97773. * @param engine defines the hosting engine
  97774. * @param successCallback defines the callback triggered once the data are available
  97775. * @param mimeType defines the mime type of the result
  97776. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  97777. */
  97778. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  97779. /**
  97780. * Converts the canvas data to blob.
  97781. * This acts as a polyfill for browsers not supporting the to blob function.
  97782. * @param canvas Defines the canvas to extract the data from
  97783. * @param successCallback Defines the callback triggered once the data are available
  97784. * @param mimeType Defines the mime type of the result
  97785. */
  97786. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  97787. /**
  97788. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  97789. * @param successCallback defines the callback triggered once the data are available
  97790. * @param mimeType defines the mime type of the result
  97791. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  97792. */
  97793. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  97794. /**
  97795. * Downloads a blob in the browser
  97796. * @param blob defines the blob to download
  97797. * @param fileName defines the name of the downloaded file
  97798. */
  97799. static Download(blob: Blob, fileName: string): void;
  97800. /**
  97801. * Captures a screenshot of the current rendering
  97802. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97803. * @param engine defines the rendering engine
  97804. * @param camera defines the source camera
  97805. * @param size This parameter can be set to a single number or to an object with the
  97806. * following (optional) properties: precision, width, height. If a single number is passed,
  97807. * it will be used for both width and height. If an object is passed, the screenshot size
  97808. * will be derived from the parameters. The precision property is a multiplier allowing
  97809. * rendering at a higher or lower resolution
  97810. * @param successCallback defines the callback receives a single parameter which contains the
  97811. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97812. * src parameter of an <img> to display it
  97813. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  97814. * Check your browser for supported MIME types
  97815. */
  97816. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  97817. /**
  97818. * Captures a screenshot of the current rendering
  97819. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97820. * @param engine defines the rendering engine
  97821. * @param camera defines the source camera
  97822. * @param size This parameter can be set to a single number or to an object with the
  97823. * following (optional) properties: precision, width, height. If a single number is passed,
  97824. * it will be used for both width and height. If an object is passed, the screenshot size
  97825. * will be derived from the parameters. The precision property is a multiplier allowing
  97826. * rendering at a higher or lower resolution
  97827. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  97828. * Check your browser for supported MIME types
  97829. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  97830. * to the src parameter of an <img> to display it
  97831. */
  97832. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  97833. /**
  97834. * Generates an image screenshot from the specified camera.
  97835. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97836. * @param engine The engine to use for rendering
  97837. * @param camera The camera to use for rendering
  97838. * @param size This parameter can be set to a single number or to an object with the
  97839. * following (optional) properties: precision, width, height. If a single number is passed,
  97840. * it will be used for both width and height. If an object is passed, the screenshot size
  97841. * will be derived from the parameters. The precision property is a multiplier allowing
  97842. * rendering at a higher or lower resolution
  97843. * @param successCallback The callback receives a single parameter which contains the
  97844. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97845. * src parameter of an <img> to display it
  97846. * @param mimeType The MIME type of the screenshot image (default: image/png).
  97847. * Check your browser for supported MIME types
  97848. * @param samples Texture samples (default: 1)
  97849. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  97850. * @param fileName A name for for the downloaded file.
  97851. */
  97852. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  97853. /**
  97854. * Generates an image screenshot from the specified camera.
  97855. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97856. * @param engine The engine to use for rendering
  97857. * @param camera The camera to use for rendering
  97858. * @param size This parameter can be set to a single number or to an object with the
  97859. * following (optional) properties: precision, width, height. If a single number is passed,
  97860. * it will be used for both width and height. If an object is passed, the screenshot size
  97861. * will be derived from the parameters. The precision property is a multiplier allowing
  97862. * rendering at a higher or lower resolution
  97863. * @param mimeType The MIME type of the screenshot image (default: image/png).
  97864. * Check your browser for supported MIME types
  97865. * @param samples Texture samples (default: 1)
  97866. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  97867. * @param fileName A name for for the downloaded file.
  97868. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  97869. * to the src parameter of an <img> to display it
  97870. */
  97871. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  97872. /**
  97873. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  97874. * Be aware Math.random() could cause collisions, but:
  97875. * "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"
  97876. * @returns a pseudo random id
  97877. */
  97878. static RandomId(): string;
  97879. /**
  97880. * Test if the given uri is a base64 string
  97881. * @param uri The uri to test
  97882. * @return True if the uri is a base64 string or false otherwise
  97883. */
  97884. static IsBase64(uri: string): boolean;
  97885. /**
  97886. * Decode the given base64 uri.
  97887. * @param uri The uri to decode
  97888. * @return The decoded base64 data.
  97889. */
  97890. static DecodeBase64(uri: string): ArrayBuffer;
  97891. /**
  97892. * Gets the absolute url.
  97893. * @param url the input url
  97894. * @return the absolute url
  97895. */
  97896. static GetAbsoluteUrl(url: string): string;
  97897. /**
  97898. * No log
  97899. */
  97900. static readonly NoneLogLevel: number;
  97901. /**
  97902. * Only message logs
  97903. */
  97904. static readonly MessageLogLevel: number;
  97905. /**
  97906. * Only warning logs
  97907. */
  97908. static readonly WarningLogLevel: number;
  97909. /**
  97910. * Only error logs
  97911. */
  97912. static readonly ErrorLogLevel: number;
  97913. /**
  97914. * All logs
  97915. */
  97916. static readonly AllLogLevel: number;
  97917. /**
  97918. * Gets a value indicating the number of loading errors
  97919. * @ignorenaming
  97920. */
  97921. static readonly errorsCount: number;
  97922. /**
  97923. * Callback called when a new log is added
  97924. */
  97925. static OnNewCacheEntry: (entry: string) => void;
  97926. /**
  97927. * Log a message to the console
  97928. * @param message defines the message to log
  97929. */
  97930. static Log(message: string): void;
  97931. /**
  97932. * Write a warning message to the console
  97933. * @param message defines the message to log
  97934. */
  97935. static Warn(message: string): void;
  97936. /**
  97937. * Write an error message to the console
  97938. * @param message defines the message to log
  97939. */
  97940. static Error(message: string): void;
  97941. /**
  97942. * Gets current log cache (list of logs)
  97943. */
  97944. static readonly LogCache: string;
  97945. /**
  97946. * Clears the log cache
  97947. */
  97948. static ClearLogCache(): void;
  97949. /**
  97950. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  97951. */
  97952. static LogLevels: number;
  97953. /**
  97954. * Checks if the window object exists
  97955. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  97956. */
  97957. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  97958. /**
  97959. * No performance log
  97960. */
  97961. static readonly PerformanceNoneLogLevel: number;
  97962. /**
  97963. * Use user marks to log performance
  97964. */
  97965. static readonly PerformanceUserMarkLogLevel: number;
  97966. /**
  97967. * Log performance to the console
  97968. */
  97969. static readonly PerformanceConsoleLogLevel: number;
  97970. private static _performance;
  97971. /**
  97972. * Sets the current performance log level
  97973. */
  97974. static PerformanceLogLevel: number;
  97975. private static _StartPerformanceCounterDisabled;
  97976. private static _EndPerformanceCounterDisabled;
  97977. private static _StartUserMark;
  97978. private static _EndUserMark;
  97979. private static _StartPerformanceConsole;
  97980. private static _EndPerformanceConsole;
  97981. /**
  97982. * Starts a performance counter
  97983. */
  97984. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  97985. /**
  97986. * Ends a specific performance coutner
  97987. */
  97988. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  97989. /**
  97990. * Gets either window.performance.now() if supported or Date.now() else
  97991. */
  97992. static readonly Now: number;
  97993. /**
  97994. * This method will return the name of the class used to create the instance of the given object.
  97995. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  97996. * @param object the object to get the class name from
  97997. * @param isType defines if the object is actually a type
  97998. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  97999. */
  98000. static GetClassName(object: any, isType?: boolean): string;
  98001. /**
  98002. * Gets the first element of an array satisfying a given predicate
  98003. * @param array defines the array to browse
  98004. * @param predicate defines the predicate to use
  98005. * @returns null if not found or the element
  98006. */
  98007. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  98008. /**
  98009. * This method will return the name of the full name of the class, including its owning module (if any).
  98010. * 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).
  98011. * @param object the object to get the class name from
  98012. * @param isType defines if the object is actually a type
  98013. * @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.
  98014. * @ignorenaming
  98015. */
  98016. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  98017. /**
  98018. * Returns a promise that resolves after the given amount of time.
  98019. * @param delay Number of milliseconds to delay
  98020. * @returns Promise that resolves after the given amount of time
  98021. */
  98022. static DelayAsync(delay: number): Promise<void>;
  98023. }
  98024. /**
  98025. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  98026. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  98027. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  98028. * @param name The name of the class, case should be preserved
  98029. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  98030. */
  98031. export function className(name: string, module?: string): (target: Object) => void;
  98032. /**
  98033. * An implementation of a loop for asynchronous functions.
  98034. */
  98035. export class AsyncLoop {
  98036. /**
  98037. * Defines the number of iterations for the loop
  98038. */
  98039. iterations: number;
  98040. /**
  98041. * Defines the current index of the loop.
  98042. */
  98043. index: number;
  98044. private _done;
  98045. private _fn;
  98046. private _successCallback;
  98047. /**
  98048. * Constructor.
  98049. * @param iterations the number of iterations.
  98050. * @param func the function to run each iteration
  98051. * @param successCallback the callback that will be called upon succesful execution
  98052. * @param offset starting offset.
  98053. */
  98054. constructor(
  98055. /**
  98056. * Defines the number of iterations for the loop
  98057. */
  98058. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  98059. /**
  98060. * Execute the next iteration. Must be called after the last iteration was finished.
  98061. */
  98062. executeNext(): void;
  98063. /**
  98064. * Break the loop and run the success callback.
  98065. */
  98066. breakLoop(): void;
  98067. /**
  98068. * Create and run an async loop.
  98069. * @param iterations the number of iterations.
  98070. * @param fn the function to run each iteration
  98071. * @param successCallback the callback that will be called upon succesful execution
  98072. * @param offset starting offset.
  98073. * @returns the created async loop object
  98074. */
  98075. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  98076. /**
  98077. * A for-loop that will run a given number of iterations synchronous and the rest async.
  98078. * @param iterations total number of iterations
  98079. * @param syncedIterations number of synchronous iterations in each async iteration.
  98080. * @param fn the function to call each iteration.
  98081. * @param callback a success call back that will be called when iterating stops.
  98082. * @param breakFunction a break condition (optional)
  98083. * @param timeout timeout settings for the setTimeout function. default - 0.
  98084. * @returns the created async loop object
  98085. */
  98086. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  98087. }
  98088. }
  98089. declare module BABYLON {
  98090. /** @hidden */
  98091. export interface ICollisionCoordinator {
  98092. createCollider(): Collider;
  98093. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  98094. init(scene: Scene): void;
  98095. }
  98096. /** @hidden */
  98097. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  98098. private _scene;
  98099. private _scaledPosition;
  98100. private _scaledVelocity;
  98101. private _finalPosition;
  98102. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  98103. createCollider(): Collider;
  98104. init(scene: Scene): void;
  98105. private _collideWithWorld;
  98106. }
  98107. }
  98108. declare module BABYLON {
  98109. /**
  98110. * Class used to manage all inputs for the scene.
  98111. */
  98112. export class InputManager {
  98113. /** The distance in pixel that you have to move to prevent some events */
  98114. static DragMovementThreshold: number;
  98115. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  98116. static LongPressDelay: number;
  98117. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  98118. static DoubleClickDelay: number;
  98119. /** If you need to check double click without raising a single click at first click, enable this flag */
  98120. static ExclusiveDoubleClickMode: boolean;
  98121. private _wheelEventName;
  98122. private _onPointerMove;
  98123. private _onPointerDown;
  98124. private _onPointerUp;
  98125. private _initClickEvent;
  98126. private _initActionManager;
  98127. private _delayedSimpleClick;
  98128. private _delayedSimpleClickTimeout;
  98129. private _previousDelayedSimpleClickTimeout;
  98130. private _meshPickProceed;
  98131. private _previousButtonPressed;
  98132. private _currentPickResult;
  98133. private _previousPickResult;
  98134. private _totalPointersPressed;
  98135. private _doubleClickOccured;
  98136. private _pointerOverMesh;
  98137. private _pickedDownMesh;
  98138. private _pickedUpMesh;
  98139. private _pointerX;
  98140. private _pointerY;
  98141. private _unTranslatedPointerX;
  98142. private _unTranslatedPointerY;
  98143. private _startingPointerPosition;
  98144. private _previousStartingPointerPosition;
  98145. private _startingPointerTime;
  98146. private _previousStartingPointerTime;
  98147. private _pointerCaptures;
  98148. private _onKeyDown;
  98149. private _onKeyUp;
  98150. private _onCanvasFocusObserver;
  98151. private _onCanvasBlurObserver;
  98152. private _scene;
  98153. /**
  98154. * Creates a new InputManager
  98155. * @param scene defines the hosting scene
  98156. */
  98157. constructor(scene: Scene);
  98158. /**
  98159. * Gets the mesh that is currently under the pointer
  98160. */
  98161. readonly meshUnderPointer: Nullable<AbstractMesh>;
  98162. /**
  98163. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  98164. */
  98165. readonly unTranslatedPointer: Vector2;
  98166. /**
  98167. * Gets or sets the current on-screen X position of the pointer
  98168. */
  98169. pointerX: number;
  98170. /**
  98171. * Gets or sets the current on-screen Y position of the pointer
  98172. */
  98173. pointerY: number;
  98174. private _updatePointerPosition;
  98175. private _processPointerMove;
  98176. private _setRayOnPointerInfo;
  98177. private _checkPrePointerObservable;
  98178. /**
  98179. * Use this method to simulate a pointer move on a mesh
  98180. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98181. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98182. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98183. */
  98184. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  98185. /**
  98186. * Use this method to simulate a pointer down on a mesh
  98187. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98188. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98189. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98190. */
  98191. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  98192. private _processPointerDown;
  98193. /** @hidden */
  98194. _isPointerSwiping(): boolean;
  98195. /**
  98196. * Use this method to simulate a pointer up on a mesh
  98197. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98198. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98199. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98200. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  98201. */
  98202. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  98203. private _processPointerUp;
  98204. /**
  98205. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  98206. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  98207. * @returns true if the pointer was captured
  98208. */
  98209. isPointerCaptured(pointerId?: number): boolean;
  98210. /**
  98211. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  98212. * @param attachUp defines if you want to attach events to pointerup
  98213. * @param attachDown defines if you want to attach events to pointerdown
  98214. * @param attachMove defines if you want to attach events to pointermove
  98215. */
  98216. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  98217. /**
  98218. * Detaches all event handlers
  98219. */
  98220. detachControl(): void;
  98221. /**
  98222. * Force the value of meshUnderPointer
  98223. * @param mesh defines the mesh to use
  98224. */
  98225. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  98226. /**
  98227. * Gets the mesh under the pointer
  98228. * @returns a Mesh or null if no mesh is under the pointer
  98229. */
  98230. getPointerOverMesh(): Nullable<AbstractMesh>;
  98231. }
  98232. }
  98233. declare module BABYLON {
  98234. /**
  98235. * Helper class used to generate session unique ID
  98236. */
  98237. export class UniqueIdGenerator {
  98238. private static _UniqueIdCounter;
  98239. /**
  98240. * Gets an unique (relatively to the current scene) Id
  98241. */
  98242. static readonly UniqueId: number;
  98243. }
  98244. }
  98245. declare module BABYLON {
  98246. /**
  98247. * This class defines the direct association between an animation and a target
  98248. */
  98249. export class TargetedAnimation {
  98250. /**
  98251. * Animation to perform
  98252. */
  98253. animation: Animation;
  98254. /**
  98255. * Target to animate
  98256. */
  98257. target: any;
  98258. /**
  98259. * Serialize the object
  98260. * @returns the JSON object representing the current entity
  98261. */
  98262. serialize(): any;
  98263. }
  98264. /**
  98265. * Use this class to create coordinated animations on multiple targets
  98266. */
  98267. export class AnimationGroup implements IDisposable {
  98268. /** The name of the animation group */
  98269. name: string;
  98270. private _scene;
  98271. private _targetedAnimations;
  98272. private _animatables;
  98273. private _from;
  98274. private _to;
  98275. private _isStarted;
  98276. private _isPaused;
  98277. private _speedRatio;
  98278. private _loopAnimation;
  98279. /**
  98280. * Gets or sets the unique id of the node
  98281. */
  98282. uniqueId: number;
  98283. /**
  98284. * This observable will notify when one animation have ended
  98285. */
  98286. onAnimationEndObservable: Observable<TargetedAnimation>;
  98287. /**
  98288. * Observer raised when one animation loops
  98289. */
  98290. onAnimationLoopObservable: Observable<TargetedAnimation>;
  98291. /**
  98292. * This observable will notify when all animations have ended.
  98293. */
  98294. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  98295. /**
  98296. * This observable will notify when all animations have paused.
  98297. */
  98298. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  98299. /**
  98300. * This observable will notify when all animations are playing.
  98301. */
  98302. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  98303. /**
  98304. * Gets the first frame
  98305. */
  98306. readonly from: number;
  98307. /**
  98308. * Gets the last frame
  98309. */
  98310. readonly to: number;
  98311. /**
  98312. * Define if the animations are started
  98313. */
  98314. readonly isStarted: boolean;
  98315. /**
  98316. * Gets a value indicating that the current group is playing
  98317. */
  98318. readonly isPlaying: boolean;
  98319. /**
  98320. * Gets or sets the speed ratio to use for all animations
  98321. */
  98322. /**
  98323. * Gets or sets the speed ratio to use for all animations
  98324. */
  98325. speedRatio: number;
  98326. /**
  98327. * Gets or sets if all animations should loop or not
  98328. */
  98329. loopAnimation: boolean;
  98330. /**
  98331. * Gets the targeted animations for this animation group
  98332. */
  98333. readonly targetedAnimations: Array<TargetedAnimation>;
  98334. /**
  98335. * returning the list of animatables controlled by this animation group.
  98336. */
  98337. readonly animatables: Array<Animatable>;
  98338. /**
  98339. * Instantiates a new Animation Group.
  98340. * This helps managing several animations at once.
  98341. * @see http://doc.babylonjs.com/how_to/group
  98342. * @param name Defines the name of the group
  98343. * @param scene Defines the scene the group belongs to
  98344. */
  98345. constructor(
  98346. /** The name of the animation group */
  98347. name: string, scene?: Nullable<Scene>);
  98348. /**
  98349. * Add an animation (with its target) in the group
  98350. * @param animation defines the animation we want to add
  98351. * @param target defines the target of the animation
  98352. * @returns the TargetedAnimation object
  98353. */
  98354. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  98355. /**
  98356. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  98357. * It can add constant keys at begin or end
  98358. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  98359. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  98360. * @returns the animation group
  98361. */
  98362. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  98363. /**
  98364. * Start all animations on given targets
  98365. * @param loop defines if animations must loop
  98366. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  98367. * @param from defines the from key (optional)
  98368. * @param to defines the to key (optional)
  98369. * @returns the current animation group
  98370. */
  98371. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  98372. /**
  98373. * Pause all animations
  98374. * @returns the animation group
  98375. */
  98376. pause(): AnimationGroup;
  98377. /**
  98378. * Play all animations to initial state
  98379. * This function will start() the animations if they were not started or will restart() them if they were paused
  98380. * @param loop defines if animations must loop
  98381. * @returns the animation group
  98382. */
  98383. play(loop?: boolean): AnimationGroup;
  98384. /**
  98385. * Reset all animations to initial state
  98386. * @returns the animation group
  98387. */
  98388. reset(): AnimationGroup;
  98389. /**
  98390. * Restart animations from key 0
  98391. * @returns the animation group
  98392. */
  98393. restart(): AnimationGroup;
  98394. /**
  98395. * Stop all animations
  98396. * @returns the animation group
  98397. */
  98398. stop(): AnimationGroup;
  98399. /**
  98400. * Set animation weight for all animatables
  98401. * @param weight defines the weight to use
  98402. * @return the animationGroup
  98403. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  98404. */
  98405. setWeightForAllAnimatables(weight: number): AnimationGroup;
  98406. /**
  98407. * Synchronize and normalize all animatables with a source animatable
  98408. * @param root defines the root animatable to synchronize with
  98409. * @return the animationGroup
  98410. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  98411. */
  98412. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  98413. /**
  98414. * Goes to a specific frame in this animation group
  98415. * @param frame the frame number to go to
  98416. * @return the animationGroup
  98417. */
  98418. goToFrame(frame: number): AnimationGroup;
  98419. /**
  98420. * Dispose all associated resources
  98421. */
  98422. dispose(): void;
  98423. private _checkAnimationGroupEnded;
  98424. /**
  98425. * Clone the current animation group and returns a copy
  98426. * @param newName defines the name of the new group
  98427. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  98428. * @returns the new aniamtion group
  98429. */
  98430. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  98431. /**
  98432. * Serializes the animationGroup to an object
  98433. * @returns Serialized object
  98434. */
  98435. serialize(): any;
  98436. /**
  98437. * Returns a new AnimationGroup object parsed from the source provided.
  98438. * @param parsedAnimationGroup defines the source
  98439. * @param scene defines the scene that will receive the animationGroup
  98440. * @returns a new AnimationGroup
  98441. */
  98442. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  98443. /**
  98444. * Returns the string "AnimationGroup"
  98445. * @returns "AnimationGroup"
  98446. */
  98447. getClassName(): string;
  98448. /**
  98449. * Creates a detailled string about the object
  98450. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  98451. * @returns a string representing the object
  98452. */
  98453. toString(fullDetails?: boolean): string;
  98454. }
  98455. }
  98456. declare module BABYLON {
  98457. /**
  98458. * Define an interface for all classes that will hold resources
  98459. */
  98460. export interface IDisposable {
  98461. /**
  98462. * Releases all held resources
  98463. */
  98464. dispose(): void;
  98465. }
  98466. /** Interface defining initialization parameters for Scene class */
  98467. export interface SceneOptions {
  98468. /**
  98469. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  98470. * It will improve performance when the number of geometries becomes important.
  98471. */
  98472. useGeometryUniqueIdsMap?: boolean;
  98473. /**
  98474. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  98475. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  98476. */
  98477. useMaterialMeshMap?: boolean;
  98478. /**
  98479. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  98480. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  98481. */
  98482. useClonedMeshhMap?: boolean;
  98483. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  98484. virtual?: boolean;
  98485. }
  98486. /**
  98487. * Represents a scene to be rendered by the engine.
  98488. * @see http://doc.babylonjs.com/features/scene
  98489. */
  98490. export class Scene extends AbstractScene implements IAnimatable {
  98491. /** The fog is deactivated */
  98492. static readonly FOGMODE_NONE: number;
  98493. /** The fog density is following an exponential function */
  98494. static readonly FOGMODE_EXP: number;
  98495. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  98496. static readonly FOGMODE_EXP2: number;
  98497. /** The fog density is following a linear function. */
  98498. static readonly FOGMODE_LINEAR: number;
  98499. /**
  98500. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  98501. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98502. */
  98503. static MinDeltaTime: number;
  98504. /**
  98505. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  98506. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98507. */
  98508. static MaxDeltaTime: number;
  98509. /**
  98510. * Factory used to create the default material.
  98511. * @param name The name of the material to create
  98512. * @param scene The scene to create the material for
  98513. * @returns The default material
  98514. */
  98515. static DefaultMaterialFactory(scene: Scene): Material;
  98516. /**
  98517. * Factory used to create the a collision coordinator.
  98518. * @returns The collision coordinator
  98519. */
  98520. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  98521. /** @hidden */
  98522. _inputManager: InputManager;
  98523. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  98524. cameraToUseForPointers: Nullable<Camera>;
  98525. /** @hidden */
  98526. readonly _isScene: boolean;
  98527. /**
  98528. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  98529. */
  98530. autoClear: boolean;
  98531. /**
  98532. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  98533. */
  98534. autoClearDepthAndStencil: boolean;
  98535. /**
  98536. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  98537. */
  98538. clearColor: Color4;
  98539. /**
  98540. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  98541. */
  98542. ambientColor: Color3;
  98543. /**
  98544. * This is use to store the default BRDF lookup for PBR materials in your scene.
  98545. * It should only be one of the following (if not the default embedded one):
  98546. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  98547. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  98548. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  98549. * The material properties need to be setup according to the type of texture in use.
  98550. */
  98551. environmentBRDFTexture: BaseTexture;
  98552. /** @hidden */
  98553. protected _environmentTexture: Nullable<BaseTexture>;
  98554. /**
  98555. * Texture used in all pbr material as the reflection texture.
  98556. * As in the majority of the scene they are the same (exception for multi room and so on),
  98557. * this is easier to reference from here than from all the materials.
  98558. */
  98559. /**
  98560. * Texture used in all pbr material as the reflection texture.
  98561. * As in the majority of the scene they are the same (exception for multi room and so on),
  98562. * this is easier to set here than in all the materials.
  98563. */
  98564. environmentTexture: Nullable<BaseTexture>;
  98565. /** @hidden */
  98566. protected _environmentIntensity: number;
  98567. /**
  98568. * Intensity of the environment in all pbr material.
  98569. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  98570. * As in the majority of the scene they are the same (exception for multi room and so on),
  98571. * this is easier to reference from here than from all the materials.
  98572. */
  98573. /**
  98574. * Intensity of the environment in all pbr material.
  98575. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  98576. * As in the majority of the scene they are the same (exception for multi room and so on),
  98577. * this is easier to set here than in all the materials.
  98578. */
  98579. environmentIntensity: number;
  98580. /** @hidden */
  98581. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98582. /**
  98583. * Default image processing configuration used either in the rendering
  98584. * Forward main pass or through the imageProcessingPostProcess if present.
  98585. * As in the majority of the scene they are the same (exception for multi camera),
  98586. * this is easier to reference from here than from all the materials and post process.
  98587. *
  98588. * No setter as we it is a shared configuration, you can set the values instead.
  98589. */
  98590. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  98591. private _forceWireframe;
  98592. /**
  98593. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  98594. */
  98595. forceWireframe: boolean;
  98596. private _forcePointsCloud;
  98597. /**
  98598. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  98599. */
  98600. forcePointsCloud: boolean;
  98601. /**
  98602. * Gets or sets the active clipplane 1
  98603. */
  98604. clipPlane: Nullable<Plane>;
  98605. /**
  98606. * Gets or sets the active clipplane 2
  98607. */
  98608. clipPlane2: Nullable<Plane>;
  98609. /**
  98610. * Gets or sets the active clipplane 3
  98611. */
  98612. clipPlane3: Nullable<Plane>;
  98613. /**
  98614. * Gets or sets the active clipplane 4
  98615. */
  98616. clipPlane4: Nullable<Plane>;
  98617. /**
  98618. * Gets or sets a boolean indicating if animations are enabled
  98619. */
  98620. animationsEnabled: boolean;
  98621. private _animationPropertiesOverride;
  98622. /**
  98623. * Gets or sets the animation properties override
  98624. */
  98625. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  98626. /**
  98627. * Gets or sets a boolean indicating if a constant deltatime has to be used
  98628. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  98629. */
  98630. useConstantAnimationDeltaTime: boolean;
  98631. /**
  98632. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  98633. * Please note that it requires to run a ray cast through the scene on every frame
  98634. */
  98635. constantlyUpdateMeshUnderPointer: boolean;
  98636. /**
  98637. * Defines the HTML cursor to use when hovering over interactive elements
  98638. */
  98639. hoverCursor: string;
  98640. /**
  98641. * Defines the HTML default cursor to use (empty by default)
  98642. */
  98643. defaultCursor: string;
  98644. /**
  98645. * This is used to call preventDefault() on pointer down
  98646. * in order to block unwanted artifacts like system double clicks
  98647. */
  98648. preventDefaultOnPointerDown: boolean;
  98649. /**
  98650. * This is used to call preventDefault() on pointer up
  98651. * in order to block unwanted artifacts like system double clicks
  98652. */
  98653. preventDefaultOnPointerUp: boolean;
  98654. /**
  98655. * Gets or sets user defined metadata
  98656. */
  98657. metadata: any;
  98658. /**
  98659. * For internal use only. Please do not use.
  98660. */
  98661. reservedDataStore: any;
  98662. /**
  98663. * Gets the name of the plugin used to load this scene (null by default)
  98664. */
  98665. loadingPluginName: string;
  98666. /**
  98667. * Use this array to add regular expressions used to disable offline support for specific urls
  98668. */
  98669. disableOfflineSupportExceptionRules: RegExp[];
  98670. /**
  98671. * An event triggered when the scene is disposed.
  98672. */
  98673. onDisposeObservable: Observable<Scene>;
  98674. private _onDisposeObserver;
  98675. /** Sets a function to be executed when this scene is disposed. */
  98676. onDispose: () => void;
  98677. /**
  98678. * An event triggered before rendering the scene (right after animations and physics)
  98679. */
  98680. onBeforeRenderObservable: Observable<Scene>;
  98681. private _onBeforeRenderObserver;
  98682. /** Sets a function to be executed before rendering this scene */
  98683. beforeRender: Nullable<() => void>;
  98684. /**
  98685. * An event triggered after rendering the scene
  98686. */
  98687. onAfterRenderObservable: Observable<Scene>;
  98688. /**
  98689. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  98690. */
  98691. onAfterRenderCameraObservable: Observable<Camera>;
  98692. private _onAfterRenderObserver;
  98693. /** Sets a function to be executed after rendering this scene */
  98694. afterRender: Nullable<() => void>;
  98695. /**
  98696. * An event triggered before animating the scene
  98697. */
  98698. onBeforeAnimationsObservable: Observable<Scene>;
  98699. /**
  98700. * An event triggered after animations processing
  98701. */
  98702. onAfterAnimationsObservable: Observable<Scene>;
  98703. /**
  98704. * An event triggered before draw calls are ready to be sent
  98705. */
  98706. onBeforeDrawPhaseObservable: Observable<Scene>;
  98707. /**
  98708. * An event triggered after draw calls have been sent
  98709. */
  98710. onAfterDrawPhaseObservable: Observable<Scene>;
  98711. /**
  98712. * An event triggered when the scene is ready
  98713. */
  98714. onReadyObservable: Observable<Scene>;
  98715. /**
  98716. * An event triggered before rendering a camera
  98717. */
  98718. onBeforeCameraRenderObservable: Observable<Camera>;
  98719. private _onBeforeCameraRenderObserver;
  98720. /** Sets a function to be executed before rendering a camera*/
  98721. beforeCameraRender: () => void;
  98722. /**
  98723. * An event triggered after rendering a camera
  98724. */
  98725. onAfterCameraRenderObservable: Observable<Camera>;
  98726. private _onAfterCameraRenderObserver;
  98727. /** Sets a function to be executed after rendering a camera*/
  98728. afterCameraRender: () => void;
  98729. /**
  98730. * An event triggered when active meshes evaluation is about to start
  98731. */
  98732. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  98733. /**
  98734. * An event triggered when active meshes evaluation is done
  98735. */
  98736. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  98737. /**
  98738. * An event triggered when particles rendering is about to start
  98739. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  98740. */
  98741. onBeforeParticlesRenderingObservable: Observable<Scene>;
  98742. /**
  98743. * An event triggered when particles rendering is done
  98744. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  98745. */
  98746. onAfterParticlesRenderingObservable: Observable<Scene>;
  98747. /**
  98748. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  98749. */
  98750. onDataLoadedObservable: Observable<Scene>;
  98751. /**
  98752. * An event triggered when a camera is created
  98753. */
  98754. onNewCameraAddedObservable: Observable<Camera>;
  98755. /**
  98756. * An event triggered when a camera is removed
  98757. */
  98758. onCameraRemovedObservable: Observable<Camera>;
  98759. /**
  98760. * An event triggered when a light is created
  98761. */
  98762. onNewLightAddedObservable: Observable<Light>;
  98763. /**
  98764. * An event triggered when a light is removed
  98765. */
  98766. onLightRemovedObservable: Observable<Light>;
  98767. /**
  98768. * An event triggered when a geometry is created
  98769. */
  98770. onNewGeometryAddedObservable: Observable<Geometry>;
  98771. /**
  98772. * An event triggered when a geometry is removed
  98773. */
  98774. onGeometryRemovedObservable: Observable<Geometry>;
  98775. /**
  98776. * An event triggered when a transform node is created
  98777. */
  98778. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  98779. /**
  98780. * An event triggered when a transform node is removed
  98781. */
  98782. onTransformNodeRemovedObservable: Observable<TransformNode>;
  98783. /**
  98784. * An event triggered when a mesh is created
  98785. */
  98786. onNewMeshAddedObservable: Observable<AbstractMesh>;
  98787. /**
  98788. * An event triggered when a mesh is removed
  98789. */
  98790. onMeshRemovedObservable: Observable<AbstractMesh>;
  98791. /**
  98792. * An event triggered when a skeleton is created
  98793. */
  98794. onNewSkeletonAddedObservable: Observable<Skeleton>;
  98795. /**
  98796. * An event triggered when a skeleton is removed
  98797. */
  98798. onSkeletonRemovedObservable: Observable<Skeleton>;
  98799. /**
  98800. * An event triggered when a material is created
  98801. */
  98802. onNewMaterialAddedObservable: Observable<Material>;
  98803. /**
  98804. * An event triggered when a material is removed
  98805. */
  98806. onMaterialRemovedObservable: Observable<Material>;
  98807. /**
  98808. * An event triggered when a texture is created
  98809. */
  98810. onNewTextureAddedObservable: Observable<BaseTexture>;
  98811. /**
  98812. * An event triggered when a texture is removed
  98813. */
  98814. onTextureRemovedObservable: Observable<BaseTexture>;
  98815. /**
  98816. * An event triggered when render targets are about to be rendered
  98817. * Can happen multiple times per frame.
  98818. */
  98819. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  98820. /**
  98821. * An event triggered when render targets were rendered.
  98822. * Can happen multiple times per frame.
  98823. */
  98824. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  98825. /**
  98826. * An event triggered before calculating deterministic simulation step
  98827. */
  98828. onBeforeStepObservable: Observable<Scene>;
  98829. /**
  98830. * An event triggered after calculating deterministic simulation step
  98831. */
  98832. onAfterStepObservable: Observable<Scene>;
  98833. /**
  98834. * An event triggered when the activeCamera property is updated
  98835. */
  98836. onActiveCameraChanged: Observable<Scene>;
  98837. /**
  98838. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  98839. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  98840. * 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)
  98841. */
  98842. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  98843. /**
  98844. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  98845. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  98846. * 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)
  98847. */
  98848. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  98849. /**
  98850. * This Observable will when a mesh has been imported into the scene.
  98851. */
  98852. onMeshImportedObservable: Observable<AbstractMesh>;
  98853. /**
  98854. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  98855. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  98856. */
  98857. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  98858. /** @hidden */
  98859. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  98860. /**
  98861. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  98862. */
  98863. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  98864. /**
  98865. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  98866. */
  98867. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  98868. /**
  98869. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  98870. */
  98871. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  98872. /** Callback called when a pointer move is detected */
  98873. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  98874. /** Callback called when a pointer down is detected */
  98875. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  98876. /** Callback called when a pointer up is detected */
  98877. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  98878. /** Callback called when a pointer pick is detected */
  98879. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  98880. /**
  98881. * 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).
  98882. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  98883. */
  98884. onPrePointerObservable: Observable<PointerInfoPre>;
  98885. /**
  98886. * Observable event triggered each time an input event is received from the rendering canvas
  98887. */
  98888. onPointerObservable: Observable<PointerInfo>;
  98889. /**
  98890. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  98891. */
  98892. readonly unTranslatedPointer: Vector2;
  98893. /**
  98894. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  98895. */
  98896. static DragMovementThreshold: number;
  98897. /**
  98898. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  98899. */
  98900. static LongPressDelay: number;
  98901. /**
  98902. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  98903. */
  98904. static DoubleClickDelay: number;
  98905. /** If you need to check double click without raising a single click at first click, enable this flag */
  98906. static ExclusiveDoubleClickMode: boolean;
  98907. /** @hidden */
  98908. _mirroredCameraPosition: Nullable<Vector3>;
  98909. /**
  98910. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  98911. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  98912. */
  98913. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  98914. /**
  98915. * Observable event triggered each time an keyboard event is received from the hosting window
  98916. */
  98917. onKeyboardObservable: Observable<KeyboardInfo>;
  98918. private _useRightHandedSystem;
  98919. /**
  98920. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  98921. */
  98922. useRightHandedSystem: boolean;
  98923. private _timeAccumulator;
  98924. private _currentStepId;
  98925. private _currentInternalStep;
  98926. /**
  98927. * Sets the step Id used by deterministic lock step
  98928. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98929. * @param newStepId defines the step Id
  98930. */
  98931. setStepId(newStepId: number): void;
  98932. /**
  98933. * Gets the step Id used by deterministic lock step
  98934. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98935. * @returns the step Id
  98936. */
  98937. getStepId(): number;
  98938. /**
  98939. * Gets the internal step used by deterministic lock step
  98940. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98941. * @returns the internal step
  98942. */
  98943. getInternalStep(): number;
  98944. private _fogEnabled;
  98945. /**
  98946. * Gets or sets a boolean indicating if fog is enabled on this scene
  98947. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98948. * (Default is true)
  98949. */
  98950. fogEnabled: boolean;
  98951. private _fogMode;
  98952. /**
  98953. * Gets or sets the fog mode to use
  98954. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98955. * | mode | value |
  98956. * | --- | --- |
  98957. * | FOGMODE_NONE | 0 |
  98958. * | FOGMODE_EXP | 1 |
  98959. * | FOGMODE_EXP2 | 2 |
  98960. * | FOGMODE_LINEAR | 3 |
  98961. */
  98962. fogMode: number;
  98963. /**
  98964. * Gets or sets the fog color to use
  98965. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98966. * (Default is Color3(0.2, 0.2, 0.3))
  98967. */
  98968. fogColor: Color3;
  98969. /**
  98970. * Gets or sets the fog density to use
  98971. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98972. * (Default is 0.1)
  98973. */
  98974. fogDensity: number;
  98975. /**
  98976. * Gets or sets the fog start distance to use
  98977. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98978. * (Default is 0)
  98979. */
  98980. fogStart: number;
  98981. /**
  98982. * Gets or sets the fog end distance to use
  98983. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98984. * (Default is 1000)
  98985. */
  98986. fogEnd: number;
  98987. private _shadowsEnabled;
  98988. /**
  98989. * Gets or sets a boolean indicating if shadows are enabled on this scene
  98990. */
  98991. shadowsEnabled: boolean;
  98992. private _lightsEnabled;
  98993. /**
  98994. * Gets or sets a boolean indicating if lights are enabled on this scene
  98995. */
  98996. lightsEnabled: boolean;
  98997. /** All of the active cameras added to this scene. */
  98998. activeCameras: Camera[];
  98999. /** @hidden */
  99000. _activeCamera: Nullable<Camera>;
  99001. /** Gets or sets the current active camera */
  99002. activeCamera: Nullable<Camera>;
  99003. private _defaultMaterial;
  99004. /** The default material used on meshes when no material is affected */
  99005. /** The default material used on meshes when no material is affected */
  99006. defaultMaterial: Material;
  99007. private _texturesEnabled;
  99008. /**
  99009. * Gets or sets a boolean indicating if textures are enabled on this scene
  99010. */
  99011. texturesEnabled: boolean;
  99012. /**
  99013. * Gets or sets a boolean indicating if particles are enabled on this scene
  99014. */
  99015. particlesEnabled: boolean;
  99016. /**
  99017. * Gets or sets a boolean indicating if sprites are enabled on this scene
  99018. */
  99019. spritesEnabled: boolean;
  99020. private _skeletonsEnabled;
  99021. /**
  99022. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  99023. */
  99024. skeletonsEnabled: boolean;
  99025. /**
  99026. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  99027. */
  99028. lensFlaresEnabled: boolean;
  99029. /**
  99030. * Gets or sets a boolean indicating if collisions are enabled on this scene
  99031. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99032. */
  99033. collisionsEnabled: boolean;
  99034. private _collisionCoordinator;
  99035. /** @hidden */
  99036. readonly collisionCoordinator: ICollisionCoordinator;
  99037. /**
  99038. * Defines the gravity applied to this scene (used only for collisions)
  99039. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99040. */
  99041. gravity: Vector3;
  99042. /**
  99043. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  99044. */
  99045. postProcessesEnabled: boolean;
  99046. /**
  99047. * The list of postprocesses added to the scene
  99048. */
  99049. postProcesses: PostProcess[];
  99050. /**
  99051. * Gets the current postprocess manager
  99052. */
  99053. postProcessManager: PostProcessManager;
  99054. /**
  99055. * Gets or sets a boolean indicating if render targets are enabled on this scene
  99056. */
  99057. renderTargetsEnabled: boolean;
  99058. /**
  99059. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  99060. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  99061. */
  99062. dumpNextRenderTargets: boolean;
  99063. /**
  99064. * The list of user defined render targets added to the scene
  99065. */
  99066. customRenderTargets: RenderTargetTexture[];
  99067. /**
  99068. * Defines if texture loading must be delayed
  99069. * If true, textures will only be loaded when they need to be rendered
  99070. */
  99071. useDelayedTextureLoading: boolean;
  99072. /**
  99073. * Gets the list of meshes imported to the scene through SceneLoader
  99074. */
  99075. importedMeshesFiles: String[];
  99076. /**
  99077. * Gets or sets a boolean indicating if probes are enabled on this scene
  99078. */
  99079. probesEnabled: boolean;
  99080. /**
  99081. * Gets or sets the current offline provider to use to store scene data
  99082. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  99083. */
  99084. offlineProvider: IOfflineProvider;
  99085. /**
  99086. * Gets or sets the action manager associated with the scene
  99087. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99088. */
  99089. actionManager: AbstractActionManager;
  99090. private _meshesForIntersections;
  99091. /**
  99092. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  99093. */
  99094. proceduralTexturesEnabled: boolean;
  99095. private _engine;
  99096. private _totalVertices;
  99097. /** @hidden */
  99098. _activeIndices: PerfCounter;
  99099. /** @hidden */
  99100. _activeParticles: PerfCounter;
  99101. /** @hidden */
  99102. _activeBones: PerfCounter;
  99103. private _animationRatio;
  99104. /** @hidden */
  99105. _animationTimeLast: number;
  99106. /** @hidden */
  99107. _animationTime: number;
  99108. /**
  99109. * Gets or sets a general scale for animation speed
  99110. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  99111. */
  99112. animationTimeScale: number;
  99113. /** @hidden */
  99114. _cachedMaterial: Nullable<Material>;
  99115. /** @hidden */
  99116. _cachedEffect: Nullable<Effect>;
  99117. /** @hidden */
  99118. _cachedVisibility: Nullable<number>;
  99119. private _renderId;
  99120. private _frameId;
  99121. private _executeWhenReadyTimeoutId;
  99122. private _intermediateRendering;
  99123. private _viewUpdateFlag;
  99124. private _projectionUpdateFlag;
  99125. /** @hidden */
  99126. _toBeDisposed: Nullable<IDisposable>[];
  99127. private _activeRequests;
  99128. /** @hidden */
  99129. _pendingData: any[];
  99130. private _isDisposed;
  99131. /**
  99132. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  99133. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  99134. */
  99135. dispatchAllSubMeshesOfActiveMeshes: boolean;
  99136. private _activeMeshes;
  99137. private _processedMaterials;
  99138. private _renderTargets;
  99139. /** @hidden */
  99140. _activeParticleSystems: SmartArray<IParticleSystem>;
  99141. private _activeSkeletons;
  99142. private _softwareSkinnedMeshes;
  99143. private _renderingManager;
  99144. /** @hidden */
  99145. _activeAnimatables: Animatable[];
  99146. private _transformMatrix;
  99147. private _sceneUbo;
  99148. /** @hidden */
  99149. _viewMatrix: Matrix;
  99150. private _projectionMatrix;
  99151. /** @hidden */
  99152. _forcedViewPosition: Nullable<Vector3>;
  99153. /** @hidden */
  99154. _frustumPlanes: Plane[];
  99155. /**
  99156. * Gets the list of frustum planes (built from the active camera)
  99157. */
  99158. readonly frustumPlanes: Plane[];
  99159. /**
  99160. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  99161. * This is useful if there are more lights that the maximum simulteanous authorized
  99162. */
  99163. requireLightSorting: boolean;
  99164. /** @hidden */
  99165. readonly useMaterialMeshMap: boolean;
  99166. /** @hidden */
  99167. readonly useClonedMeshhMap: boolean;
  99168. private _externalData;
  99169. private _uid;
  99170. /**
  99171. * @hidden
  99172. * Backing store of defined scene components.
  99173. */
  99174. _components: ISceneComponent[];
  99175. /**
  99176. * @hidden
  99177. * Backing store of defined scene components.
  99178. */
  99179. _serializableComponents: ISceneSerializableComponent[];
  99180. /**
  99181. * List of components to register on the next registration step.
  99182. */
  99183. private _transientComponents;
  99184. /**
  99185. * Registers the transient components if needed.
  99186. */
  99187. private _registerTransientComponents;
  99188. /**
  99189. * @hidden
  99190. * Add a component to the scene.
  99191. * Note that the ccomponent could be registered on th next frame if this is called after
  99192. * the register component stage.
  99193. * @param component Defines the component to add to the scene
  99194. */
  99195. _addComponent(component: ISceneComponent): void;
  99196. /**
  99197. * @hidden
  99198. * Gets a component from the scene.
  99199. * @param name defines the name of the component to retrieve
  99200. * @returns the component or null if not present
  99201. */
  99202. _getComponent(name: string): Nullable<ISceneComponent>;
  99203. /**
  99204. * @hidden
  99205. * Defines the actions happening before camera updates.
  99206. */
  99207. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  99208. /**
  99209. * @hidden
  99210. * Defines the actions happening before clear the canvas.
  99211. */
  99212. _beforeClearStage: Stage<SimpleStageAction>;
  99213. /**
  99214. * @hidden
  99215. * Defines the actions when collecting render targets for the frame.
  99216. */
  99217. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  99218. /**
  99219. * @hidden
  99220. * Defines the actions happening for one camera in the frame.
  99221. */
  99222. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  99223. /**
  99224. * @hidden
  99225. * Defines the actions happening during the per mesh ready checks.
  99226. */
  99227. _isReadyForMeshStage: Stage<MeshStageAction>;
  99228. /**
  99229. * @hidden
  99230. * Defines the actions happening before evaluate active mesh checks.
  99231. */
  99232. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  99233. /**
  99234. * @hidden
  99235. * Defines the actions happening during the evaluate sub mesh checks.
  99236. */
  99237. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  99238. /**
  99239. * @hidden
  99240. * Defines the actions happening during the active mesh stage.
  99241. */
  99242. _activeMeshStage: Stage<ActiveMeshStageAction>;
  99243. /**
  99244. * @hidden
  99245. * Defines the actions happening during the per camera render target step.
  99246. */
  99247. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  99248. /**
  99249. * @hidden
  99250. * Defines the actions happening just before the active camera is drawing.
  99251. */
  99252. _beforeCameraDrawStage: Stage<CameraStageAction>;
  99253. /**
  99254. * @hidden
  99255. * Defines the actions happening just before a render target is drawing.
  99256. */
  99257. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  99258. /**
  99259. * @hidden
  99260. * Defines the actions happening just before a rendering group is drawing.
  99261. */
  99262. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  99263. /**
  99264. * @hidden
  99265. * Defines the actions happening just before a mesh is drawing.
  99266. */
  99267. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  99268. /**
  99269. * @hidden
  99270. * Defines the actions happening just after a mesh has been drawn.
  99271. */
  99272. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  99273. /**
  99274. * @hidden
  99275. * Defines the actions happening just after a rendering group has been drawn.
  99276. */
  99277. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  99278. /**
  99279. * @hidden
  99280. * Defines the actions happening just after the active camera has been drawn.
  99281. */
  99282. _afterCameraDrawStage: Stage<CameraStageAction>;
  99283. /**
  99284. * @hidden
  99285. * Defines the actions happening just after a render target has been drawn.
  99286. */
  99287. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  99288. /**
  99289. * @hidden
  99290. * Defines the actions happening just after rendering all cameras and computing intersections.
  99291. */
  99292. _afterRenderStage: Stage<SimpleStageAction>;
  99293. /**
  99294. * @hidden
  99295. * Defines the actions happening when a pointer move event happens.
  99296. */
  99297. _pointerMoveStage: Stage<PointerMoveStageAction>;
  99298. /**
  99299. * @hidden
  99300. * Defines the actions happening when a pointer down event happens.
  99301. */
  99302. _pointerDownStage: Stage<PointerUpDownStageAction>;
  99303. /**
  99304. * @hidden
  99305. * Defines the actions happening when a pointer up event happens.
  99306. */
  99307. _pointerUpStage: Stage<PointerUpDownStageAction>;
  99308. /**
  99309. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  99310. */
  99311. private geometriesByUniqueId;
  99312. /**
  99313. * Creates a new Scene
  99314. * @param engine defines the engine to use to render this scene
  99315. * @param options defines the scene options
  99316. */
  99317. constructor(engine: Engine, options?: SceneOptions);
  99318. /**
  99319. * Gets a string idenfifying the name of the class
  99320. * @returns "Scene" string
  99321. */
  99322. getClassName(): string;
  99323. private _defaultMeshCandidates;
  99324. /**
  99325. * @hidden
  99326. */
  99327. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  99328. private _defaultSubMeshCandidates;
  99329. /**
  99330. * @hidden
  99331. */
  99332. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  99333. /**
  99334. * Sets the default candidate providers for the scene.
  99335. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  99336. * and getCollidingSubMeshCandidates to their default function
  99337. */
  99338. setDefaultCandidateProviders(): void;
  99339. /**
  99340. * Gets the mesh that is currently under the pointer
  99341. */
  99342. readonly meshUnderPointer: Nullable<AbstractMesh>;
  99343. /**
  99344. * Gets or sets the current on-screen X position of the pointer
  99345. */
  99346. pointerX: number;
  99347. /**
  99348. * Gets or sets the current on-screen Y position of the pointer
  99349. */
  99350. pointerY: number;
  99351. /**
  99352. * Gets the cached material (ie. the latest rendered one)
  99353. * @returns the cached material
  99354. */
  99355. getCachedMaterial(): Nullable<Material>;
  99356. /**
  99357. * Gets the cached effect (ie. the latest rendered one)
  99358. * @returns the cached effect
  99359. */
  99360. getCachedEffect(): Nullable<Effect>;
  99361. /**
  99362. * Gets the cached visibility state (ie. the latest rendered one)
  99363. * @returns the cached visibility state
  99364. */
  99365. getCachedVisibility(): Nullable<number>;
  99366. /**
  99367. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  99368. * @param material defines the current material
  99369. * @param effect defines the current effect
  99370. * @param visibility defines the current visibility state
  99371. * @returns true if one parameter is not cached
  99372. */
  99373. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  99374. /**
  99375. * Gets the engine associated with the scene
  99376. * @returns an Engine
  99377. */
  99378. getEngine(): Engine;
  99379. /**
  99380. * Gets the total number of vertices rendered per frame
  99381. * @returns the total number of vertices rendered per frame
  99382. */
  99383. getTotalVertices(): number;
  99384. /**
  99385. * Gets the performance counter for total vertices
  99386. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99387. */
  99388. readonly totalVerticesPerfCounter: PerfCounter;
  99389. /**
  99390. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  99391. * @returns the total number of active indices rendered per frame
  99392. */
  99393. getActiveIndices(): number;
  99394. /**
  99395. * Gets the performance counter for active indices
  99396. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99397. */
  99398. readonly totalActiveIndicesPerfCounter: PerfCounter;
  99399. /**
  99400. * Gets the total number of active particles rendered per frame
  99401. * @returns the total number of active particles rendered per frame
  99402. */
  99403. getActiveParticles(): number;
  99404. /**
  99405. * Gets the performance counter for active particles
  99406. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99407. */
  99408. readonly activeParticlesPerfCounter: PerfCounter;
  99409. /**
  99410. * Gets the total number of active bones rendered per frame
  99411. * @returns the total number of active bones rendered per frame
  99412. */
  99413. getActiveBones(): number;
  99414. /**
  99415. * Gets the performance counter for active bones
  99416. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99417. */
  99418. readonly activeBonesPerfCounter: PerfCounter;
  99419. /**
  99420. * Gets the array of active meshes
  99421. * @returns an array of AbstractMesh
  99422. */
  99423. getActiveMeshes(): SmartArray<AbstractMesh>;
  99424. /**
  99425. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  99426. * @returns a number
  99427. */
  99428. getAnimationRatio(): number;
  99429. /**
  99430. * Gets an unique Id for the current render phase
  99431. * @returns a number
  99432. */
  99433. getRenderId(): number;
  99434. /**
  99435. * Gets an unique Id for the current frame
  99436. * @returns a number
  99437. */
  99438. getFrameId(): number;
  99439. /** Call this function if you want to manually increment the render Id*/
  99440. incrementRenderId(): void;
  99441. private _createUbo;
  99442. /**
  99443. * Use this method to simulate a pointer move on a mesh
  99444. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99445. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99446. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99447. * @returns the current scene
  99448. */
  99449. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  99450. /**
  99451. * Use this method to simulate a pointer down on a mesh
  99452. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99453. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99454. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99455. * @returns the current scene
  99456. */
  99457. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  99458. /**
  99459. * Use this method to simulate a pointer up on a mesh
  99460. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99461. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99462. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99463. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  99464. * @returns the current scene
  99465. */
  99466. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  99467. /**
  99468. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  99469. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  99470. * @returns true if the pointer was captured
  99471. */
  99472. isPointerCaptured(pointerId?: number): boolean;
  99473. /**
  99474. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  99475. * @param attachUp defines if you want to attach events to pointerup
  99476. * @param attachDown defines if you want to attach events to pointerdown
  99477. * @param attachMove defines if you want to attach events to pointermove
  99478. */
  99479. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  99480. /** Detaches all event handlers*/
  99481. detachControl(): void;
  99482. /**
  99483. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  99484. * Delay loaded resources are not taking in account
  99485. * @return true if all required resources are ready
  99486. */
  99487. isReady(): boolean;
  99488. /** Resets all cached information relative to material (including effect and visibility) */
  99489. resetCachedMaterial(): void;
  99490. /**
  99491. * Registers a function to be called before every frame render
  99492. * @param func defines the function to register
  99493. */
  99494. registerBeforeRender(func: () => void): void;
  99495. /**
  99496. * Unregisters a function called before every frame render
  99497. * @param func defines the function to unregister
  99498. */
  99499. unregisterBeforeRender(func: () => void): void;
  99500. /**
  99501. * Registers a function to be called after every frame render
  99502. * @param func defines the function to register
  99503. */
  99504. registerAfterRender(func: () => void): void;
  99505. /**
  99506. * Unregisters a function called after every frame render
  99507. * @param func defines the function to unregister
  99508. */
  99509. unregisterAfterRender(func: () => void): void;
  99510. private _executeOnceBeforeRender;
  99511. /**
  99512. * The provided function will run before render once and will be disposed afterwards.
  99513. * A timeout delay can be provided so that the function will be executed in N ms.
  99514. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  99515. * @param func The function to be executed.
  99516. * @param timeout optional delay in ms
  99517. */
  99518. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  99519. /** @hidden */
  99520. _addPendingData(data: any): void;
  99521. /** @hidden */
  99522. _removePendingData(data: any): void;
  99523. /**
  99524. * Returns the number of items waiting to be loaded
  99525. * @returns the number of items waiting to be loaded
  99526. */
  99527. getWaitingItemsCount(): number;
  99528. /**
  99529. * Returns a boolean indicating if the scene is still loading data
  99530. */
  99531. readonly isLoading: boolean;
  99532. /**
  99533. * Registers a function to be executed when the scene is ready
  99534. * @param {Function} func - the function to be executed
  99535. */
  99536. executeWhenReady(func: () => void): void;
  99537. /**
  99538. * Returns a promise that resolves when the scene is ready
  99539. * @returns A promise that resolves when the scene is ready
  99540. */
  99541. whenReadyAsync(): Promise<void>;
  99542. /** @hidden */
  99543. _checkIsReady(): void;
  99544. /**
  99545. * Gets all animatable attached to the scene
  99546. */
  99547. readonly animatables: Animatable[];
  99548. /**
  99549. * Resets the last animation time frame.
  99550. * Useful to override when animations start running when loading a scene for the first time.
  99551. */
  99552. resetLastAnimationTimeFrame(): void;
  99553. /**
  99554. * Gets the current view matrix
  99555. * @returns a Matrix
  99556. */
  99557. getViewMatrix(): Matrix;
  99558. /**
  99559. * Gets the current projection matrix
  99560. * @returns a Matrix
  99561. */
  99562. getProjectionMatrix(): Matrix;
  99563. /**
  99564. * Gets the current transform matrix
  99565. * @returns a Matrix made of View * Projection
  99566. */
  99567. getTransformMatrix(): Matrix;
  99568. /**
  99569. * Sets the current transform matrix
  99570. * @param viewL defines the View matrix to use
  99571. * @param projectionL defines the Projection matrix to use
  99572. * @param viewR defines the right View matrix to use (if provided)
  99573. * @param projectionR defines the right Projection matrix to use (if provided)
  99574. */
  99575. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  99576. /**
  99577. * Gets the uniform buffer used to store scene data
  99578. * @returns a UniformBuffer
  99579. */
  99580. getSceneUniformBuffer(): UniformBuffer;
  99581. /**
  99582. * Gets an unique (relatively to the current scene) Id
  99583. * @returns an unique number for the scene
  99584. */
  99585. getUniqueId(): number;
  99586. /**
  99587. * Add a mesh to the list of scene's meshes
  99588. * @param newMesh defines the mesh to add
  99589. * @param recursive if all child meshes should also be added to the scene
  99590. */
  99591. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  99592. /**
  99593. * Remove a mesh for the list of scene's meshes
  99594. * @param toRemove defines the mesh to remove
  99595. * @param recursive if all child meshes should also be removed from the scene
  99596. * @returns the index where the mesh was in the mesh list
  99597. */
  99598. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  99599. /**
  99600. * Add a transform node to the list of scene's transform nodes
  99601. * @param newTransformNode defines the transform node to add
  99602. */
  99603. addTransformNode(newTransformNode: TransformNode): void;
  99604. /**
  99605. * Remove a transform node for the list of scene's transform nodes
  99606. * @param toRemove defines the transform node to remove
  99607. * @returns the index where the transform node was in the transform node list
  99608. */
  99609. removeTransformNode(toRemove: TransformNode): number;
  99610. /**
  99611. * Remove a skeleton for the list of scene's skeletons
  99612. * @param toRemove defines the skeleton to remove
  99613. * @returns the index where the skeleton was in the skeleton list
  99614. */
  99615. removeSkeleton(toRemove: Skeleton): number;
  99616. /**
  99617. * Remove a morph target for the list of scene's morph targets
  99618. * @param toRemove defines the morph target to remove
  99619. * @returns the index where the morph target was in the morph target list
  99620. */
  99621. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  99622. /**
  99623. * Remove a light for the list of scene's lights
  99624. * @param toRemove defines the light to remove
  99625. * @returns the index where the light was in the light list
  99626. */
  99627. removeLight(toRemove: Light): number;
  99628. /**
  99629. * Remove a camera for the list of scene's cameras
  99630. * @param toRemove defines the camera to remove
  99631. * @returns the index where the camera was in the camera list
  99632. */
  99633. removeCamera(toRemove: Camera): number;
  99634. /**
  99635. * Remove a particle system for the list of scene's particle systems
  99636. * @param toRemove defines the particle system to remove
  99637. * @returns the index where the particle system was in the particle system list
  99638. */
  99639. removeParticleSystem(toRemove: IParticleSystem): number;
  99640. /**
  99641. * Remove a animation for the list of scene's animations
  99642. * @param toRemove defines the animation to remove
  99643. * @returns the index where the animation was in the animation list
  99644. */
  99645. removeAnimation(toRemove: Animation): number;
  99646. /**
  99647. * Will stop the animation of the given target
  99648. * @param target - the target
  99649. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  99650. * @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)
  99651. */
  99652. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  99653. /**
  99654. * Removes the given animation group from this scene.
  99655. * @param toRemove The animation group to remove
  99656. * @returns The index of the removed animation group
  99657. */
  99658. removeAnimationGroup(toRemove: AnimationGroup): number;
  99659. /**
  99660. * Removes the given multi-material from this scene.
  99661. * @param toRemove The multi-material to remove
  99662. * @returns The index of the removed multi-material
  99663. */
  99664. removeMultiMaterial(toRemove: MultiMaterial): number;
  99665. /**
  99666. * Removes the given material from this scene.
  99667. * @param toRemove The material to remove
  99668. * @returns The index of the removed material
  99669. */
  99670. removeMaterial(toRemove: Material): number;
  99671. /**
  99672. * Removes the given action manager from this scene.
  99673. * @param toRemove The action manager to remove
  99674. * @returns The index of the removed action manager
  99675. */
  99676. removeActionManager(toRemove: AbstractActionManager): number;
  99677. /**
  99678. * Removes the given texture from this scene.
  99679. * @param toRemove The texture to remove
  99680. * @returns The index of the removed texture
  99681. */
  99682. removeTexture(toRemove: BaseTexture): number;
  99683. /**
  99684. * Adds the given light to this scene
  99685. * @param newLight The light to add
  99686. */
  99687. addLight(newLight: Light): void;
  99688. /**
  99689. * Sorts the list list based on light priorities
  99690. */
  99691. sortLightsByPriority(): void;
  99692. /**
  99693. * Adds the given camera to this scene
  99694. * @param newCamera The camera to add
  99695. */
  99696. addCamera(newCamera: Camera): void;
  99697. /**
  99698. * Adds the given skeleton to this scene
  99699. * @param newSkeleton The skeleton to add
  99700. */
  99701. addSkeleton(newSkeleton: Skeleton): void;
  99702. /**
  99703. * Adds the given particle system to this scene
  99704. * @param newParticleSystem The particle system to add
  99705. */
  99706. addParticleSystem(newParticleSystem: IParticleSystem): void;
  99707. /**
  99708. * Adds the given animation to this scene
  99709. * @param newAnimation The animation to add
  99710. */
  99711. addAnimation(newAnimation: Animation): void;
  99712. /**
  99713. * Adds the given animation group to this scene.
  99714. * @param newAnimationGroup The animation group to add
  99715. */
  99716. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  99717. /**
  99718. * Adds the given multi-material to this scene
  99719. * @param newMultiMaterial The multi-material to add
  99720. */
  99721. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  99722. /**
  99723. * Adds the given material to this scene
  99724. * @param newMaterial The material to add
  99725. */
  99726. addMaterial(newMaterial: Material): void;
  99727. /**
  99728. * Adds the given morph target to this scene
  99729. * @param newMorphTargetManager The morph target to add
  99730. */
  99731. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  99732. /**
  99733. * Adds the given geometry to this scene
  99734. * @param newGeometry The geometry to add
  99735. */
  99736. addGeometry(newGeometry: Geometry): void;
  99737. /**
  99738. * Adds the given action manager to this scene
  99739. * @param newActionManager The action manager to add
  99740. */
  99741. addActionManager(newActionManager: AbstractActionManager): void;
  99742. /**
  99743. * Adds the given texture to this scene.
  99744. * @param newTexture The texture to add
  99745. */
  99746. addTexture(newTexture: BaseTexture): void;
  99747. /**
  99748. * Switch active camera
  99749. * @param newCamera defines the new active camera
  99750. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  99751. */
  99752. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  99753. /**
  99754. * sets the active camera of the scene using its ID
  99755. * @param id defines the camera's ID
  99756. * @return the new active camera or null if none found.
  99757. */
  99758. setActiveCameraByID(id: string): Nullable<Camera>;
  99759. /**
  99760. * sets the active camera of the scene using its name
  99761. * @param name defines the camera's name
  99762. * @returns the new active camera or null if none found.
  99763. */
  99764. setActiveCameraByName(name: string): Nullable<Camera>;
  99765. /**
  99766. * get an animation group using its name
  99767. * @param name defines the material's name
  99768. * @return the animation group or null if none found.
  99769. */
  99770. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  99771. /**
  99772. * Get a material using its unique id
  99773. * @param uniqueId defines the material's unique id
  99774. * @return the material or null if none found.
  99775. */
  99776. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  99777. /**
  99778. * get a material using its id
  99779. * @param id defines the material's ID
  99780. * @return the material or null if none found.
  99781. */
  99782. getMaterialByID(id: string): Nullable<Material>;
  99783. /**
  99784. * Gets a the last added material using a given id
  99785. * @param id defines the material's ID
  99786. * @return the last material with the given id or null if none found.
  99787. */
  99788. getLastMaterialByID(id: string): Nullable<Material>;
  99789. /**
  99790. * Gets a material using its name
  99791. * @param name defines the material's name
  99792. * @return the material or null if none found.
  99793. */
  99794. getMaterialByName(name: string): Nullable<Material>;
  99795. /**
  99796. * Get a texture using its unique id
  99797. * @param uniqueId defines the texture's unique id
  99798. * @return the texture or null if none found.
  99799. */
  99800. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  99801. /**
  99802. * Gets a camera using its id
  99803. * @param id defines the id to look for
  99804. * @returns the camera or null if not found
  99805. */
  99806. getCameraByID(id: string): Nullable<Camera>;
  99807. /**
  99808. * Gets a camera using its unique id
  99809. * @param uniqueId defines the unique id to look for
  99810. * @returns the camera or null if not found
  99811. */
  99812. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  99813. /**
  99814. * Gets a camera using its name
  99815. * @param name defines the camera's name
  99816. * @return the camera or null if none found.
  99817. */
  99818. getCameraByName(name: string): Nullable<Camera>;
  99819. /**
  99820. * Gets a bone using its id
  99821. * @param id defines the bone's id
  99822. * @return the bone or null if not found
  99823. */
  99824. getBoneByID(id: string): Nullable<Bone>;
  99825. /**
  99826. * Gets a bone using its id
  99827. * @param name defines the bone's name
  99828. * @return the bone or null if not found
  99829. */
  99830. getBoneByName(name: string): Nullable<Bone>;
  99831. /**
  99832. * Gets a light node using its name
  99833. * @param name defines the the light's name
  99834. * @return the light or null if none found.
  99835. */
  99836. getLightByName(name: string): Nullable<Light>;
  99837. /**
  99838. * Gets a light node using its id
  99839. * @param id defines the light's id
  99840. * @return the light or null if none found.
  99841. */
  99842. getLightByID(id: string): Nullable<Light>;
  99843. /**
  99844. * Gets a light node using its scene-generated unique ID
  99845. * @param uniqueId defines the light's unique id
  99846. * @return the light or null if none found.
  99847. */
  99848. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  99849. /**
  99850. * Gets a particle system by id
  99851. * @param id defines the particle system id
  99852. * @return the corresponding system or null if none found
  99853. */
  99854. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  99855. /**
  99856. * Gets a geometry using its ID
  99857. * @param id defines the geometry's id
  99858. * @return the geometry or null if none found.
  99859. */
  99860. getGeometryByID(id: string): Nullable<Geometry>;
  99861. private _getGeometryByUniqueID;
  99862. /**
  99863. * Add a new geometry to this scene
  99864. * @param geometry defines the geometry to be added to the scene.
  99865. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  99866. * @return a boolean defining if the geometry was added or not
  99867. */
  99868. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  99869. /**
  99870. * Removes an existing geometry
  99871. * @param geometry defines the geometry to be removed from the scene
  99872. * @return a boolean defining if the geometry was removed or not
  99873. */
  99874. removeGeometry(geometry: Geometry): boolean;
  99875. /**
  99876. * Gets the list of geometries attached to the scene
  99877. * @returns an array of Geometry
  99878. */
  99879. getGeometries(): Geometry[];
  99880. /**
  99881. * Gets the first added mesh found of a given ID
  99882. * @param id defines the id to search for
  99883. * @return the mesh found or null if not found at all
  99884. */
  99885. getMeshByID(id: string): Nullable<AbstractMesh>;
  99886. /**
  99887. * Gets a list of meshes using their id
  99888. * @param id defines the id to search for
  99889. * @returns a list of meshes
  99890. */
  99891. getMeshesByID(id: string): Array<AbstractMesh>;
  99892. /**
  99893. * Gets the first added transform node found of a given ID
  99894. * @param id defines the id to search for
  99895. * @return the found transform node or null if not found at all.
  99896. */
  99897. getTransformNodeByID(id: string): Nullable<TransformNode>;
  99898. /**
  99899. * Gets a transform node with its auto-generated unique id
  99900. * @param uniqueId efines the unique id to search for
  99901. * @return the found transform node or null if not found at all.
  99902. */
  99903. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  99904. /**
  99905. * Gets a list of transform nodes using their id
  99906. * @param id defines the id to search for
  99907. * @returns a list of transform nodes
  99908. */
  99909. getTransformNodesByID(id: string): Array<TransformNode>;
  99910. /**
  99911. * Gets a mesh with its auto-generated unique id
  99912. * @param uniqueId defines the unique id to search for
  99913. * @return the found mesh or null if not found at all.
  99914. */
  99915. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  99916. /**
  99917. * Gets a the last added mesh using a given id
  99918. * @param id defines the id to search for
  99919. * @return the found mesh or null if not found at all.
  99920. */
  99921. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  99922. /**
  99923. * Gets a the last added node (Mesh, Camera, Light) using a given id
  99924. * @param id defines the id to search for
  99925. * @return the found node or null if not found at all
  99926. */
  99927. getLastEntryByID(id: string): Nullable<Node>;
  99928. /**
  99929. * Gets a node (Mesh, Camera, Light) using a given id
  99930. * @param id defines the id to search for
  99931. * @return the found node or null if not found at all
  99932. */
  99933. getNodeByID(id: string): Nullable<Node>;
  99934. /**
  99935. * Gets a node (Mesh, Camera, Light) using a given name
  99936. * @param name defines the name to search for
  99937. * @return the found node or null if not found at all.
  99938. */
  99939. getNodeByName(name: string): Nullable<Node>;
  99940. /**
  99941. * Gets a mesh using a given name
  99942. * @param name defines the name to search for
  99943. * @return the found mesh or null if not found at all.
  99944. */
  99945. getMeshByName(name: string): Nullable<AbstractMesh>;
  99946. /**
  99947. * Gets a transform node using a given name
  99948. * @param name defines the name to search for
  99949. * @return the found transform node or null if not found at all.
  99950. */
  99951. getTransformNodeByName(name: string): Nullable<TransformNode>;
  99952. /**
  99953. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  99954. * @param id defines the id to search for
  99955. * @return the found skeleton or null if not found at all.
  99956. */
  99957. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  99958. /**
  99959. * Gets a skeleton using a given auto generated unique id
  99960. * @param uniqueId defines the unique id to search for
  99961. * @return the found skeleton or null if not found at all.
  99962. */
  99963. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  99964. /**
  99965. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  99966. * @param id defines the id to search for
  99967. * @return the found skeleton or null if not found at all.
  99968. */
  99969. getSkeletonById(id: string): Nullable<Skeleton>;
  99970. /**
  99971. * Gets a skeleton using a given name
  99972. * @param name defines the name to search for
  99973. * @return the found skeleton or null if not found at all.
  99974. */
  99975. getSkeletonByName(name: string): Nullable<Skeleton>;
  99976. /**
  99977. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  99978. * @param id defines the id to search for
  99979. * @return the found morph target manager or null if not found at all.
  99980. */
  99981. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  99982. /**
  99983. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  99984. * @param id defines the id to search for
  99985. * @return the found morph target or null if not found at all.
  99986. */
  99987. getMorphTargetById(id: string): Nullable<MorphTarget>;
  99988. /**
  99989. * Gets a boolean indicating if the given mesh is active
  99990. * @param mesh defines the mesh to look for
  99991. * @returns true if the mesh is in the active list
  99992. */
  99993. isActiveMesh(mesh: AbstractMesh): boolean;
  99994. /**
  99995. * Return a unique id as a string which can serve as an identifier for the scene
  99996. */
  99997. readonly uid: string;
  99998. /**
  99999. * Add an externaly attached data from its key.
  100000. * This method call will fail and return false, if such key already exists.
  100001. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  100002. * @param key the unique key that identifies the data
  100003. * @param data the data object to associate to the key for this Engine instance
  100004. * @return true if no such key were already present and the data was added successfully, false otherwise
  100005. */
  100006. addExternalData<T>(key: string, data: T): boolean;
  100007. /**
  100008. * Get an externaly attached data from its key
  100009. * @param key the unique key that identifies the data
  100010. * @return the associated data, if present (can be null), or undefined if not present
  100011. */
  100012. getExternalData<T>(key: string): Nullable<T>;
  100013. /**
  100014. * Get an externaly attached data from its key, create it using a factory if it's not already present
  100015. * @param key the unique key that identifies the data
  100016. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  100017. * @return the associated data, can be null if the factory returned null.
  100018. */
  100019. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  100020. /**
  100021. * Remove an externaly attached data from the Engine instance
  100022. * @param key the unique key that identifies the data
  100023. * @return true if the data was successfully removed, false if it doesn't exist
  100024. */
  100025. removeExternalData(key: string): boolean;
  100026. private _evaluateSubMesh;
  100027. /**
  100028. * Clear the processed materials smart array preventing retention point in material dispose.
  100029. */
  100030. freeProcessedMaterials(): void;
  100031. private _preventFreeActiveMeshesAndRenderingGroups;
  100032. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  100033. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  100034. * when disposing several meshes in a row or a hierarchy of meshes.
  100035. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  100036. */
  100037. blockfreeActiveMeshesAndRenderingGroups: boolean;
  100038. /**
  100039. * Clear the active meshes smart array preventing retention point in mesh dispose.
  100040. */
  100041. freeActiveMeshes(): void;
  100042. /**
  100043. * Clear the info related to rendering groups preventing retention points during dispose.
  100044. */
  100045. freeRenderingGroups(): void;
  100046. /** @hidden */
  100047. _isInIntermediateRendering(): boolean;
  100048. /**
  100049. * Lambda returning the list of potentially active meshes.
  100050. */
  100051. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  100052. /**
  100053. * Lambda returning the list of potentially active sub meshes.
  100054. */
  100055. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  100056. /**
  100057. * Lambda returning the list of potentially intersecting sub meshes.
  100058. */
  100059. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  100060. /**
  100061. * Lambda returning the list of potentially colliding sub meshes.
  100062. */
  100063. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  100064. private _activeMeshesFrozen;
  100065. /**
  100066. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  100067. * @returns the current scene
  100068. */
  100069. freezeActiveMeshes(): Scene;
  100070. /**
  100071. * Use this function to restart evaluating active meshes on every frame
  100072. * @returns the current scene
  100073. */
  100074. unfreezeActiveMeshes(): Scene;
  100075. private _evaluateActiveMeshes;
  100076. private _activeMesh;
  100077. /**
  100078. * Update the transform matrix to update from the current active camera
  100079. * @param force defines a boolean used to force the update even if cache is up to date
  100080. */
  100081. updateTransformMatrix(force?: boolean): void;
  100082. private _bindFrameBuffer;
  100083. /** @hidden */
  100084. _allowPostProcessClearColor: boolean;
  100085. /** @hidden */
  100086. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  100087. private _processSubCameras;
  100088. private _checkIntersections;
  100089. /** @hidden */
  100090. _advancePhysicsEngineStep(step: number): void;
  100091. /**
  100092. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  100093. */
  100094. getDeterministicFrameTime: () => number;
  100095. /** @hidden */
  100096. _animate(): void;
  100097. /** Execute all animations (for a frame) */
  100098. animate(): void;
  100099. /**
  100100. * Render the scene
  100101. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  100102. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  100103. */
  100104. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  100105. /**
  100106. * Freeze all materials
  100107. * A frozen material will not be updatable but should be faster to render
  100108. */
  100109. freezeMaterials(): void;
  100110. /**
  100111. * Unfreeze all materials
  100112. * A frozen material will not be updatable but should be faster to render
  100113. */
  100114. unfreezeMaterials(): void;
  100115. /**
  100116. * Releases all held ressources
  100117. */
  100118. dispose(): void;
  100119. /**
  100120. * Gets if the scene is already disposed
  100121. */
  100122. readonly isDisposed: boolean;
  100123. /**
  100124. * Call this function to reduce memory footprint of the scene.
  100125. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  100126. */
  100127. clearCachedVertexData(): void;
  100128. /**
  100129. * This function will remove the local cached buffer data from texture.
  100130. * It will save memory but will prevent the texture from being rebuilt
  100131. */
  100132. cleanCachedTextureBuffer(): void;
  100133. /**
  100134. * Get the world extend vectors with an optional filter
  100135. *
  100136. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  100137. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  100138. */
  100139. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  100140. min: Vector3;
  100141. max: Vector3;
  100142. };
  100143. /**
  100144. * Creates a ray that can be used to pick in the scene
  100145. * @param x defines the x coordinate of the origin (on-screen)
  100146. * @param y defines the y coordinate of the origin (on-screen)
  100147. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  100148. * @param camera defines the camera to use for the picking
  100149. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  100150. * @returns a Ray
  100151. */
  100152. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  100153. /**
  100154. * Creates a ray that can be used to pick in the scene
  100155. * @param x defines the x coordinate of the origin (on-screen)
  100156. * @param y defines the y coordinate of the origin (on-screen)
  100157. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  100158. * @param result defines the ray where to store the picking ray
  100159. * @param camera defines the camera to use for the picking
  100160. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  100161. * @returns the current scene
  100162. */
  100163. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  100164. /**
  100165. * Creates a ray that can be used to pick in the scene
  100166. * @param x defines the x coordinate of the origin (on-screen)
  100167. * @param y defines the y coordinate of the origin (on-screen)
  100168. * @param camera defines the camera to use for the picking
  100169. * @returns a Ray
  100170. */
  100171. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  100172. /**
  100173. * Creates a ray that can be used to pick in the scene
  100174. * @param x defines the x coordinate of the origin (on-screen)
  100175. * @param y defines the y coordinate of the origin (on-screen)
  100176. * @param result defines the ray where to store the picking ray
  100177. * @param camera defines the camera to use for the picking
  100178. * @returns the current scene
  100179. */
  100180. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  100181. /** Launch a ray to try to pick a mesh in the scene
  100182. * @param x position on screen
  100183. * @param y position on screen
  100184. * @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
  100185. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  100186. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  100187. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100188. * @returns a PickingInfo
  100189. */
  100190. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  100191. /** Use the given ray to pick a mesh in the scene
  100192. * @param ray The ray to use to pick meshes
  100193. * @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
  100194. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  100195. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100196. * @returns a PickingInfo
  100197. */
  100198. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  100199. /**
  100200. * Launch a ray to try to pick a mesh in the scene
  100201. * @param x X position on screen
  100202. * @param y Y position on screen
  100203. * @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
  100204. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  100205. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100206. * @returns an array of PickingInfo
  100207. */
  100208. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  100209. /**
  100210. * Launch a ray to try to pick a mesh in the scene
  100211. * @param ray Ray to use
  100212. * @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
  100213. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100214. * @returns an array of PickingInfo
  100215. */
  100216. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  100217. /**
  100218. * Force the value of meshUnderPointer
  100219. * @param mesh defines the mesh to use
  100220. */
  100221. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  100222. /**
  100223. * Gets the mesh under the pointer
  100224. * @returns a Mesh or null if no mesh is under the pointer
  100225. */
  100226. getPointerOverMesh(): Nullable<AbstractMesh>;
  100227. /** @hidden */
  100228. _rebuildGeometries(): void;
  100229. /** @hidden */
  100230. _rebuildTextures(): void;
  100231. private _getByTags;
  100232. /**
  100233. * Get a list of meshes by tags
  100234. * @param tagsQuery defines the tags query to use
  100235. * @param forEach defines a predicate used to filter results
  100236. * @returns an array of Mesh
  100237. */
  100238. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  100239. /**
  100240. * Get a list of cameras by tags
  100241. * @param tagsQuery defines the tags query to use
  100242. * @param forEach defines a predicate used to filter results
  100243. * @returns an array of Camera
  100244. */
  100245. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  100246. /**
  100247. * Get a list of lights by tags
  100248. * @param tagsQuery defines the tags query to use
  100249. * @param forEach defines a predicate used to filter results
  100250. * @returns an array of Light
  100251. */
  100252. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  100253. /**
  100254. * Get a list of materials by tags
  100255. * @param tagsQuery defines the tags query to use
  100256. * @param forEach defines a predicate used to filter results
  100257. * @returns an array of Material
  100258. */
  100259. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  100260. /**
  100261. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  100262. * This allowed control for front to back rendering or reversly depending of the special needs.
  100263. *
  100264. * @param renderingGroupId The rendering group id corresponding to its index
  100265. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  100266. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  100267. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  100268. */
  100269. 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;
  100270. /**
  100271. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  100272. *
  100273. * @param renderingGroupId The rendering group id corresponding to its index
  100274. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  100275. * @param depth Automatically clears depth between groups if true and autoClear is true.
  100276. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  100277. */
  100278. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  100279. /**
  100280. * Gets the current auto clear configuration for one rendering group of the rendering
  100281. * manager.
  100282. * @param index the rendering group index to get the information for
  100283. * @returns The auto clear setup for the requested rendering group
  100284. */
  100285. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  100286. private _blockMaterialDirtyMechanism;
  100287. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  100288. blockMaterialDirtyMechanism: boolean;
  100289. /**
  100290. * Will flag all materials as dirty to trigger new shader compilation
  100291. * @param flag defines the flag used to specify which material part must be marked as dirty
  100292. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  100293. */
  100294. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  100295. /** @hidden */
  100296. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  100297. /** @hidden */
  100298. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  100299. }
  100300. }
  100301. declare module BABYLON {
  100302. /**
  100303. * Set of assets to keep when moving a scene into an asset container.
  100304. */
  100305. export class KeepAssets extends AbstractScene {
  100306. }
  100307. /**
  100308. * Container with a set of assets that can be added or removed from a scene.
  100309. */
  100310. export class AssetContainer extends AbstractScene {
  100311. /**
  100312. * The scene the AssetContainer belongs to.
  100313. */
  100314. scene: Scene;
  100315. /**
  100316. * Instantiates an AssetContainer.
  100317. * @param scene The scene the AssetContainer belongs to.
  100318. */
  100319. constructor(scene: Scene);
  100320. /**
  100321. * Adds all the assets from the container to the scene.
  100322. */
  100323. addAllToScene(): void;
  100324. /**
  100325. * Removes all the assets in the container from the scene
  100326. */
  100327. removeAllFromScene(): void;
  100328. /**
  100329. * Disposes all the assets in the container
  100330. */
  100331. dispose(): void;
  100332. private _moveAssets;
  100333. /**
  100334. * Removes all the assets contained in the scene and adds them to the container.
  100335. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  100336. */
  100337. moveAllFromScene(keepAssets?: KeepAssets): void;
  100338. /**
  100339. * 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.
  100340. * @returns the root mesh
  100341. */
  100342. createRootMesh(): Mesh;
  100343. }
  100344. }
  100345. declare module BABYLON {
  100346. /**
  100347. * Defines how the parser contract is defined.
  100348. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  100349. */
  100350. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  100351. /**
  100352. * Defines how the individual parser contract is defined.
  100353. * These parser can parse an individual asset
  100354. */
  100355. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  100356. /**
  100357. * Base class of the scene acting as a container for the different elements composing a scene.
  100358. * This class is dynamically extended by the different components of the scene increasing
  100359. * flexibility and reducing coupling
  100360. */
  100361. export abstract class AbstractScene {
  100362. /**
  100363. * Stores the list of available parsers in the application.
  100364. */
  100365. private static _BabylonFileParsers;
  100366. /**
  100367. * Stores the list of available individual parsers in the application.
  100368. */
  100369. private static _IndividualBabylonFileParsers;
  100370. /**
  100371. * Adds a parser in the list of available ones
  100372. * @param name Defines the name of the parser
  100373. * @param parser Defines the parser to add
  100374. */
  100375. static AddParser(name: string, parser: BabylonFileParser): void;
  100376. /**
  100377. * Gets a general parser from the list of avaialble ones
  100378. * @param name Defines the name of the parser
  100379. * @returns the requested parser or null
  100380. */
  100381. static GetParser(name: string): Nullable<BabylonFileParser>;
  100382. /**
  100383. * Adds n individual parser in the list of available ones
  100384. * @param name Defines the name of the parser
  100385. * @param parser Defines the parser to add
  100386. */
  100387. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  100388. /**
  100389. * Gets an individual parser from the list of avaialble ones
  100390. * @param name Defines the name of the parser
  100391. * @returns the requested parser or null
  100392. */
  100393. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  100394. /**
  100395. * Parser json data and populate both a scene and its associated container object
  100396. * @param jsonData Defines the data to parse
  100397. * @param scene Defines the scene to parse the data for
  100398. * @param container Defines the container attached to the parsing sequence
  100399. * @param rootUrl Defines the root url of the data
  100400. */
  100401. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  100402. /**
  100403. * Gets the list of root nodes (ie. nodes with no parent)
  100404. */
  100405. rootNodes: Node[];
  100406. /** All of the cameras added to this scene
  100407. * @see http://doc.babylonjs.com/babylon101/cameras
  100408. */
  100409. cameras: Camera[];
  100410. /**
  100411. * All of the lights added to this scene
  100412. * @see http://doc.babylonjs.com/babylon101/lights
  100413. */
  100414. lights: Light[];
  100415. /**
  100416. * All of the (abstract) meshes added to this scene
  100417. */
  100418. meshes: AbstractMesh[];
  100419. /**
  100420. * The list of skeletons added to the scene
  100421. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  100422. */
  100423. skeletons: Skeleton[];
  100424. /**
  100425. * All of the particle systems added to this scene
  100426. * @see http://doc.babylonjs.com/babylon101/particles
  100427. */
  100428. particleSystems: IParticleSystem[];
  100429. /**
  100430. * Gets a list of Animations associated with the scene
  100431. */
  100432. animations: Animation[];
  100433. /**
  100434. * All of the animation groups added to this scene
  100435. * @see http://doc.babylonjs.com/how_to/group
  100436. */
  100437. animationGroups: AnimationGroup[];
  100438. /**
  100439. * All of the multi-materials added to this scene
  100440. * @see http://doc.babylonjs.com/how_to/multi_materials
  100441. */
  100442. multiMaterials: MultiMaterial[];
  100443. /**
  100444. * All of the materials added to this scene
  100445. * In the context of a Scene, it is not supposed to be modified manually.
  100446. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  100447. * Note also that the order of the Material wihin the array is not significant and might change.
  100448. * @see http://doc.babylonjs.com/babylon101/materials
  100449. */
  100450. materials: Material[];
  100451. /**
  100452. * The list of morph target managers added to the scene
  100453. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  100454. */
  100455. morphTargetManagers: MorphTargetManager[];
  100456. /**
  100457. * The list of geometries used in the scene.
  100458. */
  100459. geometries: Geometry[];
  100460. /**
  100461. * All of the tranform nodes added to this scene
  100462. * In the context of a Scene, it is not supposed to be modified manually.
  100463. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  100464. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  100465. * @see http://doc.babylonjs.com/how_to/transformnode
  100466. */
  100467. transformNodes: TransformNode[];
  100468. /**
  100469. * ActionManagers available on the scene.
  100470. */
  100471. actionManagers: AbstractActionManager[];
  100472. /**
  100473. * Textures to keep.
  100474. */
  100475. textures: BaseTexture[];
  100476. /**
  100477. * Environment texture for the scene
  100478. */
  100479. environmentTexture: Nullable<BaseTexture>;
  100480. }
  100481. }
  100482. declare module BABYLON {
  100483. /**
  100484. * Interface used to define options for Sound class
  100485. */
  100486. export interface ISoundOptions {
  100487. /**
  100488. * Does the sound autoplay once loaded.
  100489. */
  100490. autoplay?: boolean;
  100491. /**
  100492. * Does the sound loop after it finishes playing once.
  100493. */
  100494. loop?: boolean;
  100495. /**
  100496. * Sound's volume
  100497. */
  100498. volume?: number;
  100499. /**
  100500. * Is it a spatial sound?
  100501. */
  100502. spatialSound?: boolean;
  100503. /**
  100504. * Maximum distance to hear that sound
  100505. */
  100506. maxDistance?: number;
  100507. /**
  100508. * Uses user defined attenuation function
  100509. */
  100510. useCustomAttenuation?: boolean;
  100511. /**
  100512. * Define the roll off factor of spatial sounds.
  100513. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100514. */
  100515. rolloffFactor?: number;
  100516. /**
  100517. * Define the reference distance the sound should be heard perfectly.
  100518. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100519. */
  100520. refDistance?: number;
  100521. /**
  100522. * Define the distance attenuation model the sound will follow.
  100523. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100524. */
  100525. distanceModel?: string;
  100526. /**
  100527. * Defines the playback speed (1 by default)
  100528. */
  100529. playbackRate?: number;
  100530. /**
  100531. * Defines if the sound is from a streaming source
  100532. */
  100533. streaming?: boolean;
  100534. /**
  100535. * Defines an optional length (in seconds) inside the sound file
  100536. */
  100537. length?: number;
  100538. /**
  100539. * Defines an optional offset (in seconds) inside the sound file
  100540. */
  100541. offset?: number;
  100542. /**
  100543. * If true, URLs will not be required to state the audio file codec to use.
  100544. */
  100545. skipCodecCheck?: boolean;
  100546. }
  100547. /**
  100548. * Defines a sound that can be played in the application.
  100549. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  100550. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100551. */
  100552. export class Sound {
  100553. /**
  100554. * The name of the sound in the scene.
  100555. */
  100556. name: string;
  100557. /**
  100558. * Does the sound autoplay once loaded.
  100559. */
  100560. autoplay: boolean;
  100561. /**
  100562. * Does the sound loop after it finishes playing once.
  100563. */
  100564. loop: boolean;
  100565. /**
  100566. * Does the sound use a custom attenuation curve to simulate the falloff
  100567. * happening when the source gets further away from the camera.
  100568. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  100569. */
  100570. useCustomAttenuation: boolean;
  100571. /**
  100572. * The sound track id this sound belongs to.
  100573. */
  100574. soundTrackId: number;
  100575. /**
  100576. * Is this sound currently played.
  100577. */
  100578. isPlaying: boolean;
  100579. /**
  100580. * Is this sound currently paused.
  100581. */
  100582. isPaused: boolean;
  100583. /**
  100584. * Does this sound enables spatial sound.
  100585. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100586. */
  100587. spatialSound: boolean;
  100588. /**
  100589. * Define the reference distance the sound should be heard perfectly.
  100590. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100591. */
  100592. refDistance: number;
  100593. /**
  100594. * Define the roll off factor of spatial sounds.
  100595. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100596. */
  100597. rolloffFactor: number;
  100598. /**
  100599. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  100600. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100601. */
  100602. maxDistance: number;
  100603. /**
  100604. * Define the distance attenuation model the sound will follow.
  100605. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100606. */
  100607. distanceModel: string;
  100608. /**
  100609. * @hidden
  100610. * Back Compat
  100611. **/
  100612. onended: () => any;
  100613. /**
  100614. * Observable event when the current playing sound finishes.
  100615. */
  100616. onEndedObservable: Observable<Sound>;
  100617. private _panningModel;
  100618. private _playbackRate;
  100619. private _streaming;
  100620. private _startTime;
  100621. private _startOffset;
  100622. private _position;
  100623. /** @hidden */
  100624. _positionInEmitterSpace: boolean;
  100625. private _localDirection;
  100626. private _volume;
  100627. private _isReadyToPlay;
  100628. private _isDirectional;
  100629. private _readyToPlayCallback;
  100630. private _audioBuffer;
  100631. private _soundSource;
  100632. private _streamingSource;
  100633. private _soundPanner;
  100634. private _soundGain;
  100635. private _inputAudioNode;
  100636. private _outputAudioNode;
  100637. private _coneInnerAngle;
  100638. private _coneOuterAngle;
  100639. private _coneOuterGain;
  100640. private _scene;
  100641. private _connectedTransformNode;
  100642. private _customAttenuationFunction;
  100643. private _registerFunc;
  100644. private _isOutputConnected;
  100645. private _htmlAudioElement;
  100646. private _urlType;
  100647. private _length?;
  100648. private _offset?;
  100649. /** @hidden */
  100650. static _SceneComponentInitialization: (scene: Scene) => void;
  100651. /**
  100652. * Create a sound and attach it to a scene
  100653. * @param name Name of your sound
  100654. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  100655. * @param scene defines the scene the sound belongs to
  100656. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  100657. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  100658. */
  100659. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  100660. /**
  100661. * Release the sound and its associated resources
  100662. */
  100663. dispose(): void;
  100664. /**
  100665. * Gets if the sounds is ready to be played or not.
  100666. * @returns true if ready, otherwise false
  100667. */
  100668. isReady(): boolean;
  100669. private _soundLoaded;
  100670. /**
  100671. * Sets the data of the sound from an audiobuffer
  100672. * @param audioBuffer The audioBuffer containing the data
  100673. */
  100674. setAudioBuffer(audioBuffer: AudioBuffer): void;
  100675. /**
  100676. * Updates the current sounds options such as maxdistance, loop...
  100677. * @param options A JSON object containing values named as the object properties
  100678. */
  100679. updateOptions(options: ISoundOptions): void;
  100680. private _createSpatialParameters;
  100681. private _updateSpatialParameters;
  100682. /**
  100683. * Switch the panning model to HRTF:
  100684. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  100685. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100686. */
  100687. switchPanningModelToHRTF(): void;
  100688. /**
  100689. * Switch the panning model to Equal Power:
  100690. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  100691. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100692. */
  100693. switchPanningModelToEqualPower(): void;
  100694. private _switchPanningModel;
  100695. /**
  100696. * Connect this sound to a sound track audio node like gain...
  100697. * @param soundTrackAudioNode the sound track audio node to connect to
  100698. */
  100699. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  100700. /**
  100701. * Transform this sound into a directional source
  100702. * @param coneInnerAngle Size of the inner cone in degree
  100703. * @param coneOuterAngle Size of the outer cone in degree
  100704. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  100705. */
  100706. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  100707. /**
  100708. * Gets or sets the inner angle for the directional cone.
  100709. */
  100710. /**
  100711. * Gets or sets the inner angle for the directional cone.
  100712. */
  100713. directionalConeInnerAngle: number;
  100714. /**
  100715. * Gets or sets the outer angle for the directional cone.
  100716. */
  100717. /**
  100718. * Gets or sets the outer angle for the directional cone.
  100719. */
  100720. directionalConeOuterAngle: number;
  100721. /**
  100722. * Sets the position of the emitter if spatial sound is enabled
  100723. * @param newPosition Defines the new posisiton
  100724. */
  100725. setPosition(newPosition: Vector3): void;
  100726. /**
  100727. * Sets the local direction of the emitter if spatial sound is enabled
  100728. * @param newLocalDirection Defines the new local direction
  100729. */
  100730. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  100731. private _updateDirection;
  100732. /** @hidden */
  100733. updateDistanceFromListener(): void;
  100734. /**
  100735. * Sets a new custom attenuation function for the sound.
  100736. * @param callback Defines the function used for the attenuation
  100737. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  100738. */
  100739. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  100740. /**
  100741. * Play the sound
  100742. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  100743. * @param offset (optional) Start the sound at a specific time in seconds
  100744. * @param length (optional) Sound duration (in seconds)
  100745. */
  100746. play(time?: number, offset?: number, length?: number): void;
  100747. private _onended;
  100748. /**
  100749. * Stop the sound
  100750. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  100751. */
  100752. stop(time?: number): void;
  100753. /**
  100754. * Put the sound in pause
  100755. */
  100756. pause(): void;
  100757. /**
  100758. * Sets a dedicated volume for this sounds
  100759. * @param newVolume Define the new volume of the sound
  100760. * @param time Define time for gradual change to new volume
  100761. */
  100762. setVolume(newVolume: number, time?: number): void;
  100763. /**
  100764. * Set the sound play back rate
  100765. * @param newPlaybackRate Define the playback rate the sound should be played at
  100766. */
  100767. setPlaybackRate(newPlaybackRate: number): void;
  100768. /**
  100769. * Gets the volume of the sound.
  100770. * @returns the volume of the sound
  100771. */
  100772. getVolume(): number;
  100773. /**
  100774. * Attach the sound to a dedicated mesh
  100775. * @param transformNode The transform node to connect the sound with
  100776. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  100777. */
  100778. attachToMesh(transformNode: TransformNode): void;
  100779. /**
  100780. * Detach the sound from the previously attached mesh
  100781. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  100782. */
  100783. detachFromMesh(): void;
  100784. private _onRegisterAfterWorldMatrixUpdate;
  100785. /**
  100786. * Clone the current sound in the scene.
  100787. * @returns the new sound clone
  100788. */
  100789. clone(): Nullable<Sound>;
  100790. /**
  100791. * Gets the current underlying audio buffer containing the data
  100792. * @returns the audio buffer
  100793. */
  100794. getAudioBuffer(): Nullable<AudioBuffer>;
  100795. /**
  100796. * Serializes the Sound in a JSON representation
  100797. * @returns the JSON representation of the sound
  100798. */
  100799. serialize(): any;
  100800. /**
  100801. * Parse a JSON representation of a sound to innstantiate in a given scene
  100802. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  100803. * @param scene Define the scene the new parsed sound should be created in
  100804. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  100805. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  100806. * @returns the newly parsed sound
  100807. */
  100808. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  100809. }
  100810. }
  100811. declare module BABYLON {
  100812. /**
  100813. * This defines an action helpful to play a defined sound on a triggered action.
  100814. */
  100815. export class PlaySoundAction extends Action {
  100816. private _sound;
  100817. /**
  100818. * Instantiate the action
  100819. * @param triggerOptions defines the trigger options
  100820. * @param sound defines the sound to play
  100821. * @param condition defines the trigger related conditions
  100822. */
  100823. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  100824. /** @hidden */
  100825. _prepare(): void;
  100826. /**
  100827. * Execute the action and play the sound.
  100828. */
  100829. execute(): void;
  100830. /**
  100831. * Serializes the actions and its related information.
  100832. * @param parent defines the object to serialize in
  100833. * @returns the serialized object
  100834. */
  100835. serialize(parent: any): any;
  100836. }
  100837. /**
  100838. * This defines an action helpful to stop a defined sound on a triggered action.
  100839. */
  100840. export class StopSoundAction extends Action {
  100841. private _sound;
  100842. /**
  100843. * Instantiate the action
  100844. * @param triggerOptions defines the trigger options
  100845. * @param sound defines the sound to stop
  100846. * @param condition defines the trigger related conditions
  100847. */
  100848. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  100849. /** @hidden */
  100850. _prepare(): void;
  100851. /**
  100852. * Execute the action and stop the sound.
  100853. */
  100854. execute(): void;
  100855. /**
  100856. * Serializes the actions and its related information.
  100857. * @param parent defines the object to serialize in
  100858. * @returns the serialized object
  100859. */
  100860. serialize(parent: any): any;
  100861. }
  100862. }
  100863. declare module BABYLON {
  100864. /**
  100865. * This defines an action responsible to change the value of a property
  100866. * by interpolating between its current value and the newly set one once triggered.
  100867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100868. */
  100869. export class InterpolateValueAction extends Action {
  100870. /**
  100871. * Defines the path of the property where the value should be interpolated
  100872. */
  100873. propertyPath: string;
  100874. /**
  100875. * Defines the target value at the end of the interpolation.
  100876. */
  100877. value: any;
  100878. /**
  100879. * Defines the time it will take for the property to interpolate to the value.
  100880. */
  100881. duration: number;
  100882. /**
  100883. * Defines if the other scene animations should be stopped when the action has been triggered
  100884. */
  100885. stopOtherAnimations?: boolean;
  100886. /**
  100887. * Defines a callback raised once the interpolation animation has been done.
  100888. */
  100889. onInterpolationDone?: () => void;
  100890. /**
  100891. * Observable triggered once the interpolation animation has been done.
  100892. */
  100893. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  100894. private _target;
  100895. private _effectiveTarget;
  100896. private _property;
  100897. /**
  100898. * Instantiate the action
  100899. * @param triggerOptions defines the trigger options
  100900. * @param target defines the object containing the value to interpolate
  100901. * @param propertyPath defines the path to the property in the target object
  100902. * @param value defines the target value at the end of the interpolation
  100903. * @param duration deines the time it will take for the property to interpolate to the value.
  100904. * @param condition defines the trigger related conditions
  100905. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  100906. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  100907. */
  100908. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  100909. /** @hidden */
  100910. _prepare(): void;
  100911. /**
  100912. * Execute the action starts the value interpolation.
  100913. */
  100914. execute(): void;
  100915. /**
  100916. * Serializes the actions and its related information.
  100917. * @param parent defines the object to serialize in
  100918. * @returns the serialized object
  100919. */
  100920. serialize(parent: any): any;
  100921. }
  100922. }
  100923. declare module BABYLON {
  100924. /**
  100925. * Options allowed during the creation of a sound track.
  100926. */
  100927. export interface ISoundTrackOptions {
  100928. /**
  100929. * The volume the sound track should take during creation
  100930. */
  100931. volume?: number;
  100932. /**
  100933. * Define if the sound track is the main sound track of the scene
  100934. */
  100935. mainTrack?: boolean;
  100936. }
  100937. /**
  100938. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  100939. * It will be also used in a future release to apply effects on a specific track.
  100940. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  100941. */
  100942. export class SoundTrack {
  100943. /**
  100944. * The unique identifier of the sound track in the scene.
  100945. */
  100946. id: number;
  100947. /**
  100948. * The list of sounds included in the sound track.
  100949. */
  100950. soundCollection: Array<Sound>;
  100951. private _outputAudioNode;
  100952. private _scene;
  100953. private _isMainTrack;
  100954. private _connectedAnalyser;
  100955. private _options;
  100956. private _isInitialized;
  100957. /**
  100958. * Creates a new sound track.
  100959. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  100960. * @param scene Define the scene the sound track belongs to
  100961. * @param options
  100962. */
  100963. constructor(scene: Scene, options?: ISoundTrackOptions);
  100964. private _initializeSoundTrackAudioGraph;
  100965. /**
  100966. * Release the sound track and its associated resources
  100967. */
  100968. dispose(): void;
  100969. /**
  100970. * Adds a sound to this sound track
  100971. * @param sound define the cound to add
  100972. * @ignoreNaming
  100973. */
  100974. AddSound(sound: Sound): void;
  100975. /**
  100976. * Removes a sound to this sound track
  100977. * @param sound define the cound to remove
  100978. * @ignoreNaming
  100979. */
  100980. RemoveSound(sound: Sound): void;
  100981. /**
  100982. * Set a global volume for the full sound track.
  100983. * @param newVolume Define the new volume of the sound track
  100984. */
  100985. setVolume(newVolume: number): void;
  100986. /**
  100987. * Switch the panning model to HRTF:
  100988. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  100989. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100990. */
  100991. switchPanningModelToHRTF(): void;
  100992. /**
  100993. * Switch the panning model to Equal Power:
  100994. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  100995. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100996. */
  100997. switchPanningModelToEqualPower(): void;
  100998. /**
  100999. * Connect the sound track to an audio analyser allowing some amazing
  101000. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  101001. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  101002. * @param analyser The analyser to connect to the engine
  101003. */
  101004. connectToAnalyser(analyser: Analyser): void;
  101005. }
  101006. }
  101007. declare module BABYLON {
  101008. interface AbstractScene {
  101009. /**
  101010. * The list of sounds used in the scene.
  101011. */
  101012. sounds: Nullable<Array<Sound>>;
  101013. }
  101014. interface Scene {
  101015. /**
  101016. * @hidden
  101017. * Backing field
  101018. */
  101019. _mainSoundTrack: SoundTrack;
  101020. /**
  101021. * The main sound track played by the scene.
  101022. * It cotains your primary collection of sounds.
  101023. */
  101024. mainSoundTrack: SoundTrack;
  101025. /**
  101026. * The list of sound tracks added to the scene
  101027. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101028. */
  101029. soundTracks: Nullable<Array<SoundTrack>>;
  101030. /**
  101031. * Gets a sound using a given name
  101032. * @param name defines the name to search for
  101033. * @return the found sound or null if not found at all.
  101034. */
  101035. getSoundByName(name: string): Nullable<Sound>;
  101036. /**
  101037. * Gets or sets if audio support is enabled
  101038. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101039. */
  101040. audioEnabled: boolean;
  101041. /**
  101042. * Gets or sets if audio will be output to headphones
  101043. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101044. */
  101045. headphone: boolean;
  101046. /**
  101047. * Gets or sets custom audio listener position provider
  101048. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101049. */
  101050. audioListenerPositionProvider: Nullable<() => Vector3>;
  101051. }
  101052. /**
  101053. * Defines the sound scene component responsible to manage any sounds
  101054. * in a given scene.
  101055. */
  101056. export class AudioSceneComponent implements ISceneSerializableComponent {
  101057. /**
  101058. * The component name helpfull to identify the component in the list of scene components.
  101059. */
  101060. readonly name: string;
  101061. /**
  101062. * The scene the component belongs to.
  101063. */
  101064. scene: Scene;
  101065. private _audioEnabled;
  101066. /**
  101067. * Gets whether audio is enabled or not.
  101068. * Please use related enable/disable method to switch state.
  101069. */
  101070. readonly audioEnabled: boolean;
  101071. private _headphone;
  101072. /**
  101073. * Gets whether audio is outputing to headphone or not.
  101074. * Please use the according Switch methods to change output.
  101075. */
  101076. readonly headphone: boolean;
  101077. private _audioListenerPositionProvider;
  101078. /**
  101079. * Gets the current audio listener position provider
  101080. */
  101081. /**
  101082. * Sets a custom listener position for all sounds in the scene
  101083. * By default, this is the position of the first active camera
  101084. */
  101085. audioListenerPositionProvider: Nullable<() => Vector3>;
  101086. /**
  101087. * Creates a new instance of the component for the given scene
  101088. * @param scene Defines the scene to register the component in
  101089. */
  101090. constructor(scene: Scene);
  101091. /**
  101092. * Registers the component in a given scene
  101093. */
  101094. register(): void;
  101095. /**
  101096. * Rebuilds the elements related to this component in case of
  101097. * context lost for instance.
  101098. */
  101099. rebuild(): void;
  101100. /**
  101101. * Serializes the component data to the specified json object
  101102. * @param serializationObject The object to serialize to
  101103. */
  101104. serialize(serializationObject: any): void;
  101105. /**
  101106. * Adds all the elements from the container to the scene
  101107. * @param container the container holding the elements
  101108. */
  101109. addFromContainer(container: AbstractScene): void;
  101110. /**
  101111. * Removes all the elements in the container from the scene
  101112. * @param container contains the elements to remove
  101113. * @param dispose if the removed element should be disposed (default: false)
  101114. */
  101115. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  101116. /**
  101117. * Disposes the component and the associated ressources.
  101118. */
  101119. dispose(): void;
  101120. /**
  101121. * Disables audio in the associated scene.
  101122. */
  101123. disableAudio(): void;
  101124. /**
  101125. * Enables audio in the associated scene.
  101126. */
  101127. enableAudio(): void;
  101128. /**
  101129. * Switch audio to headphone output.
  101130. */
  101131. switchAudioModeForHeadphones(): void;
  101132. /**
  101133. * Switch audio to normal speakers.
  101134. */
  101135. switchAudioModeForNormalSpeakers(): void;
  101136. private _afterRender;
  101137. }
  101138. }
  101139. declare module BABYLON {
  101140. /**
  101141. * Wraps one or more Sound objects and selects one with random weight for playback.
  101142. */
  101143. export class WeightedSound {
  101144. /** When true a Sound will be selected and played when the current playing Sound completes. */
  101145. loop: boolean;
  101146. private _coneInnerAngle;
  101147. private _coneOuterAngle;
  101148. private _volume;
  101149. /** A Sound is currently playing. */
  101150. isPlaying: boolean;
  101151. /** A Sound is currently paused. */
  101152. isPaused: boolean;
  101153. private _sounds;
  101154. private _weights;
  101155. private _currentIndex?;
  101156. /**
  101157. * Creates a new WeightedSound from the list of sounds given.
  101158. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  101159. * @param sounds Array of Sounds that will be selected from.
  101160. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  101161. */
  101162. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  101163. /**
  101164. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  101165. */
  101166. /**
  101167. * The size of cone in degress for a directional sound in which there will be no attenuation.
  101168. */
  101169. directionalConeInnerAngle: number;
  101170. /**
  101171. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  101172. * Listener angles between innerAngle and outerAngle will falloff linearly.
  101173. */
  101174. /**
  101175. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  101176. * Listener angles between innerAngle and outerAngle will falloff linearly.
  101177. */
  101178. directionalConeOuterAngle: number;
  101179. /**
  101180. * Playback volume.
  101181. */
  101182. /**
  101183. * Playback volume.
  101184. */
  101185. volume: number;
  101186. private _onended;
  101187. /**
  101188. * Suspend playback
  101189. */
  101190. pause(): void;
  101191. /**
  101192. * Stop playback
  101193. */
  101194. stop(): void;
  101195. /**
  101196. * Start playback.
  101197. * @param startOffset Position the clip head at a specific time in seconds.
  101198. */
  101199. play(startOffset?: number): void;
  101200. }
  101201. }
  101202. declare module BABYLON {
  101203. /**
  101204. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  101205. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  101206. */
  101207. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  101208. /**
  101209. * Gets the name of the behavior.
  101210. */
  101211. readonly name: string;
  101212. /**
  101213. * The easing function used by animations
  101214. */
  101215. static EasingFunction: BackEase;
  101216. /**
  101217. * The easing mode used by animations
  101218. */
  101219. static EasingMode: number;
  101220. /**
  101221. * The duration of the animation, in milliseconds
  101222. */
  101223. transitionDuration: number;
  101224. /**
  101225. * Length of the distance animated by the transition when lower radius is reached
  101226. */
  101227. lowerRadiusTransitionRange: number;
  101228. /**
  101229. * Length of the distance animated by the transition when upper radius is reached
  101230. */
  101231. upperRadiusTransitionRange: number;
  101232. private _autoTransitionRange;
  101233. /**
  101234. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  101235. */
  101236. /**
  101237. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  101238. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  101239. */
  101240. autoTransitionRange: boolean;
  101241. private _attachedCamera;
  101242. private _onAfterCheckInputsObserver;
  101243. private _onMeshTargetChangedObserver;
  101244. /**
  101245. * Initializes the behavior.
  101246. */
  101247. init(): void;
  101248. /**
  101249. * Attaches the behavior to its arc rotate camera.
  101250. * @param camera Defines the camera to attach the behavior to
  101251. */
  101252. attach(camera: ArcRotateCamera): void;
  101253. /**
  101254. * Detaches the behavior from its current arc rotate camera.
  101255. */
  101256. detach(): void;
  101257. private _radiusIsAnimating;
  101258. private _radiusBounceTransition;
  101259. private _animatables;
  101260. private _cachedWheelPrecision;
  101261. /**
  101262. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  101263. * @param radiusLimit The limit to check against.
  101264. * @return Bool to indicate if at limit.
  101265. */
  101266. private _isRadiusAtLimit;
  101267. /**
  101268. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  101269. * @param radiusDelta The delta by which to animate to. Can be negative.
  101270. */
  101271. private _applyBoundRadiusAnimation;
  101272. /**
  101273. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  101274. */
  101275. protected _clearAnimationLocks(): void;
  101276. /**
  101277. * Stops and removes all animations that have been applied to the camera
  101278. */
  101279. stopAllAnimations(): void;
  101280. }
  101281. }
  101282. declare module BABYLON {
  101283. /**
  101284. * 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.
  101285. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  101286. */
  101287. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  101288. /**
  101289. * Gets the name of the behavior.
  101290. */
  101291. readonly name: string;
  101292. private _mode;
  101293. private _radiusScale;
  101294. private _positionScale;
  101295. private _defaultElevation;
  101296. private _elevationReturnTime;
  101297. private _elevationReturnWaitTime;
  101298. private _zoomStopsAnimation;
  101299. private _framingTime;
  101300. /**
  101301. * The easing function used by animations
  101302. */
  101303. static EasingFunction: ExponentialEase;
  101304. /**
  101305. * The easing mode used by animations
  101306. */
  101307. static EasingMode: number;
  101308. /**
  101309. * Sets the current mode used by the behavior
  101310. */
  101311. /**
  101312. * Gets current mode used by the behavior.
  101313. */
  101314. mode: number;
  101315. /**
  101316. * Sets the scale applied to the radius (1 by default)
  101317. */
  101318. /**
  101319. * Gets the scale applied to the radius
  101320. */
  101321. radiusScale: number;
  101322. /**
  101323. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  101324. */
  101325. /**
  101326. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  101327. */
  101328. positionScale: number;
  101329. /**
  101330. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  101331. * behaviour is triggered, in radians.
  101332. */
  101333. /**
  101334. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  101335. * behaviour is triggered, in radians.
  101336. */
  101337. defaultElevation: number;
  101338. /**
  101339. * Sets the time (in milliseconds) taken to return to the default beta position.
  101340. * Negative value indicates camera should not return to default.
  101341. */
  101342. /**
  101343. * Gets the time (in milliseconds) taken to return to the default beta position.
  101344. * Negative value indicates camera should not return to default.
  101345. */
  101346. elevationReturnTime: number;
  101347. /**
  101348. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  101349. */
  101350. /**
  101351. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  101352. */
  101353. elevationReturnWaitTime: number;
  101354. /**
  101355. * Sets the flag that indicates if user zooming should stop animation.
  101356. */
  101357. /**
  101358. * Gets the flag that indicates if user zooming should stop animation.
  101359. */
  101360. zoomStopsAnimation: boolean;
  101361. /**
  101362. * Sets the transition time when framing the mesh, in milliseconds
  101363. */
  101364. /**
  101365. * Gets the transition time when framing the mesh, in milliseconds
  101366. */
  101367. framingTime: number;
  101368. /**
  101369. * Define if the behavior should automatically change the configured
  101370. * camera limits and sensibilities.
  101371. */
  101372. autoCorrectCameraLimitsAndSensibility: boolean;
  101373. private _onPrePointerObservableObserver;
  101374. private _onAfterCheckInputsObserver;
  101375. private _onMeshTargetChangedObserver;
  101376. private _attachedCamera;
  101377. private _isPointerDown;
  101378. private _lastInteractionTime;
  101379. /**
  101380. * Initializes the behavior.
  101381. */
  101382. init(): void;
  101383. /**
  101384. * Attaches the behavior to its arc rotate camera.
  101385. * @param camera Defines the camera to attach the behavior to
  101386. */
  101387. attach(camera: ArcRotateCamera): void;
  101388. /**
  101389. * Detaches the behavior from its current arc rotate camera.
  101390. */
  101391. detach(): void;
  101392. private _animatables;
  101393. private _betaIsAnimating;
  101394. private _betaTransition;
  101395. private _radiusTransition;
  101396. private _vectorTransition;
  101397. /**
  101398. * Targets the given mesh and updates zoom level accordingly.
  101399. * @param mesh The mesh to target.
  101400. * @param radius Optional. If a cached radius position already exists, overrides default.
  101401. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101402. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101403. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101404. */
  101405. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101406. /**
  101407. * Targets the given mesh with its children and updates zoom level accordingly.
  101408. * @param mesh The mesh to target.
  101409. * @param radius Optional. If a cached radius position already exists, overrides default.
  101410. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101411. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101412. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101413. */
  101414. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101415. /**
  101416. * Targets the given meshes with their children and updates zoom level accordingly.
  101417. * @param meshes The mesh to target.
  101418. * @param radius Optional. If a cached radius position already exists, overrides default.
  101419. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101420. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101421. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101422. */
  101423. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101424. /**
  101425. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  101426. * @param minimumWorld Determines the smaller position of the bounding box extend
  101427. * @param maximumWorld Determines the bigger position of the bounding box extend
  101428. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101429. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101430. */
  101431. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101432. /**
  101433. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  101434. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  101435. * frustum width.
  101436. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  101437. * to fully enclose the mesh in the viewing frustum.
  101438. */
  101439. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  101440. /**
  101441. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  101442. * is automatically returned to its default position (expected to be above ground plane).
  101443. */
  101444. private _maintainCameraAboveGround;
  101445. /**
  101446. * Returns the frustum slope based on the canvas ratio and camera FOV
  101447. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  101448. */
  101449. private _getFrustumSlope;
  101450. /**
  101451. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  101452. */
  101453. private _clearAnimationLocks;
  101454. /**
  101455. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  101456. */
  101457. private _applyUserInteraction;
  101458. /**
  101459. * Stops and removes all animations that have been applied to the camera
  101460. */
  101461. stopAllAnimations(): void;
  101462. /**
  101463. * Gets a value indicating if the user is moving the camera
  101464. */
  101465. readonly isUserIsMoving: boolean;
  101466. /**
  101467. * The camera can move all the way towards the mesh.
  101468. */
  101469. static IgnoreBoundsSizeMode: number;
  101470. /**
  101471. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  101472. */
  101473. static FitFrustumSidesMode: number;
  101474. }
  101475. }
  101476. declare module BABYLON {
  101477. /**
  101478. * Base class for Camera Pointer Inputs.
  101479. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  101480. * for example usage.
  101481. */
  101482. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  101483. /**
  101484. * Defines the camera the input is attached to.
  101485. */
  101486. abstract camera: Camera;
  101487. /**
  101488. * Whether keyboard modifier keys are pressed at time of last mouse event.
  101489. */
  101490. protected _altKey: boolean;
  101491. protected _ctrlKey: boolean;
  101492. protected _metaKey: boolean;
  101493. protected _shiftKey: boolean;
  101494. /**
  101495. * Which mouse buttons were pressed at time of last mouse event.
  101496. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  101497. */
  101498. protected _buttonsPressed: number;
  101499. /**
  101500. * Defines the buttons associated with the input to handle camera move.
  101501. */
  101502. buttons: number[];
  101503. /**
  101504. * Attach the input controls to a specific dom element to get the input from.
  101505. * @param element Defines the element the controls should be listened from
  101506. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101507. */
  101508. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101509. /**
  101510. * Detach the current controls from the specified dom element.
  101511. * @param element Defines the element to stop listening the inputs from
  101512. */
  101513. detachControl(element: Nullable<HTMLElement>): void;
  101514. /**
  101515. * Gets the class name of the current input.
  101516. * @returns the class name
  101517. */
  101518. getClassName(): string;
  101519. /**
  101520. * Get the friendly name associated with the input class.
  101521. * @returns the input friendly name
  101522. */
  101523. getSimpleName(): string;
  101524. /**
  101525. * Called on pointer POINTERDOUBLETAP event.
  101526. * Override this method to provide functionality on POINTERDOUBLETAP event.
  101527. */
  101528. protected onDoubleTap(type: string): void;
  101529. /**
  101530. * Called on pointer POINTERMOVE event if only a single touch is active.
  101531. * Override this method to provide functionality.
  101532. */
  101533. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101534. /**
  101535. * Called on pointer POINTERMOVE event if multiple touches are active.
  101536. * Override this method to provide functionality.
  101537. */
  101538. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101539. /**
  101540. * Called on JS contextmenu event.
  101541. * Override this method to provide functionality.
  101542. */
  101543. protected onContextMenu(evt: PointerEvent): void;
  101544. /**
  101545. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  101546. * press.
  101547. * Override this method to provide functionality.
  101548. */
  101549. protected onButtonDown(evt: PointerEvent): void;
  101550. /**
  101551. * Called each time a new POINTERUP event occurs. Ie, for each button
  101552. * release.
  101553. * Override this method to provide functionality.
  101554. */
  101555. protected onButtonUp(evt: PointerEvent): void;
  101556. /**
  101557. * Called when window becomes inactive.
  101558. * Override this method to provide functionality.
  101559. */
  101560. protected onLostFocus(): void;
  101561. private _pointerInput;
  101562. private _observer;
  101563. private _onLostFocus;
  101564. private pointA;
  101565. private pointB;
  101566. }
  101567. }
  101568. declare module BABYLON {
  101569. /**
  101570. * Manage the pointers inputs to control an arc rotate camera.
  101571. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101572. */
  101573. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  101574. /**
  101575. * Defines the camera the input is attached to.
  101576. */
  101577. camera: ArcRotateCamera;
  101578. /**
  101579. * Gets the class name of the current input.
  101580. * @returns the class name
  101581. */
  101582. getClassName(): string;
  101583. /**
  101584. * Defines the buttons associated with the input to handle camera move.
  101585. */
  101586. buttons: number[];
  101587. /**
  101588. * Defines the pointer angular sensibility along the X axis or how fast is
  101589. * the camera rotating.
  101590. */
  101591. angularSensibilityX: number;
  101592. /**
  101593. * Defines the pointer angular sensibility along the Y axis or how fast is
  101594. * the camera rotating.
  101595. */
  101596. angularSensibilityY: number;
  101597. /**
  101598. * Defines the pointer pinch precision or how fast is the camera zooming.
  101599. */
  101600. pinchPrecision: number;
  101601. /**
  101602. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  101603. * from 0.
  101604. * It defines the percentage of current camera.radius to use as delta when
  101605. * pinch zoom is used.
  101606. */
  101607. pinchDeltaPercentage: number;
  101608. /**
  101609. * Defines the pointer panning sensibility or how fast is the camera moving.
  101610. */
  101611. panningSensibility: number;
  101612. /**
  101613. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  101614. */
  101615. multiTouchPanning: boolean;
  101616. /**
  101617. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  101618. * zoom (pinch) through multitouch.
  101619. */
  101620. multiTouchPanAndZoom: boolean;
  101621. /**
  101622. * Revers pinch action direction.
  101623. */
  101624. pinchInwards: boolean;
  101625. private _isPanClick;
  101626. private _twoFingerActivityCount;
  101627. private _isPinching;
  101628. /**
  101629. * Called on pointer POINTERMOVE event if only a single touch is active.
  101630. */
  101631. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101632. /**
  101633. * Called on pointer POINTERDOUBLETAP event.
  101634. */
  101635. protected onDoubleTap(type: string): void;
  101636. /**
  101637. * Called on pointer POINTERMOVE event if multiple touches are active.
  101638. */
  101639. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101640. /**
  101641. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  101642. * press.
  101643. */
  101644. protected onButtonDown(evt: PointerEvent): void;
  101645. /**
  101646. * Called each time a new POINTERUP event occurs. Ie, for each button
  101647. * release.
  101648. */
  101649. protected onButtonUp(evt: PointerEvent): void;
  101650. /**
  101651. * Called when window becomes inactive.
  101652. */
  101653. protected onLostFocus(): void;
  101654. }
  101655. }
  101656. declare module BABYLON {
  101657. /**
  101658. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  101659. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101660. */
  101661. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  101662. /**
  101663. * Defines the camera the input is attached to.
  101664. */
  101665. camera: ArcRotateCamera;
  101666. /**
  101667. * Defines the list of key codes associated with the up action (increase alpha)
  101668. */
  101669. keysUp: number[];
  101670. /**
  101671. * Defines the list of key codes associated with the down action (decrease alpha)
  101672. */
  101673. keysDown: number[];
  101674. /**
  101675. * Defines the list of key codes associated with the left action (increase beta)
  101676. */
  101677. keysLeft: number[];
  101678. /**
  101679. * Defines the list of key codes associated with the right action (decrease beta)
  101680. */
  101681. keysRight: number[];
  101682. /**
  101683. * Defines the list of key codes associated with the reset action.
  101684. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  101685. */
  101686. keysReset: number[];
  101687. /**
  101688. * Defines the panning sensibility of the inputs.
  101689. * (How fast is the camera paning)
  101690. */
  101691. panningSensibility: number;
  101692. /**
  101693. * Defines the zooming sensibility of the inputs.
  101694. * (How fast is the camera zooming)
  101695. */
  101696. zoomingSensibility: number;
  101697. /**
  101698. * Defines wether maintaining the alt key down switch the movement mode from
  101699. * orientation to zoom.
  101700. */
  101701. useAltToZoom: boolean;
  101702. /**
  101703. * Rotation speed of the camera
  101704. */
  101705. angularSpeed: number;
  101706. private _keys;
  101707. private _ctrlPressed;
  101708. private _altPressed;
  101709. private _onCanvasBlurObserver;
  101710. private _onKeyboardObserver;
  101711. private _engine;
  101712. private _scene;
  101713. /**
  101714. * Attach the input controls to a specific dom element to get the input from.
  101715. * @param element Defines the element the controls should be listened from
  101716. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101717. */
  101718. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101719. /**
  101720. * Detach the current controls from the specified dom element.
  101721. * @param element Defines the element to stop listening the inputs from
  101722. */
  101723. detachControl(element: Nullable<HTMLElement>): void;
  101724. /**
  101725. * Update the current camera state depending on the inputs that have been used this frame.
  101726. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101727. */
  101728. checkInputs(): void;
  101729. /**
  101730. * Gets the class name of the current intput.
  101731. * @returns the class name
  101732. */
  101733. getClassName(): string;
  101734. /**
  101735. * Get the friendly name associated with the input class.
  101736. * @returns the input friendly name
  101737. */
  101738. getSimpleName(): string;
  101739. }
  101740. }
  101741. declare module BABYLON {
  101742. /**
  101743. * Manage the mouse wheel inputs to control an arc rotate camera.
  101744. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101745. */
  101746. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  101747. /**
  101748. * Defines the camera the input is attached to.
  101749. */
  101750. camera: ArcRotateCamera;
  101751. /**
  101752. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  101753. */
  101754. wheelPrecision: number;
  101755. /**
  101756. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  101757. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  101758. */
  101759. wheelDeltaPercentage: number;
  101760. private _wheel;
  101761. private _observer;
  101762. private computeDeltaFromMouseWheelLegacyEvent;
  101763. /**
  101764. * Attach the input controls to a specific dom element to get the input from.
  101765. * @param element Defines the element the controls should be listened from
  101766. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101767. */
  101768. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101769. /**
  101770. * Detach the current controls from the specified dom element.
  101771. * @param element Defines the element to stop listening the inputs from
  101772. */
  101773. detachControl(element: Nullable<HTMLElement>): void;
  101774. /**
  101775. * Gets the class name of the current intput.
  101776. * @returns the class name
  101777. */
  101778. getClassName(): string;
  101779. /**
  101780. * Get the friendly name associated with the input class.
  101781. * @returns the input friendly name
  101782. */
  101783. getSimpleName(): string;
  101784. }
  101785. }
  101786. declare module BABYLON {
  101787. /**
  101788. * Default Inputs manager for the ArcRotateCamera.
  101789. * It groups all the default supported inputs for ease of use.
  101790. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101791. */
  101792. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  101793. /**
  101794. * Instantiates a new ArcRotateCameraInputsManager.
  101795. * @param camera Defines the camera the inputs belong to
  101796. */
  101797. constructor(camera: ArcRotateCamera);
  101798. /**
  101799. * Add mouse wheel input support to the input manager.
  101800. * @returns the current input manager
  101801. */
  101802. addMouseWheel(): ArcRotateCameraInputsManager;
  101803. /**
  101804. * Add pointers input support to the input manager.
  101805. * @returns the current input manager
  101806. */
  101807. addPointers(): ArcRotateCameraInputsManager;
  101808. /**
  101809. * Add keyboard input support to the input manager.
  101810. * @returns the current input manager
  101811. */
  101812. addKeyboard(): ArcRotateCameraInputsManager;
  101813. }
  101814. }
  101815. declare module BABYLON {
  101816. /**
  101817. * This represents an orbital type of camera.
  101818. *
  101819. * 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.
  101820. * 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.
  101821. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  101822. */
  101823. export class ArcRotateCamera extends TargetCamera {
  101824. /**
  101825. * Defines the rotation angle of the camera along the longitudinal axis.
  101826. */
  101827. alpha: number;
  101828. /**
  101829. * Defines the rotation angle of the camera along the latitudinal axis.
  101830. */
  101831. beta: number;
  101832. /**
  101833. * Defines the radius of the camera from it s target point.
  101834. */
  101835. radius: number;
  101836. protected _target: Vector3;
  101837. protected _targetHost: Nullable<AbstractMesh>;
  101838. /**
  101839. * Defines the target point of the camera.
  101840. * The camera looks towards it form the radius distance.
  101841. */
  101842. target: Vector3;
  101843. /**
  101844. * Define the current local position of the camera in the scene
  101845. */
  101846. position: Vector3;
  101847. protected _upVector: Vector3;
  101848. protected _upToYMatrix: Matrix;
  101849. protected _YToUpMatrix: Matrix;
  101850. /**
  101851. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  101852. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  101853. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  101854. */
  101855. upVector: Vector3;
  101856. /**
  101857. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  101858. */
  101859. setMatUp(): void;
  101860. /**
  101861. * Current inertia value on the longitudinal axis.
  101862. * The bigger this number the longer it will take for the camera to stop.
  101863. */
  101864. inertialAlphaOffset: number;
  101865. /**
  101866. * Current inertia value on the latitudinal axis.
  101867. * The bigger this number the longer it will take for the camera to stop.
  101868. */
  101869. inertialBetaOffset: number;
  101870. /**
  101871. * Current inertia value on the radius axis.
  101872. * The bigger this number the longer it will take for the camera to stop.
  101873. */
  101874. inertialRadiusOffset: number;
  101875. /**
  101876. * Minimum allowed angle on the longitudinal axis.
  101877. * This can help limiting how the Camera is able to move in the scene.
  101878. */
  101879. lowerAlphaLimit: Nullable<number>;
  101880. /**
  101881. * Maximum allowed angle on the longitudinal axis.
  101882. * This can help limiting how the Camera is able to move in the scene.
  101883. */
  101884. upperAlphaLimit: Nullable<number>;
  101885. /**
  101886. * Minimum allowed angle on the latitudinal axis.
  101887. * This can help limiting how the Camera is able to move in the scene.
  101888. */
  101889. lowerBetaLimit: number;
  101890. /**
  101891. * Maximum allowed angle on the latitudinal axis.
  101892. * This can help limiting how the Camera is able to move in the scene.
  101893. */
  101894. upperBetaLimit: number;
  101895. /**
  101896. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  101897. * This can help limiting how the Camera is able to move in the scene.
  101898. */
  101899. lowerRadiusLimit: Nullable<number>;
  101900. /**
  101901. * Maximum allowed distance of the camera to the target (The camera can not get further).
  101902. * This can help limiting how the Camera is able to move in the scene.
  101903. */
  101904. upperRadiusLimit: Nullable<number>;
  101905. /**
  101906. * Defines the current inertia value used during panning of the camera along the X axis.
  101907. */
  101908. inertialPanningX: number;
  101909. /**
  101910. * Defines the current inertia value used during panning of the camera along the Y axis.
  101911. */
  101912. inertialPanningY: number;
  101913. /**
  101914. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  101915. * Basically if your fingers moves away from more than this distance you will be considered
  101916. * in pinch mode.
  101917. */
  101918. pinchToPanMaxDistance: number;
  101919. /**
  101920. * Defines the maximum distance the camera can pan.
  101921. * This could help keeping the cammera always in your scene.
  101922. */
  101923. panningDistanceLimit: Nullable<number>;
  101924. /**
  101925. * Defines the target of the camera before paning.
  101926. */
  101927. panningOriginTarget: Vector3;
  101928. /**
  101929. * Defines the value of the inertia used during panning.
  101930. * 0 would mean stop inertia and one would mean no decelleration at all.
  101931. */
  101932. panningInertia: number;
  101933. /**
  101934. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  101935. */
  101936. angularSensibilityX: number;
  101937. /**
  101938. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  101939. */
  101940. angularSensibilityY: number;
  101941. /**
  101942. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  101943. */
  101944. pinchPrecision: number;
  101945. /**
  101946. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  101947. * It will be used instead of pinchDeltaPrecision if different from 0.
  101948. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  101949. */
  101950. pinchDeltaPercentage: number;
  101951. /**
  101952. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  101953. */
  101954. panningSensibility: number;
  101955. /**
  101956. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  101957. */
  101958. keysUp: number[];
  101959. /**
  101960. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  101961. */
  101962. keysDown: number[];
  101963. /**
  101964. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  101965. */
  101966. keysLeft: number[];
  101967. /**
  101968. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  101969. */
  101970. keysRight: number[];
  101971. /**
  101972. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  101973. */
  101974. wheelPrecision: number;
  101975. /**
  101976. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  101977. * It will be used instead of pinchDeltaPrecision if different from 0.
  101978. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  101979. */
  101980. wheelDeltaPercentage: number;
  101981. /**
  101982. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  101983. */
  101984. zoomOnFactor: number;
  101985. /**
  101986. * Defines a screen offset for the camera position.
  101987. */
  101988. targetScreenOffset: Vector2;
  101989. /**
  101990. * Allows the camera to be completely reversed.
  101991. * If false the camera can not arrive upside down.
  101992. */
  101993. allowUpsideDown: boolean;
  101994. /**
  101995. * Define if double tap/click is used to restore the previously saved state of the camera.
  101996. */
  101997. useInputToRestoreState: boolean;
  101998. /** @hidden */
  101999. _viewMatrix: Matrix;
  102000. /** @hidden */
  102001. _useCtrlForPanning: boolean;
  102002. /** @hidden */
  102003. _panningMouseButton: number;
  102004. /**
  102005. * Defines the input associated to the camera.
  102006. */
  102007. inputs: ArcRotateCameraInputsManager;
  102008. /** @hidden */
  102009. _reset: () => void;
  102010. /**
  102011. * Defines the allowed panning axis.
  102012. */
  102013. panningAxis: Vector3;
  102014. protected _localDirection: Vector3;
  102015. protected _transformedDirection: Vector3;
  102016. private _bouncingBehavior;
  102017. /**
  102018. * Gets the bouncing behavior of the camera if it has been enabled.
  102019. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102020. */
  102021. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  102022. /**
  102023. * Defines if the bouncing behavior of the camera is enabled on the camera.
  102024. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102025. */
  102026. useBouncingBehavior: boolean;
  102027. private _framingBehavior;
  102028. /**
  102029. * Gets the framing behavior of the camera if it has been enabled.
  102030. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102031. */
  102032. readonly framingBehavior: Nullable<FramingBehavior>;
  102033. /**
  102034. * Defines if the framing behavior of the camera is enabled on the camera.
  102035. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102036. */
  102037. useFramingBehavior: boolean;
  102038. private _autoRotationBehavior;
  102039. /**
  102040. * Gets the auto rotation behavior of the camera if it has been enabled.
  102041. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102042. */
  102043. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  102044. /**
  102045. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  102046. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102047. */
  102048. useAutoRotationBehavior: boolean;
  102049. /**
  102050. * Observable triggered when the mesh target has been changed on the camera.
  102051. */
  102052. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  102053. /**
  102054. * Event raised when the camera is colliding with a mesh.
  102055. */
  102056. onCollide: (collidedMesh: AbstractMesh) => void;
  102057. /**
  102058. * Defines whether the camera should check collision with the objects oh the scene.
  102059. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  102060. */
  102061. checkCollisions: boolean;
  102062. /**
  102063. * Defines the collision radius of the camera.
  102064. * This simulates a sphere around the camera.
  102065. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  102066. */
  102067. collisionRadius: Vector3;
  102068. protected _collider: Collider;
  102069. protected _previousPosition: Vector3;
  102070. protected _collisionVelocity: Vector3;
  102071. protected _newPosition: Vector3;
  102072. protected _previousAlpha: number;
  102073. protected _previousBeta: number;
  102074. protected _previousRadius: number;
  102075. protected _collisionTriggered: boolean;
  102076. protected _targetBoundingCenter: Nullable<Vector3>;
  102077. private _computationVector;
  102078. /**
  102079. * Instantiates a new ArcRotateCamera in a given scene
  102080. * @param name Defines the name of the camera
  102081. * @param alpha Defines the camera rotation along the logitudinal axis
  102082. * @param beta Defines the camera rotation along the latitudinal axis
  102083. * @param radius Defines the camera distance from its target
  102084. * @param target Defines the camera target
  102085. * @param scene Defines the scene the camera belongs to
  102086. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  102087. */
  102088. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  102089. /** @hidden */
  102090. _initCache(): void;
  102091. /** @hidden */
  102092. _updateCache(ignoreParentClass?: boolean): void;
  102093. protected _getTargetPosition(): Vector3;
  102094. private _storedAlpha;
  102095. private _storedBeta;
  102096. private _storedRadius;
  102097. private _storedTarget;
  102098. private _storedTargetScreenOffset;
  102099. /**
  102100. * Stores the current state of the camera (alpha, beta, radius and target)
  102101. * @returns the camera itself
  102102. */
  102103. storeState(): Camera;
  102104. /**
  102105. * @hidden
  102106. * Restored camera state. You must call storeState() first
  102107. */
  102108. _restoreStateValues(): boolean;
  102109. /** @hidden */
  102110. _isSynchronizedViewMatrix(): boolean;
  102111. /**
  102112. * Attached controls to the current camera.
  102113. * @param element Defines the element the controls should be listened from
  102114. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102115. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  102116. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  102117. */
  102118. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  102119. /**
  102120. * Detach the current controls from the camera.
  102121. * The camera will stop reacting to inputs.
  102122. * @param element Defines the element to stop listening the inputs from
  102123. */
  102124. detachControl(element: HTMLElement): void;
  102125. /** @hidden */
  102126. _checkInputs(): void;
  102127. protected _checkLimits(): void;
  102128. /**
  102129. * Rebuilds angles (alpha, beta) and radius from the give position and target
  102130. */
  102131. rebuildAnglesAndRadius(): void;
  102132. /**
  102133. * Use a position to define the current camera related information like aplha, beta and radius
  102134. * @param position Defines the position to set the camera at
  102135. */
  102136. setPosition(position: Vector3): void;
  102137. /**
  102138. * Defines the target the camera should look at.
  102139. * This will automatically adapt alpha beta and radius to fit within the new target.
  102140. * @param target Defines the new target as a Vector or a mesh
  102141. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  102142. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  102143. */
  102144. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  102145. /** @hidden */
  102146. _getViewMatrix(): Matrix;
  102147. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  102148. /**
  102149. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  102150. * @param meshes Defines the mesh to zoom on
  102151. * @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)
  102152. */
  102153. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  102154. /**
  102155. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  102156. * The target will be changed but the radius
  102157. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  102158. * @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)
  102159. */
  102160. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  102161. min: Vector3;
  102162. max: Vector3;
  102163. distance: number;
  102164. }, doNotUpdateMaxZ?: boolean): void;
  102165. /**
  102166. * @override
  102167. * Override Camera.createRigCamera
  102168. */
  102169. createRigCamera(name: string, cameraIndex: number): Camera;
  102170. /**
  102171. * @hidden
  102172. * @override
  102173. * Override Camera._updateRigCameras
  102174. */
  102175. _updateRigCameras(): void;
  102176. /**
  102177. * Destroy the camera and release the current resources hold by it.
  102178. */
  102179. dispose(): void;
  102180. /**
  102181. * Gets the current object class name.
  102182. * @return the class name
  102183. */
  102184. getClassName(): string;
  102185. }
  102186. }
  102187. declare module BABYLON {
  102188. /**
  102189. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  102190. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102191. */
  102192. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  102193. /**
  102194. * Gets the name of the behavior.
  102195. */
  102196. readonly name: string;
  102197. private _zoomStopsAnimation;
  102198. private _idleRotationSpeed;
  102199. private _idleRotationWaitTime;
  102200. private _idleRotationSpinupTime;
  102201. /**
  102202. * Sets the flag that indicates if user zooming should stop animation.
  102203. */
  102204. /**
  102205. * Gets the flag that indicates if user zooming should stop animation.
  102206. */
  102207. zoomStopsAnimation: boolean;
  102208. /**
  102209. * Sets the default speed at which the camera rotates around the model.
  102210. */
  102211. /**
  102212. * Gets the default speed at which the camera rotates around the model.
  102213. */
  102214. idleRotationSpeed: number;
  102215. /**
  102216. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  102217. */
  102218. /**
  102219. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  102220. */
  102221. idleRotationWaitTime: number;
  102222. /**
  102223. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  102224. */
  102225. /**
  102226. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  102227. */
  102228. idleRotationSpinupTime: number;
  102229. /**
  102230. * Gets a value indicating if the camera is currently rotating because of this behavior
  102231. */
  102232. readonly rotationInProgress: boolean;
  102233. private _onPrePointerObservableObserver;
  102234. private _onAfterCheckInputsObserver;
  102235. private _attachedCamera;
  102236. private _isPointerDown;
  102237. private _lastFrameTime;
  102238. private _lastInteractionTime;
  102239. private _cameraRotationSpeed;
  102240. /**
  102241. * Initializes the behavior.
  102242. */
  102243. init(): void;
  102244. /**
  102245. * Attaches the behavior to its arc rotate camera.
  102246. * @param camera Defines the camera to attach the behavior to
  102247. */
  102248. attach(camera: ArcRotateCamera): void;
  102249. /**
  102250. * Detaches the behavior from its current arc rotate camera.
  102251. */
  102252. detach(): void;
  102253. /**
  102254. * Returns true if user is scrolling.
  102255. * @return true if user is scrolling.
  102256. */
  102257. private _userIsZooming;
  102258. private _lastFrameRadius;
  102259. private _shouldAnimationStopForInteraction;
  102260. /**
  102261. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  102262. */
  102263. private _applyUserInteraction;
  102264. private _userIsMoving;
  102265. }
  102266. }
  102267. declare module BABYLON {
  102268. /**
  102269. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  102270. */
  102271. export class AttachToBoxBehavior implements Behavior<Mesh> {
  102272. private ui;
  102273. /**
  102274. * The name of the behavior
  102275. */
  102276. name: string;
  102277. /**
  102278. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  102279. */
  102280. distanceAwayFromFace: number;
  102281. /**
  102282. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  102283. */
  102284. distanceAwayFromBottomOfFace: number;
  102285. private _faceVectors;
  102286. private _target;
  102287. private _scene;
  102288. private _onRenderObserver;
  102289. private _tmpMatrix;
  102290. private _tmpVector;
  102291. /**
  102292. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  102293. * @param ui The transform node that should be attched to the mesh
  102294. */
  102295. constructor(ui: TransformNode);
  102296. /**
  102297. * Initializes the behavior
  102298. */
  102299. init(): void;
  102300. private _closestFace;
  102301. private _zeroVector;
  102302. private _lookAtTmpMatrix;
  102303. private _lookAtToRef;
  102304. /**
  102305. * Attaches the AttachToBoxBehavior to the passed in mesh
  102306. * @param target The mesh that the specified node will be attached to
  102307. */
  102308. attach(target: Mesh): void;
  102309. /**
  102310. * Detaches the behavior from the mesh
  102311. */
  102312. detach(): void;
  102313. }
  102314. }
  102315. declare module BABYLON {
  102316. /**
  102317. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  102318. */
  102319. export class FadeInOutBehavior implements Behavior<Mesh> {
  102320. /**
  102321. * Time in milliseconds to delay before fading in (Default: 0)
  102322. */
  102323. delay: number;
  102324. /**
  102325. * Time in milliseconds for the mesh to fade in (Default: 300)
  102326. */
  102327. fadeInTime: number;
  102328. private _millisecondsPerFrame;
  102329. private _hovered;
  102330. private _hoverValue;
  102331. private _ownerNode;
  102332. /**
  102333. * Instatiates the FadeInOutBehavior
  102334. */
  102335. constructor();
  102336. /**
  102337. * The name of the behavior
  102338. */
  102339. readonly name: string;
  102340. /**
  102341. * Initializes the behavior
  102342. */
  102343. init(): void;
  102344. /**
  102345. * Attaches the fade behavior on the passed in mesh
  102346. * @param ownerNode The mesh that will be faded in/out once attached
  102347. */
  102348. attach(ownerNode: Mesh): void;
  102349. /**
  102350. * Detaches the behavior from the mesh
  102351. */
  102352. detach(): void;
  102353. /**
  102354. * Triggers the mesh to begin fading in or out
  102355. * @param value if the object should fade in or out (true to fade in)
  102356. */
  102357. fadeIn(value: boolean): void;
  102358. private _update;
  102359. private _setAllVisibility;
  102360. }
  102361. }
  102362. declare module BABYLON {
  102363. /**
  102364. * Class containing a set of static utilities functions for managing Pivots
  102365. * @hidden
  102366. */
  102367. export class PivotTools {
  102368. private static _PivotCached;
  102369. private static _OldPivotPoint;
  102370. private static _PivotTranslation;
  102371. private static _PivotTmpVector;
  102372. /** @hidden */
  102373. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  102374. /** @hidden */
  102375. static _RestorePivotPoint(mesh: AbstractMesh): void;
  102376. }
  102377. }
  102378. declare module BABYLON {
  102379. /**
  102380. * Class containing static functions to help procedurally build meshes
  102381. */
  102382. export class PlaneBuilder {
  102383. /**
  102384. * Creates a plane mesh
  102385. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  102386. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  102387. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  102388. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102389. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102391. * @param name defines the name of the mesh
  102392. * @param options defines the options used to create the mesh
  102393. * @param scene defines the hosting scene
  102394. * @returns the plane mesh
  102395. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  102396. */
  102397. static CreatePlane(name: string, options: {
  102398. size?: number;
  102399. width?: number;
  102400. height?: number;
  102401. sideOrientation?: number;
  102402. frontUVs?: Vector4;
  102403. backUVs?: Vector4;
  102404. updatable?: boolean;
  102405. sourcePlane?: Plane;
  102406. }, scene?: Nullable<Scene>): Mesh;
  102407. }
  102408. }
  102409. declare module BABYLON {
  102410. /**
  102411. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  102412. */
  102413. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  102414. private static _AnyMouseID;
  102415. /**
  102416. * Abstract mesh the behavior is set on
  102417. */
  102418. attachedNode: AbstractMesh;
  102419. private _dragPlane;
  102420. private _scene;
  102421. private _pointerObserver;
  102422. private _beforeRenderObserver;
  102423. private static _planeScene;
  102424. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  102425. /**
  102426. * 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)
  102427. */
  102428. maxDragAngle: number;
  102429. /**
  102430. * @hidden
  102431. */
  102432. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  102433. /**
  102434. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  102435. */
  102436. currentDraggingPointerID: number;
  102437. /**
  102438. * The last position where the pointer hit the drag plane in world space
  102439. */
  102440. lastDragPosition: Vector3;
  102441. /**
  102442. * If the behavior is currently in a dragging state
  102443. */
  102444. dragging: boolean;
  102445. /**
  102446. * 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)
  102447. */
  102448. dragDeltaRatio: number;
  102449. /**
  102450. * If the drag plane orientation should be updated during the dragging (Default: true)
  102451. */
  102452. updateDragPlane: boolean;
  102453. private _debugMode;
  102454. private _moving;
  102455. /**
  102456. * Fires each time the attached mesh is dragged with the pointer
  102457. * * delta between last drag position and current drag position in world space
  102458. * * dragDistance along the drag axis
  102459. * * dragPlaneNormal normal of the current drag plane used during the drag
  102460. * * dragPlanePoint in world space where the drag intersects the drag plane
  102461. */
  102462. onDragObservable: Observable<{
  102463. delta: Vector3;
  102464. dragPlanePoint: Vector3;
  102465. dragPlaneNormal: Vector3;
  102466. dragDistance: number;
  102467. pointerId: number;
  102468. }>;
  102469. /**
  102470. * Fires each time a drag begins (eg. mouse down on mesh)
  102471. */
  102472. onDragStartObservable: Observable<{
  102473. dragPlanePoint: Vector3;
  102474. pointerId: number;
  102475. }>;
  102476. /**
  102477. * Fires each time a drag ends (eg. mouse release after drag)
  102478. */
  102479. onDragEndObservable: Observable<{
  102480. dragPlanePoint: Vector3;
  102481. pointerId: number;
  102482. }>;
  102483. /**
  102484. * If the attached mesh should be moved when dragged
  102485. */
  102486. moveAttached: boolean;
  102487. /**
  102488. * If the drag behavior will react to drag events (Default: true)
  102489. */
  102490. enabled: boolean;
  102491. /**
  102492. * If pointer events should start and release the drag (Default: true)
  102493. */
  102494. startAndReleaseDragOnPointerEvents: boolean;
  102495. /**
  102496. * If camera controls should be detached during the drag
  102497. */
  102498. detachCameraControls: boolean;
  102499. /**
  102500. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  102501. */
  102502. useObjectOrienationForDragging: boolean;
  102503. private _options;
  102504. /**
  102505. * Creates a pointer drag behavior that can be attached to a mesh
  102506. * @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)
  102507. */
  102508. constructor(options?: {
  102509. dragAxis?: Vector3;
  102510. dragPlaneNormal?: Vector3;
  102511. });
  102512. /**
  102513. * Predicate to determine if it is valid to move the object to a new position when it is moved
  102514. */
  102515. validateDrag: (targetPosition: Vector3) => boolean;
  102516. /**
  102517. * The name of the behavior
  102518. */
  102519. readonly name: string;
  102520. /**
  102521. * Initializes the behavior
  102522. */
  102523. init(): void;
  102524. private _tmpVector;
  102525. private _alternatePickedPoint;
  102526. private _worldDragAxis;
  102527. private _targetPosition;
  102528. private _attachedElement;
  102529. /**
  102530. * Attaches the drag behavior the passed in mesh
  102531. * @param ownerNode The mesh that will be dragged around once attached
  102532. * @param predicate Predicate to use for pick filtering
  102533. */
  102534. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  102535. /**
  102536. * Force relase the drag action by code.
  102537. */
  102538. releaseDrag(): void;
  102539. private _startDragRay;
  102540. private _lastPointerRay;
  102541. /**
  102542. * Simulates the start of a pointer drag event on the behavior
  102543. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  102544. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  102545. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  102546. */
  102547. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  102548. private _startDrag;
  102549. private _dragDelta;
  102550. private _moveDrag;
  102551. private _pickWithRayOnDragPlane;
  102552. private _pointA;
  102553. private _pointB;
  102554. private _pointC;
  102555. private _lineA;
  102556. private _lineB;
  102557. private _localAxis;
  102558. private _lookAt;
  102559. private _updateDragPlanePosition;
  102560. /**
  102561. * Detaches the behavior from the mesh
  102562. */
  102563. detach(): void;
  102564. }
  102565. }
  102566. declare module BABYLON {
  102567. /**
  102568. * A behavior that when attached to a mesh will allow the mesh to be scaled
  102569. */
  102570. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  102571. private _dragBehaviorA;
  102572. private _dragBehaviorB;
  102573. private _startDistance;
  102574. private _initialScale;
  102575. private _targetScale;
  102576. private _ownerNode;
  102577. private _sceneRenderObserver;
  102578. /**
  102579. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  102580. */
  102581. constructor();
  102582. /**
  102583. * The name of the behavior
  102584. */
  102585. readonly name: string;
  102586. /**
  102587. * Initializes the behavior
  102588. */
  102589. init(): void;
  102590. private _getCurrentDistance;
  102591. /**
  102592. * Attaches the scale behavior the passed in mesh
  102593. * @param ownerNode The mesh that will be scaled around once attached
  102594. */
  102595. attach(ownerNode: Mesh): void;
  102596. /**
  102597. * Detaches the behavior from the mesh
  102598. */
  102599. detach(): void;
  102600. }
  102601. }
  102602. declare module BABYLON {
  102603. /**
  102604. * 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
  102605. */
  102606. export class SixDofDragBehavior implements Behavior<Mesh> {
  102607. private static _virtualScene;
  102608. private _ownerNode;
  102609. private _sceneRenderObserver;
  102610. private _scene;
  102611. private _targetPosition;
  102612. private _virtualOriginMesh;
  102613. private _virtualDragMesh;
  102614. private _pointerObserver;
  102615. private _moving;
  102616. private _startingOrientation;
  102617. /**
  102618. * 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)
  102619. */
  102620. private zDragFactor;
  102621. /**
  102622. * If the object should rotate to face the drag origin
  102623. */
  102624. rotateDraggedObject: boolean;
  102625. /**
  102626. * If the behavior is currently in a dragging state
  102627. */
  102628. dragging: boolean;
  102629. /**
  102630. * 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)
  102631. */
  102632. dragDeltaRatio: number;
  102633. /**
  102634. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  102635. */
  102636. currentDraggingPointerID: number;
  102637. /**
  102638. * If camera controls should be detached during the drag
  102639. */
  102640. detachCameraControls: boolean;
  102641. /**
  102642. * Fires each time a drag starts
  102643. */
  102644. onDragStartObservable: Observable<{}>;
  102645. /**
  102646. * Fires each time a drag ends (eg. mouse release after drag)
  102647. */
  102648. onDragEndObservable: Observable<{}>;
  102649. /**
  102650. * 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
  102651. */
  102652. constructor();
  102653. /**
  102654. * The name of the behavior
  102655. */
  102656. readonly name: string;
  102657. /**
  102658. * Initializes the behavior
  102659. */
  102660. init(): void;
  102661. /**
  102662. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  102663. */
  102664. private readonly _pointerCamera;
  102665. /**
  102666. * Attaches the scale behavior the passed in mesh
  102667. * @param ownerNode The mesh that will be scaled around once attached
  102668. */
  102669. attach(ownerNode: Mesh): void;
  102670. /**
  102671. * Detaches the behavior from the mesh
  102672. */
  102673. detach(): void;
  102674. }
  102675. }
  102676. declare module BABYLON {
  102677. /**
  102678. * Class used to apply inverse kinematics to bones
  102679. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  102680. */
  102681. export class BoneIKController {
  102682. private static _tmpVecs;
  102683. private static _tmpQuat;
  102684. private static _tmpMats;
  102685. /**
  102686. * Gets or sets the target mesh
  102687. */
  102688. targetMesh: AbstractMesh;
  102689. /** Gets or sets the mesh used as pole */
  102690. poleTargetMesh: AbstractMesh;
  102691. /**
  102692. * Gets or sets the bone used as pole
  102693. */
  102694. poleTargetBone: Nullable<Bone>;
  102695. /**
  102696. * Gets or sets the target position
  102697. */
  102698. targetPosition: Vector3;
  102699. /**
  102700. * Gets or sets the pole target position
  102701. */
  102702. poleTargetPosition: Vector3;
  102703. /**
  102704. * Gets or sets the pole target local offset
  102705. */
  102706. poleTargetLocalOffset: Vector3;
  102707. /**
  102708. * Gets or sets the pole angle
  102709. */
  102710. poleAngle: number;
  102711. /**
  102712. * Gets or sets the mesh associated with the controller
  102713. */
  102714. mesh: AbstractMesh;
  102715. /**
  102716. * 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)
  102717. */
  102718. slerpAmount: number;
  102719. private _bone1Quat;
  102720. private _bone1Mat;
  102721. private _bone2Ang;
  102722. private _bone1;
  102723. private _bone2;
  102724. private _bone1Length;
  102725. private _bone2Length;
  102726. private _maxAngle;
  102727. private _maxReach;
  102728. private _rightHandedSystem;
  102729. private _bendAxis;
  102730. private _slerping;
  102731. private _adjustRoll;
  102732. /**
  102733. * Gets or sets maximum allowed angle
  102734. */
  102735. maxAngle: number;
  102736. /**
  102737. * Creates a new BoneIKController
  102738. * @param mesh defines the mesh to control
  102739. * @param bone defines the bone to control
  102740. * @param options defines options to set up the controller
  102741. */
  102742. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  102743. targetMesh?: AbstractMesh;
  102744. poleTargetMesh?: AbstractMesh;
  102745. poleTargetBone?: Bone;
  102746. poleTargetLocalOffset?: Vector3;
  102747. poleAngle?: number;
  102748. bendAxis?: Vector3;
  102749. maxAngle?: number;
  102750. slerpAmount?: number;
  102751. });
  102752. private _setMaxAngle;
  102753. /**
  102754. * Force the controller to update the bones
  102755. */
  102756. update(): void;
  102757. }
  102758. }
  102759. declare module BABYLON {
  102760. /**
  102761. * Class used to make a bone look toward a point in space
  102762. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  102763. */
  102764. export class BoneLookController {
  102765. private static _tmpVecs;
  102766. private static _tmpQuat;
  102767. private static _tmpMats;
  102768. /**
  102769. * The target Vector3 that the bone will look at
  102770. */
  102771. target: Vector3;
  102772. /**
  102773. * The mesh that the bone is attached to
  102774. */
  102775. mesh: AbstractMesh;
  102776. /**
  102777. * The bone that will be looking to the target
  102778. */
  102779. bone: Bone;
  102780. /**
  102781. * The up axis of the coordinate system that is used when the bone is rotated
  102782. */
  102783. upAxis: Vector3;
  102784. /**
  102785. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  102786. */
  102787. upAxisSpace: Space;
  102788. /**
  102789. * Used to make an adjustment to the yaw of the bone
  102790. */
  102791. adjustYaw: number;
  102792. /**
  102793. * Used to make an adjustment to the pitch of the bone
  102794. */
  102795. adjustPitch: number;
  102796. /**
  102797. * Used to make an adjustment to the roll of the bone
  102798. */
  102799. adjustRoll: number;
  102800. /**
  102801. * 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)
  102802. */
  102803. slerpAmount: number;
  102804. private _minYaw;
  102805. private _maxYaw;
  102806. private _minPitch;
  102807. private _maxPitch;
  102808. private _minYawSin;
  102809. private _minYawCos;
  102810. private _maxYawSin;
  102811. private _maxYawCos;
  102812. private _midYawConstraint;
  102813. private _minPitchTan;
  102814. private _maxPitchTan;
  102815. private _boneQuat;
  102816. private _slerping;
  102817. private _transformYawPitch;
  102818. private _transformYawPitchInv;
  102819. private _firstFrameSkipped;
  102820. private _yawRange;
  102821. private _fowardAxis;
  102822. /**
  102823. * Gets or sets the minimum yaw angle that the bone can look to
  102824. */
  102825. minYaw: number;
  102826. /**
  102827. * Gets or sets the maximum yaw angle that the bone can look to
  102828. */
  102829. maxYaw: number;
  102830. /**
  102831. * Gets or sets the minimum pitch angle that the bone can look to
  102832. */
  102833. minPitch: number;
  102834. /**
  102835. * Gets or sets the maximum pitch angle that the bone can look to
  102836. */
  102837. maxPitch: number;
  102838. /**
  102839. * Create a BoneLookController
  102840. * @param mesh the mesh that the bone belongs to
  102841. * @param bone the bone that will be looking to the target
  102842. * @param target the target Vector3 to look at
  102843. * @param options optional settings:
  102844. * * maxYaw: the maximum angle the bone will yaw to
  102845. * * minYaw: the minimum angle the bone will yaw to
  102846. * * maxPitch: the maximum angle the bone will pitch to
  102847. * * minPitch: the minimum angle the bone will yaw to
  102848. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  102849. * * upAxis: the up axis of the coordinate system
  102850. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  102851. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  102852. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  102853. * * adjustYaw: used to make an adjustment to the yaw of the bone
  102854. * * adjustPitch: used to make an adjustment to the pitch of the bone
  102855. * * adjustRoll: used to make an adjustment to the roll of the bone
  102856. **/
  102857. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  102858. maxYaw?: number;
  102859. minYaw?: number;
  102860. maxPitch?: number;
  102861. minPitch?: number;
  102862. slerpAmount?: number;
  102863. upAxis?: Vector3;
  102864. upAxisSpace?: Space;
  102865. yawAxis?: Vector3;
  102866. pitchAxis?: Vector3;
  102867. adjustYaw?: number;
  102868. adjustPitch?: number;
  102869. adjustRoll?: number;
  102870. });
  102871. /**
  102872. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  102873. */
  102874. update(): void;
  102875. private _getAngleDiff;
  102876. private _getAngleBetween;
  102877. private _isAngleBetween;
  102878. }
  102879. }
  102880. declare module BABYLON {
  102881. /**
  102882. * Manage the gamepad inputs to control an arc rotate camera.
  102883. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102884. */
  102885. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  102886. /**
  102887. * Defines the camera the input is attached to.
  102888. */
  102889. camera: ArcRotateCamera;
  102890. /**
  102891. * Defines the gamepad the input is gathering event from.
  102892. */
  102893. gamepad: Nullable<Gamepad>;
  102894. /**
  102895. * Defines the gamepad rotation sensiblity.
  102896. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  102897. */
  102898. gamepadRotationSensibility: number;
  102899. /**
  102900. * Defines the gamepad move sensiblity.
  102901. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  102902. */
  102903. gamepadMoveSensibility: number;
  102904. private _onGamepadConnectedObserver;
  102905. private _onGamepadDisconnectedObserver;
  102906. /**
  102907. * Attach the input controls to a specific dom element to get the input from.
  102908. * @param element Defines the element the controls should be listened from
  102909. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102910. */
  102911. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102912. /**
  102913. * Detach the current controls from the specified dom element.
  102914. * @param element Defines the element to stop listening the inputs from
  102915. */
  102916. detachControl(element: Nullable<HTMLElement>): void;
  102917. /**
  102918. * Update the current camera state depending on the inputs that have been used this frame.
  102919. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102920. */
  102921. checkInputs(): void;
  102922. /**
  102923. * Gets the class name of the current intput.
  102924. * @returns the class name
  102925. */
  102926. getClassName(): string;
  102927. /**
  102928. * Get the friendly name associated with the input class.
  102929. * @returns the input friendly name
  102930. */
  102931. getSimpleName(): string;
  102932. }
  102933. }
  102934. declare module BABYLON {
  102935. interface ArcRotateCameraInputsManager {
  102936. /**
  102937. * Add orientation input support to the input manager.
  102938. * @returns the current input manager
  102939. */
  102940. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  102941. }
  102942. /**
  102943. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  102944. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102945. */
  102946. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  102947. /**
  102948. * Defines the camera the input is attached to.
  102949. */
  102950. camera: ArcRotateCamera;
  102951. /**
  102952. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  102953. */
  102954. alphaCorrection: number;
  102955. /**
  102956. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  102957. */
  102958. gammaCorrection: number;
  102959. private _alpha;
  102960. private _gamma;
  102961. private _dirty;
  102962. private _deviceOrientationHandler;
  102963. /**
  102964. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  102965. */
  102966. constructor();
  102967. /**
  102968. * Attach the input controls to a specific dom element to get the input from.
  102969. * @param element Defines the element the controls should be listened from
  102970. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102971. */
  102972. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102973. /** @hidden */
  102974. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  102975. /**
  102976. * Update the current camera state depending on the inputs that have been used this frame.
  102977. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102978. */
  102979. checkInputs(): void;
  102980. /**
  102981. * Detach the current controls from the specified dom element.
  102982. * @param element Defines the element to stop listening the inputs from
  102983. */
  102984. detachControl(element: Nullable<HTMLElement>): void;
  102985. /**
  102986. * Gets the class name of the current intput.
  102987. * @returns the class name
  102988. */
  102989. getClassName(): string;
  102990. /**
  102991. * Get the friendly name associated with the input class.
  102992. * @returns the input friendly name
  102993. */
  102994. getSimpleName(): string;
  102995. }
  102996. }
  102997. declare module BABYLON {
  102998. /**
  102999. * Listen to mouse events to control the camera.
  103000. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103001. */
  103002. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  103003. /**
  103004. * Defines the camera the input is attached to.
  103005. */
  103006. camera: FlyCamera;
  103007. /**
  103008. * Defines if touch is enabled. (Default is true.)
  103009. */
  103010. touchEnabled: boolean;
  103011. /**
  103012. * Defines the buttons associated with the input to handle camera rotation.
  103013. */
  103014. buttons: number[];
  103015. /**
  103016. * Assign buttons for Yaw control.
  103017. */
  103018. buttonsYaw: number[];
  103019. /**
  103020. * Assign buttons for Pitch control.
  103021. */
  103022. buttonsPitch: number[];
  103023. /**
  103024. * Assign buttons for Roll control.
  103025. */
  103026. buttonsRoll: number[];
  103027. /**
  103028. * Detect if any button is being pressed while mouse is moved.
  103029. * -1 = Mouse locked.
  103030. * 0 = Left button.
  103031. * 1 = Middle Button.
  103032. * 2 = Right Button.
  103033. */
  103034. activeButton: number;
  103035. /**
  103036. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  103037. * Higher values reduce its sensitivity.
  103038. */
  103039. angularSensibility: number;
  103040. private _mousemoveCallback;
  103041. private _observer;
  103042. private _rollObserver;
  103043. private previousPosition;
  103044. private noPreventDefault;
  103045. private element;
  103046. /**
  103047. * Listen to mouse events to control the camera.
  103048. * @param touchEnabled Define if touch is enabled. (Default is true.)
  103049. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103050. */
  103051. constructor(touchEnabled?: boolean);
  103052. /**
  103053. * Attach the mouse control to the HTML DOM element.
  103054. * @param element Defines the element that listens to the input events.
  103055. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  103056. */
  103057. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103058. /**
  103059. * Detach the current controls from the specified dom element.
  103060. * @param element Defines the element to stop listening the inputs from
  103061. */
  103062. detachControl(element: Nullable<HTMLElement>): void;
  103063. /**
  103064. * Gets the class name of the current input.
  103065. * @returns the class name.
  103066. */
  103067. getClassName(): string;
  103068. /**
  103069. * Get the friendly name associated with the input class.
  103070. * @returns the input's friendly name.
  103071. */
  103072. getSimpleName(): string;
  103073. private _pointerInput;
  103074. private _onMouseMove;
  103075. /**
  103076. * Rotate camera by mouse offset.
  103077. */
  103078. private rotateCamera;
  103079. }
  103080. }
  103081. declare module BABYLON {
  103082. /**
  103083. * Default Inputs manager for the FlyCamera.
  103084. * It groups all the default supported inputs for ease of use.
  103085. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103086. */
  103087. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  103088. /**
  103089. * Instantiates a new FlyCameraInputsManager.
  103090. * @param camera Defines the camera the inputs belong to.
  103091. */
  103092. constructor(camera: FlyCamera);
  103093. /**
  103094. * Add keyboard input support to the input manager.
  103095. * @returns the new FlyCameraKeyboardMoveInput().
  103096. */
  103097. addKeyboard(): FlyCameraInputsManager;
  103098. /**
  103099. * Add mouse input support to the input manager.
  103100. * @param touchEnabled Enable touch screen support.
  103101. * @returns the new FlyCameraMouseInput().
  103102. */
  103103. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  103104. }
  103105. }
  103106. declare module BABYLON {
  103107. /**
  103108. * This is a flying camera, designed for 3D movement and rotation in all directions,
  103109. * such as in a 3D Space Shooter or a Flight Simulator.
  103110. */
  103111. export class FlyCamera extends TargetCamera {
  103112. /**
  103113. * Define the collision ellipsoid of the camera.
  103114. * This is helpful for simulating a camera body, like a player's body.
  103115. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  103116. */
  103117. ellipsoid: Vector3;
  103118. /**
  103119. * Define an offset for the position of the ellipsoid around the camera.
  103120. * This can be helpful if the camera is attached away from the player's body center,
  103121. * such as at its head.
  103122. */
  103123. ellipsoidOffset: Vector3;
  103124. /**
  103125. * Enable or disable collisions of the camera with the rest of the scene objects.
  103126. */
  103127. checkCollisions: boolean;
  103128. /**
  103129. * Enable or disable gravity on the camera.
  103130. */
  103131. applyGravity: boolean;
  103132. /**
  103133. * Define the current direction the camera is moving to.
  103134. */
  103135. cameraDirection: Vector3;
  103136. /**
  103137. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  103138. * This overrides and empties cameraRotation.
  103139. */
  103140. rotationQuaternion: Quaternion;
  103141. /**
  103142. * Track Roll to maintain the wanted Rolling when looking around.
  103143. */
  103144. _trackRoll: number;
  103145. /**
  103146. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  103147. */
  103148. rollCorrect: number;
  103149. /**
  103150. * Mimic a banked turn, Rolling the camera when Yawing.
  103151. * It's recommended to use rollCorrect = 10 for faster banking correction.
  103152. */
  103153. bankedTurn: boolean;
  103154. /**
  103155. * Limit in radians for how much Roll banking will add. (Default: 90°)
  103156. */
  103157. bankedTurnLimit: number;
  103158. /**
  103159. * Value of 0 disables the banked Roll.
  103160. * Value of 1 is equal to the Yaw angle in radians.
  103161. */
  103162. bankedTurnMultiplier: number;
  103163. /**
  103164. * The inputs manager loads all the input sources, such as keyboard and mouse.
  103165. */
  103166. inputs: FlyCameraInputsManager;
  103167. /**
  103168. * Gets the input sensibility for mouse input.
  103169. * Higher values reduce sensitivity.
  103170. */
  103171. /**
  103172. * Sets the input sensibility for a mouse input.
  103173. * Higher values reduce sensitivity.
  103174. */
  103175. angularSensibility: number;
  103176. /**
  103177. * Get the keys for camera movement forward.
  103178. */
  103179. /**
  103180. * Set the keys for camera movement forward.
  103181. */
  103182. keysForward: number[];
  103183. /**
  103184. * Get the keys for camera movement backward.
  103185. */
  103186. keysBackward: number[];
  103187. /**
  103188. * Get the keys for camera movement up.
  103189. */
  103190. /**
  103191. * Set the keys for camera movement up.
  103192. */
  103193. keysUp: number[];
  103194. /**
  103195. * Get the keys for camera movement down.
  103196. */
  103197. /**
  103198. * Set the keys for camera movement down.
  103199. */
  103200. keysDown: number[];
  103201. /**
  103202. * Get the keys for camera movement left.
  103203. */
  103204. /**
  103205. * Set the keys for camera movement left.
  103206. */
  103207. keysLeft: number[];
  103208. /**
  103209. * Set the keys for camera movement right.
  103210. */
  103211. /**
  103212. * Set the keys for camera movement right.
  103213. */
  103214. keysRight: number[];
  103215. /**
  103216. * Event raised when the camera collides with a mesh in the scene.
  103217. */
  103218. onCollide: (collidedMesh: AbstractMesh) => void;
  103219. private _collider;
  103220. private _needMoveForGravity;
  103221. private _oldPosition;
  103222. private _diffPosition;
  103223. private _newPosition;
  103224. /** @hidden */
  103225. _localDirection: Vector3;
  103226. /** @hidden */
  103227. _transformedDirection: Vector3;
  103228. /**
  103229. * Instantiates a FlyCamera.
  103230. * This is a flying camera, designed for 3D movement and rotation in all directions,
  103231. * such as in a 3D Space Shooter or a Flight Simulator.
  103232. * @param name Define the name of the camera in the scene.
  103233. * @param position Define the starting position of the camera in the scene.
  103234. * @param scene Define the scene the camera belongs to.
  103235. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  103236. */
  103237. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  103238. /**
  103239. * Attach a control to the HTML DOM element.
  103240. * @param element Defines the element that listens to the input events.
  103241. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  103242. */
  103243. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103244. /**
  103245. * Detach a control from the HTML DOM element.
  103246. * The camera will stop reacting to that input.
  103247. * @param element Defines the element that listens to the input events.
  103248. */
  103249. detachControl(element: HTMLElement): void;
  103250. private _collisionMask;
  103251. /**
  103252. * Get the mask that the camera ignores in collision events.
  103253. */
  103254. /**
  103255. * Set the mask that the camera ignores in collision events.
  103256. */
  103257. collisionMask: number;
  103258. /** @hidden */
  103259. _collideWithWorld(displacement: Vector3): void;
  103260. /** @hidden */
  103261. private _onCollisionPositionChange;
  103262. /** @hidden */
  103263. _checkInputs(): void;
  103264. /** @hidden */
  103265. _decideIfNeedsToMove(): boolean;
  103266. /** @hidden */
  103267. _updatePosition(): void;
  103268. /**
  103269. * Restore the Roll to its target value at the rate specified.
  103270. * @param rate - Higher means slower restoring.
  103271. * @hidden
  103272. */
  103273. restoreRoll(rate: number): void;
  103274. /**
  103275. * Destroy the camera and release the current resources held by it.
  103276. */
  103277. dispose(): void;
  103278. /**
  103279. * Get the current object class name.
  103280. * @returns the class name.
  103281. */
  103282. getClassName(): string;
  103283. }
  103284. }
  103285. declare module BABYLON {
  103286. /**
  103287. * Listen to keyboard events to control the camera.
  103288. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103289. */
  103290. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  103291. /**
  103292. * Defines the camera the input is attached to.
  103293. */
  103294. camera: FlyCamera;
  103295. /**
  103296. * The list of keyboard keys used to control the forward move of the camera.
  103297. */
  103298. keysForward: number[];
  103299. /**
  103300. * The list of keyboard keys used to control the backward move of the camera.
  103301. */
  103302. keysBackward: number[];
  103303. /**
  103304. * The list of keyboard keys used to control the forward move of the camera.
  103305. */
  103306. keysUp: number[];
  103307. /**
  103308. * The list of keyboard keys used to control the backward move of the camera.
  103309. */
  103310. keysDown: number[];
  103311. /**
  103312. * The list of keyboard keys used to control the right strafe move of the camera.
  103313. */
  103314. keysRight: number[];
  103315. /**
  103316. * The list of keyboard keys used to control the left strafe move of the camera.
  103317. */
  103318. keysLeft: number[];
  103319. private _keys;
  103320. private _onCanvasBlurObserver;
  103321. private _onKeyboardObserver;
  103322. private _engine;
  103323. private _scene;
  103324. /**
  103325. * Attach the input controls to a specific dom element to get the input from.
  103326. * @param element Defines the element the controls should be listened from
  103327. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103328. */
  103329. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103330. /**
  103331. * Detach the current controls from the specified dom element.
  103332. * @param element Defines the element to stop listening the inputs from
  103333. */
  103334. detachControl(element: Nullable<HTMLElement>): void;
  103335. /**
  103336. * Gets the class name of the current intput.
  103337. * @returns the class name
  103338. */
  103339. getClassName(): string;
  103340. /** @hidden */
  103341. _onLostFocus(e: FocusEvent): void;
  103342. /**
  103343. * Get the friendly name associated with the input class.
  103344. * @returns the input friendly name
  103345. */
  103346. getSimpleName(): string;
  103347. /**
  103348. * Update the current camera state depending on the inputs that have been used this frame.
  103349. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103350. */
  103351. checkInputs(): void;
  103352. }
  103353. }
  103354. declare module BABYLON {
  103355. /**
  103356. * Manage the mouse wheel inputs to control a follow camera.
  103357. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103358. */
  103359. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  103360. /**
  103361. * Defines the camera the input is attached to.
  103362. */
  103363. camera: FollowCamera;
  103364. /**
  103365. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  103366. */
  103367. axisControlRadius: boolean;
  103368. /**
  103369. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  103370. */
  103371. axisControlHeight: boolean;
  103372. /**
  103373. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  103374. */
  103375. axisControlRotation: boolean;
  103376. /**
  103377. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  103378. * relation to mouseWheel events.
  103379. */
  103380. wheelPrecision: number;
  103381. /**
  103382. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  103383. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  103384. */
  103385. wheelDeltaPercentage: number;
  103386. private _wheel;
  103387. private _observer;
  103388. /**
  103389. * Attach the input controls to a specific dom element to get the input from.
  103390. * @param element Defines the element the controls should be listened from
  103391. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103392. */
  103393. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103394. /**
  103395. * Detach the current controls from the specified dom element.
  103396. * @param element Defines the element to stop listening the inputs from
  103397. */
  103398. detachControl(element: Nullable<HTMLElement>): void;
  103399. /**
  103400. * Gets the class name of the current intput.
  103401. * @returns the class name
  103402. */
  103403. getClassName(): string;
  103404. /**
  103405. * Get the friendly name associated with the input class.
  103406. * @returns the input friendly name
  103407. */
  103408. getSimpleName(): string;
  103409. }
  103410. }
  103411. declare module BABYLON {
  103412. /**
  103413. * Manage the pointers inputs to control an follow camera.
  103414. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103415. */
  103416. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  103417. /**
  103418. * Defines the camera the input is attached to.
  103419. */
  103420. camera: FollowCamera;
  103421. /**
  103422. * Gets the class name of the current input.
  103423. * @returns the class name
  103424. */
  103425. getClassName(): string;
  103426. /**
  103427. * Defines the pointer angular sensibility along the X axis or how fast is
  103428. * the camera rotating.
  103429. * A negative number will reverse the axis direction.
  103430. */
  103431. angularSensibilityX: number;
  103432. /**
  103433. * Defines the pointer angular sensibility along the Y axis or how fast is
  103434. * the camera rotating.
  103435. * A negative number will reverse the axis direction.
  103436. */
  103437. angularSensibilityY: number;
  103438. /**
  103439. * Defines the pointer pinch precision or how fast is the camera zooming.
  103440. * A negative number will reverse the axis direction.
  103441. */
  103442. pinchPrecision: number;
  103443. /**
  103444. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  103445. * from 0.
  103446. * It defines the percentage of current camera.radius to use as delta when
  103447. * pinch zoom is used.
  103448. */
  103449. pinchDeltaPercentage: number;
  103450. /**
  103451. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  103452. */
  103453. axisXControlRadius: boolean;
  103454. /**
  103455. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  103456. */
  103457. axisXControlHeight: boolean;
  103458. /**
  103459. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  103460. */
  103461. axisXControlRotation: boolean;
  103462. /**
  103463. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  103464. */
  103465. axisYControlRadius: boolean;
  103466. /**
  103467. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  103468. */
  103469. axisYControlHeight: boolean;
  103470. /**
  103471. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  103472. */
  103473. axisYControlRotation: boolean;
  103474. /**
  103475. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  103476. */
  103477. axisPinchControlRadius: boolean;
  103478. /**
  103479. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  103480. */
  103481. axisPinchControlHeight: boolean;
  103482. /**
  103483. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  103484. */
  103485. axisPinchControlRotation: boolean;
  103486. /**
  103487. * Log error messages if basic misconfiguration has occurred.
  103488. */
  103489. warningEnable: boolean;
  103490. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  103491. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  103492. private _warningCounter;
  103493. private _warning;
  103494. }
  103495. }
  103496. declare module BABYLON {
  103497. /**
  103498. * Default Inputs manager for the FollowCamera.
  103499. * It groups all the default supported inputs for ease of use.
  103500. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103501. */
  103502. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  103503. /**
  103504. * Instantiates a new FollowCameraInputsManager.
  103505. * @param camera Defines the camera the inputs belong to
  103506. */
  103507. constructor(camera: FollowCamera);
  103508. /**
  103509. * Add keyboard input support to the input manager.
  103510. * @returns the current input manager
  103511. */
  103512. addKeyboard(): FollowCameraInputsManager;
  103513. /**
  103514. * Add mouse wheel input support to the input manager.
  103515. * @returns the current input manager
  103516. */
  103517. addMouseWheel(): FollowCameraInputsManager;
  103518. /**
  103519. * Add pointers input support to the input manager.
  103520. * @returns the current input manager
  103521. */
  103522. addPointers(): FollowCameraInputsManager;
  103523. /**
  103524. * Add orientation input support to the input manager.
  103525. * @returns the current input manager
  103526. */
  103527. addVRDeviceOrientation(): FollowCameraInputsManager;
  103528. }
  103529. }
  103530. declare module BABYLON {
  103531. /**
  103532. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  103533. * an arc rotate version arcFollowCamera are available.
  103534. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103535. */
  103536. export class FollowCamera extends TargetCamera {
  103537. /**
  103538. * Distance the follow camera should follow an object at
  103539. */
  103540. radius: number;
  103541. /**
  103542. * Minimum allowed distance of the camera to the axis of rotation
  103543. * (The camera can not get closer).
  103544. * This can help limiting how the Camera is able to move in the scene.
  103545. */
  103546. lowerRadiusLimit: Nullable<number>;
  103547. /**
  103548. * Maximum allowed distance of the camera to the axis of rotation
  103549. * (The camera can not get further).
  103550. * This can help limiting how the Camera is able to move in the scene.
  103551. */
  103552. upperRadiusLimit: Nullable<number>;
  103553. /**
  103554. * Define a rotation offset between the camera and the object it follows
  103555. */
  103556. rotationOffset: number;
  103557. /**
  103558. * Minimum allowed angle to camera position relative to target object.
  103559. * This can help limiting how the Camera is able to move in the scene.
  103560. */
  103561. lowerRotationOffsetLimit: Nullable<number>;
  103562. /**
  103563. * Maximum allowed angle to camera position relative to target object.
  103564. * This can help limiting how the Camera is able to move in the scene.
  103565. */
  103566. upperRotationOffsetLimit: Nullable<number>;
  103567. /**
  103568. * Define a height offset between the camera and the object it follows.
  103569. * It can help following an object from the top (like a car chaing a plane)
  103570. */
  103571. heightOffset: number;
  103572. /**
  103573. * Minimum allowed height of camera position relative to target object.
  103574. * This can help limiting how the Camera is able to move in the scene.
  103575. */
  103576. lowerHeightOffsetLimit: Nullable<number>;
  103577. /**
  103578. * Maximum allowed height of camera position relative to target object.
  103579. * This can help limiting how the Camera is able to move in the scene.
  103580. */
  103581. upperHeightOffsetLimit: Nullable<number>;
  103582. /**
  103583. * Define how fast the camera can accelerate to follow it s target.
  103584. */
  103585. cameraAcceleration: number;
  103586. /**
  103587. * Define the speed limit of the camera following an object.
  103588. */
  103589. maxCameraSpeed: number;
  103590. /**
  103591. * Define the target of the camera.
  103592. */
  103593. lockedTarget: Nullable<AbstractMesh>;
  103594. /**
  103595. * Defines the input associated with the camera.
  103596. */
  103597. inputs: FollowCameraInputsManager;
  103598. /**
  103599. * Instantiates the follow camera.
  103600. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103601. * @param name Define the name of the camera in the scene
  103602. * @param position Define the position of the camera
  103603. * @param scene Define the scene the camera belong to
  103604. * @param lockedTarget Define the target of the camera
  103605. */
  103606. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  103607. private _follow;
  103608. /**
  103609. * Attached controls to the current camera.
  103610. * @param element Defines the element the controls should be listened from
  103611. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103612. */
  103613. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103614. /**
  103615. * Detach the current controls from the camera.
  103616. * The camera will stop reacting to inputs.
  103617. * @param element Defines the element to stop listening the inputs from
  103618. */
  103619. detachControl(element: HTMLElement): void;
  103620. /** @hidden */
  103621. _checkInputs(): void;
  103622. private _checkLimits;
  103623. /**
  103624. * Gets the camera class name.
  103625. * @returns the class name
  103626. */
  103627. getClassName(): string;
  103628. }
  103629. /**
  103630. * Arc Rotate version of the follow camera.
  103631. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  103632. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103633. */
  103634. export class ArcFollowCamera extends TargetCamera {
  103635. /** The longitudinal angle of the camera */
  103636. alpha: number;
  103637. /** The latitudinal angle of the camera */
  103638. beta: number;
  103639. /** The radius of the camera from its target */
  103640. radius: number;
  103641. /** Define the camera target (the messh it should follow) */
  103642. target: Nullable<AbstractMesh>;
  103643. private _cartesianCoordinates;
  103644. /**
  103645. * Instantiates a new ArcFollowCamera
  103646. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103647. * @param name Define the name of the camera
  103648. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  103649. * @param beta Define the rotation angle of the camera around the elevation axis
  103650. * @param radius Define the radius of the camera from its target point
  103651. * @param target Define the target of the camera
  103652. * @param scene Define the scene the camera belongs to
  103653. */
  103654. constructor(name: string,
  103655. /** The longitudinal angle of the camera */
  103656. alpha: number,
  103657. /** The latitudinal angle of the camera */
  103658. beta: number,
  103659. /** The radius of the camera from its target */
  103660. radius: number,
  103661. /** Define the camera target (the messh it should follow) */
  103662. target: Nullable<AbstractMesh>, scene: Scene);
  103663. private _follow;
  103664. /** @hidden */
  103665. _checkInputs(): void;
  103666. /**
  103667. * Returns the class name of the object.
  103668. * It is mostly used internally for serialization purposes.
  103669. */
  103670. getClassName(): string;
  103671. }
  103672. }
  103673. declare module BABYLON {
  103674. /**
  103675. * Manage the keyboard inputs to control the movement of a follow camera.
  103676. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103677. */
  103678. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  103679. /**
  103680. * Defines the camera the input is attached to.
  103681. */
  103682. camera: FollowCamera;
  103683. /**
  103684. * Defines the list of key codes associated with the up action (increase heightOffset)
  103685. */
  103686. keysHeightOffsetIncr: number[];
  103687. /**
  103688. * Defines the list of key codes associated with the down action (decrease heightOffset)
  103689. */
  103690. keysHeightOffsetDecr: number[];
  103691. /**
  103692. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  103693. */
  103694. keysHeightOffsetModifierAlt: boolean;
  103695. /**
  103696. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  103697. */
  103698. keysHeightOffsetModifierCtrl: boolean;
  103699. /**
  103700. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  103701. */
  103702. keysHeightOffsetModifierShift: boolean;
  103703. /**
  103704. * Defines the list of key codes associated with the left action (increase rotationOffset)
  103705. */
  103706. keysRotationOffsetIncr: number[];
  103707. /**
  103708. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  103709. */
  103710. keysRotationOffsetDecr: number[];
  103711. /**
  103712. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  103713. */
  103714. keysRotationOffsetModifierAlt: boolean;
  103715. /**
  103716. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  103717. */
  103718. keysRotationOffsetModifierCtrl: boolean;
  103719. /**
  103720. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  103721. */
  103722. keysRotationOffsetModifierShift: boolean;
  103723. /**
  103724. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  103725. */
  103726. keysRadiusIncr: number[];
  103727. /**
  103728. * Defines the list of key codes associated with the zoom-out action (increase radius)
  103729. */
  103730. keysRadiusDecr: number[];
  103731. /**
  103732. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  103733. */
  103734. keysRadiusModifierAlt: boolean;
  103735. /**
  103736. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  103737. */
  103738. keysRadiusModifierCtrl: boolean;
  103739. /**
  103740. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  103741. */
  103742. keysRadiusModifierShift: boolean;
  103743. /**
  103744. * Defines the rate of change of heightOffset.
  103745. */
  103746. heightSensibility: number;
  103747. /**
  103748. * Defines the rate of change of rotationOffset.
  103749. */
  103750. rotationSensibility: number;
  103751. /**
  103752. * Defines the rate of change of radius.
  103753. */
  103754. radiusSensibility: number;
  103755. private _keys;
  103756. private _ctrlPressed;
  103757. private _altPressed;
  103758. private _shiftPressed;
  103759. private _onCanvasBlurObserver;
  103760. private _onKeyboardObserver;
  103761. private _engine;
  103762. private _scene;
  103763. /**
  103764. * Attach the input controls to a specific dom element to get the input from.
  103765. * @param element Defines the element the controls should be listened from
  103766. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103767. */
  103768. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103769. /**
  103770. * Detach the current controls from the specified dom element.
  103771. * @param element Defines the element to stop listening the inputs from
  103772. */
  103773. detachControl(element: Nullable<HTMLElement>): void;
  103774. /**
  103775. * Update the current camera state depending on the inputs that have been used this frame.
  103776. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103777. */
  103778. checkInputs(): void;
  103779. /**
  103780. * Gets the class name of the current input.
  103781. * @returns the class name
  103782. */
  103783. getClassName(): string;
  103784. /**
  103785. * Get the friendly name associated with the input class.
  103786. * @returns the input friendly name
  103787. */
  103788. getSimpleName(): string;
  103789. /**
  103790. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  103791. * allow modification of the heightOffset value.
  103792. */
  103793. private _modifierHeightOffset;
  103794. /**
  103795. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  103796. * allow modification of the rotationOffset value.
  103797. */
  103798. private _modifierRotationOffset;
  103799. /**
  103800. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  103801. * allow modification of the radius value.
  103802. */
  103803. private _modifierRadius;
  103804. }
  103805. }
  103806. declare module BABYLON {
  103807. interface FreeCameraInputsManager {
  103808. /**
  103809. * @hidden
  103810. */
  103811. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  103812. /**
  103813. * Add orientation input support to the input manager.
  103814. * @returns the current input manager
  103815. */
  103816. addDeviceOrientation(): FreeCameraInputsManager;
  103817. }
  103818. /**
  103819. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  103820. * Screen rotation is taken into account.
  103821. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103822. */
  103823. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  103824. private _camera;
  103825. private _screenOrientationAngle;
  103826. private _constantTranform;
  103827. private _screenQuaternion;
  103828. private _alpha;
  103829. private _beta;
  103830. private _gamma;
  103831. /**
  103832. * Can be used to detect if a device orientation sensor is availible on a device
  103833. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  103834. * @returns a promise that will resolve on orientation change
  103835. */
  103836. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  103837. /**
  103838. * @hidden
  103839. */
  103840. _onDeviceOrientationChangedObservable: Observable<void>;
  103841. /**
  103842. * Instantiates a new input
  103843. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103844. */
  103845. constructor();
  103846. /**
  103847. * Define the camera controlled by the input.
  103848. */
  103849. camera: FreeCamera;
  103850. /**
  103851. * Attach the input controls to a specific dom element to get the input from.
  103852. * @param element Defines the element the controls should be listened from
  103853. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103854. */
  103855. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103856. private _orientationChanged;
  103857. private _deviceOrientation;
  103858. /**
  103859. * Detach the current controls from the specified dom element.
  103860. * @param element Defines the element to stop listening the inputs from
  103861. */
  103862. detachControl(element: Nullable<HTMLElement>): void;
  103863. /**
  103864. * Update the current camera state depending on the inputs that have been used this frame.
  103865. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103866. */
  103867. checkInputs(): void;
  103868. /**
  103869. * Gets the class name of the current intput.
  103870. * @returns the class name
  103871. */
  103872. getClassName(): string;
  103873. /**
  103874. * Get the friendly name associated with the input class.
  103875. * @returns the input friendly name
  103876. */
  103877. getSimpleName(): string;
  103878. }
  103879. }
  103880. declare module BABYLON {
  103881. /**
  103882. * Manage the gamepad inputs to control a free camera.
  103883. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103884. */
  103885. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  103886. /**
  103887. * Define the camera the input is attached to.
  103888. */
  103889. camera: FreeCamera;
  103890. /**
  103891. * Define the Gamepad controlling the input
  103892. */
  103893. gamepad: Nullable<Gamepad>;
  103894. /**
  103895. * Defines the gamepad rotation sensiblity.
  103896. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  103897. */
  103898. gamepadAngularSensibility: number;
  103899. /**
  103900. * Defines the gamepad move sensiblity.
  103901. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  103902. */
  103903. gamepadMoveSensibility: number;
  103904. private _onGamepadConnectedObserver;
  103905. private _onGamepadDisconnectedObserver;
  103906. private _cameraTransform;
  103907. private _deltaTransform;
  103908. private _vector3;
  103909. private _vector2;
  103910. /**
  103911. * Attach the input controls to a specific dom element to get the input from.
  103912. * @param element Defines the element the controls should be listened from
  103913. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103914. */
  103915. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103916. /**
  103917. * Detach the current controls from the specified dom element.
  103918. * @param element Defines the element to stop listening the inputs from
  103919. */
  103920. detachControl(element: Nullable<HTMLElement>): void;
  103921. /**
  103922. * Update the current camera state depending on the inputs that have been used this frame.
  103923. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103924. */
  103925. checkInputs(): void;
  103926. /**
  103927. * Gets the class name of the current intput.
  103928. * @returns the class name
  103929. */
  103930. getClassName(): string;
  103931. /**
  103932. * Get the friendly name associated with the input class.
  103933. * @returns the input friendly name
  103934. */
  103935. getSimpleName(): string;
  103936. }
  103937. }
  103938. declare module BABYLON {
  103939. /**
  103940. * Defines the potential axis of a Joystick
  103941. */
  103942. export enum JoystickAxis {
  103943. /** X axis */
  103944. X = 0,
  103945. /** Y axis */
  103946. Y = 1,
  103947. /** Z axis */
  103948. Z = 2
  103949. }
  103950. /**
  103951. * Class used to define virtual joystick (used in touch mode)
  103952. */
  103953. export class VirtualJoystick {
  103954. /**
  103955. * Gets or sets a boolean indicating that left and right values must be inverted
  103956. */
  103957. reverseLeftRight: boolean;
  103958. /**
  103959. * Gets or sets a boolean indicating that up and down values must be inverted
  103960. */
  103961. reverseUpDown: boolean;
  103962. /**
  103963. * Gets the offset value for the position (ie. the change of the position value)
  103964. */
  103965. deltaPosition: Vector3;
  103966. /**
  103967. * Gets a boolean indicating if the virtual joystick was pressed
  103968. */
  103969. pressed: boolean;
  103970. /**
  103971. * Canvas the virtual joystick will render onto, default z-index of this is 5
  103972. */
  103973. static Canvas: Nullable<HTMLCanvasElement>;
  103974. private static _globalJoystickIndex;
  103975. private static vjCanvasContext;
  103976. private static vjCanvasWidth;
  103977. private static vjCanvasHeight;
  103978. private static halfWidth;
  103979. private _action;
  103980. private _axisTargetedByLeftAndRight;
  103981. private _axisTargetedByUpAndDown;
  103982. private _joystickSensibility;
  103983. private _inversedSensibility;
  103984. private _joystickPointerID;
  103985. private _joystickColor;
  103986. private _joystickPointerPos;
  103987. private _joystickPreviousPointerPos;
  103988. private _joystickPointerStartPos;
  103989. private _deltaJoystickVector;
  103990. private _leftJoystick;
  103991. private _touches;
  103992. private _onPointerDownHandlerRef;
  103993. private _onPointerMoveHandlerRef;
  103994. private _onPointerUpHandlerRef;
  103995. private _onResize;
  103996. /**
  103997. * Creates a new virtual joystick
  103998. * @param leftJoystick defines that the joystick is for left hand (false by default)
  103999. */
  104000. constructor(leftJoystick?: boolean);
  104001. /**
  104002. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  104003. * @param newJoystickSensibility defines the new sensibility
  104004. */
  104005. setJoystickSensibility(newJoystickSensibility: number): void;
  104006. private _onPointerDown;
  104007. private _onPointerMove;
  104008. private _onPointerUp;
  104009. /**
  104010. * Change the color of the virtual joystick
  104011. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  104012. */
  104013. setJoystickColor(newColor: string): void;
  104014. /**
  104015. * Defines a callback to call when the joystick is touched
  104016. * @param action defines the callback
  104017. */
  104018. setActionOnTouch(action: () => any): void;
  104019. /**
  104020. * Defines which axis you'd like to control for left & right
  104021. * @param axis defines the axis to use
  104022. */
  104023. setAxisForLeftRight(axis: JoystickAxis): void;
  104024. /**
  104025. * Defines which axis you'd like to control for up & down
  104026. * @param axis defines the axis to use
  104027. */
  104028. setAxisForUpDown(axis: JoystickAxis): void;
  104029. private _drawVirtualJoystick;
  104030. /**
  104031. * Release internal HTML canvas
  104032. */
  104033. releaseCanvas(): void;
  104034. }
  104035. }
  104036. declare module BABYLON {
  104037. interface FreeCameraInputsManager {
  104038. /**
  104039. * Add virtual joystick input support to the input manager.
  104040. * @returns the current input manager
  104041. */
  104042. addVirtualJoystick(): FreeCameraInputsManager;
  104043. }
  104044. /**
  104045. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  104046. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104047. */
  104048. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  104049. /**
  104050. * Defines the camera the input is attached to.
  104051. */
  104052. camera: FreeCamera;
  104053. private _leftjoystick;
  104054. private _rightjoystick;
  104055. /**
  104056. * Gets the left stick of the virtual joystick.
  104057. * @returns The virtual Joystick
  104058. */
  104059. getLeftJoystick(): VirtualJoystick;
  104060. /**
  104061. * Gets the right stick of the virtual joystick.
  104062. * @returns The virtual Joystick
  104063. */
  104064. getRightJoystick(): VirtualJoystick;
  104065. /**
  104066. * Update the current camera state depending on the inputs that have been used this frame.
  104067. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104068. */
  104069. checkInputs(): void;
  104070. /**
  104071. * Attach the input controls to a specific dom element to get the input from.
  104072. * @param element Defines the element the controls should be listened from
  104073. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104074. */
  104075. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104076. /**
  104077. * Detach the current controls from the specified dom element.
  104078. * @param element Defines the element to stop listening the inputs from
  104079. */
  104080. detachControl(element: Nullable<HTMLElement>): void;
  104081. /**
  104082. * Gets the class name of the current intput.
  104083. * @returns the class name
  104084. */
  104085. getClassName(): string;
  104086. /**
  104087. * Get the friendly name associated with the input class.
  104088. * @returns the input friendly name
  104089. */
  104090. getSimpleName(): string;
  104091. }
  104092. }
  104093. declare module BABYLON {
  104094. /**
  104095. * This represents a FPS type of camera controlled by touch.
  104096. * This is like a universal camera minus the Gamepad controls.
  104097. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104098. */
  104099. export class TouchCamera extends FreeCamera {
  104100. /**
  104101. * Defines the touch sensibility for rotation.
  104102. * The higher the faster.
  104103. */
  104104. touchAngularSensibility: number;
  104105. /**
  104106. * Defines the touch sensibility for move.
  104107. * The higher the faster.
  104108. */
  104109. touchMoveSensibility: number;
  104110. /**
  104111. * Instantiates a new touch camera.
  104112. * This represents a FPS type of camera controlled by touch.
  104113. * This is like a universal camera minus the Gamepad controls.
  104114. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104115. * @param name Define the name of the camera in the scene
  104116. * @param position Define the start position of the camera in the scene
  104117. * @param scene Define the scene the camera belongs to
  104118. */
  104119. constructor(name: string, position: Vector3, scene: Scene);
  104120. /**
  104121. * Gets the current object class name.
  104122. * @return the class name
  104123. */
  104124. getClassName(): string;
  104125. /** @hidden */
  104126. _setupInputs(): void;
  104127. }
  104128. }
  104129. declare module BABYLON {
  104130. /**
  104131. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  104132. * being tilted forward or back and left or right.
  104133. */
  104134. export class DeviceOrientationCamera extends FreeCamera {
  104135. private _initialQuaternion;
  104136. private _quaternionCache;
  104137. private _tmpDragQuaternion;
  104138. private _disablePointerInputWhenUsingDeviceOrientation;
  104139. /**
  104140. * Creates a new device orientation camera
  104141. * @param name The name of the camera
  104142. * @param position The start position camera
  104143. * @param scene The scene the camera belongs to
  104144. */
  104145. constructor(name: string, position: Vector3, scene: Scene);
  104146. /**
  104147. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  104148. */
  104149. disablePointerInputWhenUsingDeviceOrientation: boolean;
  104150. private _dragFactor;
  104151. /**
  104152. * Enabled turning on the y axis when the orientation sensor is active
  104153. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  104154. */
  104155. enableHorizontalDragging(dragFactor?: number): void;
  104156. /**
  104157. * Gets the current instance class name ("DeviceOrientationCamera").
  104158. * This helps avoiding instanceof at run time.
  104159. * @returns the class name
  104160. */
  104161. getClassName(): string;
  104162. /**
  104163. * @hidden
  104164. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  104165. */
  104166. _checkInputs(): void;
  104167. /**
  104168. * Reset the camera to its default orientation on the specified axis only.
  104169. * @param axis The axis to reset
  104170. */
  104171. resetToCurrentRotation(axis?: Axis): void;
  104172. }
  104173. }
  104174. declare module BABYLON {
  104175. /**
  104176. * Defines supported buttons for XBox360 compatible gamepads
  104177. */
  104178. export enum Xbox360Button {
  104179. /** A */
  104180. A = 0,
  104181. /** B */
  104182. B = 1,
  104183. /** X */
  104184. X = 2,
  104185. /** Y */
  104186. Y = 3,
  104187. /** Start */
  104188. Start = 4,
  104189. /** Back */
  104190. Back = 5,
  104191. /** Left button */
  104192. LB = 6,
  104193. /** Right button */
  104194. RB = 7,
  104195. /** Left stick */
  104196. LeftStick = 8,
  104197. /** Right stick */
  104198. RightStick = 9
  104199. }
  104200. /** Defines values for XBox360 DPad */
  104201. export enum Xbox360Dpad {
  104202. /** Up */
  104203. Up = 0,
  104204. /** Down */
  104205. Down = 1,
  104206. /** Left */
  104207. Left = 2,
  104208. /** Right */
  104209. Right = 3
  104210. }
  104211. /**
  104212. * Defines a XBox360 gamepad
  104213. */
  104214. export class Xbox360Pad extends Gamepad {
  104215. private _leftTrigger;
  104216. private _rightTrigger;
  104217. private _onlefttriggerchanged;
  104218. private _onrighttriggerchanged;
  104219. private _onbuttondown;
  104220. private _onbuttonup;
  104221. private _ondpaddown;
  104222. private _ondpadup;
  104223. /** Observable raised when a button is pressed */
  104224. onButtonDownObservable: Observable<Xbox360Button>;
  104225. /** Observable raised when a button is released */
  104226. onButtonUpObservable: Observable<Xbox360Button>;
  104227. /** Observable raised when a pad is pressed */
  104228. onPadDownObservable: Observable<Xbox360Dpad>;
  104229. /** Observable raised when a pad is released */
  104230. onPadUpObservable: Observable<Xbox360Dpad>;
  104231. private _buttonA;
  104232. private _buttonB;
  104233. private _buttonX;
  104234. private _buttonY;
  104235. private _buttonBack;
  104236. private _buttonStart;
  104237. private _buttonLB;
  104238. private _buttonRB;
  104239. private _buttonLeftStick;
  104240. private _buttonRightStick;
  104241. private _dPadUp;
  104242. private _dPadDown;
  104243. private _dPadLeft;
  104244. private _dPadRight;
  104245. private _isXboxOnePad;
  104246. /**
  104247. * Creates a new XBox360 gamepad object
  104248. * @param id defines the id of this gamepad
  104249. * @param index defines its index
  104250. * @param gamepad defines the internal HTML gamepad object
  104251. * @param xboxOne defines if it is a XBox One gamepad
  104252. */
  104253. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  104254. /**
  104255. * Defines the callback to call when left trigger is pressed
  104256. * @param callback defines the callback to use
  104257. */
  104258. onlefttriggerchanged(callback: (value: number) => void): void;
  104259. /**
  104260. * Defines the callback to call when right trigger is pressed
  104261. * @param callback defines the callback to use
  104262. */
  104263. onrighttriggerchanged(callback: (value: number) => void): void;
  104264. /**
  104265. * Gets the left trigger value
  104266. */
  104267. /**
  104268. * Sets the left trigger value
  104269. */
  104270. leftTrigger: number;
  104271. /**
  104272. * Gets the right trigger value
  104273. */
  104274. /**
  104275. * Sets the right trigger value
  104276. */
  104277. rightTrigger: number;
  104278. /**
  104279. * Defines the callback to call when a button is pressed
  104280. * @param callback defines the callback to use
  104281. */
  104282. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  104283. /**
  104284. * Defines the callback to call when a button is released
  104285. * @param callback defines the callback to use
  104286. */
  104287. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  104288. /**
  104289. * Defines the callback to call when a pad is pressed
  104290. * @param callback defines the callback to use
  104291. */
  104292. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  104293. /**
  104294. * Defines the callback to call when a pad is released
  104295. * @param callback defines the callback to use
  104296. */
  104297. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  104298. private _setButtonValue;
  104299. private _setDPadValue;
  104300. /**
  104301. * Gets the value of the `A` button
  104302. */
  104303. /**
  104304. * Sets the value of the `A` button
  104305. */
  104306. buttonA: number;
  104307. /**
  104308. * Gets the value of the `B` button
  104309. */
  104310. /**
  104311. * Sets the value of the `B` button
  104312. */
  104313. buttonB: number;
  104314. /**
  104315. * Gets the value of the `X` button
  104316. */
  104317. /**
  104318. * Sets the value of the `X` button
  104319. */
  104320. buttonX: number;
  104321. /**
  104322. * Gets the value of the `Y` button
  104323. */
  104324. /**
  104325. * Sets the value of the `Y` button
  104326. */
  104327. buttonY: number;
  104328. /**
  104329. * Gets the value of the `Start` button
  104330. */
  104331. /**
  104332. * Sets the value of the `Start` button
  104333. */
  104334. buttonStart: number;
  104335. /**
  104336. * Gets the value of the `Back` button
  104337. */
  104338. /**
  104339. * Sets the value of the `Back` button
  104340. */
  104341. buttonBack: number;
  104342. /**
  104343. * Gets the value of the `Left` button
  104344. */
  104345. /**
  104346. * Sets the value of the `Left` button
  104347. */
  104348. buttonLB: number;
  104349. /**
  104350. * Gets the value of the `Right` button
  104351. */
  104352. /**
  104353. * Sets the value of the `Right` button
  104354. */
  104355. buttonRB: number;
  104356. /**
  104357. * Gets the value of the Left joystick
  104358. */
  104359. /**
  104360. * Sets the value of the Left joystick
  104361. */
  104362. buttonLeftStick: number;
  104363. /**
  104364. * Gets the value of the Right joystick
  104365. */
  104366. /**
  104367. * Sets the value of the Right joystick
  104368. */
  104369. buttonRightStick: number;
  104370. /**
  104371. * Gets the value of D-pad up
  104372. */
  104373. /**
  104374. * Sets the value of D-pad up
  104375. */
  104376. dPadUp: number;
  104377. /**
  104378. * Gets the value of D-pad down
  104379. */
  104380. /**
  104381. * Sets the value of D-pad down
  104382. */
  104383. dPadDown: number;
  104384. /**
  104385. * Gets the value of D-pad left
  104386. */
  104387. /**
  104388. * Sets the value of D-pad left
  104389. */
  104390. dPadLeft: number;
  104391. /**
  104392. * Gets the value of D-pad right
  104393. */
  104394. /**
  104395. * Sets the value of D-pad right
  104396. */
  104397. dPadRight: number;
  104398. /**
  104399. * Force the gamepad to synchronize with device values
  104400. */
  104401. update(): void;
  104402. /**
  104403. * Disposes the gamepad
  104404. */
  104405. dispose(): void;
  104406. }
  104407. }
  104408. declare module BABYLON {
  104409. /**
  104410. * Defines supported buttons for DualShock compatible gamepads
  104411. */
  104412. export enum DualShockButton {
  104413. /** Cross */
  104414. Cross = 0,
  104415. /** Circle */
  104416. Circle = 1,
  104417. /** Square */
  104418. Square = 2,
  104419. /** Triangle */
  104420. Triangle = 3,
  104421. /** Options */
  104422. Options = 4,
  104423. /** Share */
  104424. Share = 5,
  104425. /** L1 */
  104426. L1 = 6,
  104427. /** R1 */
  104428. R1 = 7,
  104429. /** Left stick */
  104430. LeftStick = 8,
  104431. /** Right stick */
  104432. RightStick = 9
  104433. }
  104434. /** Defines values for DualShock DPad */
  104435. export enum DualShockDpad {
  104436. /** Up */
  104437. Up = 0,
  104438. /** Down */
  104439. Down = 1,
  104440. /** Left */
  104441. Left = 2,
  104442. /** Right */
  104443. Right = 3
  104444. }
  104445. /**
  104446. * Defines a DualShock gamepad
  104447. */
  104448. export class DualShockPad extends Gamepad {
  104449. private _leftTrigger;
  104450. private _rightTrigger;
  104451. private _onlefttriggerchanged;
  104452. private _onrighttriggerchanged;
  104453. private _onbuttondown;
  104454. private _onbuttonup;
  104455. private _ondpaddown;
  104456. private _ondpadup;
  104457. /** Observable raised when a button is pressed */
  104458. onButtonDownObservable: Observable<DualShockButton>;
  104459. /** Observable raised when a button is released */
  104460. onButtonUpObservable: Observable<DualShockButton>;
  104461. /** Observable raised when a pad is pressed */
  104462. onPadDownObservable: Observable<DualShockDpad>;
  104463. /** Observable raised when a pad is released */
  104464. onPadUpObservable: Observable<DualShockDpad>;
  104465. private _buttonCross;
  104466. private _buttonCircle;
  104467. private _buttonSquare;
  104468. private _buttonTriangle;
  104469. private _buttonShare;
  104470. private _buttonOptions;
  104471. private _buttonL1;
  104472. private _buttonR1;
  104473. private _buttonLeftStick;
  104474. private _buttonRightStick;
  104475. private _dPadUp;
  104476. private _dPadDown;
  104477. private _dPadLeft;
  104478. private _dPadRight;
  104479. /**
  104480. * Creates a new DualShock gamepad object
  104481. * @param id defines the id of this gamepad
  104482. * @param index defines its index
  104483. * @param gamepad defines the internal HTML gamepad object
  104484. */
  104485. constructor(id: string, index: number, gamepad: any);
  104486. /**
  104487. * Defines the callback to call when left trigger is pressed
  104488. * @param callback defines the callback to use
  104489. */
  104490. onlefttriggerchanged(callback: (value: number) => void): void;
  104491. /**
  104492. * Defines the callback to call when right trigger is pressed
  104493. * @param callback defines the callback to use
  104494. */
  104495. onrighttriggerchanged(callback: (value: number) => void): void;
  104496. /**
  104497. * Gets the left trigger value
  104498. */
  104499. /**
  104500. * Sets the left trigger value
  104501. */
  104502. leftTrigger: number;
  104503. /**
  104504. * Gets the right trigger value
  104505. */
  104506. /**
  104507. * Sets the right trigger value
  104508. */
  104509. rightTrigger: number;
  104510. /**
  104511. * Defines the callback to call when a button is pressed
  104512. * @param callback defines the callback to use
  104513. */
  104514. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  104515. /**
  104516. * Defines the callback to call when a button is released
  104517. * @param callback defines the callback to use
  104518. */
  104519. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  104520. /**
  104521. * Defines the callback to call when a pad is pressed
  104522. * @param callback defines the callback to use
  104523. */
  104524. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  104525. /**
  104526. * Defines the callback to call when a pad is released
  104527. * @param callback defines the callback to use
  104528. */
  104529. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  104530. private _setButtonValue;
  104531. private _setDPadValue;
  104532. /**
  104533. * Gets the value of the `Cross` button
  104534. */
  104535. /**
  104536. * Sets the value of the `Cross` button
  104537. */
  104538. buttonCross: number;
  104539. /**
  104540. * Gets the value of the `Circle` button
  104541. */
  104542. /**
  104543. * Sets the value of the `Circle` button
  104544. */
  104545. buttonCircle: number;
  104546. /**
  104547. * Gets the value of the `Square` button
  104548. */
  104549. /**
  104550. * Sets the value of the `Square` button
  104551. */
  104552. buttonSquare: number;
  104553. /**
  104554. * Gets the value of the `Triangle` button
  104555. */
  104556. /**
  104557. * Sets the value of the `Triangle` button
  104558. */
  104559. buttonTriangle: number;
  104560. /**
  104561. * Gets the value of the `Options` button
  104562. */
  104563. /**
  104564. * Sets the value of the `Options` button
  104565. */
  104566. buttonOptions: number;
  104567. /**
  104568. * Gets the value of the `Share` button
  104569. */
  104570. /**
  104571. * Sets the value of the `Share` button
  104572. */
  104573. buttonShare: number;
  104574. /**
  104575. * Gets the value of the `L1` button
  104576. */
  104577. /**
  104578. * Sets the value of the `L1` button
  104579. */
  104580. buttonL1: number;
  104581. /**
  104582. * Gets the value of the `R1` button
  104583. */
  104584. /**
  104585. * Sets the value of the `R1` button
  104586. */
  104587. buttonR1: number;
  104588. /**
  104589. * Gets the value of the Left joystick
  104590. */
  104591. /**
  104592. * Sets the value of the Left joystick
  104593. */
  104594. buttonLeftStick: number;
  104595. /**
  104596. * Gets the value of the Right joystick
  104597. */
  104598. /**
  104599. * Sets the value of the Right joystick
  104600. */
  104601. buttonRightStick: number;
  104602. /**
  104603. * Gets the value of D-pad up
  104604. */
  104605. /**
  104606. * Sets the value of D-pad up
  104607. */
  104608. dPadUp: number;
  104609. /**
  104610. * Gets the value of D-pad down
  104611. */
  104612. /**
  104613. * Sets the value of D-pad down
  104614. */
  104615. dPadDown: number;
  104616. /**
  104617. * Gets the value of D-pad left
  104618. */
  104619. /**
  104620. * Sets the value of D-pad left
  104621. */
  104622. dPadLeft: number;
  104623. /**
  104624. * Gets the value of D-pad right
  104625. */
  104626. /**
  104627. * Sets the value of D-pad right
  104628. */
  104629. dPadRight: number;
  104630. /**
  104631. * Force the gamepad to synchronize with device values
  104632. */
  104633. update(): void;
  104634. /**
  104635. * Disposes the gamepad
  104636. */
  104637. dispose(): void;
  104638. }
  104639. }
  104640. declare module BABYLON {
  104641. /**
  104642. * Manager for handling gamepads
  104643. */
  104644. export class GamepadManager {
  104645. private _scene?;
  104646. private _babylonGamepads;
  104647. private _oneGamepadConnected;
  104648. /** @hidden */
  104649. _isMonitoring: boolean;
  104650. private _gamepadEventSupported;
  104651. private _gamepadSupport;
  104652. /**
  104653. * observable to be triggered when the gamepad controller has been connected
  104654. */
  104655. onGamepadConnectedObservable: Observable<Gamepad>;
  104656. /**
  104657. * observable to be triggered when the gamepad controller has been disconnected
  104658. */
  104659. onGamepadDisconnectedObservable: Observable<Gamepad>;
  104660. private _onGamepadConnectedEvent;
  104661. private _onGamepadDisconnectedEvent;
  104662. /**
  104663. * Initializes the gamepad manager
  104664. * @param _scene BabylonJS scene
  104665. */
  104666. constructor(_scene?: Scene | undefined);
  104667. /**
  104668. * The gamepads in the game pad manager
  104669. */
  104670. readonly gamepads: Gamepad[];
  104671. /**
  104672. * Get the gamepad controllers based on type
  104673. * @param type The type of gamepad controller
  104674. * @returns Nullable gamepad
  104675. */
  104676. getGamepadByType(type?: number): Nullable<Gamepad>;
  104677. /**
  104678. * Disposes the gamepad manager
  104679. */
  104680. dispose(): void;
  104681. private _addNewGamepad;
  104682. private _startMonitoringGamepads;
  104683. private _stopMonitoringGamepads;
  104684. /** @hidden */
  104685. _checkGamepadsStatus(): void;
  104686. private _updateGamepadObjects;
  104687. }
  104688. }
  104689. declare module BABYLON {
  104690. interface Scene {
  104691. /** @hidden */
  104692. _gamepadManager: Nullable<GamepadManager>;
  104693. /**
  104694. * Gets the gamepad manager associated with the scene
  104695. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  104696. */
  104697. gamepadManager: GamepadManager;
  104698. }
  104699. /**
  104700. * Interface representing a free camera inputs manager
  104701. */
  104702. interface FreeCameraInputsManager {
  104703. /**
  104704. * Adds gamepad input support to the FreeCameraInputsManager.
  104705. * @returns the FreeCameraInputsManager
  104706. */
  104707. addGamepad(): FreeCameraInputsManager;
  104708. }
  104709. /**
  104710. * Interface representing an arc rotate camera inputs manager
  104711. */
  104712. interface ArcRotateCameraInputsManager {
  104713. /**
  104714. * Adds gamepad input support to the ArcRotateCamera InputManager.
  104715. * @returns the camera inputs manager
  104716. */
  104717. addGamepad(): ArcRotateCameraInputsManager;
  104718. }
  104719. /**
  104720. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  104721. */
  104722. export class GamepadSystemSceneComponent implements ISceneComponent {
  104723. /**
  104724. * The component name helpfull to identify the component in the list of scene components.
  104725. */
  104726. readonly name: string;
  104727. /**
  104728. * The scene the component belongs to.
  104729. */
  104730. scene: Scene;
  104731. /**
  104732. * Creates a new instance of the component for the given scene
  104733. * @param scene Defines the scene to register the component in
  104734. */
  104735. constructor(scene: Scene);
  104736. /**
  104737. * Registers the component in a given scene
  104738. */
  104739. register(): void;
  104740. /**
  104741. * Rebuilds the elements related to this component in case of
  104742. * context lost for instance.
  104743. */
  104744. rebuild(): void;
  104745. /**
  104746. * Disposes the component and the associated ressources
  104747. */
  104748. dispose(): void;
  104749. private _beforeCameraUpdate;
  104750. }
  104751. }
  104752. declare module BABYLON {
  104753. /**
  104754. * 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,
  104755. * which still works and will still be found in many Playgrounds.
  104756. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104757. */
  104758. export class UniversalCamera extends TouchCamera {
  104759. /**
  104760. * Defines the gamepad rotation sensiblity.
  104761. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104762. */
  104763. gamepadAngularSensibility: number;
  104764. /**
  104765. * Defines the gamepad move sensiblity.
  104766. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104767. */
  104768. gamepadMoveSensibility: number;
  104769. /**
  104770. * 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,
  104771. * which still works and will still be found in many Playgrounds.
  104772. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104773. * @param name Define the name of the camera in the scene
  104774. * @param position Define the start position of the camera in the scene
  104775. * @param scene Define the scene the camera belongs to
  104776. */
  104777. constructor(name: string, position: Vector3, scene: Scene);
  104778. /**
  104779. * Gets the current object class name.
  104780. * @return the class name
  104781. */
  104782. getClassName(): string;
  104783. }
  104784. }
  104785. declare module BABYLON {
  104786. /**
  104787. * This represents a FPS type of camera. This is only here for back compat purpose.
  104788. * Please use the UniversalCamera instead as both are identical.
  104789. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104790. */
  104791. export class GamepadCamera extends UniversalCamera {
  104792. /**
  104793. * Instantiates a new Gamepad Camera
  104794. * This represents a FPS type of camera. This is only here for back compat purpose.
  104795. * Please use the UniversalCamera instead as both are identical.
  104796. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104797. * @param name Define the name of the camera in the scene
  104798. * @param position Define the start position of the camera in the scene
  104799. * @param scene Define the scene the camera belongs to
  104800. */
  104801. constructor(name: string, position: Vector3, scene: Scene);
  104802. /**
  104803. * Gets the current object class name.
  104804. * @return the class name
  104805. */
  104806. getClassName(): string;
  104807. }
  104808. }
  104809. declare module BABYLON {
  104810. /** @hidden */
  104811. export var passPixelShader: {
  104812. name: string;
  104813. shader: string;
  104814. };
  104815. }
  104816. declare module BABYLON {
  104817. /** @hidden */
  104818. export var passCubePixelShader: {
  104819. name: string;
  104820. shader: string;
  104821. };
  104822. }
  104823. declare module BABYLON {
  104824. /**
  104825. * PassPostProcess which produces an output the same as it's input
  104826. */
  104827. export class PassPostProcess extends PostProcess {
  104828. /**
  104829. * Creates the PassPostProcess
  104830. * @param name The name of the effect.
  104831. * @param options The required width/height ratio to downsize to before computing the render pass.
  104832. * @param camera The camera to apply the render pass to.
  104833. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104834. * @param engine The engine which the post process will be applied. (default: current engine)
  104835. * @param reusable If the post process can be reused on the same frame. (default: false)
  104836. * @param textureType The type of texture to be used when performing the post processing.
  104837. * @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)
  104838. */
  104839. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  104840. }
  104841. /**
  104842. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  104843. */
  104844. export class PassCubePostProcess extends PostProcess {
  104845. private _face;
  104846. /**
  104847. * Gets or sets the cube face to display.
  104848. * * 0 is +X
  104849. * * 1 is -X
  104850. * * 2 is +Y
  104851. * * 3 is -Y
  104852. * * 4 is +Z
  104853. * * 5 is -Z
  104854. */
  104855. face: number;
  104856. /**
  104857. * Creates the PassCubePostProcess
  104858. * @param name The name of the effect.
  104859. * @param options The required width/height ratio to downsize to before computing the render pass.
  104860. * @param camera The camera to apply the render pass to.
  104861. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104862. * @param engine The engine which the post process will be applied. (default: current engine)
  104863. * @param reusable If the post process can be reused on the same frame. (default: false)
  104864. * @param textureType The type of texture to be used when performing the post processing.
  104865. * @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)
  104866. */
  104867. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  104868. }
  104869. }
  104870. declare module BABYLON {
  104871. /** @hidden */
  104872. export var anaglyphPixelShader: {
  104873. name: string;
  104874. shader: string;
  104875. };
  104876. }
  104877. declare module BABYLON {
  104878. /**
  104879. * Postprocess used to generate anaglyphic rendering
  104880. */
  104881. export class AnaglyphPostProcess extends PostProcess {
  104882. private _passedProcess;
  104883. /**
  104884. * Creates a new AnaglyphPostProcess
  104885. * @param name defines postprocess name
  104886. * @param options defines creation options or target ratio scale
  104887. * @param rigCameras defines cameras using this postprocess
  104888. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  104889. * @param engine defines hosting engine
  104890. * @param reusable defines if the postprocess will be reused multiple times per frame
  104891. */
  104892. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  104893. }
  104894. }
  104895. declare module BABYLON {
  104896. /**
  104897. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  104898. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  104899. */
  104900. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  104901. /**
  104902. * Creates a new AnaglyphArcRotateCamera
  104903. * @param name defines camera name
  104904. * @param alpha defines alpha angle (in radians)
  104905. * @param beta defines beta angle (in radians)
  104906. * @param radius defines radius
  104907. * @param target defines camera target
  104908. * @param interaxialDistance defines distance between each color axis
  104909. * @param scene defines the hosting scene
  104910. */
  104911. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  104912. /**
  104913. * Gets camera class name
  104914. * @returns AnaglyphArcRotateCamera
  104915. */
  104916. getClassName(): string;
  104917. }
  104918. }
  104919. declare module BABYLON {
  104920. /**
  104921. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  104922. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  104923. */
  104924. export class AnaglyphFreeCamera extends FreeCamera {
  104925. /**
  104926. * Creates a new AnaglyphFreeCamera
  104927. * @param name defines camera name
  104928. * @param position defines initial position
  104929. * @param interaxialDistance defines distance between each color axis
  104930. * @param scene defines the hosting scene
  104931. */
  104932. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  104933. /**
  104934. * Gets camera class name
  104935. * @returns AnaglyphFreeCamera
  104936. */
  104937. getClassName(): string;
  104938. }
  104939. }
  104940. declare module BABYLON {
  104941. /**
  104942. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  104943. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  104944. */
  104945. export class AnaglyphGamepadCamera extends GamepadCamera {
  104946. /**
  104947. * Creates a new AnaglyphGamepadCamera
  104948. * @param name defines camera name
  104949. * @param position defines initial position
  104950. * @param interaxialDistance defines distance between each color axis
  104951. * @param scene defines the hosting scene
  104952. */
  104953. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  104954. /**
  104955. * Gets camera class name
  104956. * @returns AnaglyphGamepadCamera
  104957. */
  104958. getClassName(): string;
  104959. }
  104960. }
  104961. declare module BABYLON {
  104962. /**
  104963. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  104964. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  104965. */
  104966. export class AnaglyphUniversalCamera extends UniversalCamera {
  104967. /**
  104968. * Creates a new AnaglyphUniversalCamera
  104969. * @param name defines camera name
  104970. * @param position defines initial position
  104971. * @param interaxialDistance defines distance between each color axis
  104972. * @param scene defines the hosting scene
  104973. */
  104974. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  104975. /**
  104976. * Gets camera class name
  104977. * @returns AnaglyphUniversalCamera
  104978. */
  104979. getClassName(): string;
  104980. }
  104981. }
  104982. declare module BABYLON {
  104983. /** @hidden */
  104984. export var stereoscopicInterlacePixelShader: {
  104985. name: string;
  104986. shader: string;
  104987. };
  104988. }
  104989. declare module BABYLON {
  104990. /**
  104991. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  104992. */
  104993. export class StereoscopicInterlacePostProcess extends PostProcess {
  104994. private _stepSize;
  104995. private _passedProcess;
  104996. /**
  104997. * Initializes a StereoscopicInterlacePostProcess
  104998. * @param name The name of the effect.
  104999. * @param rigCameras The rig cameras to be appled to the post process
  105000. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  105001. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105002. * @param engine The engine which the post process will be applied. (default: current engine)
  105003. * @param reusable If the post process can be reused on the same frame. (default: false)
  105004. */
  105005. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  105006. }
  105007. }
  105008. declare module BABYLON {
  105009. /**
  105010. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  105011. * @see http://doc.babylonjs.com/features/cameras
  105012. */
  105013. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  105014. /**
  105015. * Creates a new StereoscopicArcRotateCamera
  105016. * @param name defines camera name
  105017. * @param alpha defines alpha angle (in radians)
  105018. * @param beta defines beta angle (in radians)
  105019. * @param radius defines radius
  105020. * @param target defines camera target
  105021. * @param interaxialDistance defines distance between each color axis
  105022. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105023. * @param scene defines the hosting scene
  105024. */
  105025. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105026. /**
  105027. * Gets camera class name
  105028. * @returns StereoscopicArcRotateCamera
  105029. */
  105030. getClassName(): string;
  105031. }
  105032. }
  105033. declare module BABYLON {
  105034. /**
  105035. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  105036. * @see http://doc.babylonjs.com/features/cameras
  105037. */
  105038. export class StereoscopicFreeCamera extends FreeCamera {
  105039. /**
  105040. * Creates a new StereoscopicFreeCamera
  105041. * @param name defines camera name
  105042. * @param position defines initial position
  105043. * @param interaxialDistance defines distance between each color axis
  105044. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105045. * @param scene defines the hosting scene
  105046. */
  105047. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105048. /**
  105049. * Gets camera class name
  105050. * @returns StereoscopicFreeCamera
  105051. */
  105052. getClassName(): string;
  105053. }
  105054. }
  105055. declare module BABYLON {
  105056. /**
  105057. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  105058. * @see http://doc.babylonjs.com/features/cameras
  105059. */
  105060. export class StereoscopicGamepadCamera extends GamepadCamera {
  105061. /**
  105062. * Creates a new StereoscopicGamepadCamera
  105063. * @param name defines camera name
  105064. * @param position defines initial position
  105065. * @param interaxialDistance defines distance between each color axis
  105066. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105067. * @param scene defines the hosting scene
  105068. */
  105069. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105070. /**
  105071. * Gets camera class name
  105072. * @returns StereoscopicGamepadCamera
  105073. */
  105074. getClassName(): string;
  105075. }
  105076. }
  105077. declare module BABYLON {
  105078. /**
  105079. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  105080. * @see http://doc.babylonjs.com/features/cameras
  105081. */
  105082. export class StereoscopicUniversalCamera extends UniversalCamera {
  105083. /**
  105084. * Creates a new StereoscopicUniversalCamera
  105085. * @param name defines camera name
  105086. * @param position defines initial position
  105087. * @param interaxialDistance defines distance between each color axis
  105088. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105089. * @param scene defines the hosting scene
  105090. */
  105091. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105092. /**
  105093. * Gets camera class name
  105094. * @returns StereoscopicUniversalCamera
  105095. */
  105096. getClassName(): string;
  105097. }
  105098. }
  105099. declare module BABYLON {
  105100. /**
  105101. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  105102. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  105103. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  105104. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  105105. */
  105106. export class VirtualJoysticksCamera extends FreeCamera {
  105107. /**
  105108. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  105109. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  105110. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  105111. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  105112. * @param name Define the name of the camera in the scene
  105113. * @param position Define the start position of the camera in the scene
  105114. * @param scene Define the scene the camera belongs to
  105115. */
  105116. constructor(name: string, position: Vector3, scene: Scene);
  105117. /**
  105118. * Gets the current object class name.
  105119. * @return the class name
  105120. */
  105121. getClassName(): string;
  105122. }
  105123. }
  105124. declare module BABYLON {
  105125. /**
  105126. * This represents all the required metrics to create a VR camera.
  105127. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  105128. */
  105129. export class VRCameraMetrics {
  105130. /**
  105131. * Define the horizontal resolution off the screen.
  105132. */
  105133. hResolution: number;
  105134. /**
  105135. * Define the vertical resolution off the screen.
  105136. */
  105137. vResolution: number;
  105138. /**
  105139. * Define the horizontal screen size.
  105140. */
  105141. hScreenSize: number;
  105142. /**
  105143. * Define the vertical screen size.
  105144. */
  105145. vScreenSize: number;
  105146. /**
  105147. * Define the vertical screen center position.
  105148. */
  105149. vScreenCenter: number;
  105150. /**
  105151. * Define the distance of the eyes to the screen.
  105152. */
  105153. eyeToScreenDistance: number;
  105154. /**
  105155. * Define the distance between both lenses
  105156. */
  105157. lensSeparationDistance: number;
  105158. /**
  105159. * Define the distance between both viewer's eyes.
  105160. */
  105161. interpupillaryDistance: number;
  105162. /**
  105163. * Define the distortion factor of the VR postprocess.
  105164. * Please, touch with care.
  105165. */
  105166. distortionK: number[];
  105167. /**
  105168. * Define the chromatic aberration correction factors for the VR post process.
  105169. */
  105170. chromaAbCorrection: number[];
  105171. /**
  105172. * Define the scale factor of the post process.
  105173. * The smaller the better but the slower.
  105174. */
  105175. postProcessScaleFactor: number;
  105176. /**
  105177. * Define an offset for the lens center.
  105178. */
  105179. lensCenterOffset: number;
  105180. /**
  105181. * Define if the current vr camera should compensate the distortion of the lense or not.
  105182. */
  105183. compensateDistortion: boolean;
  105184. /**
  105185. * Defines if multiview should be enabled when rendering (Default: false)
  105186. */
  105187. multiviewEnabled: boolean;
  105188. /**
  105189. * Gets the rendering aspect ratio based on the provided resolutions.
  105190. */
  105191. readonly aspectRatio: number;
  105192. /**
  105193. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  105194. */
  105195. readonly aspectRatioFov: number;
  105196. /**
  105197. * @hidden
  105198. */
  105199. readonly leftHMatrix: Matrix;
  105200. /**
  105201. * @hidden
  105202. */
  105203. readonly rightHMatrix: Matrix;
  105204. /**
  105205. * @hidden
  105206. */
  105207. readonly leftPreViewMatrix: Matrix;
  105208. /**
  105209. * @hidden
  105210. */
  105211. readonly rightPreViewMatrix: Matrix;
  105212. /**
  105213. * Get the default VRMetrics based on the most generic setup.
  105214. * @returns the default vr metrics
  105215. */
  105216. static GetDefault(): VRCameraMetrics;
  105217. }
  105218. }
  105219. declare module BABYLON {
  105220. /** @hidden */
  105221. export var vrDistortionCorrectionPixelShader: {
  105222. name: string;
  105223. shader: string;
  105224. };
  105225. }
  105226. declare module BABYLON {
  105227. /**
  105228. * VRDistortionCorrectionPostProcess used for mobile VR
  105229. */
  105230. export class VRDistortionCorrectionPostProcess extends PostProcess {
  105231. private _isRightEye;
  105232. private _distortionFactors;
  105233. private _postProcessScaleFactor;
  105234. private _lensCenterOffset;
  105235. private _scaleIn;
  105236. private _scaleFactor;
  105237. private _lensCenter;
  105238. /**
  105239. * Initializes the VRDistortionCorrectionPostProcess
  105240. * @param name The name of the effect.
  105241. * @param camera The camera to apply the render pass to.
  105242. * @param isRightEye If this is for the right eye distortion
  105243. * @param vrMetrics All the required metrics for the VR camera
  105244. */
  105245. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  105246. }
  105247. }
  105248. declare module BABYLON {
  105249. /**
  105250. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  105251. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105252. */
  105253. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  105254. /**
  105255. * Creates a new VRDeviceOrientationArcRotateCamera
  105256. * @param name defines camera name
  105257. * @param alpha defines the camera rotation along the logitudinal axis
  105258. * @param beta defines the camera rotation along the latitudinal axis
  105259. * @param radius defines the camera distance from its target
  105260. * @param target defines the camera target
  105261. * @param scene defines the scene the camera belongs to
  105262. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105263. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105264. */
  105265. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105266. /**
  105267. * Gets camera class name
  105268. * @returns VRDeviceOrientationArcRotateCamera
  105269. */
  105270. getClassName(): string;
  105271. }
  105272. }
  105273. declare module BABYLON {
  105274. /**
  105275. * Camera used to simulate VR rendering (based on FreeCamera)
  105276. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105277. */
  105278. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  105279. /**
  105280. * Creates a new VRDeviceOrientationFreeCamera
  105281. * @param name defines camera name
  105282. * @param position defines the start position of the camera
  105283. * @param scene defines the scene the camera belongs to
  105284. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105285. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105286. */
  105287. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105288. /**
  105289. * Gets camera class name
  105290. * @returns VRDeviceOrientationFreeCamera
  105291. */
  105292. getClassName(): string;
  105293. }
  105294. }
  105295. declare module BABYLON {
  105296. /**
  105297. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  105298. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105299. */
  105300. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  105301. /**
  105302. * Creates a new VRDeviceOrientationGamepadCamera
  105303. * @param name defines camera name
  105304. * @param position defines the start position of the camera
  105305. * @param scene defines the scene the camera belongs to
  105306. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105307. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105308. */
  105309. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105310. /**
  105311. * Gets camera class name
  105312. * @returns VRDeviceOrientationGamepadCamera
  105313. */
  105314. getClassName(): string;
  105315. }
  105316. }
  105317. declare module BABYLON {
  105318. /**
  105319. * Base class of materials working in push mode in babylon JS
  105320. * @hidden
  105321. */
  105322. export class PushMaterial extends Material {
  105323. protected _activeEffect: Effect;
  105324. protected _normalMatrix: Matrix;
  105325. /**
  105326. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  105327. * This means that the material can keep using a previous shader while a new one is being compiled.
  105328. * This is mostly used when shader parallel compilation is supported (true by default)
  105329. */
  105330. allowShaderHotSwapping: boolean;
  105331. constructor(name: string, scene: Scene);
  105332. getEffect(): Effect;
  105333. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  105334. /**
  105335. * Binds the given world matrix to the active effect
  105336. *
  105337. * @param world the matrix to bind
  105338. */
  105339. bindOnlyWorldMatrix(world: Matrix): void;
  105340. /**
  105341. * Binds the given normal matrix to the active effect
  105342. *
  105343. * @param normalMatrix the matrix to bind
  105344. */
  105345. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  105346. bind(world: Matrix, mesh?: Mesh): void;
  105347. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  105348. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  105349. }
  105350. }
  105351. declare module BABYLON {
  105352. /**
  105353. * This groups all the flags used to control the materials channel.
  105354. */
  105355. export class MaterialFlags {
  105356. private static _DiffuseTextureEnabled;
  105357. /**
  105358. * Are diffuse textures enabled in the application.
  105359. */
  105360. static DiffuseTextureEnabled: boolean;
  105361. private static _AmbientTextureEnabled;
  105362. /**
  105363. * Are ambient textures enabled in the application.
  105364. */
  105365. static AmbientTextureEnabled: boolean;
  105366. private static _OpacityTextureEnabled;
  105367. /**
  105368. * Are opacity textures enabled in the application.
  105369. */
  105370. static OpacityTextureEnabled: boolean;
  105371. private static _ReflectionTextureEnabled;
  105372. /**
  105373. * Are reflection textures enabled in the application.
  105374. */
  105375. static ReflectionTextureEnabled: boolean;
  105376. private static _EmissiveTextureEnabled;
  105377. /**
  105378. * Are emissive textures enabled in the application.
  105379. */
  105380. static EmissiveTextureEnabled: boolean;
  105381. private static _SpecularTextureEnabled;
  105382. /**
  105383. * Are specular textures enabled in the application.
  105384. */
  105385. static SpecularTextureEnabled: boolean;
  105386. private static _BumpTextureEnabled;
  105387. /**
  105388. * Are bump textures enabled in the application.
  105389. */
  105390. static BumpTextureEnabled: boolean;
  105391. private static _LightmapTextureEnabled;
  105392. /**
  105393. * Are lightmap textures enabled in the application.
  105394. */
  105395. static LightmapTextureEnabled: boolean;
  105396. private static _RefractionTextureEnabled;
  105397. /**
  105398. * Are refraction textures enabled in the application.
  105399. */
  105400. static RefractionTextureEnabled: boolean;
  105401. private static _ColorGradingTextureEnabled;
  105402. /**
  105403. * Are color grading textures enabled in the application.
  105404. */
  105405. static ColorGradingTextureEnabled: boolean;
  105406. private static _FresnelEnabled;
  105407. /**
  105408. * Are fresnels enabled in the application.
  105409. */
  105410. static FresnelEnabled: boolean;
  105411. private static _ClearCoatTextureEnabled;
  105412. /**
  105413. * Are clear coat textures enabled in the application.
  105414. */
  105415. static ClearCoatTextureEnabled: boolean;
  105416. private static _ClearCoatBumpTextureEnabled;
  105417. /**
  105418. * Are clear coat bump textures enabled in the application.
  105419. */
  105420. static ClearCoatBumpTextureEnabled: boolean;
  105421. private static _ClearCoatTintTextureEnabled;
  105422. /**
  105423. * Are clear coat tint textures enabled in the application.
  105424. */
  105425. static ClearCoatTintTextureEnabled: boolean;
  105426. private static _SheenTextureEnabled;
  105427. /**
  105428. * Are sheen textures enabled in the application.
  105429. */
  105430. static SheenTextureEnabled: boolean;
  105431. private static _AnisotropicTextureEnabled;
  105432. /**
  105433. * Are anisotropic textures enabled in the application.
  105434. */
  105435. static AnisotropicTextureEnabled: boolean;
  105436. private static _ThicknessTextureEnabled;
  105437. /**
  105438. * Are thickness textures enabled in the application.
  105439. */
  105440. static ThicknessTextureEnabled: boolean;
  105441. }
  105442. }
  105443. declare module BABYLON {
  105444. /** @hidden */
  105445. export var defaultFragmentDeclaration: {
  105446. name: string;
  105447. shader: string;
  105448. };
  105449. }
  105450. declare module BABYLON {
  105451. /** @hidden */
  105452. export var defaultUboDeclaration: {
  105453. name: string;
  105454. shader: string;
  105455. };
  105456. }
  105457. declare module BABYLON {
  105458. /** @hidden */
  105459. export var lightFragmentDeclaration: {
  105460. name: string;
  105461. shader: string;
  105462. };
  105463. }
  105464. declare module BABYLON {
  105465. /** @hidden */
  105466. export var lightUboDeclaration: {
  105467. name: string;
  105468. shader: string;
  105469. };
  105470. }
  105471. declare module BABYLON {
  105472. /** @hidden */
  105473. export var lightsFragmentFunctions: {
  105474. name: string;
  105475. shader: string;
  105476. };
  105477. }
  105478. declare module BABYLON {
  105479. /** @hidden */
  105480. export var shadowsFragmentFunctions: {
  105481. name: string;
  105482. shader: string;
  105483. };
  105484. }
  105485. declare module BABYLON {
  105486. /** @hidden */
  105487. export var fresnelFunction: {
  105488. name: string;
  105489. shader: string;
  105490. };
  105491. }
  105492. declare module BABYLON {
  105493. /** @hidden */
  105494. export var reflectionFunction: {
  105495. name: string;
  105496. shader: string;
  105497. };
  105498. }
  105499. declare module BABYLON {
  105500. /** @hidden */
  105501. export var bumpFragmentFunctions: {
  105502. name: string;
  105503. shader: string;
  105504. };
  105505. }
  105506. declare module BABYLON {
  105507. /** @hidden */
  105508. export var logDepthDeclaration: {
  105509. name: string;
  105510. shader: string;
  105511. };
  105512. }
  105513. declare module BABYLON {
  105514. /** @hidden */
  105515. export var bumpFragment: {
  105516. name: string;
  105517. shader: string;
  105518. };
  105519. }
  105520. declare module BABYLON {
  105521. /** @hidden */
  105522. export var depthPrePass: {
  105523. name: string;
  105524. shader: string;
  105525. };
  105526. }
  105527. declare module BABYLON {
  105528. /** @hidden */
  105529. export var lightFragment: {
  105530. name: string;
  105531. shader: string;
  105532. };
  105533. }
  105534. declare module BABYLON {
  105535. /** @hidden */
  105536. export var logDepthFragment: {
  105537. name: string;
  105538. shader: string;
  105539. };
  105540. }
  105541. declare module BABYLON {
  105542. /** @hidden */
  105543. export var defaultPixelShader: {
  105544. name: string;
  105545. shader: string;
  105546. };
  105547. }
  105548. declare module BABYLON {
  105549. /** @hidden */
  105550. export var defaultVertexDeclaration: {
  105551. name: string;
  105552. shader: string;
  105553. };
  105554. }
  105555. declare module BABYLON {
  105556. /** @hidden */
  105557. export var bumpVertexDeclaration: {
  105558. name: string;
  105559. shader: string;
  105560. };
  105561. }
  105562. declare module BABYLON {
  105563. /** @hidden */
  105564. export var bumpVertex: {
  105565. name: string;
  105566. shader: string;
  105567. };
  105568. }
  105569. declare module BABYLON {
  105570. /** @hidden */
  105571. export var fogVertex: {
  105572. name: string;
  105573. shader: string;
  105574. };
  105575. }
  105576. declare module BABYLON {
  105577. /** @hidden */
  105578. export var shadowsVertex: {
  105579. name: string;
  105580. shader: string;
  105581. };
  105582. }
  105583. declare module BABYLON {
  105584. /** @hidden */
  105585. export var pointCloudVertex: {
  105586. name: string;
  105587. shader: string;
  105588. };
  105589. }
  105590. declare module BABYLON {
  105591. /** @hidden */
  105592. export var logDepthVertex: {
  105593. name: string;
  105594. shader: string;
  105595. };
  105596. }
  105597. declare module BABYLON {
  105598. /** @hidden */
  105599. export var defaultVertexShader: {
  105600. name: string;
  105601. shader: string;
  105602. };
  105603. }
  105604. declare module BABYLON {
  105605. /** @hidden */
  105606. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  105607. MAINUV1: boolean;
  105608. MAINUV2: boolean;
  105609. DIFFUSE: boolean;
  105610. DIFFUSEDIRECTUV: number;
  105611. AMBIENT: boolean;
  105612. AMBIENTDIRECTUV: number;
  105613. OPACITY: boolean;
  105614. OPACITYDIRECTUV: number;
  105615. OPACITYRGB: boolean;
  105616. REFLECTION: boolean;
  105617. EMISSIVE: boolean;
  105618. EMISSIVEDIRECTUV: number;
  105619. SPECULAR: boolean;
  105620. SPECULARDIRECTUV: number;
  105621. BUMP: boolean;
  105622. BUMPDIRECTUV: number;
  105623. PARALLAX: boolean;
  105624. PARALLAXOCCLUSION: boolean;
  105625. SPECULAROVERALPHA: boolean;
  105626. CLIPPLANE: boolean;
  105627. CLIPPLANE2: boolean;
  105628. CLIPPLANE3: boolean;
  105629. CLIPPLANE4: boolean;
  105630. ALPHATEST: boolean;
  105631. DEPTHPREPASS: boolean;
  105632. ALPHAFROMDIFFUSE: boolean;
  105633. POINTSIZE: boolean;
  105634. FOG: boolean;
  105635. SPECULARTERM: boolean;
  105636. DIFFUSEFRESNEL: boolean;
  105637. OPACITYFRESNEL: boolean;
  105638. REFLECTIONFRESNEL: boolean;
  105639. REFRACTIONFRESNEL: boolean;
  105640. EMISSIVEFRESNEL: boolean;
  105641. FRESNEL: boolean;
  105642. NORMAL: boolean;
  105643. UV1: boolean;
  105644. UV2: boolean;
  105645. VERTEXCOLOR: boolean;
  105646. VERTEXALPHA: boolean;
  105647. NUM_BONE_INFLUENCERS: number;
  105648. BonesPerMesh: number;
  105649. BONETEXTURE: boolean;
  105650. INSTANCES: boolean;
  105651. GLOSSINESS: boolean;
  105652. ROUGHNESS: boolean;
  105653. EMISSIVEASILLUMINATION: boolean;
  105654. LINKEMISSIVEWITHDIFFUSE: boolean;
  105655. REFLECTIONFRESNELFROMSPECULAR: boolean;
  105656. LIGHTMAP: boolean;
  105657. LIGHTMAPDIRECTUV: number;
  105658. OBJECTSPACE_NORMALMAP: boolean;
  105659. USELIGHTMAPASSHADOWMAP: boolean;
  105660. REFLECTIONMAP_3D: boolean;
  105661. REFLECTIONMAP_SPHERICAL: boolean;
  105662. REFLECTIONMAP_PLANAR: boolean;
  105663. REFLECTIONMAP_CUBIC: boolean;
  105664. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  105665. REFLECTIONMAP_PROJECTION: boolean;
  105666. REFLECTIONMAP_SKYBOX: boolean;
  105667. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  105668. REFLECTIONMAP_EXPLICIT: boolean;
  105669. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  105670. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  105671. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  105672. INVERTCUBICMAP: boolean;
  105673. LOGARITHMICDEPTH: boolean;
  105674. REFRACTION: boolean;
  105675. REFRACTIONMAP_3D: boolean;
  105676. REFLECTIONOVERALPHA: boolean;
  105677. TWOSIDEDLIGHTING: boolean;
  105678. SHADOWFLOAT: boolean;
  105679. MORPHTARGETS: boolean;
  105680. MORPHTARGETS_NORMAL: boolean;
  105681. MORPHTARGETS_TANGENT: boolean;
  105682. MORPHTARGETS_UV: boolean;
  105683. NUM_MORPH_INFLUENCERS: number;
  105684. NONUNIFORMSCALING: boolean;
  105685. PREMULTIPLYALPHA: boolean;
  105686. IMAGEPROCESSING: boolean;
  105687. VIGNETTE: boolean;
  105688. VIGNETTEBLENDMODEMULTIPLY: boolean;
  105689. VIGNETTEBLENDMODEOPAQUE: boolean;
  105690. TONEMAPPING: boolean;
  105691. TONEMAPPING_ACES: boolean;
  105692. CONTRAST: boolean;
  105693. COLORCURVES: boolean;
  105694. COLORGRADING: boolean;
  105695. COLORGRADING3D: boolean;
  105696. SAMPLER3DGREENDEPTH: boolean;
  105697. SAMPLER3DBGRMAP: boolean;
  105698. IMAGEPROCESSINGPOSTPROCESS: boolean;
  105699. MULTIVIEW: boolean;
  105700. /**
  105701. * If the reflection texture on this material is in linear color space
  105702. * @hidden
  105703. */
  105704. IS_REFLECTION_LINEAR: boolean;
  105705. /**
  105706. * If the refraction texture on this material is in linear color space
  105707. * @hidden
  105708. */
  105709. IS_REFRACTION_LINEAR: boolean;
  105710. EXPOSURE: boolean;
  105711. constructor();
  105712. setReflectionMode(modeToEnable: string): void;
  105713. }
  105714. /**
  105715. * This is the default material used in Babylon. It is the best trade off between quality
  105716. * and performances.
  105717. * @see http://doc.babylonjs.com/babylon101/materials
  105718. */
  105719. export class StandardMaterial extends PushMaterial {
  105720. private _diffuseTexture;
  105721. /**
  105722. * The basic texture of the material as viewed under a light.
  105723. */
  105724. diffuseTexture: Nullable<BaseTexture>;
  105725. private _ambientTexture;
  105726. /**
  105727. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  105728. */
  105729. ambientTexture: Nullable<BaseTexture>;
  105730. private _opacityTexture;
  105731. /**
  105732. * Define the transparency of the material from a texture.
  105733. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  105734. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  105735. */
  105736. opacityTexture: Nullable<BaseTexture>;
  105737. private _reflectionTexture;
  105738. /**
  105739. * Define the texture used to display the reflection.
  105740. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105741. */
  105742. reflectionTexture: Nullable<BaseTexture>;
  105743. private _emissiveTexture;
  105744. /**
  105745. * Define texture of the material as if self lit.
  105746. * This will be mixed in the final result even in the absence of light.
  105747. */
  105748. emissiveTexture: Nullable<BaseTexture>;
  105749. private _specularTexture;
  105750. /**
  105751. * Define how the color and intensity of the highlight given by the light in the material.
  105752. */
  105753. specularTexture: Nullable<BaseTexture>;
  105754. private _bumpTexture;
  105755. /**
  105756. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  105757. * 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.
  105758. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  105759. */
  105760. bumpTexture: Nullable<BaseTexture>;
  105761. private _lightmapTexture;
  105762. /**
  105763. * Complex lighting can be computationally expensive to compute at runtime.
  105764. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  105765. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  105766. */
  105767. lightmapTexture: Nullable<BaseTexture>;
  105768. private _refractionTexture;
  105769. /**
  105770. * Define the texture used to display the refraction.
  105771. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105772. */
  105773. refractionTexture: Nullable<BaseTexture>;
  105774. /**
  105775. * The color of the material lit by the environmental background lighting.
  105776. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  105777. */
  105778. ambientColor: Color3;
  105779. /**
  105780. * The basic color of the material as viewed under a light.
  105781. */
  105782. diffuseColor: Color3;
  105783. /**
  105784. * Define how the color and intensity of the highlight given by the light in the material.
  105785. */
  105786. specularColor: Color3;
  105787. /**
  105788. * Define the color of the material as if self lit.
  105789. * This will be mixed in the final result even in the absence of light.
  105790. */
  105791. emissiveColor: Color3;
  105792. /**
  105793. * Defines how sharp are the highlights in the material.
  105794. * The bigger the value the sharper giving a more glossy feeling to the result.
  105795. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  105796. */
  105797. specularPower: number;
  105798. private _useAlphaFromDiffuseTexture;
  105799. /**
  105800. * Does the transparency come from the diffuse texture alpha channel.
  105801. */
  105802. useAlphaFromDiffuseTexture: boolean;
  105803. private _useEmissiveAsIllumination;
  105804. /**
  105805. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  105806. */
  105807. useEmissiveAsIllumination: boolean;
  105808. private _linkEmissiveWithDiffuse;
  105809. /**
  105810. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  105811. * the emissive level when the final color is close to one.
  105812. */
  105813. linkEmissiveWithDiffuse: boolean;
  105814. private _useSpecularOverAlpha;
  105815. /**
  105816. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  105817. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105818. */
  105819. useSpecularOverAlpha: boolean;
  105820. private _useReflectionOverAlpha;
  105821. /**
  105822. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105823. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105824. */
  105825. useReflectionOverAlpha: boolean;
  105826. private _disableLighting;
  105827. /**
  105828. * Does lights from the scene impacts this material.
  105829. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  105830. */
  105831. disableLighting: boolean;
  105832. private _useObjectSpaceNormalMap;
  105833. /**
  105834. * Allows using an object space normal map (instead of tangent space).
  105835. */
  105836. useObjectSpaceNormalMap: boolean;
  105837. private _useParallax;
  105838. /**
  105839. * Is parallax enabled or not.
  105840. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  105841. */
  105842. useParallax: boolean;
  105843. private _useParallaxOcclusion;
  105844. /**
  105845. * Is parallax occlusion enabled or not.
  105846. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  105847. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  105848. */
  105849. useParallaxOcclusion: boolean;
  105850. /**
  105851. * 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.
  105852. */
  105853. parallaxScaleBias: number;
  105854. private _roughness;
  105855. /**
  105856. * Helps to define how blurry the reflections should appears in the material.
  105857. */
  105858. roughness: number;
  105859. /**
  105860. * In case of refraction, define the value of the index of refraction.
  105861. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105862. */
  105863. indexOfRefraction: number;
  105864. /**
  105865. * Invert the refraction texture alongside the y axis.
  105866. * It can be useful with procedural textures or probe for instance.
  105867. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105868. */
  105869. invertRefractionY: boolean;
  105870. /**
  105871. * Defines the alpha limits in alpha test mode.
  105872. */
  105873. alphaCutOff: number;
  105874. private _useLightmapAsShadowmap;
  105875. /**
  105876. * In case of light mapping, define whether the map contains light or shadow informations.
  105877. */
  105878. useLightmapAsShadowmap: boolean;
  105879. private _diffuseFresnelParameters;
  105880. /**
  105881. * Define the diffuse fresnel parameters of the material.
  105882. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105883. */
  105884. diffuseFresnelParameters: FresnelParameters;
  105885. private _opacityFresnelParameters;
  105886. /**
  105887. * Define the opacity fresnel parameters of the material.
  105888. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105889. */
  105890. opacityFresnelParameters: FresnelParameters;
  105891. private _reflectionFresnelParameters;
  105892. /**
  105893. * Define the reflection fresnel parameters of the material.
  105894. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105895. */
  105896. reflectionFresnelParameters: FresnelParameters;
  105897. private _refractionFresnelParameters;
  105898. /**
  105899. * Define the refraction fresnel parameters of the material.
  105900. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105901. */
  105902. refractionFresnelParameters: FresnelParameters;
  105903. private _emissiveFresnelParameters;
  105904. /**
  105905. * Define the emissive fresnel parameters of the material.
  105906. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105907. */
  105908. emissiveFresnelParameters: FresnelParameters;
  105909. private _useReflectionFresnelFromSpecular;
  105910. /**
  105911. * If true automatically deducts the fresnels values from the material specularity.
  105912. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105913. */
  105914. useReflectionFresnelFromSpecular: boolean;
  105915. private _useGlossinessFromSpecularMapAlpha;
  105916. /**
  105917. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  105918. */
  105919. useGlossinessFromSpecularMapAlpha: boolean;
  105920. private _maxSimultaneousLights;
  105921. /**
  105922. * Defines the maximum number of lights that can be used in the material
  105923. */
  105924. maxSimultaneousLights: number;
  105925. private _invertNormalMapX;
  105926. /**
  105927. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105928. */
  105929. invertNormalMapX: boolean;
  105930. private _invertNormalMapY;
  105931. /**
  105932. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105933. */
  105934. invertNormalMapY: boolean;
  105935. private _twoSidedLighting;
  105936. /**
  105937. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105938. */
  105939. twoSidedLighting: boolean;
  105940. /**
  105941. * Default configuration related to image processing available in the standard Material.
  105942. */
  105943. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105944. /**
  105945. * Gets the image processing configuration used either in this material.
  105946. */
  105947. /**
  105948. * Sets the Default image processing configuration used either in the this material.
  105949. *
  105950. * If sets to null, the scene one is in use.
  105951. */
  105952. imageProcessingConfiguration: ImageProcessingConfiguration;
  105953. /**
  105954. * Keep track of the image processing observer to allow dispose and replace.
  105955. */
  105956. private _imageProcessingObserver;
  105957. /**
  105958. * Attaches a new image processing configuration to the Standard Material.
  105959. * @param configuration
  105960. */
  105961. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  105962. /**
  105963. * Gets wether the color curves effect is enabled.
  105964. */
  105965. /**
  105966. * Sets wether the color curves effect is enabled.
  105967. */
  105968. cameraColorCurvesEnabled: boolean;
  105969. /**
  105970. * Gets wether the color grading effect is enabled.
  105971. */
  105972. /**
  105973. * Gets wether the color grading effect is enabled.
  105974. */
  105975. cameraColorGradingEnabled: boolean;
  105976. /**
  105977. * Gets wether tonemapping is enabled or not.
  105978. */
  105979. /**
  105980. * Sets wether tonemapping is enabled or not
  105981. */
  105982. cameraToneMappingEnabled: boolean;
  105983. /**
  105984. * The camera exposure used on this material.
  105985. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105986. * This corresponds to a photographic exposure.
  105987. */
  105988. /**
  105989. * The camera exposure used on this material.
  105990. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105991. * This corresponds to a photographic exposure.
  105992. */
  105993. cameraExposure: number;
  105994. /**
  105995. * Gets The camera contrast used on this material.
  105996. */
  105997. /**
  105998. * Sets The camera contrast used on this material.
  105999. */
  106000. cameraContrast: number;
  106001. /**
  106002. * Gets the Color Grading 2D Lookup Texture.
  106003. */
  106004. /**
  106005. * Sets the Color Grading 2D Lookup Texture.
  106006. */
  106007. cameraColorGradingTexture: Nullable<BaseTexture>;
  106008. /**
  106009. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106010. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106011. * 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;
  106012. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106013. */
  106014. /**
  106015. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106016. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106017. * 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;
  106018. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106019. */
  106020. cameraColorCurves: Nullable<ColorCurves>;
  106021. /**
  106022. * Custom callback helping to override the default shader used in the material.
  106023. */
  106024. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  106025. protected _renderTargets: SmartArray<RenderTargetTexture>;
  106026. protected _worldViewProjectionMatrix: Matrix;
  106027. protected _globalAmbientColor: Color3;
  106028. protected _useLogarithmicDepth: boolean;
  106029. protected _rebuildInParallel: boolean;
  106030. /**
  106031. * Instantiates a new standard material.
  106032. * This is the default material used in Babylon. It is the best trade off between quality
  106033. * and performances.
  106034. * @see http://doc.babylonjs.com/babylon101/materials
  106035. * @param name Define the name of the material in the scene
  106036. * @param scene Define the scene the material belong to
  106037. */
  106038. constructor(name: string, scene: Scene);
  106039. /**
  106040. * Gets a boolean indicating that current material needs to register RTT
  106041. */
  106042. readonly hasRenderTargetTextures: boolean;
  106043. /**
  106044. * Gets the current class name of the material e.g. "StandardMaterial"
  106045. * Mainly use in serialization.
  106046. * @returns the class name
  106047. */
  106048. getClassName(): string;
  106049. /**
  106050. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  106051. * You can try switching to logarithmic depth.
  106052. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  106053. */
  106054. useLogarithmicDepth: boolean;
  106055. /**
  106056. * Specifies if the material will require alpha blending
  106057. * @returns a boolean specifying if alpha blending is needed
  106058. */
  106059. needAlphaBlending(): boolean;
  106060. /**
  106061. * Specifies if this material should be rendered in alpha test mode
  106062. * @returns a boolean specifying if an alpha test is needed.
  106063. */
  106064. needAlphaTesting(): boolean;
  106065. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  106066. /**
  106067. * Get the texture used for alpha test purpose.
  106068. * @returns the diffuse texture in case of the standard material.
  106069. */
  106070. getAlphaTestTexture(): Nullable<BaseTexture>;
  106071. /**
  106072. * Get if the submesh is ready to be used and all its information available.
  106073. * Child classes can use it to update shaders
  106074. * @param mesh defines the mesh to check
  106075. * @param subMesh defines which submesh to check
  106076. * @param useInstances specifies that instances should be used
  106077. * @returns a boolean indicating that the submesh is ready or not
  106078. */
  106079. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  106080. /**
  106081. * Builds the material UBO layouts.
  106082. * Used internally during the effect preparation.
  106083. */
  106084. buildUniformLayout(): void;
  106085. /**
  106086. * Unbinds the material from the mesh
  106087. */
  106088. unbind(): void;
  106089. /**
  106090. * Binds the submesh to this material by preparing the effect and shader to draw
  106091. * @param world defines the world transformation matrix
  106092. * @param mesh defines the mesh containing the submesh
  106093. * @param subMesh defines the submesh to bind the material to
  106094. */
  106095. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  106096. /**
  106097. * Get the list of animatables in the material.
  106098. * @returns the list of animatables object used in the material
  106099. */
  106100. getAnimatables(): IAnimatable[];
  106101. /**
  106102. * Gets the active textures from the material
  106103. * @returns an array of textures
  106104. */
  106105. getActiveTextures(): BaseTexture[];
  106106. /**
  106107. * Specifies if the material uses a texture
  106108. * @param texture defines the texture to check against the material
  106109. * @returns a boolean specifying if the material uses the texture
  106110. */
  106111. hasTexture(texture: BaseTexture): boolean;
  106112. /**
  106113. * Disposes the material
  106114. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  106115. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  106116. */
  106117. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  106118. /**
  106119. * Makes a duplicate of the material, and gives it a new name
  106120. * @param name defines the new name for the duplicated material
  106121. * @returns the cloned material
  106122. */
  106123. clone(name: string): StandardMaterial;
  106124. /**
  106125. * Serializes this material in a JSON representation
  106126. * @returns the serialized material object
  106127. */
  106128. serialize(): any;
  106129. /**
  106130. * Creates a standard material from parsed material data
  106131. * @param source defines the JSON representation of the material
  106132. * @param scene defines the hosting scene
  106133. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  106134. * @returns a new standard material
  106135. */
  106136. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  106137. /**
  106138. * Are diffuse textures enabled in the application.
  106139. */
  106140. static DiffuseTextureEnabled: boolean;
  106141. /**
  106142. * Are ambient textures enabled in the application.
  106143. */
  106144. static AmbientTextureEnabled: boolean;
  106145. /**
  106146. * Are opacity textures enabled in the application.
  106147. */
  106148. static OpacityTextureEnabled: boolean;
  106149. /**
  106150. * Are reflection textures enabled in the application.
  106151. */
  106152. static ReflectionTextureEnabled: boolean;
  106153. /**
  106154. * Are emissive textures enabled in the application.
  106155. */
  106156. static EmissiveTextureEnabled: boolean;
  106157. /**
  106158. * Are specular textures enabled in the application.
  106159. */
  106160. static SpecularTextureEnabled: boolean;
  106161. /**
  106162. * Are bump textures enabled in the application.
  106163. */
  106164. static BumpTextureEnabled: boolean;
  106165. /**
  106166. * Are lightmap textures enabled in the application.
  106167. */
  106168. static LightmapTextureEnabled: boolean;
  106169. /**
  106170. * Are refraction textures enabled in the application.
  106171. */
  106172. static RefractionTextureEnabled: boolean;
  106173. /**
  106174. * Are color grading textures enabled in the application.
  106175. */
  106176. static ColorGradingTextureEnabled: boolean;
  106177. /**
  106178. * Are fresnels enabled in the application.
  106179. */
  106180. static FresnelEnabled: boolean;
  106181. }
  106182. }
  106183. declare module BABYLON {
  106184. /**
  106185. * A class extending Texture allowing drawing on a texture
  106186. * @see http://doc.babylonjs.com/how_to/dynamictexture
  106187. */
  106188. export class DynamicTexture extends Texture {
  106189. private _generateMipMaps;
  106190. private _canvas;
  106191. private _context;
  106192. private _engine;
  106193. /**
  106194. * Creates a DynamicTexture
  106195. * @param name defines the name of the texture
  106196. * @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
  106197. * @param scene defines the scene where you want the texture
  106198. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  106199. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  106200. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  106201. */
  106202. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  106203. /**
  106204. * Get the current class name of the texture useful for serialization or dynamic coding.
  106205. * @returns "DynamicTexture"
  106206. */
  106207. getClassName(): string;
  106208. /**
  106209. * Gets the current state of canRescale
  106210. */
  106211. readonly canRescale: boolean;
  106212. private _recreate;
  106213. /**
  106214. * Scales the texture
  106215. * @param ratio the scale factor to apply to both width and height
  106216. */
  106217. scale(ratio: number): void;
  106218. /**
  106219. * Resizes the texture
  106220. * @param width the new width
  106221. * @param height the new height
  106222. */
  106223. scaleTo(width: number, height: number): void;
  106224. /**
  106225. * Gets the context of the canvas used by the texture
  106226. * @returns the canvas context of the dynamic texture
  106227. */
  106228. getContext(): CanvasRenderingContext2D;
  106229. /**
  106230. * Clears the texture
  106231. */
  106232. clear(): void;
  106233. /**
  106234. * Updates the texture
  106235. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  106236. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  106237. */
  106238. update(invertY?: boolean, premulAlpha?: boolean): void;
  106239. /**
  106240. * Draws text onto the texture
  106241. * @param text defines the text to be drawn
  106242. * @param x defines the placement of the text from the left
  106243. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  106244. * @param font defines the font to be used with font-style, font-size, font-name
  106245. * @param color defines the color used for the text
  106246. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  106247. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  106248. * @param update defines whether texture is immediately update (default is true)
  106249. */
  106250. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  106251. /**
  106252. * Clones the texture
  106253. * @returns the clone of the texture.
  106254. */
  106255. clone(): DynamicTexture;
  106256. /**
  106257. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  106258. * @returns a serialized dynamic texture object
  106259. */
  106260. serialize(): any;
  106261. /** @hidden */
  106262. _rebuild(): void;
  106263. }
  106264. }
  106265. declare module BABYLON {
  106266. /** @hidden */
  106267. export var imageProcessingPixelShader: {
  106268. name: string;
  106269. shader: string;
  106270. };
  106271. }
  106272. declare module BABYLON {
  106273. /**
  106274. * ImageProcessingPostProcess
  106275. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  106276. */
  106277. export class ImageProcessingPostProcess extends PostProcess {
  106278. /**
  106279. * Default configuration related to image processing available in the PBR Material.
  106280. */
  106281. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106282. /**
  106283. * Gets the image processing configuration used either in this material.
  106284. */
  106285. /**
  106286. * Sets the Default image processing configuration used either in the this material.
  106287. *
  106288. * If sets to null, the scene one is in use.
  106289. */
  106290. imageProcessingConfiguration: ImageProcessingConfiguration;
  106291. /**
  106292. * Keep track of the image processing observer to allow dispose and replace.
  106293. */
  106294. private _imageProcessingObserver;
  106295. /**
  106296. * Attaches a new image processing configuration to the PBR Material.
  106297. * @param configuration
  106298. */
  106299. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  106300. /**
  106301. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  106302. */
  106303. /**
  106304. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  106305. */
  106306. colorCurves: Nullable<ColorCurves>;
  106307. /**
  106308. * Gets wether the color curves effect is enabled.
  106309. */
  106310. /**
  106311. * Sets wether the color curves effect is enabled.
  106312. */
  106313. colorCurvesEnabled: boolean;
  106314. /**
  106315. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  106316. */
  106317. /**
  106318. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  106319. */
  106320. colorGradingTexture: Nullable<BaseTexture>;
  106321. /**
  106322. * Gets wether the color grading effect is enabled.
  106323. */
  106324. /**
  106325. * Gets wether the color grading effect is enabled.
  106326. */
  106327. colorGradingEnabled: boolean;
  106328. /**
  106329. * Gets exposure used in the effect.
  106330. */
  106331. /**
  106332. * Sets exposure used in the effect.
  106333. */
  106334. exposure: number;
  106335. /**
  106336. * Gets wether tonemapping is enabled or not.
  106337. */
  106338. /**
  106339. * Sets wether tonemapping is enabled or not
  106340. */
  106341. toneMappingEnabled: boolean;
  106342. /**
  106343. * Gets the type of tone mapping effect.
  106344. */
  106345. /**
  106346. * Sets the type of tone mapping effect.
  106347. */
  106348. toneMappingType: number;
  106349. /**
  106350. * Gets contrast used in the effect.
  106351. */
  106352. /**
  106353. * Sets contrast used in the effect.
  106354. */
  106355. contrast: number;
  106356. /**
  106357. * Gets Vignette stretch size.
  106358. */
  106359. /**
  106360. * Sets Vignette stretch size.
  106361. */
  106362. vignetteStretch: number;
  106363. /**
  106364. * Gets Vignette centre X Offset.
  106365. */
  106366. /**
  106367. * Sets Vignette centre X Offset.
  106368. */
  106369. vignetteCentreX: number;
  106370. /**
  106371. * Gets Vignette centre Y Offset.
  106372. */
  106373. /**
  106374. * Sets Vignette centre Y Offset.
  106375. */
  106376. vignetteCentreY: number;
  106377. /**
  106378. * Gets Vignette weight or intensity of the vignette effect.
  106379. */
  106380. /**
  106381. * Sets Vignette weight or intensity of the vignette effect.
  106382. */
  106383. vignetteWeight: number;
  106384. /**
  106385. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  106386. * if vignetteEnabled is set to true.
  106387. */
  106388. /**
  106389. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  106390. * if vignetteEnabled is set to true.
  106391. */
  106392. vignetteColor: Color4;
  106393. /**
  106394. * Gets Camera field of view used by the Vignette effect.
  106395. */
  106396. /**
  106397. * Sets Camera field of view used by the Vignette effect.
  106398. */
  106399. vignetteCameraFov: number;
  106400. /**
  106401. * Gets the vignette blend mode allowing different kind of effect.
  106402. */
  106403. /**
  106404. * Sets the vignette blend mode allowing different kind of effect.
  106405. */
  106406. vignetteBlendMode: number;
  106407. /**
  106408. * Gets wether the vignette effect is enabled.
  106409. */
  106410. /**
  106411. * Sets wether the vignette effect is enabled.
  106412. */
  106413. vignetteEnabled: boolean;
  106414. private _fromLinearSpace;
  106415. /**
  106416. * Gets wether the input of the processing is in Gamma or Linear Space.
  106417. */
  106418. /**
  106419. * Sets wether the input of the processing is in Gamma or Linear Space.
  106420. */
  106421. fromLinearSpace: boolean;
  106422. /**
  106423. * Defines cache preventing GC.
  106424. */
  106425. private _defines;
  106426. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  106427. /**
  106428. * "ImageProcessingPostProcess"
  106429. * @returns "ImageProcessingPostProcess"
  106430. */
  106431. getClassName(): string;
  106432. protected _updateParameters(): void;
  106433. dispose(camera?: Camera): void;
  106434. }
  106435. }
  106436. declare module BABYLON {
  106437. /**
  106438. * Class containing static functions to help procedurally build meshes
  106439. */
  106440. export class GroundBuilder {
  106441. /**
  106442. * Creates a ground mesh
  106443. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  106444. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  106445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106446. * @param name defines the name of the mesh
  106447. * @param options defines the options used to create the mesh
  106448. * @param scene defines the hosting scene
  106449. * @returns the ground mesh
  106450. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  106451. */
  106452. static CreateGround(name: string, options: {
  106453. width?: number;
  106454. height?: number;
  106455. subdivisions?: number;
  106456. subdivisionsX?: number;
  106457. subdivisionsY?: number;
  106458. updatable?: boolean;
  106459. }, scene: any): Mesh;
  106460. /**
  106461. * Creates a tiled ground mesh
  106462. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  106463. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  106464. * * 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
  106465. * * 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
  106466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106467. * @param name defines the name of the mesh
  106468. * @param options defines the options used to create the mesh
  106469. * @param scene defines the hosting scene
  106470. * @returns the tiled ground mesh
  106471. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  106472. */
  106473. static CreateTiledGround(name: string, options: {
  106474. xmin: number;
  106475. zmin: number;
  106476. xmax: number;
  106477. zmax: number;
  106478. subdivisions?: {
  106479. w: number;
  106480. h: number;
  106481. };
  106482. precision?: {
  106483. w: number;
  106484. h: number;
  106485. };
  106486. updatable?: boolean;
  106487. }, scene?: Nullable<Scene>): Mesh;
  106488. /**
  106489. * Creates a ground mesh from a height map
  106490. * * The parameter `url` sets the URL of the height map image resource.
  106491. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  106492. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  106493. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  106494. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  106495. * * 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.
  106496. * * 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).
  106497. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106499. * @param name defines the name of the mesh
  106500. * @param url defines the url to the height map
  106501. * @param options defines the options used to create the mesh
  106502. * @param scene defines the hosting scene
  106503. * @returns the ground mesh
  106504. * @see https://doc.babylonjs.com/babylon101/height_map
  106505. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  106506. */
  106507. static CreateGroundFromHeightMap(name: string, url: string, options: {
  106508. width?: number;
  106509. height?: number;
  106510. subdivisions?: number;
  106511. minHeight?: number;
  106512. maxHeight?: number;
  106513. colorFilter?: Color3;
  106514. alphaFilter?: number;
  106515. updatable?: boolean;
  106516. onReady?: (mesh: GroundMesh) => void;
  106517. }, scene?: Nullable<Scene>): GroundMesh;
  106518. }
  106519. }
  106520. declare module BABYLON {
  106521. /**
  106522. * Class containing static functions to help procedurally build meshes
  106523. */
  106524. export class TorusBuilder {
  106525. /**
  106526. * Creates a torus mesh
  106527. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  106528. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  106529. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  106530. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106531. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106533. * @param name defines the name of the mesh
  106534. * @param options defines the options used to create the mesh
  106535. * @param scene defines the hosting scene
  106536. * @returns the torus mesh
  106537. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  106538. */
  106539. static CreateTorus(name: string, options: {
  106540. diameter?: number;
  106541. thickness?: number;
  106542. tessellation?: number;
  106543. updatable?: boolean;
  106544. sideOrientation?: number;
  106545. frontUVs?: Vector4;
  106546. backUVs?: Vector4;
  106547. }, scene: any): Mesh;
  106548. }
  106549. }
  106550. declare module BABYLON {
  106551. /**
  106552. * Class containing static functions to help procedurally build meshes
  106553. */
  106554. export class CylinderBuilder {
  106555. /**
  106556. * Creates a cylinder or a cone mesh
  106557. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  106558. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  106559. * * 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.
  106560. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  106561. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  106562. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  106563. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  106564. * * 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).
  106565. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  106566. * * 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).
  106567. * * 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
  106568. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  106569. * * 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
  106570. * * 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.
  106571. * * If `enclose` is false, a ring surface is one element.
  106572. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  106573. * * 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
  106574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106575. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106577. * @param name defines the name of the mesh
  106578. * @param options defines the options used to create the mesh
  106579. * @param scene defines the hosting scene
  106580. * @returns the cylinder mesh
  106581. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  106582. */
  106583. static CreateCylinder(name: string, options: {
  106584. height?: number;
  106585. diameterTop?: number;
  106586. diameterBottom?: number;
  106587. diameter?: number;
  106588. tessellation?: number;
  106589. subdivisions?: number;
  106590. arc?: number;
  106591. faceColors?: Color4[];
  106592. faceUV?: Vector4[];
  106593. updatable?: boolean;
  106594. hasRings?: boolean;
  106595. enclose?: boolean;
  106596. cap?: number;
  106597. sideOrientation?: number;
  106598. frontUVs?: Vector4;
  106599. backUVs?: Vector4;
  106600. }, scene: any): Mesh;
  106601. }
  106602. }
  106603. declare module BABYLON {
  106604. /**
  106605. * Options to modify the vr teleportation behavior.
  106606. */
  106607. export interface VRTeleportationOptions {
  106608. /**
  106609. * The name of the mesh which should be used as the teleportation floor. (default: null)
  106610. */
  106611. floorMeshName?: string;
  106612. /**
  106613. * A list of meshes to be used as the teleportation floor. (default: empty)
  106614. */
  106615. floorMeshes?: Mesh[];
  106616. }
  106617. /**
  106618. * Options to modify the vr experience helper's behavior.
  106619. */
  106620. export interface VRExperienceHelperOptions extends WebVROptions {
  106621. /**
  106622. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  106623. */
  106624. createDeviceOrientationCamera?: boolean;
  106625. /**
  106626. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  106627. */
  106628. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  106629. /**
  106630. * Uses the main button on the controller to toggle the laser casted. (default: true)
  106631. */
  106632. laserToggle?: boolean;
  106633. /**
  106634. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  106635. */
  106636. floorMeshes?: Mesh[];
  106637. /**
  106638. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  106639. */
  106640. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  106641. }
  106642. /**
  106643. * Event containing information after VR has been entered
  106644. */
  106645. export class OnAfterEnteringVRObservableEvent {
  106646. /**
  106647. * If entering vr was successful
  106648. */
  106649. success: boolean;
  106650. }
  106651. /**
  106652. * Helps to quickly add VR support to an existing scene.
  106653. * See http://doc.babylonjs.com/how_to/webvr_helper
  106654. */
  106655. export class VRExperienceHelper {
  106656. /** Options to modify the vr experience helper's behavior. */
  106657. webVROptions: VRExperienceHelperOptions;
  106658. private _scene;
  106659. private _position;
  106660. private _btnVR;
  106661. private _btnVRDisplayed;
  106662. private _webVRsupported;
  106663. private _webVRready;
  106664. private _webVRrequesting;
  106665. private _webVRpresenting;
  106666. private _hasEnteredVR;
  106667. private _fullscreenVRpresenting;
  106668. private _canvas;
  106669. private _webVRCamera;
  106670. private _vrDeviceOrientationCamera;
  106671. private _deviceOrientationCamera;
  106672. private _existingCamera;
  106673. private _onKeyDown;
  106674. private _onVrDisplayPresentChange;
  106675. private _onVRDisplayChanged;
  106676. private _onVRRequestPresentStart;
  106677. private _onVRRequestPresentComplete;
  106678. /**
  106679. * 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)
  106680. */
  106681. enableGazeEvenWhenNoPointerLock: boolean;
  106682. /**
  106683. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  106684. */
  106685. exitVROnDoubleTap: boolean;
  106686. /**
  106687. * Observable raised right before entering VR.
  106688. */
  106689. onEnteringVRObservable: Observable<VRExperienceHelper>;
  106690. /**
  106691. * Observable raised when entering VR has completed.
  106692. */
  106693. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  106694. /**
  106695. * Observable raised when exiting VR.
  106696. */
  106697. onExitingVRObservable: Observable<VRExperienceHelper>;
  106698. /**
  106699. * Observable raised when controller mesh is loaded.
  106700. */
  106701. onControllerMeshLoadedObservable: Observable<WebVRController>;
  106702. /** Return this.onEnteringVRObservable
  106703. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  106704. */
  106705. readonly onEnteringVR: Observable<VRExperienceHelper>;
  106706. /** Return this.onExitingVRObservable
  106707. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  106708. */
  106709. readonly onExitingVR: Observable<VRExperienceHelper>;
  106710. /** Return this.onControllerMeshLoadedObservable
  106711. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  106712. */
  106713. readonly onControllerMeshLoaded: Observable<WebVRController>;
  106714. private _rayLength;
  106715. private _useCustomVRButton;
  106716. private _teleportationRequested;
  106717. private _teleportActive;
  106718. private _floorMeshName;
  106719. private _floorMeshesCollection;
  106720. private _rotationAllowed;
  106721. private _teleportBackwardsVector;
  106722. private _teleportationTarget;
  106723. private _isDefaultTeleportationTarget;
  106724. private _postProcessMove;
  106725. private _teleportationFillColor;
  106726. private _teleportationBorderColor;
  106727. private _rotationAngle;
  106728. private _haloCenter;
  106729. private _cameraGazer;
  106730. private _padSensibilityUp;
  106731. private _padSensibilityDown;
  106732. private _leftController;
  106733. private _rightController;
  106734. /**
  106735. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  106736. */
  106737. onNewMeshSelected: Observable<AbstractMesh>;
  106738. /**
  106739. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  106740. * This observable will provide the mesh and the controller used to select the mesh
  106741. */
  106742. onMeshSelectedWithController: Observable<{
  106743. mesh: AbstractMesh;
  106744. controller: WebVRController;
  106745. }>;
  106746. /**
  106747. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  106748. */
  106749. onNewMeshPicked: Observable<PickingInfo>;
  106750. private _circleEase;
  106751. /**
  106752. * Observable raised before camera teleportation
  106753. */
  106754. onBeforeCameraTeleport: Observable<Vector3>;
  106755. /**
  106756. * Observable raised after camera teleportation
  106757. */
  106758. onAfterCameraTeleport: Observable<Vector3>;
  106759. /**
  106760. * Observable raised when current selected mesh gets unselected
  106761. */
  106762. onSelectedMeshUnselected: Observable<AbstractMesh>;
  106763. private _raySelectionPredicate;
  106764. /**
  106765. * To be optionaly changed by user to define custom ray selection
  106766. */
  106767. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  106768. /**
  106769. * To be optionaly changed by user to define custom selection logic (after ray selection)
  106770. */
  106771. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  106772. /**
  106773. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  106774. */
  106775. teleportationEnabled: boolean;
  106776. private _defaultHeight;
  106777. private _teleportationInitialized;
  106778. private _interactionsEnabled;
  106779. private _interactionsRequested;
  106780. private _displayGaze;
  106781. private _displayLaserPointer;
  106782. /**
  106783. * The mesh used to display where the user is going to teleport.
  106784. */
  106785. /**
  106786. * Sets the mesh to be used to display where the user is going to teleport.
  106787. */
  106788. teleportationTarget: Mesh;
  106789. /**
  106790. * 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
  106791. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  106792. * See http://doc.babylonjs.com/resources/baking_transformations
  106793. */
  106794. gazeTrackerMesh: Mesh;
  106795. /**
  106796. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  106797. */
  106798. updateGazeTrackerScale: boolean;
  106799. /**
  106800. * If the gaze trackers color should be updated when selecting meshes
  106801. */
  106802. updateGazeTrackerColor: boolean;
  106803. /**
  106804. * If the controller laser color should be updated when selecting meshes
  106805. */
  106806. updateControllerLaserColor: boolean;
  106807. /**
  106808. * The gaze tracking mesh corresponding to the left controller
  106809. */
  106810. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  106811. /**
  106812. * The gaze tracking mesh corresponding to the right controller
  106813. */
  106814. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  106815. /**
  106816. * If the ray of the gaze should be displayed.
  106817. */
  106818. /**
  106819. * Sets if the ray of the gaze should be displayed.
  106820. */
  106821. displayGaze: boolean;
  106822. /**
  106823. * If the ray of the LaserPointer should be displayed.
  106824. */
  106825. /**
  106826. * Sets if the ray of the LaserPointer should be displayed.
  106827. */
  106828. displayLaserPointer: boolean;
  106829. /**
  106830. * The deviceOrientationCamera used as the camera when not in VR.
  106831. */
  106832. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  106833. /**
  106834. * Based on the current WebVR support, returns the current VR camera used.
  106835. */
  106836. readonly currentVRCamera: Nullable<Camera>;
  106837. /**
  106838. * The webVRCamera which is used when in VR.
  106839. */
  106840. readonly webVRCamera: WebVRFreeCamera;
  106841. /**
  106842. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  106843. */
  106844. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  106845. /**
  106846. * The html button that is used to trigger entering into VR.
  106847. */
  106848. readonly vrButton: Nullable<HTMLButtonElement>;
  106849. private readonly _teleportationRequestInitiated;
  106850. /**
  106851. * Defines wether or not Pointer lock should be requested when switching to
  106852. * full screen.
  106853. */
  106854. requestPointerLockOnFullScreen: boolean;
  106855. /**
  106856. * Instantiates a VRExperienceHelper.
  106857. * Helps to quickly add VR support to an existing scene.
  106858. * @param scene The scene the VRExperienceHelper belongs to.
  106859. * @param webVROptions Options to modify the vr experience helper's behavior.
  106860. */
  106861. constructor(scene: Scene,
  106862. /** Options to modify the vr experience helper's behavior. */
  106863. webVROptions?: VRExperienceHelperOptions);
  106864. private _onDefaultMeshLoaded;
  106865. private _onResize;
  106866. private _onFullscreenChange;
  106867. /**
  106868. * Gets a value indicating if we are currently in VR mode.
  106869. */
  106870. readonly isInVRMode: boolean;
  106871. private onVrDisplayPresentChange;
  106872. private onVRDisplayChanged;
  106873. private moveButtonToBottomRight;
  106874. private displayVRButton;
  106875. private updateButtonVisibility;
  106876. private _cachedAngularSensibility;
  106877. /**
  106878. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  106879. * Otherwise, will use the fullscreen API.
  106880. */
  106881. enterVR(): void;
  106882. /**
  106883. * Attempt to exit VR, or fullscreen.
  106884. */
  106885. exitVR(): void;
  106886. /**
  106887. * The position of the vr experience helper.
  106888. */
  106889. /**
  106890. * Sets the position of the vr experience helper.
  106891. */
  106892. position: Vector3;
  106893. /**
  106894. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  106895. */
  106896. enableInteractions(): void;
  106897. private readonly _noControllerIsActive;
  106898. private beforeRender;
  106899. private _isTeleportationFloor;
  106900. /**
  106901. * Adds a floor mesh to be used for teleportation.
  106902. * @param floorMesh the mesh to be used for teleportation.
  106903. */
  106904. addFloorMesh(floorMesh: Mesh): void;
  106905. /**
  106906. * Removes a floor mesh from being used for teleportation.
  106907. * @param floorMesh the mesh to be removed.
  106908. */
  106909. removeFloorMesh(floorMesh: Mesh): void;
  106910. /**
  106911. * Enables interactions and teleportation using the VR controllers and gaze.
  106912. * @param vrTeleportationOptions options to modify teleportation behavior.
  106913. */
  106914. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  106915. private _onNewGamepadConnected;
  106916. private _tryEnableInteractionOnController;
  106917. private _onNewGamepadDisconnected;
  106918. private _enableInteractionOnController;
  106919. private _checkTeleportWithRay;
  106920. private _checkRotate;
  106921. private _checkTeleportBackwards;
  106922. private _enableTeleportationOnController;
  106923. private _createTeleportationCircles;
  106924. private _displayTeleportationTarget;
  106925. private _hideTeleportationTarget;
  106926. private _rotateCamera;
  106927. private _moveTeleportationSelectorTo;
  106928. private _workingVector;
  106929. private _workingQuaternion;
  106930. private _workingMatrix;
  106931. /**
  106932. * Teleports the users feet to the desired location
  106933. * @param location The location where the user's feet should be placed
  106934. */
  106935. teleportCamera(location: Vector3): void;
  106936. private _convertNormalToDirectionOfRay;
  106937. private _castRayAndSelectObject;
  106938. private _notifySelectedMeshUnselected;
  106939. /**
  106940. * Sets the color of the laser ray from the vr controllers.
  106941. * @param color new color for the ray.
  106942. */
  106943. changeLaserColor(color: Color3): void;
  106944. /**
  106945. * Sets the color of the ray from the vr headsets gaze.
  106946. * @param color new color for the ray.
  106947. */
  106948. changeGazeColor(color: Color3): void;
  106949. /**
  106950. * Exits VR and disposes of the vr experience helper
  106951. */
  106952. dispose(): void;
  106953. /**
  106954. * Gets the name of the VRExperienceHelper class
  106955. * @returns "VRExperienceHelper"
  106956. */
  106957. getClassName(): string;
  106958. }
  106959. }
  106960. declare module BABYLON {
  106961. /**
  106962. * Manages an XRSession to work with Babylon's engine
  106963. * @see https://doc.babylonjs.com/how_to/webxr
  106964. */
  106965. export class WebXRSessionManager implements IDisposable {
  106966. private scene;
  106967. /**
  106968. * Fires every time a new xrFrame arrives which can be used to update the camera
  106969. */
  106970. onXRFrameObservable: Observable<any>;
  106971. /**
  106972. * Fires when the xr session is ended either by the device or manually done
  106973. */
  106974. onXRSessionEnded: Observable<any>;
  106975. /**
  106976. * Underlying xr session
  106977. */
  106978. session: XRSession;
  106979. /**
  106980. * Type of reference space used when creating the session
  106981. */
  106982. referenceSpace: XRReferenceSpace;
  106983. /** @hidden */
  106984. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  106985. /**
  106986. * Current XR frame
  106987. */
  106988. currentFrame: Nullable<XRFrame>;
  106989. private _xrNavigator;
  106990. private baseLayer;
  106991. /**
  106992. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  106993. * @param scene The scene which the session should be created for
  106994. */
  106995. constructor(scene: Scene);
  106996. /**
  106997. * Initializes the manager
  106998. * After initialization enterXR can be called to start an XR session
  106999. * @returns Promise which resolves after it is initialized
  107000. */
  107001. initializeAsync(): Promise<void>;
  107002. /**
  107003. * Initializes an xr session
  107004. * @param xrSessionMode mode to initialize
  107005. * @returns a promise which will resolve once the session has been initialized
  107006. */
  107007. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  107008. /**
  107009. * Sets the reference space on the xr session
  107010. * @param referenceSpace space to set
  107011. * @returns a promise that will resolve once the reference space has been set
  107012. */
  107013. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  107014. /**
  107015. * Updates the render state of the session
  107016. * @param state state to set
  107017. * @returns a promise that resolves once the render state has been updated
  107018. */
  107019. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  107020. /**
  107021. * Starts rendering to the xr layer
  107022. * @returns a promise that will resolve once rendering has started
  107023. */
  107024. startRenderingToXRAsync(): Promise<void>;
  107025. /**
  107026. * Stops the xrSession and restores the renderloop
  107027. * @returns Promise which resolves after it exits XR
  107028. */
  107029. exitXRAsync(): Promise<unknown>;
  107030. /**
  107031. * Checks if a session would be supported for the creation options specified
  107032. * @param sessionMode session mode to check if supported eg. immersive-vr
  107033. * @returns true if supported
  107034. */
  107035. supportsSessionAsync(sessionMode: XRSessionMode): any;
  107036. /**
  107037. * @hidden
  107038. * Converts the render layer of xrSession to a render target
  107039. * @param session session to create render target for
  107040. * @param scene scene the new render target should be created for
  107041. */
  107042. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  107043. /**
  107044. * Disposes of the session manager
  107045. */
  107046. dispose(): void;
  107047. }
  107048. }
  107049. declare module BABYLON {
  107050. /**
  107051. * WebXR Camera which holds the views for the xrSession
  107052. * @see https://doc.babylonjs.com/how_to/webxr
  107053. */
  107054. export class WebXRCamera extends FreeCamera {
  107055. private static _TmpMatrix;
  107056. /**
  107057. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  107058. * @param name the name of the camera
  107059. * @param scene the scene to add the camera to
  107060. */
  107061. constructor(name: string, scene: Scene);
  107062. private _updateNumberOfRigCameras;
  107063. /** @hidden */
  107064. _updateForDualEyeDebugging(pupilDistance?: number): void;
  107065. /**
  107066. * Updates the cameras position from the current pose information of the XR session
  107067. * @param xrSessionManager the session containing pose information
  107068. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  107069. */
  107070. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  107071. }
  107072. }
  107073. declare module BABYLON {
  107074. /**
  107075. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  107076. */
  107077. export class WebXRManagedOutputCanvas implements IDisposable {
  107078. private helper;
  107079. private _canvas;
  107080. /**
  107081. * xrpresent context of the canvas which can be used to display/mirror xr content
  107082. */
  107083. canvasContext: WebGLRenderingContext;
  107084. /**
  107085. * xr layer for the canvas
  107086. */
  107087. xrLayer: Nullable<XRWebGLLayer>;
  107088. /**
  107089. * Initializes the xr layer for the session
  107090. * @param xrSession xr session
  107091. * @returns a promise that will resolve once the XR Layer has been created
  107092. */
  107093. initializeXRLayerAsync(xrSession: any): any;
  107094. /**
  107095. * Initializes the canvas to be added/removed upon entering/exiting xr
  107096. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  107097. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  107098. */
  107099. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  107100. /**
  107101. * Disposes of the object
  107102. */
  107103. dispose(): void;
  107104. private _setManagedOutputCanvas;
  107105. private _addCanvas;
  107106. private _removeCanvas;
  107107. }
  107108. }
  107109. declare module BABYLON {
  107110. /**
  107111. * States of the webXR experience
  107112. */
  107113. export enum WebXRState {
  107114. /**
  107115. * Transitioning to being in XR mode
  107116. */
  107117. ENTERING_XR = 0,
  107118. /**
  107119. * Transitioning to non XR mode
  107120. */
  107121. EXITING_XR = 1,
  107122. /**
  107123. * In XR mode and presenting
  107124. */
  107125. IN_XR = 2,
  107126. /**
  107127. * Not entered XR mode
  107128. */
  107129. NOT_IN_XR = 3
  107130. }
  107131. /**
  107132. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  107133. * @see https://doc.babylonjs.com/how_to/webxr
  107134. */
  107135. export class WebXRExperienceHelper implements IDisposable {
  107136. private scene;
  107137. /**
  107138. * 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
  107139. */
  107140. container: AbstractMesh;
  107141. /**
  107142. * Camera used to render xr content
  107143. */
  107144. camera: WebXRCamera;
  107145. /**
  107146. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  107147. */
  107148. state: WebXRState;
  107149. private _setState;
  107150. private static _TmpVector;
  107151. /**
  107152. * Fires when the state of the experience helper has changed
  107153. */
  107154. onStateChangedObservable: Observable<WebXRState>;
  107155. /** Session manager used to keep track of xr session */
  107156. sessionManager: WebXRSessionManager;
  107157. private _nonVRCamera;
  107158. private _originalSceneAutoClear;
  107159. private _supported;
  107160. /**
  107161. * Creates the experience helper
  107162. * @param scene the scene to attach the experience helper to
  107163. * @returns a promise for the experience helper
  107164. */
  107165. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  107166. /**
  107167. * Creates a WebXRExperienceHelper
  107168. * @param scene The scene the helper should be created in
  107169. */
  107170. private constructor();
  107171. /**
  107172. * Exits XR mode and returns the scene to its original state
  107173. * @returns promise that resolves after xr mode has exited
  107174. */
  107175. exitXRAsync(): Promise<unknown>;
  107176. /**
  107177. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  107178. * @param sessionCreationOptions options for the XR session
  107179. * @param referenceSpaceType frame of reference of the XR session
  107180. * @param outputCanvas the output canvas that will be used to enter XR mode
  107181. * @returns promise that resolves after xr mode has entered
  107182. */
  107183. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  107184. /**
  107185. * Updates the global position of the camera by moving the camera's container
  107186. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  107187. * @param position The desired global position of the camera
  107188. */
  107189. setPositionOfCameraUsingContainer(position: Vector3): void;
  107190. /**
  107191. * Rotates the xr camera by rotating the camera's container around the camera's position
  107192. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  107193. * @param rotation the desired quaternion rotation to apply to the camera
  107194. */
  107195. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  107196. /**
  107197. * Disposes of the experience helper
  107198. */
  107199. dispose(): void;
  107200. }
  107201. }
  107202. declare module BABYLON {
  107203. /**
  107204. * Button which can be used to enter a different mode of XR
  107205. */
  107206. export class WebXREnterExitUIButton {
  107207. /** button element */
  107208. element: HTMLElement;
  107209. /** XR initialization options for the button */
  107210. sessionMode: XRSessionMode;
  107211. /** Reference space type */
  107212. referenceSpaceType: XRReferenceSpaceType;
  107213. /**
  107214. * Creates a WebXREnterExitUIButton
  107215. * @param element button element
  107216. * @param sessionMode XR initialization session mode
  107217. * @param referenceSpaceType the type of reference space to be used
  107218. */
  107219. constructor(
  107220. /** button element */
  107221. element: HTMLElement,
  107222. /** XR initialization options for the button */
  107223. sessionMode: XRSessionMode,
  107224. /** Reference space type */
  107225. referenceSpaceType: XRReferenceSpaceType);
  107226. /**
  107227. * Overwritable function which can be used to update the button's visuals when the state changes
  107228. * @param activeButton the current active button in the UI
  107229. */
  107230. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  107231. }
  107232. /**
  107233. * Options to create the webXR UI
  107234. */
  107235. export class WebXREnterExitUIOptions {
  107236. /**
  107237. * Context to enter xr with
  107238. */
  107239. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  107240. /**
  107241. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  107242. */
  107243. customButtons?: Array<WebXREnterExitUIButton>;
  107244. }
  107245. /**
  107246. * UI to allow the user to enter/exit XR mode
  107247. */
  107248. export class WebXREnterExitUI implements IDisposable {
  107249. private scene;
  107250. private _overlay;
  107251. private _buttons;
  107252. private _activeButton;
  107253. /**
  107254. * Fired every time the active button is changed.
  107255. *
  107256. * When xr is entered via a button that launches xr that button will be the callback parameter
  107257. *
  107258. * When exiting xr the callback parameter will be null)
  107259. */
  107260. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  107261. /**
  107262. * Creates UI to allow the user to enter/exit XR mode
  107263. * @param scene the scene to add the ui to
  107264. * @param helper the xr experience helper to enter/exit xr with
  107265. * @param options options to configure the UI
  107266. * @returns the created ui
  107267. */
  107268. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  107269. private constructor();
  107270. private _updateButtons;
  107271. /**
  107272. * Disposes of the object
  107273. */
  107274. dispose(): void;
  107275. }
  107276. }
  107277. declare module BABYLON {
  107278. /**
  107279. * Represents an XR input
  107280. */
  107281. export class WebXRController {
  107282. private scene;
  107283. /** The underlying input source for the controller */
  107284. inputSource: XRInputSource;
  107285. private parentContainer;
  107286. /**
  107287. * 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
  107288. */
  107289. grip?: AbstractMesh;
  107290. /**
  107291. * Pointer which can be used to select objects or attach a visible laser to
  107292. */
  107293. pointer: AbstractMesh;
  107294. /**
  107295. * Event that fires when the controller is removed/disposed
  107296. */
  107297. onDisposeObservable: Observable<{}>;
  107298. private _tmpMatrix;
  107299. private _tmpQuaternion;
  107300. private _tmpVector;
  107301. /**
  107302. * Creates the controller
  107303. * @see https://doc.babylonjs.com/how_to/webxr
  107304. * @param scene the scene which the controller should be associated to
  107305. * @param inputSource the underlying input source for the controller
  107306. * @param parentContainer parent that the controller meshes should be children of
  107307. */
  107308. constructor(scene: Scene,
  107309. /** The underlying input source for the controller */
  107310. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  107311. /**
  107312. * Updates the controller pose based on the given XRFrame
  107313. * @param xrFrame xr frame to update the pose with
  107314. * @param referenceSpace reference space to use
  107315. */
  107316. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  107317. /**
  107318. * Gets a world space ray coming from the controller
  107319. * @param result the resulting ray
  107320. */
  107321. getWorldPointerRayToRef(result: Ray): void;
  107322. /**
  107323. * Disposes of the object
  107324. */
  107325. dispose(): void;
  107326. }
  107327. }
  107328. declare module BABYLON {
  107329. /**
  107330. * XR input used to track XR inputs such as controllers/rays
  107331. */
  107332. export class WebXRInput implements IDisposable {
  107333. /**
  107334. * Base experience the input listens to
  107335. */
  107336. baseExperience: WebXRExperienceHelper;
  107337. /**
  107338. * XR controllers being tracked
  107339. */
  107340. controllers: Array<WebXRController>;
  107341. private _frameObserver;
  107342. private _stateObserver;
  107343. /**
  107344. * Event when a controller has been connected/added
  107345. */
  107346. onControllerAddedObservable: Observable<WebXRController>;
  107347. /**
  107348. * Event when a controller has been removed/disconnected
  107349. */
  107350. onControllerRemovedObservable: Observable<WebXRController>;
  107351. /**
  107352. * Initializes the WebXRInput
  107353. * @param baseExperience experience helper which the input should be created for
  107354. */
  107355. constructor(
  107356. /**
  107357. * Base experience the input listens to
  107358. */
  107359. baseExperience: WebXRExperienceHelper);
  107360. private _onInputSourcesChange;
  107361. private _addAndRemoveControllers;
  107362. /**
  107363. * Disposes of the object
  107364. */
  107365. dispose(): void;
  107366. }
  107367. }
  107368. declare module BABYLON {
  107369. /**
  107370. * Enables teleportation
  107371. */
  107372. export class WebXRControllerTeleportation {
  107373. private _teleportationFillColor;
  107374. private _teleportationBorderColor;
  107375. private _tmpRay;
  107376. private _tmpVector;
  107377. /**
  107378. * Creates a WebXRControllerTeleportation
  107379. * @param input input manager to add teleportation to
  107380. * @param floorMeshes floormeshes which can be teleported to
  107381. */
  107382. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  107383. }
  107384. }
  107385. declare module BABYLON {
  107386. /**
  107387. * Handles pointer input automatically for the pointer of XR controllers
  107388. */
  107389. export class WebXRControllerPointerSelection {
  107390. private static _idCounter;
  107391. private _tmpRay;
  107392. /**
  107393. * Creates a WebXRControllerPointerSelection
  107394. * @param input input manager to setup pointer selection
  107395. */
  107396. constructor(input: WebXRInput);
  107397. private _convertNormalToDirectionOfRay;
  107398. private _updatePointerDistance;
  107399. }
  107400. }
  107401. declare module BABYLON {
  107402. /**
  107403. * Class used to represent data loading progression
  107404. */
  107405. export class SceneLoaderProgressEvent {
  107406. /** defines if data length to load can be evaluated */
  107407. readonly lengthComputable: boolean;
  107408. /** defines the loaded data length */
  107409. readonly loaded: number;
  107410. /** defines the data length to load */
  107411. readonly total: number;
  107412. /**
  107413. * Create a new progress event
  107414. * @param lengthComputable defines if data length to load can be evaluated
  107415. * @param loaded defines the loaded data length
  107416. * @param total defines the data length to load
  107417. */
  107418. constructor(
  107419. /** defines if data length to load can be evaluated */
  107420. lengthComputable: boolean,
  107421. /** defines the loaded data length */
  107422. loaded: number,
  107423. /** defines the data length to load */
  107424. total: number);
  107425. /**
  107426. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  107427. * @param event defines the source event
  107428. * @returns a new SceneLoaderProgressEvent
  107429. */
  107430. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  107431. }
  107432. /**
  107433. * Interface used by SceneLoader plugins to define supported file extensions
  107434. */
  107435. export interface ISceneLoaderPluginExtensions {
  107436. /**
  107437. * Defines the list of supported extensions
  107438. */
  107439. [extension: string]: {
  107440. isBinary: boolean;
  107441. };
  107442. }
  107443. /**
  107444. * Interface used by SceneLoader plugin factory
  107445. */
  107446. export interface ISceneLoaderPluginFactory {
  107447. /**
  107448. * Defines the name of the factory
  107449. */
  107450. name: string;
  107451. /**
  107452. * Function called to create a new plugin
  107453. * @return the new plugin
  107454. */
  107455. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  107456. /**
  107457. * Boolean indicating if the plugin can direct load specific data
  107458. */
  107459. canDirectLoad?: (data: string) => boolean;
  107460. }
  107461. /**
  107462. * Interface used to define a SceneLoader plugin
  107463. */
  107464. export interface ISceneLoaderPlugin {
  107465. /**
  107466. * The friendly name of this plugin.
  107467. */
  107468. name: string;
  107469. /**
  107470. * The file extensions supported by this plugin.
  107471. */
  107472. extensions: string | ISceneLoaderPluginExtensions;
  107473. /**
  107474. * Import meshes into a scene.
  107475. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107476. * @param scene The scene to import into
  107477. * @param data The data to import
  107478. * @param rootUrl The root url for scene and resources
  107479. * @param meshes The meshes array to import into
  107480. * @param particleSystems The particle systems array to import into
  107481. * @param skeletons The skeletons array to import into
  107482. * @param onError The callback when import fails
  107483. * @returns True if successful or false otherwise
  107484. */
  107485. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  107486. /**
  107487. * Load into a scene.
  107488. * @param scene The scene to load into
  107489. * @param data The data to import
  107490. * @param rootUrl The root url for scene and resources
  107491. * @param onError The callback when import fails
  107492. * @returns true if successful or false otherwise
  107493. */
  107494. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  107495. /**
  107496. * The callback that returns true if the data can be directly loaded.
  107497. */
  107498. canDirectLoad?: (data: string) => boolean;
  107499. /**
  107500. * The callback that allows custom handling of the root url based on the response url.
  107501. */
  107502. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  107503. /**
  107504. * Load into an asset container.
  107505. * @param scene The scene to load into
  107506. * @param data The data to import
  107507. * @param rootUrl The root url for scene and resources
  107508. * @param onError The callback when import fails
  107509. * @returns The loaded asset container
  107510. */
  107511. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  107512. }
  107513. /**
  107514. * Interface used to define an async SceneLoader plugin
  107515. */
  107516. export interface ISceneLoaderPluginAsync {
  107517. /**
  107518. * The friendly name of this plugin.
  107519. */
  107520. name: string;
  107521. /**
  107522. * The file extensions supported by this plugin.
  107523. */
  107524. extensions: string | ISceneLoaderPluginExtensions;
  107525. /**
  107526. * Import meshes into a scene.
  107527. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107528. * @param scene The scene to import into
  107529. * @param data The data to import
  107530. * @param rootUrl The root url for scene and resources
  107531. * @param onProgress The callback when the load progresses
  107532. * @param fileName Defines the name of the file to load
  107533. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  107534. */
  107535. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  107536. meshes: AbstractMesh[];
  107537. particleSystems: IParticleSystem[];
  107538. skeletons: Skeleton[];
  107539. animationGroups: AnimationGroup[];
  107540. }>;
  107541. /**
  107542. * Load into a scene.
  107543. * @param scene The scene to load into
  107544. * @param data The data to import
  107545. * @param rootUrl The root url for scene and resources
  107546. * @param onProgress The callback when the load progresses
  107547. * @param fileName Defines the name of the file to load
  107548. * @returns Nothing
  107549. */
  107550. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  107551. /**
  107552. * The callback that returns true if the data can be directly loaded.
  107553. */
  107554. canDirectLoad?: (data: string) => boolean;
  107555. /**
  107556. * The callback that allows custom handling of the root url based on the response url.
  107557. */
  107558. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  107559. /**
  107560. * Load into an asset container.
  107561. * @param scene The scene to load into
  107562. * @param data The data to import
  107563. * @param rootUrl The root url for scene and resources
  107564. * @param onProgress The callback when the load progresses
  107565. * @param fileName Defines the name of the file to load
  107566. * @returns The loaded asset container
  107567. */
  107568. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  107569. }
  107570. /**
  107571. * Class used to load scene from various file formats using registered plugins
  107572. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  107573. */
  107574. export class SceneLoader {
  107575. /**
  107576. * No logging while loading
  107577. */
  107578. static readonly NO_LOGGING: number;
  107579. /**
  107580. * Minimal logging while loading
  107581. */
  107582. static readonly MINIMAL_LOGGING: number;
  107583. /**
  107584. * Summary logging while loading
  107585. */
  107586. static readonly SUMMARY_LOGGING: number;
  107587. /**
  107588. * Detailled logging while loading
  107589. */
  107590. static readonly DETAILED_LOGGING: number;
  107591. /**
  107592. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  107593. */
  107594. static ForceFullSceneLoadingForIncremental: boolean;
  107595. /**
  107596. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  107597. */
  107598. static ShowLoadingScreen: boolean;
  107599. /**
  107600. * Defines the current logging level (while loading the scene)
  107601. * @ignorenaming
  107602. */
  107603. static loggingLevel: number;
  107604. /**
  107605. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  107606. */
  107607. static CleanBoneMatrixWeights: boolean;
  107608. /**
  107609. * Event raised when a plugin is used to load a scene
  107610. */
  107611. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  107612. private static _registeredPlugins;
  107613. private static _getDefaultPlugin;
  107614. private static _getPluginForExtension;
  107615. private static _getPluginForDirectLoad;
  107616. private static _getPluginForFilename;
  107617. private static _getDirectLoad;
  107618. private static _loadData;
  107619. private static _getFileInfo;
  107620. /**
  107621. * Gets a plugin that can load the given extension
  107622. * @param extension defines the extension to load
  107623. * @returns a plugin or null if none works
  107624. */
  107625. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  107626. /**
  107627. * Gets a boolean indicating that the given extension can be loaded
  107628. * @param extension defines the extension to load
  107629. * @returns true if the extension is supported
  107630. */
  107631. static IsPluginForExtensionAvailable(extension: string): boolean;
  107632. /**
  107633. * Adds a new plugin to the list of registered plugins
  107634. * @param plugin defines the plugin to add
  107635. */
  107636. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  107637. /**
  107638. * Import meshes into a scene
  107639. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107640. * @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)
  107641. * @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)
  107642. * @param scene the instance of BABYLON.Scene to append to
  107643. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  107644. * @param onProgress a callback with a progress event for each file being loaded
  107645. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107646. * @param pluginExtension the extension used to determine the plugin
  107647. * @returns The loaded plugin
  107648. */
  107649. 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>;
  107650. /**
  107651. * Import meshes into a scene
  107652. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107653. * @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)
  107654. * @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)
  107655. * @param scene the instance of BABYLON.Scene to append to
  107656. * @param onProgress a callback with a progress event for each file being loaded
  107657. * @param pluginExtension the extension used to determine the plugin
  107658. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  107659. */
  107660. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  107661. meshes: AbstractMesh[];
  107662. particleSystems: IParticleSystem[];
  107663. skeletons: Skeleton[];
  107664. animationGroups: AnimationGroup[];
  107665. }>;
  107666. /**
  107667. * Load a scene
  107668. * @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)
  107669. * @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)
  107670. * @param engine is the instance of BABYLON.Engine to use to create the scene
  107671. * @param onSuccess a callback with the scene when import succeeds
  107672. * @param onProgress a callback with a progress event for each file being loaded
  107673. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107674. * @param pluginExtension the extension used to determine the plugin
  107675. * @returns The loaded plugin
  107676. */
  107677. 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>;
  107678. /**
  107679. * Load a scene
  107680. * @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)
  107681. * @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)
  107682. * @param engine is the instance of BABYLON.Engine to use to create the scene
  107683. * @param onProgress a callback with a progress event for each file being loaded
  107684. * @param pluginExtension the extension used to determine the plugin
  107685. * @returns The loaded scene
  107686. */
  107687. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  107688. /**
  107689. * Append a scene
  107690. * @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)
  107691. * @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)
  107692. * @param scene is the instance of BABYLON.Scene to append to
  107693. * @param onSuccess a callback with the scene when import succeeds
  107694. * @param onProgress a callback with a progress event for each file being loaded
  107695. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107696. * @param pluginExtension the extension used to determine the plugin
  107697. * @returns The loaded plugin
  107698. */
  107699. 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>;
  107700. /**
  107701. * Append a scene
  107702. * @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)
  107703. * @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)
  107704. * @param scene is the instance of BABYLON.Scene to append to
  107705. * @param onProgress a callback with a progress event for each file being loaded
  107706. * @param pluginExtension the extension used to determine the plugin
  107707. * @returns The given scene
  107708. */
  107709. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  107710. /**
  107711. * Load a scene into an asset container
  107712. * @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)
  107713. * @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)
  107714. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  107715. * @param onSuccess a callback with the scene when import succeeds
  107716. * @param onProgress a callback with a progress event for each file being loaded
  107717. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107718. * @param pluginExtension the extension used to determine the plugin
  107719. * @returns The loaded plugin
  107720. */
  107721. 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>;
  107722. /**
  107723. * Load a scene into an asset container
  107724. * @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)
  107725. * @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)
  107726. * @param scene is the instance of Scene to append to
  107727. * @param onProgress a callback with a progress event for each file being loaded
  107728. * @param pluginExtension the extension used to determine the plugin
  107729. * @returns The loaded asset container
  107730. */
  107731. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  107732. }
  107733. }
  107734. declare module BABYLON {
  107735. /**
  107736. * Generic Controller
  107737. */
  107738. export class GenericController extends WebVRController {
  107739. /**
  107740. * Base Url for the controller model.
  107741. */
  107742. static readonly MODEL_BASE_URL: string;
  107743. /**
  107744. * File name for the controller model.
  107745. */
  107746. static readonly MODEL_FILENAME: string;
  107747. /**
  107748. * Creates a new GenericController from a gamepad
  107749. * @param vrGamepad the gamepad that the controller should be created from
  107750. */
  107751. constructor(vrGamepad: any);
  107752. /**
  107753. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107754. * @param scene scene in which to add meshes
  107755. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107756. */
  107757. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107758. /**
  107759. * Called once for each button that changed state since the last frame
  107760. * @param buttonIdx Which button index changed
  107761. * @param state New state of the button
  107762. * @param changes Which properties on the state changed since last frame
  107763. */
  107764. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107765. }
  107766. }
  107767. declare module BABYLON {
  107768. /**
  107769. * Defines the WindowsMotionController object that the state of the windows motion controller
  107770. */
  107771. export class WindowsMotionController extends WebVRController {
  107772. /**
  107773. * The base url used to load the left and right controller models
  107774. */
  107775. static MODEL_BASE_URL: string;
  107776. /**
  107777. * The name of the left controller model file
  107778. */
  107779. static MODEL_LEFT_FILENAME: string;
  107780. /**
  107781. * The name of the right controller model file
  107782. */
  107783. static MODEL_RIGHT_FILENAME: string;
  107784. /**
  107785. * The controller name prefix for this controller type
  107786. */
  107787. static readonly GAMEPAD_ID_PREFIX: string;
  107788. /**
  107789. * The controller id pattern for this controller type
  107790. */
  107791. private static readonly GAMEPAD_ID_PATTERN;
  107792. private _loadedMeshInfo;
  107793. private readonly _mapping;
  107794. /**
  107795. * Fired when the trackpad on this controller is clicked
  107796. */
  107797. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  107798. /**
  107799. * Fired when the trackpad on this controller is modified
  107800. */
  107801. onTrackpadValuesChangedObservable: Observable<StickValues>;
  107802. /**
  107803. * The current x and y values of this controller's trackpad
  107804. */
  107805. trackpad: StickValues;
  107806. /**
  107807. * Creates a new WindowsMotionController from a gamepad
  107808. * @param vrGamepad the gamepad that the controller should be created from
  107809. */
  107810. constructor(vrGamepad: any);
  107811. /**
  107812. * Fired when the trigger on this controller is modified
  107813. */
  107814. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107815. /**
  107816. * Fired when the menu button on this controller is modified
  107817. */
  107818. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107819. /**
  107820. * Fired when the grip button on this controller is modified
  107821. */
  107822. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107823. /**
  107824. * Fired when the thumbstick button on this controller is modified
  107825. */
  107826. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107827. /**
  107828. * Fired when the touchpad button on this controller is modified
  107829. */
  107830. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107831. /**
  107832. * Fired when the touchpad values on this controller are modified
  107833. */
  107834. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  107835. private _updateTrackpad;
  107836. /**
  107837. * Called once per frame by the engine.
  107838. */
  107839. update(): void;
  107840. /**
  107841. * Called once for each button that changed state since the last frame
  107842. * @param buttonIdx Which button index changed
  107843. * @param state New state of the button
  107844. * @param changes Which properties on the state changed since last frame
  107845. */
  107846. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107847. /**
  107848. * Moves the buttons on the controller mesh based on their current state
  107849. * @param buttonName the name of the button to move
  107850. * @param buttonValue the value of the button which determines the buttons new position
  107851. */
  107852. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  107853. /**
  107854. * Moves the axis on the controller mesh based on its current state
  107855. * @param axis the index of the axis
  107856. * @param axisValue the value of the axis which determines the meshes new position
  107857. * @hidden
  107858. */
  107859. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  107860. /**
  107861. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107862. * @param scene scene in which to add meshes
  107863. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107864. */
  107865. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  107866. /**
  107867. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  107868. * can be transformed by button presses and axes values, based on this._mapping.
  107869. *
  107870. * @param scene scene in which the meshes exist
  107871. * @param meshes list of meshes that make up the controller model to process
  107872. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  107873. */
  107874. private processModel;
  107875. private createMeshInfo;
  107876. /**
  107877. * Gets the ray of the controller in the direction the controller is pointing
  107878. * @param length the length the resulting ray should be
  107879. * @returns a ray in the direction the controller is pointing
  107880. */
  107881. getForwardRay(length?: number): Ray;
  107882. /**
  107883. * Disposes of the controller
  107884. */
  107885. dispose(): void;
  107886. }
  107887. }
  107888. declare module BABYLON {
  107889. /**
  107890. * Oculus Touch Controller
  107891. */
  107892. export class OculusTouchController extends WebVRController {
  107893. /**
  107894. * Base Url for the controller model.
  107895. */
  107896. static MODEL_BASE_URL: string;
  107897. /**
  107898. * File name for the left controller model.
  107899. */
  107900. static MODEL_LEFT_FILENAME: string;
  107901. /**
  107902. * File name for the right controller model.
  107903. */
  107904. static MODEL_RIGHT_FILENAME: string;
  107905. /**
  107906. * Base Url for the Quest controller model.
  107907. */
  107908. static QUEST_MODEL_BASE_URL: string;
  107909. /**
  107910. * @hidden
  107911. * If the controllers are running on a device that needs the updated Quest controller models
  107912. */
  107913. static _IsQuest: boolean;
  107914. /**
  107915. * Fired when the secondary trigger on this controller is modified
  107916. */
  107917. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  107918. /**
  107919. * Fired when the thumb rest on this controller is modified
  107920. */
  107921. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  107922. /**
  107923. * Creates a new OculusTouchController from a gamepad
  107924. * @param vrGamepad the gamepad that the controller should be created from
  107925. */
  107926. constructor(vrGamepad: any);
  107927. /**
  107928. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107929. * @param scene scene in which to add meshes
  107930. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107931. */
  107932. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107933. /**
  107934. * Fired when the A button on this controller is modified
  107935. */
  107936. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107937. /**
  107938. * Fired when the B button on this controller is modified
  107939. */
  107940. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107941. /**
  107942. * Fired when the X button on this controller is modified
  107943. */
  107944. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107945. /**
  107946. * Fired when the Y button on this controller is modified
  107947. */
  107948. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107949. /**
  107950. * Called once for each button that changed state since the last frame
  107951. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  107952. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  107953. * 2) secondary trigger (same)
  107954. * 3) A (right) X (left), touch, pressed = value
  107955. * 4) B / Y
  107956. * 5) thumb rest
  107957. * @param buttonIdx Which button index changed
  107958. * @param state New state of the button
  107959. * @param changes Which properties on the state changed since last frame
  107960. */
  107961. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107962. }
  107963. }
  107964. declare module BABYLON {
  107965. /**
  107966. * Vive Controller
  107967. */
  107968. export class ViveController extends WebVRController {
  107969. /**
  107970. * Base Url for the controller model.
  107971. */
  107972. static MODEL_BASE_URL: string;
  107973. /**
  107974. * File name for the controller model.
  107975. */
  107976. static MODEL_FILENAME: string;
  107977. /**
  107978. * Creates a new ViveController from a gamepad
  107979. * @param vrGamepad the gamepad that the controller should be created from
  107980. */
  107981. constructor(vrGamepad: any);
  107982. /**
  107983. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107984. * @param scene scene in which to add meshes
  107985. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107986. */
  107987. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107988. /**
  107989. * Fired when the left button on this controller is modified
  107990. */
  107991. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107992. /**
  107993. * Fired when the right button on this controller is modified
  107994. */
  107995. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107996. /**
  107997. * Fired when the menu button on this controller is modified
  107998. */
  107999. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108000. /**
  108001. * Called once for each button that changed state since the last frame
  108002. * Vive mapping:
  108003. * 0: touchpad
  108004. * 1: trigger
  108005. * 2: left AND right buttons
  108006. * 3: menu button
  108007. * @param buttonIdx Which button index changed
  108008. * @param state New state of the button
  108009. * @param changes Which properties on the state changed since last frame
  108010. */
  108011. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108012. }
  108013. }
  108014. declare module BABYLON {
  108015. /**
  108016. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  108017. */
  108018. export class WebXRControllerModelLoader {
  108019. /**
  108020. * Creates the WebXRControllerModelLoader
  108021. * @param input xr input that creates the controllers
  108022. */
  108023. constructor(input: WebXRInput);
  108024. }
  108025. }
  108026. declare module BABYLON {
  108027. /**
  108028. * Contains an array of blocks representing the octree
  108029. */
  108030. export interface IOctreeContainer<T> {
  108031. /**
  108032. * Blocks within the octree
  108033. */
  108034. blocks: Array<OctreeBlock<T>>;
  108035. }
  108036. /**
  108037. * Class used to store a cell in an octree
  108038. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108039. */
  108040. export class OctreeBlock<T> {
  108041. /**
  108042. * Gets the content of the current block
  108043. */
  108044. entries: T[];
  108045. /**
  108046. * Gets the list of block children
  108047. */
  108048. blocks: Array<OctreeBlock<T>>;
  108049. private _depth;
  108050. private _maxDepth;
  108051. private _capacity;
  108052. private _minPoint;
  108053. private _maxPoint;
  108054. private _boundingVectors;
  108055. private _creationFunc;
  108056. /**
  108057. * Creates a new block
  108058. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  108059. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  108060. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  108061. * @param depth defines the current depth of this block in the octree
  108062. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  108063. * @param creationFunc defines a callback to call when an element is added to the block
  108064. */
  108065. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  108066. /**
  108067. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  108068. */
  108069. readonly capacity: number;
  108070. /**
  108071. * Gets the minimum vector (in world space) of the block's bounding box
  108072. */
  108073. readonly minPoint: Vector3;
  108074. /**
  108075. * Gets the maximum vector (in world space) of the block's bounding box
  108076. */
  108077. readonly maxPoint: Vector3;
  108078. /**
  108079. * Add a new element to this block
  108080. * @param entry defines the element to add
  108081. */
  108082. addEntry(entry: T): void;
  108083. /**
  108084. * Remove an element from this block
  108085. * @param entry defines the element to remove
  108086. */
  108087. removeEntry(entry: T): void;
  108088. /**
  108089. * Add an array of elements to this block
  108090. * @param entries defines the array of elements to add
  108091. */
  108092. addEntries(entries: T[]): void;
  108093. /**
  108094. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  108095. * @param frustumPlanes defines the frustum planes to test
  108096. * @param selection defines the array to store current content if selection is positive
  108097. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108098. */
  108099. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  108100. /**
  108101. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  108102. * @param sphereCenter defines the bounding sphere center
  108103. * @param sphereRadius defines the bounding sphere radius
  108104. * @param selection defines the array to store current content if selection is positive
  108105. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108106. */
  108107. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  108108. /**
  108109. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  108110. * @param ray defines the ray to test with
  108111. * @param selection defines the array to store current content if selection is positive
  108112. */
  108113. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  108114. /**
  108115. * Subdivide the content into child blocks (this block will then be empty)
  108116. */
  108117. createInnerBlocks(): void;
  108118. /**
  108119. * @hidden
  108120. */
  108121. 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;
  108122. }
  108123. }
  108124. declare module BABYLON {
  108125. /**
  108126. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  108127. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108128. */
  108129. export class Octree<T> {
  108130. /** 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.) */
  108131. maxDepth: number;
  108132. /**
  108133. * Blocks within the octree containing objects
  108134. */
  108135. blocks: Array<OctreeBlock<T>>;
  108136. /**
  108137. * Content stored in the octree
  108138. */
  108139. dynamicContent: T[];
  108140. private _maxBlockCapacity;
  108141. private _selectionContent;
  108142. private _creationFunc;
  108143. /**
  108144. * Creates a octree
  108145. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108146. * @param creationFunc function to be used to instatiate the octree
  108147. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  108148. * @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.)
  108149. */
  108150. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  108151. /** 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.) */
  108152. maxDepth?: number);
  108153. /**
  108154. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  108155. * @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);
  108156. * @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);
  108157. * @param entries meshes to be added to the octree blocks
  108158. */
  108159. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  108160. /**
  108161. * Adds a mesh to the octree
  108162. * @param entry Mesh to add to the octree
  108163. */
  108164. addMesh(entry: T): void;
  108165. /**
  108166. * Remove an element from the octree
  108167. * @param entry defines the element to remove
  108168. */
  108169. removeMesh(entry: T): void;
  108170. /**
  108171. * Selects an array of meshes within the frustum
  108172. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  108173. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  108174. * @returns array of meshes within the frustum
  108175. */
  108176. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  108177. /**
  108178. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  108179. * @param sphereCenter defines the bounding sphere center
  108180. * @param sphereRadius defines the bounding sphere radius
  108181. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108182. * @returns an array of objects that intersect the sphere
  108183. */
  108184. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  108185. /**
  108186. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  108187. * @param ray defines the ray to test with
  108188. * @returns array of intersected objects
  108189. */
  108190. intersectsRay(ray: Ray): SmartArray<T>;
  108191. /**
  108192. * Adds a mesh into the octree block if it intersects the block
  108193. */
  108194. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  108195. /**
  108196. * Adds a submesh into the octree block if it intersects the block
  108197. */
  108198. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  108199. }
  108200. }
  108201. declare module BABYLON {
  108202. interface Scene {
  108203. /**
  108204. * @hidden
  108205. * Backing Filed
  108206. */
  108207. _selectionOctree: Octree<AbstractMesh>;
  108208. /**
  108209. * Gets the octree used to boost mesh selection (picking)
  108210. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108211. */
  108212. selectionOctree: Octree<AbstractMesh>;
  108213. /**
  108214. * Creates or updates the octree used to boost selection (picking)
  108215. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108216. * @param maxCapacity defines the maximum capacity per leaf
  108217. * @param maxDepth defines the maximum depth of the octree
  108218. * @returns an octree of AbstractMesh
  108219. */
  108220. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  108221. }
  108222. interface AbstractMesh {
  108223. /**
  108224. * @hidden
  108225. * Backing Field
  108226. */
  108227. _submeshesOctree: Octree<SubMesh>;
  108228. /**
  108229. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  108230. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  108231. * @param maxCapacity defines the maximum size of each block (64 by default)
  108232. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  108233. * @returns the new octree
  108234. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  108235. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108236. */
  108237. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  108238. }
  108239. /**
  108240. * Defines the octree scene component responsible to manage any octrees
  108241. * in a given scene.
  108242. */
  108243. export class OctreeSceneComponent {
  108244. /**
  108245. * The component name help to identify the component in the list of scene components.
  108246. */
  108247. readonly name: string;
  108248. /**
  108249. * The scene the component belongs to.
  108250. */
  108251. scene: Scene;
  108252. /**
  108253. * Indicates if the meshes have been checked to make sure they are isEnabled()
  108254. */
  108255. readonly checksIsEnabled: boolean;
  108256. /**
  108257. * Creates a new instance of the component for the given scene
  108258. * @param scene Defines the scene to register the component in
  108259. */
  108260. constructor(scene: Scene);
  108261. /**
  108262. * Registers the component in a given scene
  108263. */
  108264. register(): void;
  108265. /**
  108266. * Return the list of active meshes
  108267. * @returns the list of active meshes
  108268. */
  108269. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  108270. /**
  108271. * Return the list of active sub meshes
  108272. * @param mesh The mesh to get the candidates sub meshes from
  108273. * @returns the list of active sub meshes
  108274. */
  108275. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  108276. private _tempRay;
  108277. /**
  108278. * Return the list of sub meshes intersecting with a given local ray
  108279. * @param mesh defines the mesh to find the submesh for
  108280. * @param localRay defines the ray in local space
  108281. * @returns the list of intersecting sub meshes
  108282. */
  108283. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  108284. /**
  108285. * Return the list of sub meshes colliding with a collider
  108286. * @param mesh defines the mesh to find the submesh for
  108287. * @param collider defines the collider to evaluate the collision against
  108288. * @returns the list of colliding sub meshes
  108289. */
  108290. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  108291. /**
  108292. * Rebuilds the elements related to this component in case of
  108293. * context lost for instance.
  108294. */
  108295. rebuild(): void;
  108296. /**
  108297. * Disposes the component and the associated ressources.
  108298. */
  108299. dispose(): void;
  108300. }
  108301. }
  108302. declare module BABYLON {
  108303. /**
  108304. * Renders a layer on top of an existing scene
  108305. */
  108306. export class UtilityLayerRenderer implements IDisposable {
  108307. /** the original scene that will be rendered on top of */
  108308. originalScene: Scene;
  108309. private _pointerCaptures;
  108310. private _lastPointerEvents;
  108311. private static _DefaultUtilityLayer;
  108312. private static _DefaultKeepDepthUtilityLayer;
  108313. private _sharedGizmoLight;
  108314. private _renderCamera;
  108315. /**
  108316. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  108317. * @returns the camera that is used when rendering the utility layer
  108318. */
  108319. getRenderCamera(): Nullable<Camera>;
  108320. /**
  108321. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  108322. * @param cam the camera that should be used when rendering the utility layer
  108323. */
  108324. setRenderCamera(cam: Nullable<Camera>): void;
  108325. /**
  108326. * @hidden
  108327. * Light which used by gizmos to get light shading
  108328. */
  108329. _getSharedGizmoLight(): HemisphericLight;
  108330. /**
  108331. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  108332. */
  108333. pickUtilitySceneFirst: boolean;
  108334. /**
  108335. * 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)
  108336. */
  108337. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  108338. /**
  108339. * 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)
  108340. */
  108341. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  108342. /**
  108343. * The scene that is rendered on top of the original scene
  108344. */
  108345. utilityLayerScene: Scene;
  108346. /**
  108347. * If the utility layer should automatically be rendered on top of existing scene
  108348. */
  108349. shouldRender: boolean;
  108350. /**
  108351. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  108352. */
  108353. onlyCheckPointerDownEvents: boolean;
  108354. /**
  108355. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  108356. */
  108357. processAllEvents: boolean;
  108358. /**
  108359. * Observable raised when the pointer move from the utility layer scene to the main scene
  108360. */
  108361. onPointerOutObservable: Observable<number>;
  108362. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  108363. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  108364. private _afterRenderObserver;
  108365. private _sceneDisposeObserver;
  108366. private _originalPointerObserver;
  108367. /**
  108368. * Instantiates a UtilityLayerRenderer
  108369. * @param originalScene the original scene that will be rendered on top of
  108370. * @param handleEvents boolean indicating if the utility layer should handle events
  108371. */
  108372. constructor(
  108373. /** the original scene that will be rendered on top of */
  108374. originalScene: Scene, handleEvents?: boolean);
  108375. private _notifyObservers;
  108376. /**
  108377. * Renders the utility layers scene on top of the original scene
  108378. */
  108379. render(): void;
  108380. /**
  108381. * Disposes of the renderer
  108382. */
  108383. dispose(): void;
  108384. private _updateCamera;
  108385. }
  108386. }
  108387. declare module BABYLON {
  108388. /**
  108389. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  108390. */
  108391. export class Gizmo implements IDisposable {
  108392. /** The utility layer the gizmo will be added to */
  108393. gizmoLayer: UtilityLayerRenderer;
  108394. /**
  108395. * The root mesh of the gizmo
  108396. */
  108397. _rootMesh: Mesh;
  108398. private _attachedMesh;
  108399. /**
  108400. * Ratio for the scale of the gizmo (Default: 1)
  108401. */
  108402. scaleRatio: number;
  108403. /**
  108404. * If a custom mesh has been set (Default: false)
  108405. */
  108406. protected _customMeshSet: boolean;
  108407. /**
  108408. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  108409. * * When set, interactions will be enabled
  108410. */
  108411. attachedMesh: Nullable<AbstractMesh>;
  108412. /**
  108413. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  108414. * @param mesh The mesh to replace the default mesh of the gizmo
  108415. */
  108416. setCustomMesh(mesh: Mesh): void;
  108417. /**
  108418. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  108419. */
  108420. updateGizmoRotationToMatchAttachedMesh: boolean;
  108421. /**
  108422. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  108423. */
  108424. updateGizmoPositionToMatchAttachedMesh: boolean;
  108425. /**
  108426. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  108427. */
  108428. updateScale: boolean;
  108429. protected _interactionsEnabled: boolean;
  108430. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108431. private _beforeRenderObserver;
  108432. private _tempVector;
  108433. /**
  108434. * Creates a gizmo
  108435. * @param gizmoLayer The utility layer the gizmo will be added to
  108436. */
  108437. constructor(
  108438. /** The utility layer the gizmo will be added to */
  108439. gizmoLayer?: UtilityLayerRenderer);
  108440. /**
  108441. * Updates the gizmo to match the attached mesh's position/rotation
  108442. */
  108443. protected _update(): void;
  108444. /**
  108445. * Disposes of the gizmo
  108446. */
  108447. dispose(): void;
  108448. }
  108449. }
  108450. declare module BABYLON {
  108451. /**
  108452. * Single plane drag gizmo
  108453. */
  108454. export class PlaneDragGizmo extends Gizmo {
  108455. /**
  108456. * Drag behavior responsible for the gizmos dragging interactions
  108457. */
  108458. dragBehavior: PointerDragBehavior;
  108459. private _pointerObserver;
  108460. /**
  108461. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108462. */
  108463. snapDistance: number;
  108464. /**
  108465. * Event that fires each time the gizmo snaps to a new location.
  108466. * * snapDistance is the the change in distance
  108467. */
  108468. onSnapObservable: Observable<{
  108469. snapDistance: number;
  108470. }>;
  108471. private _plane;
  108472. private _coloredMaterial;
  108473. private _hoverMaterial;
  108474. private _isEnabled;
  108475. private _parent;
  108476. /** @hidden */
  108477. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  108478. /** @hidden */
  108479. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  108480. /**
  108481. * Creates a PlaneDragGizmo
  108482. * @param gizmoLayer The utility layer the gizmo will be added to
  108483. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  108484. * @param color The color of the gizmo
  108485. */
  108486. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  108487. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108488. /**
  108489. * If the gizmo is enabled
  108490. */
  108491. isEnabled: boolean;
  108492. /**
  108493. * Disposes of the gizmo
  108494. */
  108495. dispose(): void;
  108496. }
  108497. }
  108498. declare module BABYLON {
  108499. /**
  108500. * Gizmo that enables dragging a mesh along 3 axis
  108501. */
  108502. export class PositionGizmo extends Gizmo {
  108503. /**
  108504. * Internal gizmo used for interactions on the x axis
  108505. */
  108506. xGizmo: AxisDragGizmo;
  108507. /**
  108508. * Internal gizmo used for interactions on the y axis
  108509. */
  108510. yGizmo: AxisDragGizmo;
  108511. /**
  108512. * Internal gizmo used for interactions on the z axis
  108513. */
  108514. zGizmo: AxisDragGizmo;
  108515. /**
  108516. * Internal gizmo used for interactions on the yz plane
  108517. */
  108518. xPlaneGizmo: PlaneDragGizmo;
  108519. /**
  108520. * Internal gizmo used for interactions on the xz plane
  108521. */
  108522. yPlaneGizmo: PlaneDragGizmo;
  108523. /**
  108524. * Internal gizmo used for interactions on the xy plane
  108525. */
  108526. zPlaneGizmo: PlaneDragGizmo;
  108527. /**
  108528. * private variables
  108529. */
  108530. private _meshAttached;
  108531. private _updateGizmoRotationToMatchAttachedMesh;
  108532. private _snapDistance;
  108533. private _scaleRatio;
  108534. /** Fires an event when any of it's sub gizmos are dragged */
  108535. onDragStartObservable: Observable<unknown>;
  108536. /** Fires an event when any of it's sub gizmos are released from dragging */
  108537. onDragEndObservable: Observable<unknown>;
  108538. /**
  108539. * If set to true, planar drag is enabled
  108540. */
  108541. private _planarGizmoEnabled;
  108542. attachedMesh: Nullable<AbstractMesh>;
  108543. /**
  108544. * Creates a PositionGizmo
  108545. * @param gizmoLayer The utility layer the gizmo will be added to
  108546. */
  108547. constructor(gizmoLayer?: UtilityLayerRenderer);
  108548. /**
  108549. * If the planar drag gizmo is enabled
  108550. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  108551. */
  108552. planarGizmoEnabled: boolean;
  108553. updateGizmoRotationToMatchAttachedMesh: boolean;
  108554. /**
  108555. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108556. */
  108557. snapDistance: number;
  108558. /**
  108559. * Ratio for the scale of the gizmo (Default: 1)
  108560. */
  108561. scaleRatio: number;
  108562. /**
  108563. * Disposes of the gizmo
  108564. */
  108565. dispose(): void;
  108566. /**
  108567. * CustomMeshes are not supported by this gizmo
  108568. * @param mesh The mesh to replace the default mesh of the gizmo
  108569. */
  108570. setCustomMesh(mesh: Mesh): void;
  108571. }
  108572. }
  108573. declare module BABYLON {
  108574. /**
  108575. * Single axis drag gizmo
  108576. */
  108577. export class AxisDragGizmo extends Gizmo {
  108578. /**
  108579. * Drag behavior responsible for the gizmos dragging interactions
  108580. */
  108581. dragBehavior: PointerDragBehavior;
  108582. private _pointerObserver;
  108583. /**
  108584. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108585. */
  108586. snapDistance: number;
  108587. /**
  108588. * Event that fires each time the gizmo snaps to a new location.
  108589. * * snapDistance is the the change in distance
  108590. */
  108591. onSnapObservable: Observable<{
  108592. snapDistance: number;
  108593. }>;
  108594. private _isEnabled;
  108595. private _parent;
  108596. private _arrow;
  108597. private _coloredMaterial;
  108598. private _hoverMaterial;
  108599. /** @hidden */
  108600. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  108601. /** @hidden */
  108602. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  108603. /**
  108604. * Creates an AxisDragGizmo
  108605. * @param gizmoLayer The utility layer the gizmo will be added to
  108606. * @param dragAxis The axis which the gizmo will be able to drag on
  108607. * @param color The color of the gizmo
  108608. */
  108609. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  108610. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108611. /**
  108612. * If the gizmo is enabled
  108613. */
  108614. isEnabled: boolean;
  108615. /**
  108616. * Disposes of the gizmo
  108617. */
  108618. dispose(): void;
  108619. }
  108620. }
  108621. declare module BABYLON.Debug {
  108622. /**
  108623. * The Axes viewer will show 3 axes in a specific point in space
  108624. */
  108625. export class AxesViewer {
  108626. private _xAxis;
  108627. private _yAxis;
  108628. private _zAxis;
  108629. private _scaleLinesFactor;
  108630. private _instanced;
  108631. /**
  108632. * Gets the hosting scene
  108633. */
  108634. scene: Scene;
  108635. /**
  108636. * Gets or sets a number used to scale line length
  108637. */
  108638. scaleLines: number;
  108639. /** Gets the node hierarchy used to render x-axis */
  108640. readonly xAxis: TransformNode;
  108641. /** Gets the node hierarchy used to render y-axis */
  108642. readonly yAxis: TransformNode;
  108643. /** Gets the node hierarchy used to render z-axis */
  108644. readonly zAxis: TransformNode;
  108645. /**
  108646. * Creates a new AxesViewer
  108647. * @param scene defines the hosting scene
  108648. * @param scaleLines defines a number used to scale line length (1 by default)
  108649. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  108650. * @param xAxis defines the node hierarchy used to render the x-axis
  108651. * @param yAxis defines the node hierarchy used to render the y-axis
  108652. * @param zAxis defines the node hierarchy used to render the z-axis
  108653. */
  108654. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  108655. /**
  108656. * Force the viewer to update
  108657. * @param position defines the position of the viewer
  108658. * @param xaxis defines the x axis of the viewer
  108659. * @param yaxis defines the y axis of the viewer
  108660. * @param zaxis defines the z axis of the viewer
  108661. */
  108662. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  108663. /**
  108664. * Creates an instance of this axes viewer.
  108665. * @returns a new axes viewer with instanced meshes
  108666. */
  108667. createInstance(): AxesViewer;
  108668. /** Releases resources */
  108669. dispose(): void;
  108670. private static _SetRenderingGroupId;
  108671. }
  108672. }
  108673. declare module BABYLON.Debug {
  108674. /**
  108675. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  108676. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  108677. */
  108678. export class BoneAxesViewer extends AxesViewer {
  108679. /**
  108680. * Gets or sets the target mesh where to display the axes viewer
  108681. */
  108682. mesh: Nullable<Mesh>;
  108683. /**
  108684. * Gets or sets the target bone where to display the axes viewer
  108685. */
  108686. bone: Nullable<Bone>;
  108687. /** Gets current position */
  108688. pos: Vector3;
  108689. /** Gets direction of X axis */
  108690. xaxis: Vector3;
  108691. /** Gets direction of Y axis */
  108692. yaxis: Vector3;
  108693. /** Gets direction of Z axis */
  108694. zaxis: Vector3;
  108695. /**
  108696. * Creates a new BoneAxesViewer
  108697. * @param scene defines the hosting scene
  108698. * @param bone defines the target bone
  108699. * @param mesh defines the target mesh
  108700. * @param scaleLines defines a scaling factor for line length (1 by default)
  108701. */
  108702. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  108703. /**
  108704. * Force the viewer to update
  108705. */
  108706. update(): void;
  108707. /** Releases resources */
  108708. dispose(): void;
  108709. }
  108710. }
  108711. declare module BABYLON {
  108712. /**
  108713. * Interface used to define scene explorer extensibility option
  108714. */
  108715. export interface IExplorerExtensibilityOption {
  108716. /**
  108717. * Define the option label
  108718. */
  108719. label: string;
  108720. /**
  108721. * Defines the action to execute on click
  108722. */
  108723. action: (entity: any) => void;
  108724. }
  108725. /**
  108726. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  108727. */
  108728. export interface IExplorerExtensibilityGroup {
  108729. /**
  108730. * Defines a predicate to test if a given type mut be extended
  108731. */
  108732. predicate: (entity: any) => boolean;
  108733. /**
  108734. * Gets the list of options added to a type
  108735. */
  108736. entries: IExplorerExtensibilityOption[];
  108737. }
  108738. /**
  108739. * Interface used to define the options to use to create the Inspector
  108740. */
  108741. export interface IInspectorOptions {
  108742. /**
  108743. * Display in overlay mode (default: false)
  108744. */
  108745. overlay?: boolean;
  108746. /**
  108747. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  108748. */
  108749. globalRoot?: HTMLElement;
  108750. /**
  108751. * Display the Scene explorer
  108752. */
  108753. showExplorer?: boolean;
  108754. /**
  108755. * Display the property inspector
  108756. */
  108757. showInspector?: boolean;
  108758. /**
  108759. * Display in embed mode (both panes on the right)
  108760. */
  108761. embedMode?: boolean;
  108762. /**
  108763. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  108764. */
  108765. handleResize?: boolean;
  108766. /**
  108767. * Allow the panes to popup (default: true)
  108768. */
  108769. enablePopup?: boolean;
  108770. /**
  108771. * Allow the panes to be closed by users (default: true)
  108772. */
  108773. enableClose?: boolean;
  108774. /**
  108775. * Optional list of extensibility entries
  108776. */
  108777. explorerExtensibility?: IExplorerExtensibilityGroup[];
  108778. /**
  108779. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  108780. */
  108781. inspectorURL?: string;
  108782. }
  108783. interface Scene {
  108784. /**
  108785. * @hidden
  108786. * Backing field
  108787. */
  108788. _debugLayer: DebugLayer;
  108789. /**
  108790. * Gets the debug layer (aka Inspector) associated with the scene
  108791. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108792. */
  108793. debugLayer: DebugLayer;
  108794. }
  108795. /**
  108796. * The debug layer (aka Inspector) is the go to tool in order to better understand
  108797. * what is happening in your scene
  108798. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108799. */
  108800. export class DebugLayer {
  108801. /**
  108802. * Define the url to get the inspector script from.
  108803. * By default it uses the babylonjs CDN.
  108804. * @ignoreNaming
  108805. */
  108806. static InspectorURL: string;
  108807. private _scene;
  108808. private BJSINSPECTOR;
  108809. private _onPropertyChangedObservable?;
  108810. /**
  108811. * Observable triggered when a property is changed through the inspector.
  108812. */
  108813. readonly onPropertyChangedObservable: any;
  108814. /**
  108815. * Instantiates a new debug layer.
  108816. * The debug layer (aka Inspector) is the go to tool in order to better understand
  108817. * what is happening in your scene
  108818. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108819. * @param scene Defines the scene to inspect
  108820. */
  108821. constructor(scene: Scene);
  108822. /** Creates the inspector window. */
  108823. private _createInspector;
  108824. /**
  108825. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  108826. * @param entity defines the entity to select
  108827. * @param lineContainerTitle defines the specific block to highlight
  108828. */
  108829. select(entity: any, lineContainerTitle?: string): void;
  108830. /** Get the inspector from bundle or global */
  108831. private _getGlobalInspector;
  108832. /**
  108833. * Get if the inspector is visible or not.
  108834. * @returns true if visible otherwise, false
  108835. */
  108836. isVisible(): boolean;
  108837. /**
  108838. * Hide the inspector and close its window.
  108839. */
  108840. hide(): void;
  108841. /**
  108842. * Launch the debugLayer.
  108843. * @param config Define the configuration of the inspector
  108844. * @return a promise fulfilled when the debug layer is visible
  108845. */
  108846. show(config?: IInspectorOptions): Promise<DebugLayer>;
  108847. }
  108848. }
  108849. declare module BABYLON {
  108850. /**
  108851. * Class containing static functions to help procedurally build meshes
  108852. */
  108853. export class BoxBuilder {
  108854. /**
  108855. * Creates a box mesh
  108856. * * The parameter `size` sets the size (float) of each box side (default 1)
  108857. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  108858. * * 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)
  108859. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  108860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108861. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108863. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  108864. * @param name defines the name of the mesh
  108865. * @param options defines the options used to create the mesh
  108866. * @param scene defines the hosting scene
  108867. * @returns the box mesh
  108868. */
  108869. static CreateBox(name: string, options: {
  108870. size?: number;
  108871. width?: number;
  108872. height?: number;
  108873. depth?: number;
  108874. faceUV?: Vector4[];
  108875. faceColors?: Color4[];
  108876. sideOrientation?: number;
  108877. frontUVs?: Vector4;
  108878. backUVs?: Vector4;
  108879. wrap?: boolean;
  108880. topBaseAt?: number;
  108881. bottomBaseAt?: number;
  108882. updatable?: boolean;
  108883. }, scene?: Nullable<Scene>): Mesh;
  108884. }
  108885. }
  108886. declare module BABYLON {
  108887. /**
  108888. * Class containing static functions to help procedurally build meshes
  108889. */
  108890. export class SphereBuilder {
  108891. /**
  108892. * Creates a sphere mesh
  108893. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  108894. * * 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`)
  108895. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  108896. * * 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
  108897. * * 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)
  108898. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108899. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108901. * @param name defines the name of the mesh
  108902. * @param options defines the options used to create the mesh
  108903. * @param scene defines the hosting scene
  108904. * @returns the sphere mesh
  108905. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  108906. */
  108907. static CreateSphere(name: string, options: {
  108908. segments?: number;
  108909. diameter?: number;
  108910. diameterX?: number;
  108911. diameterY?: number;
  108912. diameterZ?: number;
  108913. arc?: number;
  108914. slice?: number;
  108915. sideOrientation?: number;
  108916. frontUVs?: Vector4;
  108917. backUVs?: Vector4;
  108918. updatable?: boolean;
  108919. }, scene?: Nullable<Scene>): Mesh;
  108920. }
  108921. }
  108922. declare module BABYLON.Debug {
  108923. /**
  108924. * Used to show the physics impostor around the specific mesh
  108925. */
  108926. export class PhysicsViewer {
  108927. /** @hidden */
  108928. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  108929. /** @hidden */
  108930. protected _meshes: Array<Nullable<AbstractMesh>>;
  108931. /** @hidden */
  108932. protected _scene: Nullable<Scene>;
  108933. /** @hidden */
  108934. protected _numMeshes: number;
  108935. /** @hidden */
  108936. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  108937. private _renderFunction;
  108938. private _utilityLayer;
  108939. private _debugBoxMesh;
  108940. private _debugSphereMesh;
  108941. private _debugCylinderMesh;
  108942. private _debugMaterial;
  108943. private _debugMeshMeshes;
  108944. /**
  108945. * Creates a new PhysicsViewer
  108946. * @param scene defines the hosting scene
  108947. */
  108948. constructor(scene: Scene);
  108949. /** @hidden */
  108950. protected _updateDebugMeshes(): void;
  108951. /**
  108952. * Renders a specified physic impostor
  108953. * @param impostor defines the impostor to render
  108954. * @param targetMesh defines the mesh represented by the impostor
  108955. * @returns the new debug mesh used to render the impostor
  108956. */
  108957. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  108958. /**
  108959. * Hides a specified physic impostor
  108960. * @param impostor defines the impostor to hide
  108961. */
  108962. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  108963. private _getDebugMaterial;
  108964. private _getDebugBoxMesh;
  108965. private _getDebugSphereMesh;
  108966. private _getDebugCylinderMesh;
  108967. private _getDebugMeshMesh;
  108968. private _getDebugMesh;
  108969. /** Releases all resources */
  108970. dispose(): void;
  108971. }
  108972. }
  108973. declare module BABYLON {
  108974. /**
  108975. * Class containing static functions to help procedurally build meshes
  108976. */
  108977. export class LinesBuilder {
  108978. /**
  108979. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  108980. * * 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
  108981. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  108982. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  108983. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  108984. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  108985. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  108986. * * 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
  108987. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  108988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108989. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  108990. * @param name defines the name of the new line system
  108991. * @param options defines the options used to create the line system
  108992. * @param scene defines the hosting scene
  108993. * @returns a new line system mesh
  108994. */
  108995. static CreateLineSystem(name: string, options: {
  108996. lines: Vector3[][];
  108997. updatable?: boolean;
  108998. instance?: Nullable<LinesMesh>;
  108999. colors?: Nullable<Color4[][]>;
  109000. useVertexAlpha?: boolean;
  109001. }, scene: Nullable<Scene>): LinesMesh;
  109002. /**
  109003. * Creates a line mesh
  109004. * 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
  109005. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109006. * * The parameter `points` is an array successive Vector3
  109007. * * 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
  109008. * * The optional parameter `colors` is an array of successive Color4, one per line point
  109009. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  109010. * * When updating an instance, remember that only point positions can change, not the number of points
  109011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109012. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  109013. * @param name defines the name of the new line system
  109014. * @param options defines the options used to create the line system
  109015. * @param scene defines the hosting scene
  109016. * @returns a new line mesh
  109017. */
  109018. static CreateLines(name: string, options: {
  109019. points: Vector3[];
  109020. updatable?: boolean;
  109021. instance?: Nullable<LinesMesh>;
  109022. colors?: Color4[];
  109023. useVertexAlpha?: boolean;
  109024. }, scene?: Nullable<Scene>): LinesMesh;
  109025. /**
  109026. * Creates a dashed line mesh
  109027. * * 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
  109028. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109029. * * The parameter `points` is an array successive Vector3
  109030. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  109031. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  109032. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109033. * * 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
  109034. * * When updating an instance, remember that only point positions can change, not the number of points
  109035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109036. * @param name defines the name of the mesh
  109037. * @param options defines the options used to create the mesh
  109038. * @param scene defines the hosting scene
  109039. * @returns the dashed line mesh
  109040. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  109041. */
  109042. static CreateDashedLines(name: string, options: {
  109043. points: Vector3[];
  109044. dashSize?: number;
  109045. gapSize?: number;
  109046. dashNb?: number;
  109047. updatable?: boolean;
  109048. instance?: LinesMesh;
  109049. }, scene?: Nullable<Scene>): LinesMesh;
  109050. }
  109051. }
  109052. declare module BABYLON {
  109053. /**
  109054. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  109055. * in order to better appreciate the issue one might have.
  109056. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  109057. */
  109058. export class RayHelper {
  109059. /**
  109060. * Defines the ray we are currently tryin to visualize.
  109061. */
  109062. ray: Nullable<Ray>;
  109063. private _renderPoints;
  109064. private _renderLine;
  109065. private _renderFunction;
  109066. private _scene;
  109067. private _updateToMeshFunction;
  109068. private _attachedToMesh;
  109069. private _meshSpaceDirection;
  109070. private _meshSpaceOrigin;
  109071. /**
  109072. * Helper function to create a colored helper in a scene in one line.
  109073. * @param ray Defines the ray we are currently tryin to visualize
  109074. * @param scene Defines the scene the ray is used in
  109075. * @param color Defines the color we want to see the ray in
  109076. * @returns The newly created ray helper.
  109077. */
  109078. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  109079. /**
  109080. * Instantiate a new ray helper.
  109081. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  109082. * in order to better appreciate the issue one might have.
  109083. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  109084. * @param ray Defines the ray we are currently tryin to visualize
  109085. */
  109086. constructor(ray: Ray);
  109087. /**
  109088. * Shows the ray we are willing to debug.
  109089. * @param scene Defines the scene the ray needs to be rendered in
  109090. * @param color Defines the color the ray needs to be rendered in
  109091. */
  109092. show(scene: Scene, color?: Color3): void;
  109093. /**
  109094. * Hides the ray we are debugging.
  109095. */
  109096. hide(): void;
  109097. private _render;
  109098. /**
  109099. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  109100. * @param mesh Defines the mesh we want the helper attached to
  109101. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  109102. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  109103. * @param length Defines the length of the ray
  109104. */
  109105. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  109106. /**
  109107. * Detach the ray helper from the mesh it has previously been attached to.
  109108. */
  109109. detachFromMesh(): void;
  109110. private _updateToMesh;
  109111. /**
  109112. * Dispose the helper and release its associated resources.
  109113. */
  109114. dispose(): void;
  109115. }
  109116. }
  109117. declare module BABYLON.Debug {
  109118. /**
  109119. * Class used to render a debug view of a given skeleton
  109120. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  109121. */
  109122. export class SkeletonViewer {
  109123. /** defines the skeleton to render */
  109124. skeleton: Skeleton;
  109125. /** defines the mesh attached to the skeleton */
  109126. mesh: AbstractMesh;
  109127. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  109128. autoUpdateBonesMatrices: boolean;
  109129. /** defines the rendering group id to use with the viewer */
  109130. renderingGroupId: number;
  109131. /** Gets or sets the color used to render the skeleton */
  109132. color: Color3;
  109133. private _scene;
  109134. private _debugLines;
  109135. private _debugMesh;
  109136. private _isEnabled;
  109137. private _renderFunction;
  109138. private _utilityLayer;
  109139. /**
  109140. * Returns the mesh used to render the bones
  109141. */
  109142. readonly debugMesh: Nullable<LinesMesh>;
  109143. /**
  109144. * Creates a new SkeletonViewer
  109145. * @param skeleton defines the skeleton to render
  109146. * @param mesh defines the mesh attached to the skeleton
  109147. * @param scene defines the hosting scene
  109148. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  109149. * @param renderingGroupId defines the rendering group id to use with the viewer
  109150. */
  109151. constructor(
  109152. /** defines the skeleton to render */
  109153. skeleton: Skeleton,
  109154. /** defines the mesh attached to the skeleton */
  109155. mesh: AbstractMesh, scene: Scene,
  109156. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  109157. autoUpdateBonesMatrices?: boolean,
  109158. /** defines the rendering group id to use with the viewer */
  109159. renderingGroupId?: number);
  109160. /** Gets or sets a boolean indicating if the viewer is enabled */
  109161. isEnabled: boolean;
  109162. private _getBonePosition;
  109163. private _getLinesForBonesWithLength;
  109164. private _getLinesForBonesNoLength;
  109165. /** Update the viewer to sync with current skeleton state */
  109166. update(): void;
  109167. /** Release associated resources */
  109168. dispose(): void;
  109169. }
  109170. }
  109171. declare module BABYLON {
  109172. /**
  109173. * Options to create the null engine
  109174. */
  109175. export class NullEngineOptions {
  109176. /**
  109177. * Render width (Default: 512)
  109178. */
  109179. renderWidth: number;
  109180. /**
  109181. * Render height (Default: 256)
  109182. */
  109183. renderHeight: number;
  109184. /**
  109185. * Texture size (Default: 512)
  109186. */
  109187. textureSize: number;
  109188. /**
  109189. * If delta time between frames should be constant
  109190. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109191. */
  109192. deterministicLockstep: boolean;
  109193. /**
  109194. * Maximum about of steps between frames (Default: 4)
  109195. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109196. */
  109197. lockstepMaxSteps: number;
  109198. }
  109199. /**
  109200. * The null engine class provides support for headless version of babylon.js.
  109201. * This can be used in server side scenario or for testing purposes
  109202. */
  109203. export class NullEngine extends Engine {
  109204. private _options;
  109205. /**
  109206. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109207. */
  109208. isDeterministicLockStep(): boolean;
  109209. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  109210. getLockstepMaxSteps(): number;
  109211. /**
  109212. * Sets hardware scaling, used to save performance if needed
  109213. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109214. */
  109215. getHardwareScalingLevel(): number;
  109216. constructor(options?: NullEngineOptions);
  109217. createVertexBuffer(vertices: FloatArray): DataBuffer;
  109218. createIndexBuffer(indices: IndicesArray): DataBuffer;
  109219. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  109220. getRenderWidth(useScreen?: boolean): number;
  109221. getRenderHeight(useScreen?: boolean): number;
  109222. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  109223. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  109224. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  109225. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  109226. bindSamplers(effect: Effect): void;
  109227. enableEffect(effect: Effect): void;
  109228. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  109229. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  109230. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  109231. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  109232. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  109233. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  109234. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  109235. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  109236. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  109237. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  109238. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  109239. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  109240. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  109241. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  109242. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109243. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109244. setFloat(uniform: WebGLUniformLocation, value: number): void;
  109245. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  109246. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  109247. setBool(uniform: WebGLUniformLocation, bool: number): void;
  109248. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  109249. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  109250. bindBuffers(vertexBuffers: {
  109251. [key: string]: VertexBuffer;
  109252. }, indexBuffer: DataBuffer, effect: Effect): void;
  109253. wipeCaches(bruteForce?: boolean): void;
  109254. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  109255. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  109256. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  109257. /** @hidden */
  109258. _createTexture(): WebGLTexture;
  109259. /** @hidden */
  109260. _releaseTexture(texture: InternalTexture): void;
  109261. 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;
  109262. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  109263. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  109264. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  109265. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  109266. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  109267. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  109268. areAllEffectsReady(): boolean;
  109269. /**
  109270. * @hidden
  109271. * Get the current error code of the webGL context
  109272. * @returns the error code
  109273. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  109274. */
  109275. getError(): number;
  109276. /** @hidden */
  109277. _getUnpackAlignement(): number;
  109278. /** @hidden */
  109279. _unpackFlipY(value: boolean): void;
  109280. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  109281. /**
  109282. * Updates a dynamic vertex buffer.
  109283. * @param vertexBuffer the vertex buffer to update
  109284. * @param data the data used to update the vertex buffer
  109285. * @param byteOffset the byte offset of the data (optional)
  109286. * @param byteLength the byte length of the data (optional)
  109287. */
  109288. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  109289. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  109290. /** @hidden */
  109291. _bindTexture(channel: number, texture: InternalTexture): void;
  109292. protected _deleteBuffer(buffer: WebGLBuffer): void;
  109293. releaseEffects(): void;
  109294. displayLoadingUI(): void;
  109295. hideLoadingUI(): void;
  109296. /** @hidden */
  109297. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109298. /** @hidden */
  109299. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109300. /** @hidden */
  109301. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109302. /** @hidden */
  109303. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  109304. }
  109305. }
  109306. declare module BABYLON {
  109307. /** @hidden */
  109308. export class _OcclusionDataStorage {
  109309. /** @hidden */
  109310. occlusionInternalRetryCounter: number;
  109311. /** @hidden */
  109312. isOcclusionQueryInProgress: boolean;
  109313. /** @hidden */
  109314. isOccluded: boolean;
  109315. /** @hidden */
  109316. occlusionRetryCount: number;
  109317. /** @hidden */
  109318. occlusionType: number;
  109319. /** @hidden */
  109320. occlusionQueryAlgorithmType: number;
  109321. }
  109322. interface Engine {
  109323. /**
  109324. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  109325. * @return the new query
  109326. */
  109327. createQuery(): WebGLQuery;
  109328. /**
  109329. * Delete and release a webGL query
  109330. * @param query defines the query to delete
  109331. * @return the current engine
  109332. */
  109333. deleteQuery(query: WebGLQuery): Engine;
  109334. /**
  109335. * Check if a given query has resolved and got its value
  109336. * @param query defines the query to check
  109337. * @returns true if the query got its value
  109338. */
  109339. isQueryResultAvailable(query: WebGLQuery): boolean;
  109340. /**
  109341. * Gets the value of a given query
  109342. * @param query defines the query to check
  109343. * @returns the value of the query
  109344. */
  109345. getQueryResult(query: WebGLQuery): number;
  109346. /**
  109347. * Initiates an occlusion query
  109348. * @param algorithmType defines the algorithm to use
  109349. * @param query defines the query to use
  109350. * @returns the current engine
  109351. * @see http://doc.babylonjs.com/features/occlusionquery
  109352. */
  109353. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  109354. /**
  109355. * Ends an occlusion query
  109356. * @see http://doc.babylonjs.com/features/occlusionquery
  109357. * @param algorithmType defines the algorithm to use
  109358. * @returns the current engine
  109359. */
  109360. endOcclusionQuery(algorithmType: number): Engine;
  109361. /**
  109362. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  109363. * Please note that only one query can be issued at a time
  109364. * @returns a time token used to track the time span
  109365. */
  109366. startTimeQuery(): Nullable<_TimeToken>;
  109367. /**
  109368. * Ends a time query
  109369. * @param token defines the token used to measure the time span
  109370. * @returns the time spent (in ns)
  109371. */
  109372. endTimeQuery(token: _TimeToken): int;
  109373. /** @hidden */
  109374. _currentNonTimestampToken: Nullable<_TimeToken>;
  109375. /** @hidden */
  109376. _createTimeQuery(): WebGLQuery;
  109377. /** @hidden */
  109378. _deleteTimeQuery(query: WebGLQuery): void;
  109379. /** @hidden */
  109380. _getGlAlgorithmType(algorithmType: number): number;
  109381. /** @hidden */
  109382. _getTimeQueryResult(query: WebGLQuery): any;
  109383. /** @hidden */
  109384. _getTimeQueryAvailability(query: WebGLQuery): any;
  109385. }
  109386. interface AbstractMesh {
  109387. /**
  109388. * Backing filed
  109389. * @hidden
  109390. */
  109391. __occlusionDataStorage: _OcclusionDataStorage;
  109392. /**
  109393. * Access property
  109394. * @hidden
  109395. */
  109396. _occlusionDataStorage: _OcclusionDataStorage;
  109397. /**
  109398. * 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.
  109399. * The default value is -1 which means don't break the query and wait till the result
  109400. * @see http://doc.babylonjs.com/features/occlusionquery
  109401. */
  109402. occlusionRetryCount: number;
  109403. /**
  109404. * 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:
  109405. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  109406. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  109407. * * 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.
  109408. * @see http://doc.babylonjs.com/features/occlusionquery
  109409. */
  109410. occlusionType: number;
  109411. /**
  109412. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  109413. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  109414. * * 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.
  109415. * @see http://doc.babylonjs.com/features/occlusionquery
  109416. */
  109417. occlusionQueryAlgorithmType: number;
  109418. /**
  109419. * 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
  109420. * @see http://doc.babylonjs.com/features/occlusionquery
  109421. */
  109422. isOccluded: boolean;
  109423. /**
  109424. * Flag to check the progress status of the query
  109425. * @see http://doc.babylonjs.com/features/occlusionquery
  109426. */
  109427. isOcclusionQueryInProgress: boolean;
  109428. }
  109429. }
  109430. declare module BABYLON {
  109431. /** @hidden */
  109432. export var _forceTransformFeedbackToBundle: boolean;
  109433. interface Engine {
  109434. /**
  109435. * Creates a webGL transform feedback object
  109436. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  109437. * @returns the webGL transform feedback object
  109438. */
  109439. createTransformFeedback(): WebGLTransformFeedback;
  109440. /**
  109441. * Delete a webGL transform feedback object
  109442. * @param value defines the webGL transform feedback object to delete
  109443. */
  109444. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  109445. /**
  109446. * Bind a webGL transform feedback object to the webgl context
  109447. * @param value defines the webGL transform feedback object to bind
  109448. */
  109449. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  109450. /**
  109451. * Begins a transform feedback operation
  109452. * @param usePoints defines if points or triangles must be used
  109453. */
  109454. beginTransformFeedback(usePoints: boolean): void;
  109455. /**
  109456. * Ends a transform feedback operation
  109457. */
  109458. endTransformFeedback(): void;
  109459. /**
  109460. * Specify the varyings to use with transform feedback
  109461. * @param program defines the associated webGL program
  109462. * @param value defines the list of strings representing the varying names
  109463. */
  109464. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  109465. /**
  109466. * Bind a webGL buffer for a transform feedback operation
  109467. * @param value defines the webGL buffer to bind
  109468. */
  109469. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  109470. }
  109471. }
  109472. declare module BABYLON {
  109473. /**
  109474. * Creation options of the multi render target texture.
  109475. */
  109476. export interface IMultiRenderTargetOptions {
  109477. /**
  109478. * Define if the texture needs to create mip maps after render.
  109479. */
  109480. generateMipMaps?: boolean;
  109481. /**
  109482. * Define the types of all the draw buffers we want to create
  109483. */
  109484. types?: number[];
  109485. /**
  109486. * Define the sampling modes of all the draw buffers we want to create
  109487. */
  109488. samplingModes?: number[];
  109489. /**
  109490. * Define if a depth buffer is required
  109491. */
  109492. generateDepthBuffer?: boolean;
  109493. /**
  109494. * Define if a stencil buffer is required
  109495. */
  109496. generateStencilBuffer?: boolean;
  109497. /**
  109498. * Define if a depth texture is required instead of a depth buffer
  109499. */
  109500. generateDepthTexture?: boolean;
  109501. /**
  109502. * Define the number of desired draw buffers
  109503. */
  109504. textureCount?: number;
  109505. /**
  109506. * Define if aspect ratio should be adapted to the texture or stay the scene one
  109507. */
  109508. doNotChangeAspectRatio?: boolean;
  109509. /**
  109510. * Define the default type of the buffers we are creating
  109511. */
  109512. defaultType?: number;
  109513. }
  109514. /**
  109515. * A multi render target, like a render target provides the ability to render to a texture.
  109516. * Unlike the render target, it can render to several draw buffers in one draw.
  109517. * This is specially interesting in deferred rendering or for any effects requiring more than
  109518. * just one color from a single pass.
  109519. */
  109520. export class MultiRenderTarget extends RenderTargetTexture {
  109521. private _internalTextures;
  109522. private _textures;
  109523. private _multiRenderTargetOptions;
  109524. /**
  109525. * Get if draw buffers are currently supported by the used hardware and browser.
  109526. */
  109527. readonly isSupported: boolean;
  109528. /**
  109529. * Get the list of textures generated by the multi render target.
  109530. */
  109531. readonly textures: Texture[];
  109532. /**
  109533. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  109534. */
  109535. readonly depthTexture: Texture;
  109536. /**
  109537. * Set the wrapping mode on U of all the textures we are rendering to.
  109538. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  109539. */
  109540. wrapU: number;
  109541. /**
  109542. * Set the wrapping mode on V of all the textures we are rendering to.
  109543. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  109544. */
  109545. wrapV: number;
  109546. /**
  109547. * Instantiate a new multi render target texture.
  109548. * A multi render target, like a render target provides the ability to render to a texture.
  109549. * Unlike the render target, it can render to several draw buffers in one draw.
  109550. * This is specially interesting in deferred rendering or for any effects requiring more than
  109551. * just one color from a single pass.
  109552. * @param name Define the name of the texture
  109553. * @param size Define the size of the buffers to render to
  109554. * @param count Define the number of target we are rendering into
  109555. * @param scene Define the scene the texture belongs to
  109556. * @param options Define the options used to create the multi render target
  109557. */
  109558. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  109559. /** @hidden */
  109560. _rebuild(): void;
  109561. private _createInternalTextures;
  109562. private _createTextures;
  109563. /**
  109564. * Define the number of samples used if MSAA is enabled.
  109565. */
  109566. samples: number;
  109567. /**
  109568. * Resize all the textures in the multi render target.
  109569. * Be carrefull as it will recreate all the data in the new texture.
  109570. * @param size Define the new size
  109571. */
  109572. resize(size: any): void;
  109573. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  109574. /**
  109575. * Dispose the render targets and their associated resources
  109576. */
  109577. dispose(): void;
  109578. /**
  109579. * Release all the underlying texture used as draw buffers.
  109580. */
  109581. releaseInternalTextures(): void;
  109582. }
  109583. }
  109584. declare module BABYLON {
  109585. interface Engine {
  109586. /**
  109587. * Unbind a list of render target textures from the webGL context
  109588. * This is used only when drawBuffer extension or webGL2 are active
  109589. * @param textures defines the render target textures to unbind
  109590. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  109591. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  109592. */
  109593. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  109594. /**
  109595. * Create a multi render target texture
  109596. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  109597. * @param size defines the size of the texture
  109598. * @param options defines the creation options
  109599. * @returns the cube texture as an InternalTexture
  109600. */
  109601. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  109602. /**
  109603. * Update the sample count for a given multiple render target texture
  109604. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  109605. * @param textures defines the textures to update
  109606. * @param samples defines the sample count to set
  109607. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  109608. */
  109609. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  109610. }
  109611. }
  109612. declare module BABYLON {
  109613. /** @hidden */
  109614. export var rgbdEncodePixelShader: {
  109615. name: string;
  109616. shader: string;
  109617. };
  109618. }
  109619. declare module BABYLON {
  109620. /** @hidden */
  109621. export var rgbdDecodePixelShader: {
  109622. name: string;
  109623. shader: string;
  109624. };
  109625. }
  109626. declare module BABYLON {
  109627. /**
  109628. * Raw texture data and descriptor sufficient for WebGL texture upload
  109629. */
  109630. export interface EnvironmentTextureInfo {
  109631. /**
  109632. * Version of the environment map
  109633. */
  109634. version: number;
  109635. /**
  109636. * Width of image
  109637. */
  109638. width: number;
  109639. /**
  109640. * Irradiance information stored in the file.
  109641. */
  109642. irradiance: any;
  109643. /**
  109644. * Specular information stored in the file.
  109645. */
  109646. specular: any;
  109647. }
  109648. /**
  109649. * Defines One Image in the file. It requires only the position in the file
  109650. * as well as the length.
  109651. */
  109652. interface BufferImageData {
  109653. /**
  109654. * Length of the image data.
  109655. */
  109656. length: number;
  109657. /**
  109658. * Position of the data from the null terminator delimiting the end of the JSON.
  109659. */
  109660. position: number;
  109661. }
  109662. /**
  109663. * Defines the specular data enclosed in the file.
  109664. * This corresponds to the version 1 of the data.
  109665. */
  109666. export interface EnvironmentTextureSpecularInfoV1 {
  109667. /**
  109668. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  109669. */
  109670. specularDataPosition?: number;
  109671. /**
  109672. * This contains all the images data needed to reconstruct the cubemap.
  109673. */
  109674. mipmaps: Array<BufferImageData>;
  109675. /**
  109676. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  109677. */
  109678. lodGenerationScale: number;
  109679. }
  109680. /**
  109681. * Sets of helpers addressing the serialization and deserialization of environment texture
  109682. * stored in a BabylonJS env file.
  109683. * Those files are usually stored as .env files.
  109684. */
  109685. export class EnvironmentTextureTools {
  109686. /**
  109687. * Magic number identifying the env file.
  109688. */
  109689. private static _MagicBytes;
  109690. /**
  109691. * Gets the environment info from an env file.
  109692. * @param data The array buffer containing the .env bytes.
  109693. * @returns the environment file info (the json header) if successfully parsed.
  109694. */
  109695. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  109696. /**
  109697. * Creates an environment texture from a loaded cube texture.
  109698. * @param texture defines the cube texture to convert in env file
  109699. * @return a promise containing the environment data if succesfull.
  109700. */
  109701. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  109702. /**
  109703. * Creates a JSON representation of the spherical data.
  109704. * @param texture defines the texture containing the polynomials
  109705. * @return the JSON representation of the spherical info
  109706. */
  109707. private static _CreateEnvTextureIrradiance;
  109708. /**
  109709. * Creates the ArrayBufferViews used for initializing environment texture image data.
  109710. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  109711. * @param info parameters that determine what views will be created for accessing the underlying buffer
  109712. * @return the views described by info providing access to the underlying buffer
  109713. */
  109714. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  109715. /**
  109716. * Uploads the texture info contained in the env file to the GPU.
  109717. * @param texture defines the internal texture to upload to
  109718. * @param arrayBuffer defines the buffer cotaining the data to load
  109719. * @param info defines the texture info retrieved through the GetEnvInfo method
  109720. * @returns a promise
  109721. */
  109722. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  109723. /**
  109724. * Uploads the levels of image data to the GPU.
  109725. * @param texture defines the internal texture to upload to
  109726. * @param imageData defines the array buffer views of image data [mipmap][face]
  109727. * @returns a promise
  109728. */
  109729. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  109730. /**
  109731. * Uploads spherical polynomials information to the texture.
  109732. * @param texture defines the texture we are trying to upload the information to
  109733. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  109734. */
  109735. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  109736. /** @hidden */
  109737. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109738. }
  109739. }
  109740. declare module BABYLON {
  109741. /**
  109742. * Contains position and normal vectors for a vertex
  109743. */
  109744. export class PositionNormalVertex {
  109745. /** the position of the vertex (defaut: 0,0,0) */
  109746. position: Vector3;
  109747. /** the normal of the vertex (defaut: 0,1,0) */
  109748. normal: Vector3;
  109749. /**
  109750. * Creates a PositionNormalVertex
  109751. * @param position the position of the vertex (defaut: 0,0,0)
  109752. * @param normal the normal of the vertex (defaut: 0,1,0)
  109753. */
  109754. constructor(
  109755. /** the position of the vertex (defaut: 0,0,0) */
  109756. position?: Vector3,
  109757. /** the normal of the vertex (defaut: 0,1,0) */
  109758. normal?: Vector3);
  109759. /**
  109760. * Clones the PositionNormalVertex
  109761. * @returns the cloned PositionNormalVertex
  109762. */
  109763. clone(): PositionNormalVertex;
  109764. }
  109765. /**
  109766. * Contains position, normal and uv vectors for a vertex
  109767. */
  109768. export class PositionNormalTextureVertex {
  109769. /** the position of the vertex (defaut: 0,0,0) */
  109770. position: Vector3;
  109771. /** the normal of the vertex (defaut: 0,1,0) */
  109772. normal: Vector3;
  109773. /** the uv of the vertex (default: 0,0) */
  109774. uv: Vector2;
  109775. /**
  109776. * Creates a PositionNormalTextureVertex
  109777. * @param position the position of the vertex (defaut: 0,0,0)
  109778. * @param normal the normal of the vertex (defaut: 0,1,0)
  109779. * @param uv the uv of the vertex (default: 0,0)
  109780. */
  109781. constructor(
  109782. /** the position of the vertex (defaut: 0,0,0) */
  109783. position?: Vector3,
  109784. /** the normal of the vertex (defaut: 0,1,0) */
  109785. normal?: Vector3,
  109786. /** the uv of the vertex (default: 0,0) */
  109787. uv?: Vector2);
  109788. /**
  109789. * Clones the PositionNormalTextureVertex
  109790. * @returns the cloned PositionNormalTextureVertex
  109791. */
  109792. clone(): PositionNormalTextureVertex;
  109793. }
  109794. }
  109795. declare module BABYLON {
  109796. /** @hidden */
  109797. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  109798. private _genericAttributeLocation;
  109799. private _varyingLocationCount;
  109800. private _varyingLocationMap;
  109801. private _replacements;
  109802. private _textureCount;
  109803. private _uniforms;
  109804. lineProcessor(line: string): string;
  109805. attributeProcessor(attribute: string): string;
  109806. varyingProcessor(varying: string, isFragment: boolean): string;
  109807. uniformProcessor(uniform: string): string;
  109808. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  109809. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  109810. }
  109811. }
  109812. declare module BABYLON {
  109813. /**
  109814. * Container for accessors for natively-stored mesh data buffers.
  109815. */
  109816. class NativeDataBuffer extends DataBuffer {
  109817. /**
  109818. * Accessor value used to identify/retrieve a natively-stored index buffer.
  109819. */
  109820. nativeIndexBuffer?: any;
  109821. /**
  109822. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  109823. */
  109824. nativeVertexBuffer?: any;
  109825. }
  109826. /** @hidden */
  109827. export class NativeEngine extends Engine {
  109828. private readonly _native;
  109829. getHardwareScalingLevel(): number;
  109830. constructor();
  109831. /**
  109832. * Can be used to override the current requestAnimationFrame requester.
  109833. * @hidden
  109834. */
  109835. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  109836. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  109837. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  109838. createVertexBuffer(data: DataArray): NativeDataBuffer;
  109839. recordVertexArrayObject(vertexBuffers: {
  109840. [key: string]: VertexBuffer;
  109841. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  109842. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  109843. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  109844. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  109845. /**
  109846. * Draw a list of indexed primitives
  109847. * @param fillMode defines the primitive to use
  109848. * @param indexStart defines the starting index
  109849. * @param indexCount defines the number of index to draw
  109850. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  109851. */
  109852. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  109853. /**
  109854. * Draw a list of unindexed primitives
  109855. * @param fillMode defines the primitive to use
  109856. * @param verticesStart defines the index of first vertex to draw
  109857. * @param verticesCount defines the count of vertices to draw
  109858. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  109859. */
  109860. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  109861. createPipelineContext(): IPipelineContext;
  109862. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  109863. /** @hidden */
  109864. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  109865. /** @hidden */
  109866. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  109867. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  109868. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  109869. protected _setProgram(program: WebGLProgram): void;
  109870. _releaseEffect(effect: Effect): void;
  109871. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  109872. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  109873. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  109874. bindSamplers(effect: Effect): void;
  109875. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  109876. getRenderWidth(useScreen?: boolean): number;
  109877. getRenderHeight(useScreen?: boolean): number;
  109878. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  109879. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  109880. /**
  109881. * Set the z offset to apply to current rendering
  109882. * @param value defines the offset to apply
  109883. */
  109884. setZOffset(value: number): void;
  109885. /**
  109886. * Gets the current value of the zOffset
  109887. * @returns the current zOffset state
  109888. */
  109889. getZOffset(): number;
  109890. /**
  109891. * Enable or disable depth buffering
  109892. * @param enable defines the state to set
  109893. */
  109894. setDepthBuffer(enable: boolean): void;
  109895. /**
  109896. * Gets a boolean indicating if depth writing is enabled
  109897. * @returns the current depth writing state
  109898. */
  109899. getDepthWrite(): boolean;
  109900. /**
  109901. * Enable or disable depth writing
  109902. * @param enable defines the state to set
  109903. */
  109904. setDepthWrite(enable: boolean): void;
  109905. /**
  109906. * Enable or disable color writing
  109907. * @param enable defines the state to set
  109908. */
  109909. setColorWrite(enable: boolean): void;
  109910. /**
  109911. * Gets a boolean indicating if color writing is enabled
  109912. * @returns the current color writing state
  109913. */
  109914. getColorWrite(): boolean;
  109915. /**
  109916. * Sets alpha constants used by some alpha blending modes
  109917. * @param r defines the red component
  109918. * @param g defines the green component
  109919. * @param b defines the blue component
  109920. * @param a defines the alpha component
  109921. */
  109922. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  109923. /**
  109924. * Sets the current alpha mode
  109925. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  109926. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  109927. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  109928. */
  109929. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  109930. /**
  109931. * Gets the current alpha mode
  109932. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  109933. * @returns the current alpha mode
  109934. */
  109935. getAlphaMode(): number;
  109936. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  109937. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  109938. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  109939. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  109940. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  109941. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  109942. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  109943. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  109944. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  109945. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  109946. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  109947. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  109948. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  109949. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109950. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109951. setFloat(uniform: WebGLUniformLocation, value: number): void;
  109952. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  109953. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  109954. setBool(uniform: WebGLUniformLocation, bool: number): void;
  109955. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  109956. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  109957. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  109958. wipeCaches(bruteForce?: boolean): void;
  109959. _createTexture(): WebGLTexture;
  109960. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  109961. /**
  109962. * Usually called from BABYLON.Texture.ts.
  109963. * Passed information to create a WebGLTexture
  109964. * @param urlArg defines a value which contains one of the following:
  109965. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  109966. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  109967. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  109968. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  109969. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  109970. * @param scene needed for loading to the correct scene
  109971. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  109972. * @param onLoad optional callback to be called upon successful completion
  109973. * @param onError optional callback to be called upon failure
  109974. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  109975. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  109976. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  109977. * @param forcedExtension defines the extension to use to pick the right loader
  109978. * @returns a InternalTexture for assignment back into BABYLON.Texture
  109979. */
  109980. 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;
  109981. /**
  109982. * Creates a cube texture
  109983. * @param rootUrl defines the url where the files to load is located
  109984. * @param scene defines the current scene
  109985. * @param files defines the list of files to load (1 per face)
  109986. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  109987. * @param onLoad defines an optional callback raised when the texture is loaded
  109988. * @param onError defines an optional callback raised if there is an issue to load the texture
  109989. * @param format defines the format of the data
  109990. * @param forcedExtension defines the extension to use to pick the right loader
  109991. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  109992. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  109993. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  109994. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  109995. * @returns the cube texture as an InternalTexture
  109996. */
  109997. 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;
  109998. private _getSamplingFilter;
  109999. private static _GetNativeTextureFormat;
  110000. createRenderTargetTexture(size: number | {
  110001. width: number;
  110002. height: number;
  110003. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  110004. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  110005. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  110006. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  110007. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  110008. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  110009. /**
  110010. * Updates a dynamic vertex buffer.
  110011. * @param vertexBuffer the vertex buffer to update
  110012. * @param data the data used to update the vertex buffer
  110013. * @param byteOffset the byte offset of the data (optional)
  110014. * @param byteLength the byte length of the data (optional)
  110015. */
  110016. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  110017. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  110018. private _updateAnisotropicLevel;
  110019. private _getAddressMode;
  110020. /** @hidden */
  110021. _bindTexture(channel: number, texture: InternalTexture): void;
  110022. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  110023. releaseEffects(): void;
  110024. /** @hidden */
  110025. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110026. /** @hidden */
  110027. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110028. /** @hidden */
  110029. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110030. /** @hidden */
  110031. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  110032. }
  110033. }
  110034. declare module BABYLON {
  110035. /**
  110036. * Gather the list of clipboard event types as constants.
  110037. */
  110038. export class ClipboardEventTypes {
  110039. /**
  110040. * The clipboard event is fired when a copy command is active (pressed).
  110041. */
  110042. static readonly COPY: number;
  110043. /**
  110044. * The clipboard event is fired when a cut command is active (pressed).
  110045. */
  110046. static readonly CUT: number;
  110047. /**
  110048. * The clipboard event is fired when a paste command is active (pressed).
  110049. */
  110050. static readonly PASTE: number;
  110051. }
  110052. /**
  110053. * This class is used to store clipboard related info for the onClipboardObservable event.
  110054. */
  110055. export class ClipboardInfo {
  110056. /**
  110057. * Defines the type of event (BABYLON.ClipboardEventTypes)
  110058. */
  110059. type: number;
  110060. /**
  110061. * Defines the related dom event
  110062. */
  110063. event: ClipboardEvent;
  110064. /**
  110065. *Creates an instance of ClipboardInfo.
  110066. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  110067. * @param event Defines the related dom event
  110068. */
  110069. constructor(
  110070. /**
  110071. * Defines the type of event (BABYLON.ClipboardEventTypes)
  110072. */
  110073. type: number,
  110074. /**
  110075. * Defines the related dom event
  110076. */
  110077. event: ClipboardEvent);
  110078. /**
  110079. * Get the clipboard event's type from the keycode.
  110080. * @param keyCode Defines the keyCode for the current keyboard event.
  110081. * @return {number}
  110082. */
  110083. static GetTypeFromCharacter(keyCode: number): number;
  110084. }
  110085. }
  110086. declare module BABYLON {
  110087. /**
  110088. * Google Daydream controller
  110089. */
  110090. export class DaydreamController extends WebVRController {
  110091. /**
  110092. * Base Url for the controller model.
  110093. */
  110094. static MODEL_BASE_URL: string;
  110095. /**
  110096. * File name for the controller model.
  110097. */
  110098. static MODEL_FILENAME: string;
  110099. /**
  110100. * Gamepad Id prefix used to identify Daydream Controller.
  110101. */
  110102. static readonly GAMEPAD_ID_PREFIX: string;
  110103. /**
  110104. * Creates a new DaydreamController from a gamepad
  110105. * @param vrGamepad the gamepad that the controller should be created from
  110106. */
  110107. constructor(vrGamepad: any);
  110108. /**
  110109. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110110. * @param scene scene in which to add meshes
  110111. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110112. */
  110113. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110114. /**
  110115. * Called once for each button that changed state since the last frame
  110116. * @param buttonIdx Which button index changed
  110117. * @param state New state of the button
  110118. * @param changes Which properties on the state changed since last frame
  110119. */
  110120. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110121. }
  110122. }
  110123. declare module BABYLON {
  110124. /**
  110125. * Gear VR Controller
  110126. */
  110127. export class GearVRController extends WebVRController {
  110128. /**
  110129. * Base Url for the controller model.
  110130. */
  110131. static MODEL_BASE_URL: string;
  110132. /**
  110133. * File name for the controller model.
  110134. */
  110135. static MODEL_FILENAME: string;
  110136. /**
  110137. * Gamepad Id prefix used to identify this controller.
  110138. */
  110139. static readonly GAMEPAD_ID_PREFIX: string;
  110140. private readonly _buttonIndexToObservableNameMap;
  110141. /**
  110142. * Creates a new GearVRController from a gamepad
  110143. * @param vrGamepad the gamepad that the controller should be created from
  110144. */
  110145. constructor(vrGamepad: any);
  110146. /**
  110147. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110148. * @param scene scene in which to add meshes
  110149. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110150. */
  110151. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110152. /**
  110153. * Called once for each button that changed state since the last frame
  110154. * @param buttonIdx Which button index changed
  110155. * @param state New state of the button
  110156. * @param changes Which properties on the state changed since last frame
  110157. */
  110158. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110159. }
  110160. }
  110161. declare module BABYLON {
  110162. /**
  110163. * Class containing static functions to help procedurally build meshes
  110164. */
  110165. export class PolyhedronBuilder {
  110166. /**
  110167. * Creates a polyhedron mesh
  110168. * * 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
  110169. * * The parameter `size` (positive float, default 1) sets the polygon size
  110170. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  110171. * * 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`
  110172. * * 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
  110173. * * 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)`)
  110174. * * 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
  110175. * * 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
  110176. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110177. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110179. * @param name defines the name of the mesh
  110180. * @param options defines the options used to create the mesh
  110181. * @param scene defines the hosting scene
  110182. * @returns the polyhedron mesh
  110183. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  110184. */
  110185. static CreatePolyhedron(name: string, options: {
  110186. type?: number;
  110187. size?: number;
  110188. sizeX?: number;
  110189. sizeY?: number;
  110190. sizeZ?: number;
  110191. custom?: any;
  110192. faceUV?: Vector4[];
  110193. faceColors?: Color4[];
  110194. flat?: boolean;
  110195. updatable?: boolean;
  110196. sideOrientation?: number;
  110197. frontUVs?: Vector4;
  110198. backUVs?: Vector4;
  110199. }, scene?: Nullable<Scene>): Mesh;
  110200. }
  110201. }
  110202. declare module BABYLON {
  110203. /**
  110204. * Gizmo that enables scaling a mesh along 3 axis
  110205. */
  110206. export class ScaleGizmo extends Gizmo {
  110207. /**
  110208. * Internal gizmo used for interactions on the x axis
  110209. */
  110210. xGizmo: AxisScaleGizmo;
  110211. /**
  110212. * Internal gizmo used for interactions on the y axis
  110213. */
  110214. yGizmo: AxisScaleGizmo;
  110215. /**
  110216. * Internal gizmo used for interactions on the z axis
  110217. */
  110218. zGizmo: AxisScaleGizmo;
  110219. /**
  110220. * Internal gizmo used to scale all axis equally
  110221. */
  110222. uniformScaleGizmo: AxisScaleGizmo;
  110223. private _meshAttached;
  110224. private _updateGizmoRotationToMatchAttachedMesh;
  110225. private _snapDistance;
  110226. private _scaleRatio;
  110227. private _uniformScalingMesh;
  110228. private _octahedron;
  110229. /** Fires an event when any of it's sub gizmos are dragged */
  110230. onDragStartObservable: Observable<unknown>;
  110231. /** Fires an event when any of it's sub gizmos are released from dragging */
  110232. onDragEndObservable: Observable<unknown>;
  110233. attachedMesh: Nullable<AbstractMesh>;
  110234. /**
  110235. * Creates a ScaleGizmo
  110236. * @param gizmoLayer The utility layer the gizmo will be added to
  110237. */
  110238. constructor(gizmoLayer?: UtilityLayerRenderer);
  110239. updateGizmoRotationToMatchAttachedMesh: boolean;
  110240. /**
  110241. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110242. */
  110243. snapDistance: number;
  110244. /**
  110245. * Ratio for the scale of the gizmo (Default: 1)
  110246. */
  110247. scaleRatio: number;
  110248. /**
  110249. * Disposes of the gizmo
  110250. */
  110251. dispose(): void;
  110252. }
  110253. }
  110254. declare module BABYLON {
  110255. /**
  110256. * Single axis scale gizmo
  110257. */
  110258. export class AxisScaleGizmo extends Gizmo {
  110259. /**
  110260. * Drag behavior responsible for the gizmos dragging interactions
  110261. */
  110262. dragBehavior: PointerDragBehavior;
  110263. private _pointerObserver;
  110264. /**
  110265. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110266. */
  110267. snapDistance: number;
  110268. /**
  110269. * Event that fires each time the gizmo snaps to a new location.
  110270. * * snapDistance is the the change in distance
  110271. */
  110272. onSnapObservable: Observable<{
  110273. snapDistance: number;
  110274. }>;
  110275. /**
  110276. * If the scaling operation should be done on all axis (default: false)
  110277. */
  110278. uniformScaling: boolean;
  110279. private _isEnabled;
  110280. private _parent;
  110281. private _arrow;
  110282. private _coloredMaterial;
  110283. private _hoverMaterial;
  110284. /**
  110285. * Creates an AxisScaleGizmo
  110286. * @param gizmoLayer The utility layer the gizmo will be added to
  110287. * @param dragAxis The axis which the gizmo will be able to scale on
  110288. * @param color The color of the gizmo
  110289. */
  110290. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  110291. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110292. /**
  110293. * If the gizmo is enabled
  110294. */
  110295. isEnabled: boolean;
  110296. /**
  110297. * Disposes of the gizmo
  110298. */
  110299. dispose(): void;
  110300. /**
  110301. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  110302. * @param mesh The mesh to replace the default mesh of the gizmo
  110303. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  110304. */
  110305. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  110306. }
  110307. }
  110308. declare module BABYLON {
  110309. /**
  110310. * Bounding box gizmo
  110311. */
  110312. export class BoundingBoxGizmo extends Gizmo {
  110313. private _lineBoundingBox;
  110314. private _rotateSpheresParent;
  110315. private _scaleBoxesParent;
  110316. private _boundingDimensions;
  110317. private _renderObserver;
  110318. private _pointerObserver;
  110319. private _scaleDragSpeed;
  110320. private _tmpQuaternion;
  110321. private _tmpVector;
  110322. private _tmpRotationMatrix;
  110323. /**
  110324. * 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)
  110325. */
  110326. ignoreChildren: boolean;
  110327. /**
  110328. * 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)
  110329. */
  110330. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  110331. /**
  110332. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  110333. */
  110334. rotationSphereSize: number;
  110335. /**
  110336. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  110337. */
  110338. scaleBoxSize: number;
  110339. /**
  110340. * 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)
  110341. */
  110342. fixedDragMeshScreenSize: boolean;
  110343. /**
  110344. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  110345. */
  110346. fixedDragMeshScreenSizeDistanceFactor: number;
  110347. /**
  110348. * Fired when a rotation sphere or scale box is dragged
  110349. */
  110350. onDragStartObservable: Observable<{}>;
  110351. /**
  110352. * Fired when a scale box is dragged
  110353. */
  110354. onScaleBoxDragObservable: Observable<{}>;
  110355. /**
  110356. * Fired when a scale box drag is ended
  110357. */
  110358. onScaleBoxDragEndObservable: Observable<{}>;
  110359. /**
  110360. * Fired when a rotation sphere is dragged
  110361. */
  110362. onRotationSphereDragObservable: Observable<{}>;
  110363. /**
  110364. * Fired when a rotation sphere drag is ended
  110365. */
  110366. onRotationSphereDragEndObservable: Observable<{}>;
  110367. /**
  110368. * 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)
  110369. */
  110370. scalePivot: Nullable<Vector3>;
  110371. /**
  110372. * Mesh used as a pivot to rotate the attached mesh
  110373. */
  110374. private _anchorMesh;
  110375. private _existingMeshScale;
  110376. private _dragMesh;
  110377. private pointerDragBehavior;
  110378. private coloredMaterial;
  110379. private hoverColoredMaterial;
  110380. /**
  110381. * Sets the color of the bounding box gizmo
  110382. * @param color the color to set
  110383. */
  110384. setColor(color: Color3): void;
  110385. /**
  110386. * Creates an BoundingBoxGizmo
  110387. * @param gizmoLayer The utility layer the gizmo will be added to
  110388. * @param color The color of the gizmo
  110389. */
  110390. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  110391. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110392. private _selectNode;
  110393. /**
  110394. * Updates the bounding box information for the Gizmo
  110395. */
  110396. updateBoundingBox(): void;
  110397. private _updateRotationSpheres;
  110398. private _updateScaleBoxes;
  110399. /**
  110400. * Enables rotation on the specified axis and disables rotation on the others
  110401. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  110402. */
  110403. setEnabledRotationAxis(axis: string): void;
  110404. /**
  110405. * Enables/disables scaling
  110406. * @param enable if scaling should be enabled
  110407. */
  110408. setEnabledScaling(enable: boolean): void;
  110409. private _updateDummy;
  110410. /**
  110411. * Enables a pointer drag behavior on the bounding box of the gizmo
  110412. */
  110413. enableDragBehavior(): void;
  110414. /**
  110415. * Disposes of the gizmo
  110416. */
  110417. dispose(): void;
  110418. /**
  110419. * 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)
  110420. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  110421. * @returns the bounding box mesh with the passed in mesh as a child
  110422. */
  110423. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  110424. /**
  110425. * CustomMeshes are not supported by this gizmo
  110426. * @param mesh The mesh to replace the default mesh of the gizmo
  110427. */
  110428. setCustomMesh(mesh: Mesh): void;
  110429. }
  110430. }
  110431. declare module BABYLON {
  110432. /**
  110433. * Single plane rotation gizmo
  110434. */
  110435. export class PlaneRotationGizmo extends Gizmo {
  110436. /**
  110437. * Drag behavior responsible for the gizmos dragging interactions
  110438. */
  110439. dragBehavior: PointerDragBehavior;
  110440. private _pointerObserver;
  110441. /**
  110442. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  110443. */
  110444. snapDistance: number;
  110445. /**
  110446. * Event that fires each time the gizmo snaps to a new location.
  110447. * * snapDistance is the the change in distance
  110448. */
  110449. onSnapObservable: Observable<{
  110450. snapDistance: number;
  110451. }>;
  110452. private _isEnabled;
  110453. private _parent;
  110454. /**
  110455. * Creates a PlaneRotationGizmo
  110456. * @param gizmoLayer The utility layer the gizmo will be added to
  110457. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  110458. * @param color The color of the gizmo
  110459. * @param tessellation Amount of tessellation to be used when creating rotation circles
  110460. * @param useEulerRotation Use and update Euler angle instead of quaternion
  110461. */
  110462. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  110463. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110464. /**
  110465. * If the gizmo is enabled
  110466. */
  110467. isEnabled: boolean;
  110468. /**
  110469. * Disposes of the gizmo
  110470. */
  110471. dispose(): void;
  110472. }
  110473. }
  110474. declare module BABYLON {
  110475. /**
  110476. * Gizmo that enables rotating a mesh along 3 axis
  110477. */
  110478. export class RotationGizmo extends Gizmo {
  110479. /**
  110480. * Internal gizmo used for interactions on the x axis
  110481. */
  110482. xGizmo: PlaneRotationGizmo;
  110483. /**
  110484. * Internal gizmo used for interactions on the y axis
  110485. */
  110486. yGizmo: PlaneRotationGizmo;
  110487. /**
  110488. * Internal gizmo used for interactions on the z axis
  110489. */
  110490. zGizmo: PlaneRotationGizmo;
  110491. /** Fires an event when any of it's sub gizmos are dragged */
  110492. onDragStartObservable: Observable<unknown>;
  110493. /** Fires an event when any of it's sub gizmos are released from dragging */
  110494. onDragEndObservable: Observable<unknown>;
  110495. private _meshAttached;
  110496. attachedMesh: Nullable<AbstractMesh>;
  110497. /**
  110498. * Creates a RotationGizmo
  110499. * @param gizmoLayer The utility layer the gizmo will be added to
  110500. * @param tessellation Amount of tessellation to be used when creating rotation circles
  110501. * @param useEulerRotation Use and update Euler angle instead of quaternion
  110502. */
  110503. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  110504. updateGizmoRotationToMatchAttachedMesh: boolean;
  110505. /**
  110506. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110507. */
  110508. snapDistance: number;
  110509. /**
  110510. * Ratio for the scale of the gizmo (Default: 1)
  110511. */
  110512. scaleRatio: number;
  110513. /**
  110514. * Disposes of the gizmo
  110515. */
  110516. dispose(): void;
  110517. /**
  110518. * CustomMeshes are not supported by this gizmo
  110519. * @param mesh The mesh to replace the default mesh of the gizmo
  110520. */
  110521. setCustomMesh(mesh: Mesh): void;
  110522. }
  110523. }
  110524. declare module BABYLON {
  110525. /**
  110526. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  110527. */
  110528. export class GizmoManager implements IDisposable {
  110529. private scene;
  110530. /**
  110531. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  110532. */
  110533. gizmos: {
  110534. positionGizmo: Nullable<PositionGizmo>;
  110535. rotationGizmo: Nullable<RotationGizmo>;
  110536. scaleGizmo: Nullable<ScaleGizmo>;
  110537. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  110538. };
  110539. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  110540. clearGizmoOnEmptyPointerEvent: boolean;
  110541. /** Fires an event when the manager is attached to a mesh */
  110542. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  110543. private _gizmosEnabled;
  110544. private _pointerObserver;
  110545. private _attachedMesh;
  110546. private _boundingBoxColor;
  110547. private _defaultUtilityLayer;
  110548. private _defaultKeepDepthUtilityLayer;
  110549. /**
  110550. * When bounding box gizmo is enabled, this can be used to track drag/end events
  110551. */
  110552. boundingBoxDragBehavior: SixDofDragBehavior;
  110553. /**
  110554. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  110555. */
  110556. attachableMeshes: Nullable<Array<AbstractMesh>>;
  110557. /**
  110558. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  110559. */
  110560. usePointerToAttachGizmos: boolean;
  110561. /**
  110562. * Utility layer that the bounding box gizmo belongs to
  110563. */
  110564. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  110565. /**
  110566. * Utility layer that all gizmos besides bounding box belong to
  110567. */
  110568. readonly utilityLayer: UtilityLayerRenderer;
  110569. /**
  110570. * Instatiates a gizmo manager
  110571. * @param scene the scene to overlay the gizmos on top of
  110572. */
  110573. constructor(scene: Scene);
  110574. /**
  110575. * Attaches a set of gizmos to the specified mesh
  110576. * @param mesh The mesh the gizmo's should be attached to
  110577. */
  110578. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  110579. /**
  110580. * If the position gizmo is enabled
  110581. */
  110582. positionGizmoEnabled: boolean;
  110583. /**
  110584. * If the rotation gizmo is enabled
  110585. */
  110586. rotationGizmoEnabled: boolean;
  110587. /**
  110588. * If the scale gizmo is enabled
  110589. */
  110590. scaleGizmoEnabled: boolean;
  110591. /**
  110592. * If the boundingBox gizmo is enabled
  110593. */
  110594. boundingBoxGizmoEnabled: boolean;
  110595. /**
  110596. * Disposes of the gizmo manager
  110597. */
  110598. dispose(): void;
  110599. }
  110600. }
  110601. declare module BABYLON {
  110602. /**
  110603. * A directional light is defined by a direction (what a surprise!).
  110604. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  110605. * 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.
  110606. * Documentation: https://doc.babylonjs.com/babylon101/lights
  110607. */
  110608. export class DirectionalLight extends ShadowLight {
  110609. private _shadowFrustumSize;
  110610. /**
  110611. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  110612. */
  110613. /**
  110614. * Specifies a fix frustum size for the shadow generation.
  110615. */
  110616. shadowFrustumSize: number;
  110617. private _shadowOrthoScale;
  110618. /**
  110619. * Gets the shadow projection scale against the optimal computed one.
  110620. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  110621. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  110622. */
  110623. /**
  110624. * Sets the shadow projection scale against the optimal computed one.
  110625. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  110626. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  110627. */
  110628. shadowOrthoScale: number;
  110629. /**
  110630. * Automatically compute the projection matrix to best fit (including all the casters)
  110631. * on each frame.
  110632. */
  110633. autoUpdateExtends: boolean;
  110634. private _orthoLeft;
  110635. private _orthoRight;
  110636. private _orthoTop;
  110637. private _orthoBottom;
  110638. /**
  110639. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  110640. * The directional light is emitted from everywhere in the given direction.
  110641. * It can cast shadows.
  110642. * Documentation : https://doc.babylonjs.com/babylon101/lights
  110643. * @param name The friendly name of the light
  110644. * @param direction The direction of the light
  110645. * @param scene The scene the light belongs to
  110646. */
  110647. constructor(name: string, direction: Vector3, scene: Scene);
  110648. /**
  110649. * Returns the string "DirectionalLight".
  110650. * @return The class name
  110651. */
  110652. getClassName(): string;
  110653. /**
  110654. * Returns the integer 1.
  110655. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  110656. */
  110657. getTypeID(): number;
  110658. /**
  110659. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  110660. * Returns the DirectionalLight Shadow projection matrix.
  110661. */
  110662. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110663. /**
  110664. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  110665. * Returns the DirectionalLight Shadow projection matrix.
  110666. */
  110667. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  110668. /**
  110669. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  110670. * Returns the DirectionalLight Shadow projection matrix.
  110671. */
  110672. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110673. protected _buildUniformLayout(): void;
  110674. /**
  110675. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  110676. * @param effect The effect to update
  110677. * @param lightIndex The index of the light in the effect to update
  110678. * @returns The directional light
  110679. */
  110680. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  110681. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  110682. /**
  110683. * Gets the minZ used for shadow according to both the scene and the light.
  110684. *
  110685. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  110686. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  110687. * @param activeCamera The camera we are returning the min for
  110688. * @returns the depth min z
  110689. */
  110690. getDepthMinZ(activeCamera: Camera): number;
  110691. /**
  110692. * Gets the maxZ used for shadow according to both the scene and the light.
  110693. *
  110694. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  110695. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  110696. * @param activeCamera The camera we are returning the max for
  110697. * @returns the depth max z
  110698. */
  110699. getDepthMaxZ(activeCamera: Camera): number;
  110700. /**
  110701. * Prepares the list of defines specific to the light type.
  110702. * @param defines the list of defines
  110703. * @param lightIndex defines the index of the light for the effect
  110704. */
  110705. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  110706. }
  110707. }
  110708. declare module BABYLON {
  110709. /**
  110710. * Class containing static functions to help procedurally build meshes
  110711. */
  110712. export class HemisphereBuilder {
  110713. /**
  110714. * Creates a hemisphere mesh
  110715. * @param name defines the name of the mesh
  110716. * @param options defines the options used to create the mesh
  110717. * @param scene defines the hosting scene
  110718. * @returns the hemisphere mesh
  110719. */
  110720. static CreateHemisphere(name: string, options: {
  110721. segments?: number;
  110722. diameter?: number;
  110723. sideOrientation?: number;
  110724. }, scene: any): Mesh;
  110725. }
  110726. }
  110727. declare module BABYLON {
  110728. /**
  110729. * A spot light is defined by a position, a direction, an angle, and an exponent.
  110730. * These values define a cone of light starting from the position, emitting toward the direction.
  110731. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  110732. * and the exponent defines the speed of the decay of the light with distance (reach).
  110733. * Documentation: https://doc.babylonjs.com/babylon101/lights
  110734. */
  110735. export class SpotLight extends ShadowLight {
  110736. private _angle;
  110737. private _innerAngle;
  110738. private _cosHalfAngle;
  110739. private _lightAngleScale;
  110740. private _lightAngleOffset;
  110741. /**
  110742. * Gets the cone angle of the spot light in Radians.
  110743. */
  110744. /**
  110745. * Sets the cone angle of the spot light in Radians.
  110746. */
  110747. angle: number;
  110748. /**
  110749. * Only used in gltf falloff mode, this defines the angle where
  110750. * the directional falloff will start before cutting at angle which could be seen
  110751. * as outer angle.
  110752. */
  110753. /**
  110754. * Only used in gltf falloff mode, this defines the angle where
  110755. * the directional falloff will start before cutting at angle which could be seen
  110756. * as outer angle.
  110757. */
  110758. innerAngle: number;
  110759. private _shadowAngleScale;
  110760. /**
  110761. * Allows scaling the angle of the light for shadow generation only.
  110762. */
  110763. /**
  110764. * Allows scaling the angle of the light for shadow generation only.
  110765. */
  110766. shadowAngleScale: number;
  110767. /**
  110768. * The light decay speed with the distance from the emission spot.
  110769. */
  110770. exponent: number;
  110771. private _projectionTextureMatrix;
  110772. /**
  110773. * Allows reading the projecton texture
  110774. */
  110775. readonly projectionTextureMatrix: Matrix;
  110776. protected _projectionTextureLightNear: number;
  110777. /**
  110778. * Gets the near clip of the Spotlight for texture projection.
  110779. */
  110780. /**
  110781. * Sets the near clip of the Spotlight for texture projection.
  110782. */
  110783. projectionTextureLightNear: number;
  110784. protected _projectionTextureLightFar: number;
  110785. /**
  110786. * Gets the far clip of the Spotlight for texture projection.
  110787. */
  110788. /**
  110789. * Sets the far clip of the Spotlight for texture projection.
  110790. */
  110791. projectionTextureLightFar: number;
  110792. protected _projectionTextureUpDirection: Vector3;
  110793. /**
  110794. * Gets the Up vector of the Spotlight for texture projection.
  110795. */
  110796. /**
  110797. * Sets the Up vector of the Spotlight for texture projection.
  110798. */
  110799. projectionTextureUpDirection: Vector3;
  110800. private _projectionTexture;
  110801. /**
  110802. * Gets the projection texture of the light.
  110803. */
  110804. /**
  110805. * Sets the projection texture of the light.
  110806. */
  110807. projectionTexture: Nullable<BaseTexture>;
  110808. private _projectionTextureViewLightDirty;
  110809. private _projectionTextureProjectionLightDirty;
  110810. private _projectionTextureDirty;
  110811. private _projectionTextureViewTargetVector;
  110812. private _projectionTextureViewLightMatrix;
  110813. private _projectionTextureProjectionLightMatrix;
  110814. private _projectionTextureScalingMatrix;
  110815. /**
  110816. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  110817. * It can cast shadows.
  110818. * Documentation : https://doc.babylonjs.com/babylon101/lights
  110819. * @param name The light friendly name
  110820. * @param position The position of the spot light in the scene
  110821. * @param direction The direction of the light in the scene
  110822. * @param angle The cone angle of the light in Radians
  110823. * @param exponent The light decay speed with the distance from the emission spot
  110824. * @param scene The scene the lights belongs to
  110825. */
  110826. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  110827. /**
  110828. * Returns the string "SpotLight".
  110829. * @returns the class name
  110830. */
  110831. getClassName(): string;
  110832. /**
  110833. * Returns the integer 2.
  110834. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  110835. */
  110836. getTypeID(): number;
  110837. /**
  110838. * Overrides the direction setter to recompute the projection texture view light Matrix.
  110839. */
  110840. protected _setDirection(value: Vector3): void;
  110841. /**
  110842. * Overrides the position setter to recompute the projection texture view light Matrix.
  110843. */
  110844. protected _setPosition(value: Vector3): void;
  110845. /**
  110846. * 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.
  110847. * Returns the SpotLight.
  110848. */
  110849. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110850. protected _computeProjectionTextureViewLightMatrix(): void;
  110851. protected _computeProjectionTextureProjectionLightMatrix(): void;
  110852. /**
  110853. * Main function for light texture projection matrix computing.
  110854. */
  110855. protected _computeProjectionTextureMatrix(): void;
  110856. protected _buildUniformLayout(): void;
  110857. private _computeAngleValues;
  110858. /**
  110859. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  110860. * @param effect The effect to update
  110861. * @param lightIndex The index of the light in the effect to update
  110862. * @returns The spot light
  110863. */
  110864. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  110865. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  110866. /**
  110867. * Disposes the light and the associated resources.
  110868. */
  110869. dispose(): void;
  110870. /**
  110871. * Prepares the list of defines specific to the light type.
  110872. * @param defines the list of defines
  110873. * @param lightIndex defines the index of the light for the effect
  110874. */
  110875. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  110876. }
  110877. }
  110878. declare module BABYLON {
  110879. /**
  110880. * Gizmo that enables viewing a light
  110881. */
  110882. export class LightGizmo extends Gizmo {
  110883. private _lightMesh;
  110884. private _material;
  110885. private cachedPosition;
  110886. private cachedForward;
  110887. /**
  110888. * Creates a LightGizmo
  110889. * @param gizmoLayer The utility layer the gizmo will be added to
  110890. */
  110891. constructor(gizmoLayer?: UtilityLayerRenderer);
  110892. private _light;
  110893. /**
  110894. * The light that the gizmo is attached to
  110895. */
  110896. light: Nullable<Light>;
  110897. /**
  110898. * Gets the material used to render the light gizmo
  110899. */
  110900. readonly material: StandardMaterial;
  110901. /**
  110902. * @hidden
  110903. * Updates the gizmo to match the attached mesh's position/rotation
  110904. */
  110905. protected _update(): void;
  110906. private static _Scale;
  110907. /**
  110908. * Creates the lines for a light mesh
  110909. */
  110910. private static _createLightLines;
  110911. /**
  110912. * Disposes of the light gizmo
  110913. */
  110914. dispose(): void;
  110915. private static _CreateHemisphericLightMesh;
  110916. private static _CreatePointLightMesh;
  110917. private static _CreateSpotLightMesh;
  110918. private static _CreateDirectionalLightMesh;
  110919. }
  110920. }
  110921. declare module BABYLON {
  110922. /** @hidden */
  110923. export var backgroundFragmentDeclaration: {
  110924. name: string;
  110925. shader: string;
  110926. };
  110927. }
  110928. declare module BABYLON {
  110929. /** @hidden */
  110930. export var backgroundUboDeclaration: {
  110931. name: string;
  110932. shader: string;
  110933. };
  110934. }
  110935. declare module BABYLON {
  110936. /** @hidden */
  110937. export var backgroundPixelShader: {
  110938. name: string;
  110939. shader: string;
  110940. };
  110941. }
  110942. declare module BABYLON {
  110943. /** @hidden */
  110944. export var backgroundVertexDeclaration: {
  110945. name: string;
  110946. shader: string;
  110947. };
  110948. }
  110949. declare module BABYLON {
  110950. /** @hidden */
  110951. export var backgroundVertexShader: {
  110952. name: string;
  110953. shader: string;
  110954. };
  110955. }
  110956. declare module BABYLON {
  110957. /**
  110958. * Background material used to create an efficient environement around your scene.
  110959. */
  110960. export class BackgroundMaterial extends PushMaterial {
  110961. /**
  110962. * Standard reflectance value at parallel view angle.
  110963. */
  110964. static StandardReflectance0: number;
  110965. /**
  110966. * Standard reflectance value at grazing angle.
  110967. */
  110968. static StandardReflectance90: number;
  110969. protected _primaryColor: Color3;
  110970. /**
  110971. * Key light Color (multiply against the environement texture)
  110972. */
  110973. primaryColor: Color3;
  110974. protected __perceptualColor: Nullable<Color3>;
  110975. /**
  110976. * Experimental Internal Use Only.
  110977. *
  110978. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  110979. * This acts as a helper to set the primary color to a more "human friendly" value.
  110980. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  110981. * output color as close as possible from the chosen value.
  110982. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  110983. * part of lighting setup.)
  110984. */
  110985. _perceptualColor: Nullable<Color3>;
  110986. protected _primaryColorShadowLevel: float;
  110987. /**
  110988. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  110989. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  110990. */
  110991. primaryColorShadowLevel: float;
  110992. protected _primaryColorHighlightLevel: float;
  110993. /**
  110994. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  110995. * The primary color is used at the level chosen to define what the white area would look.
  110996. */
  110997. primaryColorHighlightLevel: float;
  110998. protected _reflectionTexture: Nullable<BaseTexture>;
  110999. /**
  111000. * Reflection Texture used in the material.
  111001. * Should be author in a specific way for the best result (refer to the documentation).
  111002. */
  111003. reflectionTexture: Nullable<BaseTexture>;
  111004. protected _reflectionBlur: float;
  111005. /**
  111006. * Reflection Texture level of blur.
  111007. *
  111008. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  111009. * texture twice.
  111010. */
  111011. reflectionBlur: float;
  111012. protected _diffuseTexture: Nullable<BaseTexture>;
  111013. /**
  111014. * Diffuse Texture used in the material.
  111015. * Should be author in a specific way for the best result (refer to the documentation).
  111016. */
  111017. diffuseTexture: Nullable<BaseTexture>;
  111018. protected _shadowLights: Nullable<IShadowLight[]>;
  111019. /**
  111020. * Specify the list of lights casting shadow on the material.
  111021. * All scene shadow lights will be included if null.
  111022. */
  111023. shadowLights: Nullable<IShadowLight[]>;
  111024. protected _shadowLevel: float;
  111025. /**
  111026. * Helps adjusting the shadow to a softer level if required.
  111027. * 0 means black shadows and 1 means no shadows.
  111028. */
  111029. shadowLevel: float;
  111030. protected _sceneCenter: Vector3;
  111031. /**
  111032. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  111033. * It is usually zero but might be interesting to modify according to your setup.
  111034. */
  111035. sceneCenter: Vector3;
  111036. protected _opacityFresnel: boolean;
  111037. /**
  111038. * This helps specifying that the material is falling off to the sky box at grazing angle.
  111039. * This helps ensuring a nice transition when the camera goes under the ground.
  111040. */
  111041. opacityFresnel: boolean;
  111042. protected _reflectionFresnel: boolean;
  111043. /**
  111044. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  111045. * This helps adding a mirror texture on the ground.
  111046. */
  111047. reflectionFresnel: boolean;
  111048. protected _reflectionFalloffDistance: number;
  111049. /**
  111050. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  111051. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  111052. */
  111053. reflectionFalloffDistance: number;
  111054. protected _reflectionAmount: number;
  111055. /**
  111056. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  111057. */
  111058. reflectionAmount: number;
  111059. protected _reflectionReflectance0: number;
  111060. /**
  111061. * This specifies the weight of the reflection at grazing angle.
  111062. */
  111063. reflectionReflectance0: number;
  111064. protected _reflectionReflectance90: number;
  111065. /**
  111066. * This specifies the weight of the reflection at a perpendicular point of view.
  111067. */
  111068. reflectionReflectance90: number;
  111069. /**
  111070. * Sets the reflection reflectance fresnel values according to the default standard
  111071. * empirically know to work well :-)
  111072. */
  111073. reflectionStandardFresnelWeight: number;
  111074. protected _useRGBColor: boolean;
  111075. /**
  111076. * Helps to directly use the maps channels instead of their level.
  111077. */
  111078. useRGBColor: boolean;
  111079. protected _enableNoise: boolean;
  111080. /**
  111081. * This helps reducing the banding effect that could occur on the background.
  111082. */
  111083. enableNoise: boolean;
  111084. /**
  111085. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  111086. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  111087. * Recommended to be keep at 1.0 except for special cases.
  111088. */
  111089. fovMultiplier: number;
  111090. private _fovMultiplier;
  111091. /**
  111092. * Enable the FOV adjustment feature controlled by fovMultiplier.
  111093. */
  111094. useEquirectangularFOV: boolean;
  111095. private _maxSimultaneousLights;
  111096. /**
  111097. * Number of Simultaneous lights allowed on the material.
  111098. */
  111099. maxSimultaneousLights: int;
  111100. /**
  111101. * Default configuration related to image processing available in the Background Material.
  111102. */
  111103. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111104. /**
  111105. * Keep track of the image processing observer to allow dispose and replace.
  111106. */
  111107. private _imageProcessingObserver;
  111108. /**
  111109. * Attaches a new image processing configuration to the PBR Material.
  111110. * @param configuration (if null the scene configuration will be use)
  111111. */
  111112. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  111113. /**
  111114. * Gets the image processing configuration used either in this material.
  111115. */
  111116. /**
  111117. * Sets the Default image processing configuration used either in the this material.
  111118. *
  111119. * If sets to null, the scene one is in use.
  111120. */
  111121. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  111122. /**
  111123. * Gets wether the color curves effect is enabled.
  111124. */
  111125. /**
  111126. * Sets wether the color curves effect is enabled.
  111127. */
  111128. cameraColorCurvesEnabled: boolean;
  111129. /**
  111130. * Gets wether the color grading effect is enabled.
  111131. */
  111132. /**
  111133. * Gets wether the color grading effect is enabled.
  111134. */
  111135. cameraColorGradingEnabled: boolean;
  111136. /**
  111137. * Gets wether tonemapping is enabled or not.
  111138. */
  111139. /**
  111140. * Sets wether tonemapping is enabled or not
  111141. */
  111142. cameraToneMappingEnabled: boolean;
  111143. /**
  111144. * The camera exposure used on this material.
  111145. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111146. * This corresponds to a photographic exposure.
  111147. */
  111148. /**
  111149. * The camera exposure used on this material.
  111150. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111151. * This corresponds to a photographic exposure.
  111152. */
  111153. cameraExposure: float;
  111154. /**
  111155. * Gets The camera contrast used on this material.
  111156. */
  111157. /**
  111158. * Sets The camera contrast used on this material.
  111159. */
  111160. cameraContrast: float;
  111161. /**
  111162. * Gets the Color Grading 2D Lookup Texture.
  111163. */
  111164. /**
  111165. * Sets the Color Grading 2D Lookup Texture.
  111166. */
  111167. cameraColorGradingTexture: Nullable<BaseTexture>;
  111168. /**
  111169. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111170. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111171. * 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;
  111172. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111173. */
  111174. /**
  111175. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111176. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111177. * 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;
  111178. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111179. */
  111180. cameraColorCurves: Nullable<ColorCurves>;
  111181. /**
  111182. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  111183. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  111184. */
  111185. switchToBGR: boolean;
  111186. private _renderTargets;
  111187. private _reflectionControls;
  111188. private _white;
  111189. private _primaryShadowColor;
  111190. private _primaryHighlightColor;
  111191. /**
  111192. * Instantiates a Background Material in the given scene
  111193. * @param name The friendly name of the material
  111194. * @param scene The scene to add the material to
  111195. */
  111196. constructor(name: string, scene: Scene);
  111197. /**
  111198. * Gets a boolean indicating that current material needs to register RTT
  111199. */
  111200. readonly hasRenderTargetTextures: boolean;
  111201. /**
  111202. * The entire material has been created in order to prevent overdraw.
  111203. * @returns false
  111204. */
  111205. needAlphaTesting(): boolean;
  111206. /**
  111207. * The entire material has been created in order to prevent overdraw.
  111208. * @returns true if blending is enable
  111209. */
  111210. needAlphaBlending(): boolean;
  111211. /**
  111212. * Checks wether the material is ready to be rendered for a given mesh.
  111213. * @param mesh The mesh to render
  111214. * @param subMesh The submesh to check against
  111215. * @param useInstances Specify wether or not the material is used with instances
  111216. * @returns true if all the dependencies are ready (Textures, Effects...)
  111217. */
  111218. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111219. /**
  111220. * Compute the primary color according to the chosen perceptual color.
  111221. */
  111222. private _computePrimaryColorFromPerceptualColor;
  111223. /**
  111224. * Compute the highlights and shadow colors according to their chosen levels.
  111225. */
  111226. private _computePrimaryColors;
  111227. /**
  111228. * Build the uniform buffer used in the material.
  111229. */
  111230. buildUniformLayout(): void;
  111231. /**
  111232. * Unbind the material.
  111233. */
  111234. unbind(): void;
  111235. /**
  111236. * Bind only the world matrix to the material.
  111237. * @param world The world matrix to bind.
  111238. */
  111239. bindOnlyWorldMatrix(world: Matrix): void;
  111240. /**
  111241. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  111242. * @param world The world matrix to bind.
  111243. * @param subMesh The submesh to bind for.
  111244. */
  111245. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111246. /**
  111247. * Checks to see if a texture is used in the material.
  111248. * @param texture - Base texture to use.
  111249. * @returns - Boolean specifying if a texture is used in the material.
  111250. */
  111251. hasTexture(texture: BaseTexture): boolean;
  111252. /**
  111253. * Dispose the material.
  111254. * @param forceDisposeEffect Force disposal of the associated effect.
  111255. * @param forceDisposeTextures Force disposal of the associated textures.
  111256. */
  111257. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  111258. /**
  111259. * Clones the material.
  111260. * @param name The cloned name.
  111261. * @returns The cloned material.
  111262. */
  111263. clone(name: string): BackgroundMaterial;
  111264. /**
  111265. * Serializes the current material to its JSON representation.
  111266. * @returns The JSON representation.
  111267. */
  111268. serialize(): any;
  111269. /**
  111270. * Gets the class name of the material
  111271. * @returns "BackgroundMaterial"
  111272. */
  111273. getClassName(): string;
  111274. /**
  111275. * Parse a JSON input to create back a background material.
  111276. * @param source The JSON data to parse
  111277. * @param scene The scene to create the parsed material in
  111278. * @param rootUrl The root url of the assets the material depends upon
  111279. * @returns the instantiated BackgroundMaterial.
  111280. */
  111281. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  111282. }
  111283. }
  111284. declare module BABYLON {
  111285. /**
  111286. * Represents the different options available during the creation of
  111287. * a Environment helper.
  111288. *
  111289. * This can control the default ground, skybox and image processing setup of your scene.
  111290. */
  111291. export interface IEnvironmentHelperOptions {
  111292. /**
  111293. * Specifies wether or not to create a ground.
  111294. * True by default.
  111295. */
  111296. createGround: boolean;
  111297. /**
  111298. * Specifies the ground size.
  111299. * 15 by default.
  111300. */
  111301. groundSize: number;
  111302. /**
  111303. * The texture used on the ground for the main color.
  111304. * Comes from the BabylonJS CDN by default.
  111305. *
  111306. * Remarks: Can be either a texture or a url.
  111307. */
  111308. groundTexture: string | BaseTexture;
  111309. /**
  111310. * The color mixed in the ground texture by default.
  111311. * BabylonJS clearColor by default.
  111312. */
  111313. groundColor: Color3;
  111314. /**
  111315. * Specifies the ground opacity.
  111316. * 1 by default.
  111317. */
  111318. groundOpacity: number;
  111319. /**
  111320. * Enables the ground to receive shadows.
  111321. * True by default.
  111322. */
  111323. enableGroundShadow: boolean;
  111324. /**
  111325. * Helps preventing the shadow to be fully black on the ground.
  111326. * 0.5 by default.
  111327. */
  111328. groundShadowLevel: number;
  111329. /**
  111330. * Creates a mirror texture attach to the ground.
  111331. * false by default.
  111332. */
  111333. enableGroundMirror: boolean;
  111334. /**
  111335. * Specifies the ground mirror size ratio.
  111336. * 0.3 by default as the default kernel is 64.
  111337. */
  111338. groundMirrorSizeRatio: number;
  111339. /**
  111340. * Specifies the ground mirror blur kernel size.
  111341. * 64 by default.
  111342. */
  111343. groundMirrorBlurKernel: number;
  111344. /**
  111345. * Specifies the ground mirror visibility amount.
  111346. * 1 by default
  111347. */
  111348. groundMirrorAmount: number;
  111349. /**
  111350. * Specifies the ground mirror reflectance weight.
  111351. * This uses the standard weight of the background material to setup the fresnel effect
  111352. * of the mirror.
  111353. * 1 by default.
  111354. */
  111355. groundMirrorFresnelWeight: number;
  111356. /**
  111357. * Specifies the ground mirror Falloff distance.
  111358. * This can helps reducing the size of the reflection.
  111359. * 0 by Default.
  111360. */
  111361. groundMirrorFallOffDistance: number;
  111362. /**
  111363. * Specifies the ground mirror texture type.
  111364. * Unsigned Int by Default.
  111365. */
  111366. groundMirrorTextureType: number;
  111367. /**
  111368. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  111369. * the shown objects.
  111370. */
  111371. groundYBias: number;
  111372. /**
  111373. * Specifies wether or not to create a skybox.
  111374. * True by default.
  111375. */
  111376. createSkybox: boolean;
  111377. /**
  111378. * Specifies the skybox size.
  111379. * 20 by default.
  111380. */
  111381. skyboxSize: number;
  111382. /**
  111383. * The texture used on the skybox for the main color.
  111384. * Comes from the BabylonJS CDN by default.
  111385. *
  111386. * Remarks: Can be either a texture or a url.
  111387. */
  111388. skyboxTexture: string | BaseTexture;
  111389. /**
  111390. * The color mixed in the skybox texture by default.
  111391. * BabylonJS clearColor by default.
  111392. */
  111393. skyboxColor: Color3;
  111394. /**
  111395. * The background rotation around the Y axis of the scene.
  111396. * This helps aligning the key lights of your scene with the background.
  111397. * 0 by default.
  111398. */
  111399. backgroundYRotation: number;
  111400. /**
  111401. * Compute automatically the size of the elements to best fit with the scene.
  111402. */
  111403. sizeAuto: boolean;
  111404. /**
  111405. * Default position of the rootMesh if autoSize is not true.
  111406. */
  111407. rootPosition: Vector3;
  111408. /**
  111409. * Sets up the image processing in the scene.
  111410. * true by default.
  111411. */
  111412. setupImageProcessing: boolean;
  111413. /**
  111414. * The texture used as your environment texture in the scene.
  111415. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  111416. *
  111417. * Remarks: Can be either a texture or a url.
  111418. */
  111419. environmentTexture: string | BaseTexture;
  111420. /**
  111421. * The value of the exposure to apply to the scene.
  111422. * 0.6 by default if setupImageProcessing is true.
  111423. */
  111424. cameraExposure: number;
  111425. /**
  111426. * The value of the contrast to apply to the scene.
  111427. * 1.6 by default if setupImageProcessing is true.
  111428. */
  111429. cameraContrast: number;
  111430. /**
  111431. * Specifies wether or not tonemapping should be enabled in the scene.
  111432. * true by default if setupImageProcessing is true.
  111433. */
  111434. toneMappingEnabled: boolean;
  111435. }
  111436. /**
  111437. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  111438. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  111439. * It also helps with the default setup of your imageProcessing configuration.
  111440. */
  111441. export class EnvironmentHelper {
  111442. /**
  111443. * Default ground texture URL.
  111444. */
  111445. private static _groundTextureCDNUrl;
  111446. /**
  111447. * Default skybox texture URL.
  111448. */
  111449. private static _skyboxTextureCDNUrl;
  111450. /**
  111451. * Default environment texture URL.
  111452. */
  111453. private static _environmentTextureCDNUrl;
  111454. /**
  111455. * Creates the default options for the helper.
  111456. */
  111457. private static _getDefaultOptions;
  111458. private _rootMesh;
  111459. /**
  111460. * Gets the root mesh created by the helper.
  111461. */
  111462. readonly rootMesh: Mesh;
  111463. private _skybox;
  111464. /**
  111465. * Gets the skybox created by the helper.
  111466. */
  111467. readonly skybox: Nullable<Mesh>;
  111468. private _skyboxTexture;
  111469. /**
  111470. * Gets the skybox texture created by the helper.
  111471. */
  111472. readonly skyboxTexture: Nullable<BaseTexture>;
  111473. private _skyboxMaterial;
  111474. /**
  111475. * Gets the skybox material created by the helper.
  111476. */
  111477. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  111478. private _ground;
  111479. /**
  111480. * Gets the ground mesh created by the helper.
  111481. */
  111482. readonly ground: Nullable<Mesh>;
  111483. private _groundTexture;
  111484. /**
  111485. * Gets the ground texture created by the helper.
  111486. */
  111487. readonly groundTexture: Nullable<BaseTexture>;
  111488. private _groundMirror;
  111489. /**
  111490. * Gets the ground mirror created by the helper.
  111491. */
  111492. readonly groundMirror: Nullable<MirrorTexture>;
  111493. /**
  111494. * Gets the ground mirror render list to helps pushing the meshes
  111495. * you wish in the ground reflection.
  111496. */
  111497. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  111498. private _groundMaterial;
  111499. /**
  111500. * Gets the ground material created by the helper.
  111501. */
  111502. readonly groundMaterial: Nullable<BackgroundMaterial>;
  111503. /**
  111504. * Stores the creation options.
  111505. */
  111506. private readonly _scene;
  111507. private _options;
  111508. /**
  111509. * This observable will be notified with any error during the creation of the environment,
  111510. * mainly texture creation errors.
  111511. */
  111512. onErrorObservable: Observable<{
  111513. message?: string;
  111514. exception?: any;
  111515. }>;
  111516. /**
  111517. * constructor
  111518. * @param options Defines the options we want to customize the helper
  111519. * @param scene The scene to add the material to
  111520. */
  111521. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  111522. /**
  111523. * Updates the background according to the new options
  111524. * @param options
  111525. */
  111526. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  111527. /**
  111528. * Sets the primary color of all the available elements.
  111529. * @param color the main color to affect to the ground and the background
  111530. */
  111531. setMainColor(color: Color3): void;
  111532. /**
  111533. * Setup the image processing according to the specified options.
  111534. */
  111535. private _setupImageProcessing;
  111536. /**
  111537. * Setup the environment texture according to the specified options.
  111538. */
  111539. private _setupEnvironmentTexture;
  111540. /**
  111541. * Setup the background according to the specified options.
  111542. */
  111543. private _setupBackground;
  111544. /**
  111545. * Get the scene sizes according to the setup.
  111546. */
  111547. private _getSceneSize;
  111548. /**
  111549. * Setup the ground according to the specified options.
  111550. */
  111551. private _setupGround;
  111552. /**
  111553. * Setup the ground material according to the specified options.
  111554. */
  111555. private _setupGroundMaterial;
  111556. /**
  111557. * Setup the ground diffuse texture according to the specified options.
  111558. */
  111559. private _setupGroundDiffuseTexture;
  111560. /**
  111561. * Setup the ground mirror texture according to the specified options.
  111562. */
  111563. private _setupGroundMirrorTexture;
  111564. /**
  111565. * Setup the ground to receive the mirror texture.
  111566. */
  111567. private _setupMirrorInGroundMaterial;
  111568. /**
  111569. * Setup the skybox according to the specified options.
  111570. */
  111571. private _setupSkybox;
  111572. /**
  111573. * Setup the skybox material according to the specified options.
  111574. */
  111575. private _setupSkyboxMaterial;
  111576. /**
  111577. * Setup the skybox reflection texture according to the specified options.
  111578. */
  111579. private _setupSkyboxReflectionTexture;
  111580. private _errorHandler;
  111581. /**
  111582. * Dispose all the elements created by the Helper.
  111583. */
  111584. dispose(): void;
  111585. }
  111586. }
  111587. declare module BABYLON {
  111588. /**
  111589. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  111590. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  111591. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  111592. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  111593. */
  111594. export class PhotoDome extends TransformNode {
  111595. /**
  111596. * Define the image as a Monoscopic panoramic 360 image.
  111597. */
  111598. static readonly MODE_MONOSCOPIC: number;
  111599. /**
  111600. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  111601. */
  111602. static readonly MODE_TOPBOTTOM: number;
  111603. /**
  111604. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  111605. */
  111606. static readonly MODE_SIDEBYSIDE: number;
  111607. private _useDirectMapping;
  111608. /**
  111609. * The texture being displayed on the sphere
  111610. */
  111611. protected _photoTexture: Texture;
  111612. /**
  111613. * Gets or sets the texture being displayed on the sphere
  111614. */
  111615. photoTexture: Texture;
  111616. /**
  111617. * Observable raised when an error occured while loading the 360 image
  111618. */
  111619. onLoadErrorObservable: Observable<string>;
  111620. /**
  111621. * The skybox material
  111622. */
  111623. protected _material: BackgroundMaterial;
  111624. /**
  111625. * The surface used for the skybox
  111626. */
  111627. protected _mesh: Mesh;
  111628. /**
  111629. * Gets the mesh used for the skybox.
  111630. */
  111631. readonly mesh: Mesh;
  111632. /**
  111633. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  111634. * Also see the options.resolution property.
  111635. */
  111636. fovMultiplier: number;
  111637. private _imageMode;
  111638. /**
  111639. * Gets or set the current video mode for the video. It can be:
  111640. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  111641. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  111642. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  111643. */
  111644. imageMode: number;
  111645. /**
  111646. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  111647. * @param name Element's name, child elements will append suffixes for their own names.
  111648. * @param urlsOfPhoto defines the url of the photo to display
  111649. * @param options defines an object containing optional or exposed sub element properties
  111650. * @param onError defines a callback called when an error occured while loading the texture
  111651. */
  111652. constructor(name: string, urlOfPhoto: string, options: {
  111653. resolution?: number;
  111654. size?: number;
  111655. useDirectMapping?: boolean;
  111656. faceForward?: boolean;
  111657. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  111658. private _onBeforeCameraRenderObserver;
  111659. private _changeImageMode;
  111660. /**
  111661. * Releases resources associated with this node.
  111662. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111663. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111664. */
  111665. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111666. }
  111667. }
  111668. declare module BABYLON {
  111669. /**
  111670. * Class used to host RGBD texture specific utilities
  111671. */
  111672. export class RGBDTextureTools {
  111673. /**
  111674. * Expand the RGBD Texture from RGBD to Half Float if possible.
  111675. * @param texture the texture to expand.
  111676. */
  111677. static ExpandRGBDTexture(texture: Texture): void;
  111678. }
  111679. }
  111680. declare module BABYLON {
  111681. /**
  111682. * Class used to host texture specific utilities
  111683. */
  111684. export class BRDFTextureTools {
  111685. /**
  111686. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  111687. * @param scene defines the hosting scene
  111688. * @returns the environment BRDF texture
  111689. */
  111690. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  111691. private static _environmentBRDFBase64Texture;
  111692. }
  111693. }
  111694. declare module BABYLON {
  111695. /**
  111696. * @hidden
  111697. */
  111698. export interface IMaterialClearCoatDefines {
  111699. CLEARCOAT: boolean;
  111700. CLEARCOAT_DEFAULTIOR: boolean;
  111701. CLEARCOAT_TEXTURE: boolean;
  111702. CLEARCOAT_TEXTUREDIRECTUV: number;
  111703. CLEARCOAT_BUMP: boolean;
  111704. CLEARCOAT_BUMPDIRECTUV: number;
  111705. CLEARCOAT_TINT: boolean;
  111706. CLEARCOAT_TINT_TEXTURE: boolean;
  111707. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  111708. /** @hidden */
  111709. _areTexturesDirty: boolean;
  111710. }
  111711. /**
  111712. * Define the code related to the clear coat parameters of the pbr material.
  111713. */
  111714. export class PBRClearCoatConfiguration {
  111715. /**
  111716. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  111717. * The default fits with a polyurethane material.
  111718. */
  111719. private static readonly _DefaultIndexOfRefraction;
  111720. private _isEnabled;
  111721. /**
  111722. * Defines if the clear coat is enabled in the material.
  111723. */
  111724. isEnabled: boolean;
  111725. /**
  111726. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  111727. */
  111728. intensity: number;
  111729. /**
  111730. * Defines the clear coat layer roughness.
  111731. */
  111732. roughness: number;
  111733. private _indexOfRefraction;
  111734. /**
  111735. * Defines the index of refraction of the clear coat.
  111736. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  111737. * The default fits with a polyurethane material.
  111738. * Changing the default value is more performance intensive.
  111739. */
  111740. indexOfRefraction: number;
  111741. private _texture;
  111742. /**
  111743. * Stores the clear coat values in a texture.
  111744. */
  111745. texture: Nullable<BaseTexture>;
  111746. private _bumpTexture;
  111747. /**
  111748. * Define the clear coat specific bump texture.
  111749. */
  111750. bumpTexture: Nullable<BaseTexture>;
  111751. private _isTintEnabled;
  111752. /**
  111753. * Defines if the clear coat tint is enabled in the material.
  111754. */
  111755. isTintEnabled: boolean;
  111756. /**
  111757. * Defines the clear coat tint of the material.
  111758. * This is only use if tint is enabled
  111759. */
  111760. tintColor: Color3;
  111761. /**
  111762. * Defines the distance at which the tint color should be found in the
  111763. * clear coat media.
  111764. * This is only use if tint is enabled
  111765. */
  111766. tintColorAtDistance: number;
  111767. /**
  111768. * Defines the clear coat layer thickness.
  111769. * This is only use if tint is enabled
  111770. */
  111771. tintThickness: number;
  111772. private _tintTexture;
  111773. /**
  111774. * Stores the clear tint values in a texture.
  111775. * rgb is tint
  111776. * a is a thickness factor
  111777. */
  111778. tintTexture: Nullable<BaseTexture>;
  111779. /** @hidden */
  111780. private _internalMarkAllSubMeshesAsTexturesDirty;
  111781. /** @hidden */
  111782. _markAllSubMeshesAsTexturesDirty(): void;
  111783. /**
  111784. * Instantiate a new istance of clear coat configuration.
  111785. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  111786. */
  111787. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  111788. /**
  111789. * Gets wehter the submesh is ready to be used or not.
  111790. * @param defines the list of "defines" to update.
  111791. * @param scene defines the scene the material belongs to.
  111792. * @param engine defines the engine the material belongs to.
  111793. * @param disableBumpMap defines wether the material disables bump or not.
  111794. * @returns - boolean indicating that the submesh is ready or not.
  111795. */
  111796. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  111797. /**
  111798. * Checks to see if a texture is used in the material.
  111799. * @param defines the list of "defines" to update.
  111800. * @param scene defines the scene to the material belongs to.
  111801. */
  111802. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  111803. /**
  111804. * Binds the material data.
  111805. * @param uniformBuffer defines the Uniform buffer to fill in.
  111806. * @param scene defines the scene the material belongs to.
  111807. * @param engine defines the engine the material belongs to.
  111808. * @param disableBumpMap defines wether the material disables bump or not.
  111809. * @param isFrozen defines wether the material is frozen or not.
  111810. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  111811. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  111812. */
  111813. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  111814. /**
  111815. * Checks to see if a texture is used in the material.
  111816. * @param texture - Base texture to use.
  111817. * @returns - Boolean specifying if a texture is used in the material.
  111818. */
  111819. hasTexture(texture: BaseTexture): boolean;
  111820. /**
  111821. * Returns an array of the actively used textures.
  111822. * @param activeTextures Array of BaseTextures
  111823. */
  111824. getActiveTextures(activeTextures: BaseTexture[]): void;
  111825. /**
  111826. * Returns the animatable textures.
  111827. * @param animatables Array of animatable textures.
  111828. */
  111829. getAnimatables(animatables: IAnimatable[]): void;
  111830. /**
  111831. * Disposes the resources of the material.
  111832. * @param forceDisposeTextures - Forces the disposal of all textures.
  111833. */
  111834. dispose(forceDisposeTextures?: boolean): void;
  111835. /**
  111836. * Get the current class name of the texture useful for serialization or dynamic coding.
  111837. * @returns "PBRClearCoatConfiguration"
  111838. */
  111839. getClassName(): string;
  111840. /**
  111841. * Add fallbacks to the effect fallbacks list.
  111842. * @param defines defines the Base texture to use.
  111843. * @param fallbacks defines the current fallback list.
  111844. * @param currentRank defines the current fallback rank.
  111845. * @returns the new fallback rank.
  111846. */
  111847. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  111848. /**
  111849. * Add the required uniforms to the current list.
  111850. * @param uniforms defines the current uniform list.
  111851. */
  111852. static AddUniforms(uniforms: string[]): void;
  111853. /**
  111854. * Add the required samplers to the current list.
  111855. * @param samplers defines the current sampler list.
  111856. */
  111857. static AddSamplers(samplers: string[]): void;
  111858. /**
  111859. * Add the required uniforms to the current buffer.
  111860. * @param uniformBuffer defines the current uniform buffer.
  111861. */
  111862. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  111863. /**
  111864. * Makes a duplicate of the current configuration into another one.
  111865. * @param clearCoatConfiguration define the config where to copy the info
  111866. */
  111867. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  111868. /**
  111869. * Serializes this clear coat configuration.
  111870. * @returns - An object with the serialized config.
  111871. */
  111872. serialize(): any;
  111873. /**
  111874. * Parses a anisotropy Configuration from a serialized object.
  111875. * @param source - Serialized object.
  111876. * @param scene Defines the scene we are parsing for
  111877. * @param rootUrl Defines the rootUrl to load from
  111878. */
  111879. parse(source: any, scene: Scene, rootUrl: string): void;
  111880. }
  111881. }
  111882. declare module BABYLON {
  111883. /**
  111884. * @hidden
  111885. */
  111886. export interface IMaterialAnisotropicDefines {
  111887. ANISOTROPIC: boolean;
  111888. ANISOTROPIC_TEXTURE: boolean;
  111889. ANISOTROPIC_TEXTUREDIRECTUV: number;
  111890. MAINUV1: boolean;
  111891. _areTexturesDirty: boolean;
  111892. _needUVs: boolean;
  111893. }
  111894. /**
  111895. * Define the code related to the anisotropic parameters of the pbr material.
  111896. */
  111897. export class PBRAnisotropicConfiguration {
  111898. private _isEnabled;
  111899. /**
  111900. * Defines if the anisotropy is enabled in the material.
  111901. */
  111902. isEnabled: boolean;
  111903. /**
  111904. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  111905. */
  111906. intensity: number;
  111907. /**
  111908. * Defines if the effect is along the tangents, bitangents or in between.
  111909. * By default, the effect is "strectching" the highlights along the tangents.
  111910. */
  111911. direction: Vector2;
  111912. private _texture;
  111913. /**
  111914. * Stores the anisotropy values in a texture.
  111915. * rg is direction (like normal from -1 to 1)
  111916. * b is a intensity
  111917. */
  111918. texture: Nullable<BaseTexture>;
  111919. /** @hidden */
  111920. private _internalMarkAllSubMeshesAsTexturesDirty;
  111921. /** @hidden */
  111922. _markAllSubMeshesAsTexturesDirty(): void;
  111923. /**
  111924. * Instantiate a new istance of anisotropy configuration.
  111925. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  111926. */
  111927. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  111928. /**
  111929. * Specifies that the submesh is ready to be used.
  111930. * @param defines the list of "defines" to update.
  111931. * @param scene defines the scene the material belongs to.
  111932. * @returns - boolean indicating that the submesh is ready or not.
  111933. */
  111934. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  111935. /**
  111936. * Checks to see if a texture is used in the material.
  111937. * @param defines the list of "defines" to update.
  111938. * @param mesh the mesh we are preparing the defines for.
  111939. * @param scene defines the scene the material belongs to.
  111940. */
  111941. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  111942. /**
  111943. * Binds the material data.
  111944. * @param uniformBuffer defines the Uniform buffer to fill in.
  111945. * @param scene defines the scene the material belongs to.
  111946. * @param isFrozen defines wether the material is frozen or not.
  111947. */
  111948. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  111949. /**
  111950. * Checks to see if a texture is used in the material.
  111951. * @param texture - Base texture to use.
  111952. * @returns - Boolean specifying if a texture is used in the material.
  111953. */
  111954. hasTexture(texture: BaseTexture): boolean;
  111955. /**
  111956. * Returns an array of the actively used textures.
  111957. * @param activeTextures Array of BaseTextures
  111958. */
  111959. getActiveTextures(activeTextures: BaseTexture[]): void;
  111960. /**
  111961. * Returns the animatable textures.
  111962. * @param animatables Array of animatable textures.
  111963. */
  111964. getAnimatables(animatables: IAnimatable[]): void;
  111965. /**
  111966. * Disposes the resources of the material.
  111967. * @param forceDisposeTextures - Forces the disposal of all textures.
  111968. */
  111969. dispose(forceDisposeTextures?: boolean): void;
  111970. /**
  111971. * Get the current class name of the texture useful for serialization or dynamic coding.
  111972. * @returns "PBRAnisotropicConfiguration"
  111973. */
  111974. getClassName(): string;
  111975. /**
  111976. * Add fallbacks to the effect fallbacks list.
  111977. * @param defines defines the Base texture to use.
  111978. * @param fallbacks defines the current fallback list.
  111979. * @param currentRank defines the current fallback rank.
  111980. * @returns the new fallback rank.
  111981. */
  111982. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  111983. /**
  111984. * Add the required uniforms to the current list.
  111985. * @param uniforms defines the current uniform list.
  111986. */
  111987. static AddUniforms(uniforms: string[]): void;
  111988. /**
  111989. * Add the required uniforms to the current buffer.
  111990. * @param uniformBuffer defines the current uniform buffer.
  111991. */
  111992. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  111993. /**
  111994. * Add the required samplers to the current list.
  111995. * @param samplers defines the current sampler list.
  111996. */
  111997. static AddSamplers(samplers: string[]): void;
  111998. /**
  111999. * Makes a duplicate of the current configuration into another one.
  112000. * @param anisotropicConfiguration define the config where to copy the info
  112001. */
  112002. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  112003. /**
  112004. * Serializes this anisotropy configuration.
  112005. * @returns - An object with the serialized config.
  112006. */
  112007. serialize(): any;
  112008. /**
  112009. * Parses a anisotropy Configuration from a serialized object.
  112010. * @param source - Serialized object.
  112011. * @param scene Defines the scene we are parsing for
  112012. * @param rootUrl Defines the rootUrl to load from
  112013. */
  112014. parse(source: any, scene: Scene, rootUrl: string): void;
  112015. }
  112016. }
  112017. declare module BABYLON {
  112018. /**
  112019. * @hidden
  112020. */
  112021. export interface IMaterialBRDFDefines {
  112022. BRDF_V_HEIGHT_CORRELATED: boolean;
  112023. MS_BRDF_ENERGY_CONSERVATION: boolean;
  112024. SPHERICAL_HARMONICS: boolean;
  112025. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  112026. /** @hidden */
  112027. _areMiscDirty: boolean;
  112028. }
  112029. /**
  112030. * Define the code related to the BRDF parameters of the pbr material.
  112031. */
  112032. export class PBRBRDFConfiguration {
  112033. /**
  112034. * Default value used for the energy conservation.
  112035. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  112036. */
  112037. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  112038. /**
  112039. * Default value used for the Smith Visibility Height Correlated mode.
  112040. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  112041. */
  112042. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  112043. /**
  112044. * Default value used for the IBL diffuse part.
  112045. * This can help switching back to the polynomials mode globally which is a tiny bit
  112046. * less GPU intensive at the drawback of a lower quality.
  112047. */
  112048. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  112049. /**
  112050. * Default value used for activating energy conservation for the specular workflow.
  112051. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  112052. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  112053. */
  112054. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  112055. private _useEnergyConservation;
  112056. /**
  112057. * Defines if the material uses energy conservation.
  112058. */
  112059. useEnergyConservation: boolean;
  112060. private _useSmithVisibilityHeightCorrelated;
  112061. /**
  112062. * LEGACY Mode set to false
  112063. * Defines if the material uses height smith correlated visibility term.
  112064. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  112065. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  112066. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  112067. * Not relying on height correlated will also disable energy conservation.
  112068. */
  112069. useSmithVisibilityHeightCorrelated: boolean;
  112070. private _useSphericalHarmonics;
  112071. /**
  112072. * LEGACY Mode set to false
  112073. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  112074. * diffuse part of the IBL.
  112075. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  112076. * to the ground truth.
  112077. */
  112078. useSphericalHarmonics: boolean;
  112079. private _useSpecularGlossinessInputEnergyConservation;
  112080. /**
  112081. * Defines if the material uses energy conservation, when the specular workflow is active.
  112082. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  112083. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  112084. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  112085. */
  112086. useSpecularGlossinessInputEnergyConservation: boolean;
  112087. /** @hidden */
  112088. private _internalMarkAllSubMeshesAsMiscDirty;
  112089. /** @hidden */
  112090. _markAllSubMeshesAsMiscDirty(): void;
  112091. /**
  112092. * Instantiate a new istance of clear coat configuration.
  112093. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  112094. */
  112095. constructor(markAllSubMeshesAsMiscDirty: () => void);
  112096. /**
  112097. * Checks to see if a texture is used in the material.
  112098. * @param defines the list of "defines" to update.
  112099. */
  112100. prepareDefines(defines: IMaterialBRDFDefines): void;
  112101. /**
  112102. * Get the current class name of the texture useful for serialization or dynamic coding.
  112103. * @returns "PBRClearCoatConfiguration"
  112104. */
  112105. getClassName(): string;
  112106. /**
  112107. * Makes a duplicate of the current configuration into another one.
  112108. * @param brdfConfiguration define the config where to copy the info
  112109. */
  112110. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  112111. /**
  112112. * Serializes this BRDF configuration.
  112113. * @returns - An object with the serialized config.
  112114. */
  112115. serialize(): any;
  112116. /**
  112117. * Parses a anisotropy Configuration from a serialized object.
  112118. * @param source - Serialized object.
  112119. * @param scene Defines the scene we are parsing for
  112120. * @param rootUrl Defines the rootUrl to load from
  112121. */
  112122. parse(source: any, scene: Scene, rootUrl: string): void;
  112123. }
  112124. }
  112125. declare module BABYLON {
  112126. /**
  112127. * @hidden
  112128. */
  112129. export interface IMaterialSheenDefines {
  112130. SHEEN: boolean;
  112131. SHEEN_TEXTURE: boolean;
  112132. SHEEN_TEXTUREDIRECTUV: number;
  112133. SHEEN_LINKWITHALBEDO: boolean;
  112134. /** @hidden */
  112135. _areTexturesDirty: boolean;
  112136. }
  112137. /**
  112138. * Define the code related to the Sheen parameters of the pbr material.
  112139. */
  112140. export class PBRSheenConfiguration {
  112141. private _isEnabled;
  112142. /**
  112143. * Defines if the material uses sheen.
  112144. */
  112145. isEnabled: boolean;
  112146. private _linkSheenWithAlbedo;
  112147. /**
  112148. * Defines if the sheen is linked to the sheen color.
  112149. */
  112150. linkSheenWithAlbedo: boolean;
  112151. /**
  112152. * Defines the sheen intensity.
  112153. */
  112154. intensity: number;
  112155. /**
  112156. * Defines the sheen color.
  112157. */
  112158. color: Color3;
  112159. private _texture;
  112160. /**
  112161. * Stores the sheen tint values in a texture.
  112162. * rgb is tint
  112163. * a is a intensity
  112164. */
  112165. texture: Nullable<BaseTexture>;
  112166. /** @hidden */
  112167. private _internalMarkAllSubMeshesAsTexturesDirty;
  112168. /** @hidden */
  112169. _markAllSubMeshesAsTexturesDirty(): void;
  112170. /**
  112171. * Instantiate a new istance of clear coat configuration.
  112172. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112173. */
  112174. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112175. /**
  112176. * Specifies that the submesh is ready to be used.
  112177. * @param defines the list of "defines" to update.
  112178. * @param scene defines the scene the material belongs to.
  112179. * @returns - boolean indicating that the submesh is ready or not.
  112180. */
  112181. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  112182. /**
  112183. * Checks to see if a texture is used in the material.
  112184. * @param defines the list of "defines" to update.
  112185. * @param scene defines the scene the material belongs to.
  112186. */
  112187. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  112188. /**
  112189. * Binds the material data.
  112190. * @param uniformBuffer defines the Uniform buffer to fill in.
  112191. * @param scene defines the scene the material belongs to.
  112192. * @param isFrozen defines wether the material is frozen or not.
  112193. */
  112194. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  112195. /**
  112196. * Checks to see if a texture is used in the material.
  112197. * @param texture - Base texture to use.
  112198. * @returns - Boolean specifying if a texture is used in the material.
  112199. */
  112200. hasTexture(texture: BaseTexture): boolean;
  112201. /**
  112202. * Returns an array of the actively used textures.
  112203. * @param activeTextures Array of BaseTextures
  112204. */
  112205. getActiveTextures(activeTextures: BaseTexture[]): void;
  112206. /**
  112207. * Returns the animatable textures.
  112208. * @param animatables Array of animatable textures.
  112209. */
  112210. getAnimatables(animatables: IAnimatable[]): void;
  112211. /**
  112212. * Disposes the resources of the material.
  112213. * @param forceDisposeTextures - Forces the disposal of all textures.
  112214. */
  112215. dispose(forceDisposeTextures?: boolean): void;
  112216. /**
  112217. * Get the current class name of the texture useful for serialization or dynamic coding.
  112218. * @returns "PBRSheenConfiguration"
  112219. */
  112220. getClassName(): string;
  112221. /**
  112222. * Add fallbacks to the effect fallbacks list.
  112223. * @param defines defines the Base texture to use.
  112224. * @param fallbacks defines the current fallback list.
  112225. * @param currentRank defines the current fallback rank.
  112226. * @returns the new fallback rank.
  112227. */
  112228. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112229. /**
  112230. * Add the required uniforms to the current list.
  112231. * @param uniforms defines the current uniform list.
  112232. */
  112233. static AddUniforms(uniforms: string[]): void;
  112234. /**
  112235. * Add the required uniforms to the current buffer.
  112236. * @param uniformBuffer defines the current uniform buffer.
  112237. */
  112238. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112239. /**
  112240. * Add the required samplers to the current list.
  112241. * @param samplers defines the current sampler list.
  112242. */
  112243. static AddSamplers(samplers: string[]): void;
  112244. /**
  112245. * Makes a duplicate of the current configuration into another one.
  112246. * @param sheenConfiguration define the config where to copy the info
  112247. */
  112248. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  112249. /**
  112250. * Serializes this BRDF configuration.
  112251. * @returns - An object with the serialized config.
  112252. */
  112253. serialize(): any;
  112254. /**
  112255. * Parses a anisotropy Configuration from a serialized object.
  112256. * @param source - Serialized object.
  112257. * @param scene Defines the scene we are parsing for
  112258. * @param rootUrl Defines the rootUrl to load from
  112259. */
  112260. parse(source: any, scene: Scene, rootUrl: string): void;
  112261. }
  112262. }
  112263. declare module BABYLON {
  112264. /**
  112265. * @hidden
  112266. */
  112267. export interface IMaterialSubSurfaceDefines {
  112268. SUBSURFACE: boolean;
  112269. SS_REFRACTION: boolean;
  112270. SS_TRANSLUCENCY: boolean;
  112271. SS_SCATERRING: boolean;
  112272. SS_THICKNESSANDMASK_TEXTURE: boolean;
  112273. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  112274. SS_REFRACTIONMAP_3D: boolean;
  112275. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  112276. SS_LODINREFRACTIONALPHA: boolean;
  112277. SS_GAMMAREFRACTION: boolean;
  112278. SS_RGBDREFRACTION: boolean;
  112279. SS_LINEARSPECULARREFRACTION: boolean;
  112280. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  112281. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  112282. /** @hidden */
  112283. _areTexturesDirty: boolean;
  112284. }
  112285. /**
  112286. * Define the code related to the sub surface parameters of the pbr material.
  112287. */
  112288. export class PBRSubSurfaceConfiguration {
  112289. private _isRefractionEnabled;
  112290. /**
  112291. * Defines if the refraction is enabled in the material.
  112292. */
  112293. isRefractionEnabled: boolean;
  112294. private _isTranslucencyEnabled;
  112295. /**
  112296. * Defines if the translucency is enabled in the material.
  112297. */
  112298. isTranslucencyEnabled: boolean;
  112299. private _isScatteringEnabled;
  112300. /**
  112301. * Defines the refraction intensity of the material.
  112302. * The refraction when enabled replaces the Diffuse part of the material.
  112303. * The intensity helps transitionning between diffuse and refraction.
  112304. */
  112305. refractionIntensity: number;
  112306. /**
  112307. * Defines the translucency intensity of the material.
  112308. * When translucency has been enabled, this defines how much of the "translucency"
  112309. * is addded to the diffuse part of the material.
  112310. */
  112311. translucencyIntensity: number;
  112312. /**
  112313. * Defines the scattering intensity of the material.
  112314. * When scattering has been enabled, this defines how much of the "scattered light"
  112315. * is addded to the diffuse part of the material.
  112316. */
  112317. scatteringIntensity: number;
  112318. private _thicknessTexture;
  112319. /**
  112320. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  112321. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  112322. * 0 would mean minimumThickness
  112323. * 1 would mean maximumThickness
  112324. * The other channels might be use as a mask to vary the different effects intensity.
  112325. */
  112326. thicknessTexture: Nullable<BaseTexture>;
  112327. private _refractionTexture;
  112328. /**
  112329. * Defines the texture to use for refraction.
  112330. */
  112331. refractionTexture: Nullable<BaseTexture>;
  112332. private _indexOfRefraction;
  112333. /**
  112334. * Defines the index of refraction used in the material.
  112335. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  112336. */
  112337. indexOfRefraction: number;
  112338. private _invertRefractionY;
  112339. /**
  112340. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  112341. */
  112342. invertRefractionY: boolean;
  112343. private _linkRefractionWithTransparency;
  112344. /**
  112345. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  112346. * Materials half opaque for instance using refraction could benefit from this control.
  112347. */
  112348. linkRefractionWithTransparency: boolean;
  112349. /**
  112350. * Defines the minimum thickness stored in the thickness map.
  112351. * If no thickness map is defined, this value will be used to simulate thickness.
  112352. */
  112353. minimumThickness: number;
  112354. /**
  112355. * Defines the maximum thickness stored in the thickness map.
  112356. */
  112357. maximumThickness: number;
  112358. /**
  112359. * Defines the volume tint of the material.
  112360. * This is used for both translucency and scattering.
  112361. */
  112362. tintColor: Color3;
  112363. /**
  112364. * Defines the distance at which the tint color should be found in the media.
  112365. * This is used for refraction only.
  112366. */
  112367. tintColorAtDistance: number;
  112368. /**
  112369. * Defines how far each channel transmit through the media.
  112370. * It is defined as a color to simplify it selection.
  112371. */
  112372. diffusionDistance: Color3;
  112373. private _useMaskFromThicknessTexture;
  112374. /**
  112375. * Stores the intensity of the different subsurface effects in the thickness texture.
  112376. * * the green channel is the translucency intensity.
  112377. * * the blue channel is the scattering intensity.
  112378. * * the alpha channel is the refraction intensity.
  112379. */
  112380. useMaskFromThicknessTexture: boolean;
  112381. /** @hidden */
  112382. private _internalMarkAllSubMeshesAsTexturesDirty;
  112383. /** @hidden */
  112384. _markAllSubMeshesAsTexturesDirty(): void;
  112385. /**
  112386. * Instantiate a new istance of sub surface configuration.
  112387. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112388. */
  112389. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112390. /**
  112391. * Gets wehter the submesh is ready to be used or not.
  112392. * @param defines the list of "defines" to update.
  112393. * @param scene defines the scene the material belongs to.
  112394. * @returns - boolean indicating that the submesh is ready or not.
  112395. */
  112396. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  112397. /**
  112398. * Checks to see if a texture is used in the material.
  112399. * @param defines the list of "defines" to update.
  112400. * @param scene defines the scene to the material belongs to.
  112401. */
  112402. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  112403. /**
  112404. * Binds the material data.
  112405. * @param uniformBuffer defines the Uniform buffer to fill in.
  112406. * @param scene defines the scene the material belongs to.
  112407. * @param engine defines the engine the material belongs to.
  112408. * @param isFrozen defines wether the material is frozen or not.
  112409. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  112410. */
  112411. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  112412. /**
  112413. * Unbinds the material from the mesh.
  112414. * @param activeEffect defines the effect that should be unbound from.
  112415. * @returns true if unbound, otherwise false
  112416. */
  112417. unbind(activeEffect: Effect): boolean;
  112418. /**
  112419. * Returns the texture used for refraction or null if none is used.
  112420. * @param scene defines the scene the material belongs to.
  112421. * @returns - Refraction texture if present. If no refraction texture and refraction
  112422. * is linked with transparency, returns environment texture. Otherwise, returns null.
  112423. */
  112424. private _getRefractionTexture;
  112425. /**
  112426. * Returns true if alpha blending should be disabled.
  112427. */
  112428. readonly disableAlphaBlending: boolean;
  112429. /**
  112430. * Fills the list of render target textures.
  112431. * @param renderTargets the list of render targets to update
  112432. */
  112433. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  112434. /**
  112435. * Checks to see if a texture is used in the material.
  112436. * @param texture - Base texture to use.
  112437. * @returns - Boolean specifying if a texture is used in the material.
  112438. */
  112439. hasTexture(texture: BaseTexture): boolean;
  112440. /**
  112441. * Gets a boolean indicating that current material needs to register RTT
  112442. * @returns true if this uses a render target otherwise false.
  112443. */
  112444. hasRenderTargetTextures(): boolean;
  112445. /**
  112446. * Returns an array of the actively used textures.
  112447. * @param activeTextures Array of BaseTextures
  112448. */
  112449. getActiveTextures(activeTextures: BaseTexture[]): void;
  112450. /**
  112451. * Returns the animatable textures.
  112452. * @param animatables Array of animatable textures.
  112453. */
  112454. getAnimatables(animatables: IAnimatable[]): void;
  112455. /**
  112456. * Disposes the resources of the material.
  112457. * @param forceDisposeTextures - Forces the disposal of all textures.
  112458. */
  112459. dispose(forceDisposeTextures?: boolean): void;
  112460. /**
  112461. * Get the current class name of the texture useful for serialization or dynamic coding.
  112462. * @returns "PBRSubSurfaceConfiguration"
  112463. */
  112464. getClassName(): string;
  112465. /**
  112466. * Add fallbacks to the effect fallbacks list.
  112467. * @param defines defines the Base texture to use.
  112468. * @param fallbacks defines the current fallback list.
  112469. * @param currentRank defines the current fallback rank.
  112470. * @returns the new fallback rank.
  112471. */
  112472. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112473. /**
  112474. * Add the required uniforms to the current list.
  112475. * @param uniforms defines the current uniform list.
  112476. */
  112477. static AddUniforms(uniforms: string[]): void;
  112478. /**
  112479. * Add the required samplers to the current list.
  112480. * @param samplers defines the current sampler list.
  112481. */
  112482. static AddSamplers(samplers: string[]): void;
  112483. /**
  112484. * Add the required uniforms to the current buffer.
  112485. * @param uniformBuffer defines the current uniform buffer.
  112486. */
  112487. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112488. /**
  112489. * Makes a duplicate of the current configuration into another one.
  112490. * @param configuration define the config where to copy the info
  112491. */
  112492. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  112493. /**
  112494. * Serializes this Sub Surface configuration.
  112495. * @returns - An object with the serialized config.
  112496. */
  112497. serialize(): any;
  112498. /**
  112499. * Parses a anisotropy Configuration from a serialized object.
  112500. * @param source - Serialized object.
  112501. * @param scene Defines the scene we are parsing for
  112502. * @param rootUrl Defines the rootUrl to load from
  112503. */
  112504. parse(source: any, scene: Scene, rootUrl: string): void;
  112505. }
  112506. }
  112507. declare module BABYLON {
  112508. /** @hidden */
  112509. export var pbrFragmentDeclaration: {
  112510. name: string;
  112511. shader: string;
  112512. };
  112513. }
  112514. declare module BABYLON {
  112515. /** @hidden */
  112516. export var pbrUboDeclaration: {
  112517. name: string;
  112518. shader: string;
  112519. };
  112520. }
  112521. declare module BABYLON {
  112522. /** @hidden */
  112523. export var pbrFragmentExtraDeclaration: {
  112524. name: string;
  112525. shader: string;
  112526. };
  112527. }
  112528. declare module BABYLON {
  112529. /** @hidden */
  112530. export var pbrFragmentSamplersDeclaration: {
  112531. name: string;
  112532. shader: string;
  112533. };
  112534. }
  112535. declare module BABYLON {
  112536. /** @hidden */
  112537. export var pbrHelperFunctions: {
  112538. name: string;
  112539. shader: string;
  112540. };
  112541. }
  112542. declare module BABYLON {
  112543. /** @hidden */
  112544. export var harmonicsFunctions: {
  112545. name: string;
  112546. shader: string;
  112547. };
  112548. }
  112549. declare module BABYLON {
  112550. /** @hidden */
  112551. export var pbrDirectLightingSetupFunctions: {
  112552. name: string;
  112553. shader: string;
  112554. };
  112555. }
  112556. declare module BABYLON {
  112557. /** @hidden */
  112558. export var pbrDirectLightingFalloffFunctions: {
  112559. name: string;
  112560. shader: string;
  112561. };
  112562. }
  112563. declare module BABYLON {
  112564. /** @hidden */
  112565. export var pbrBRDFFunctions: {
  112566. name: string;
  112567. shader: string;
  112568. };
  112569. }
  112570. declare module BABYLON {
  112571. /** @hidden */
  112572. export var pbrDirectLightingFunctions: {
  112573. name: string;
  112574. shader: string;
  112575. };
  112576. }
  112577. declare module BABYLON {
  112578. /** @hidden */
  112579. export var pbrIBLFunctions: {
  112580. name: string;
  112581. shader: string;
  112582. };
  112583. }
  112584. declare module BABYLON {
  112585. /** @hidden */
  112586. export var pbrDebug: {
  112587. name: string;
  112588. shader: string;
  112589. };
  112590. }
  112591. declare module BABYLON {
  112592. /** @hidden */
  112593. export var pbrPixelShader: {
  112594. name: string;
  112595. shader: string;
  112596. };
  112597. }
  112598. declare module BABYLON {
  112599. /** @hidden */
  112600. export var pbrVertexDeclaration: {
  112601. name: string;
  112602. shader: string;
  112603. };
  112604. }
  112605. declare module BABYLON {
  112606. /** @hidden */
  112607. export var pbrVertexShader: {
  112608. name: string;
  112609. shader: string;
  112610. };
  112611. }
  112612. declare module BABYLON {
  112613. /**
  112614. * Manages the defines for the PBR Material.
  112615. * @hidden
  112616. */
  112617. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  112618. PBR: boolean;
  112619. MAINUV1: boolean;
  112620. MAINUV2: boolean;
  112621. UV1: boolean;
  112622. UV2: boolean;
  112623. ALBEDO: boolean;
  112624. ALBEDODIRECTUV: number;
  112625. VERTEXCOLOR: boolean;
  112626. AMBIENT: boolean;
  112627. AMBIENTDIRECTUV: number;
  112628. AMBIENTINGRAYSCALE: boolean;
  112629. OPACITY: boolean;
  112630. VERTEXALPHA: boolean;
  112631. OPACITYDIRECTUV: number;
  112632. OPACITYRGB: boolean;
  112633. ALPHATEST: boolean;
  112634. DEPTHPREPASS: boolean;
  112635. ALPHABLEND: boolean;
  112636. ALPHAFROMALBEDO: boolean;
  112637. ALPHATESTVALUE: string;
  112638. SPECULAROVERALPHA: boolean;
  112639. RADIANCEOVERALPHA: boolean;
  112640. ALPHAFRESNEL: boolean;
  112641. LINEARALPHAFRESNEL: boolean;
  112642. PREMULTIPLYALPHA: boolean;
  112643. EMISSIVE: boolean;
  112644. EMISSIVEDIRECTUV: number;
  112645. REFLECTIVITY: boolean;
  112646. REFLECTIVITYDIRECTUV: number;
  112647. SPECULARTERM: boolean;
  112648. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  112649. MICROSURFACEAUTOMATIC: boolean;
  112650. LODBASEDMICROSFURACE: boolean;
  112651. MICROSURFACEMAP: boolean;
  112652. MICROSURFACEMAPDIRECTUV: number;
  112653. METALLICWORKFLOW: boolean;
  112654. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  112655. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  112656. METALLNESSSTOREINMETALMAPBLUE: boolean;
  112657. AOSTOREINMETALMAPRED: boolean;
  112658. ENVIRONMENTBRDF: boolean;
  112659. ENVIRONMENTBRDF_RGBD: boolean;
  112660. NORMAL: boolean;
  112661. TANGENT: boolean;
  112662. BUMP: boolean;
  112663. BUMPDIRECTUV: number;
  112664. OBJECTSPACE_NORMALMAP: boolean;
  112665. PARALLAX: boolean;
  112666. PARALLAXOCCLUSION: boolean;
  112667. NORMALXYSCALE: boolean;
  112668. LIGHTMAP: boolean;
  112669. LIGHTMAPDIRECTUV: number;
  112670. USELIGHTMAPASSHADOWMAP: boolean;
  112671. GAMMALIGHTMAP: boolean;
  112672. RGBDLIGHTMAP: boolean;
  112673. REFLECTION: boolean;
  112674. REFLECTIONMAP_3D: boolean;
  112675. REFLECTIONMAP_SPHERICAL: boolean;
  112676. REFLECTIONMAP_PLANAR: boolean;
  112677. REFLECTIONMAP_CUBIC: boolean;
  112678. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  112679. REFLECTIONMAP_PROJECTION: boolean;
  112680. REFLECTIONMAP_SKYBOX: boolean;
  112681. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  112682. REFLECTIONMAP_EXPLICIT: boolean;
  112683. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  112684. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  112685. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  112686. INVERTCUBICMAP: boolean;
  112687. USESPHERICALFROMREFLECTIONMAP: boolean;
  112688. USEIRRADIANCEMAP: boolean;
  112689. SPHERICAL_HARMONICS: boolean;
  112690. USESPHERICALINVERTEX: boolean;
  112691. REFLECTIONMAP_OPPOSITEZ: boolean;
  112692. LODINREFLECTIONALPHA: boolean;
  112693. GAMMAREFLECTION: boolean;
  112694. RGBDREFLECTION: boolean;
  112695. LINEARSPECULARREFLECTION: boolean;
  112696. RADIANCEOCCLUSION: boolean;
  112697. HORIZONOCCLUSION: boolean;
  112698. INSTANCES: boolean;
  112699. NUM_BONE_INFLUENCERS: number;
  112700. BonesPerMesh: number;
  112701. BONETEXTURE: boolean;
  112702. NONUNIFORMSCALING: boolean;
  112703. MORPHTARGETS: boolean;
  112704. MORPHTARGETS_NORMAL: boolean;
  112705. MORPHTARGETS_TANGENT: boolean;
  112706. MORPHTARGETS_UV: boolean;
  112707. NUM_MORPH_INFLUENCERS: number;
  112708. IMAGEPROCESSING: boolean;
  112709. VIGNETTE: boolean;
  112710. VIGNETTEBLENDMODEMULTIPLY: boolean;
  112711. VIGNETTEBLENDMODEOPAQUE: boolean;
  112712. TONEMAPPING: boolean;
  112713. TONEMAPPING_ACES: boolean;
  112714. CONTRAST: boolean;
  112715. COLORCURVES: boolean;
  112716. COLORGRADING: boolean;
  112717. COLORGRADING3D: boolean;
  112718. SAMPLER3DGREENDEPTH: boolean;
  112719. SAMPLER3DBGRMAP: boolean;
  112720. IMAGEPROCESSINGPOSTPROCESS: boolean;
  112721. EXPOSURE: boolean;
  112722. MULTIVIEW: boolean;
  112723. USEPHYSICALLIGHTFALLOFF: boolean;
  112724. USEGLTFLIGHTFALLOFF: boolean;
  112725. TWOSIDEDLIGHTING: boolean;
  112726. SHADOWFLOAT: boolean;
  112727. CLIPPLANE: boolean;
  112728. CLIPPLANE2: boolean;
  112729. CLIPPLANE3: boolean;
  112730. CLIPPLANE4: boolean;
  112731. POINTSIZE: boolean;
  112732. FOG: boolean;
  112733. LOGARITHMICDEPTH: boolean;
  112734. FORCENORMALFORWARD: boolean;
  112735. SPECULARAA: boolean;
  112736. CLEARCOAT: boolean;
  112737. CLEARCOAT_DEFAULTIOR: boolean;
  112738. CLEARCOAT_TEXTURE: boolean;
  112739. CLEARCOAT_TEXTUREDIRECTUV: number;
  112740. CLEARCOAT_BUMP: boolean;
  112741. CLEARCOAT_BUMPDIRECTUV: number;
  112742. CLEARCOAT_TINT: boolean;
  112743. CLEARCOAT_TINT_TEXTURE: boolean;
  112744. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  112745. ANISOTROPIC: boolean;
  112746. ANISOTROPIC_TEXTURE: boolean;
  112747. ANISOTROPIC_TEXTUREDIRECTUV: number;
  112748. BRDF_V_HEIGHT_CORRELATED: boolean;
  112749. MS_BRDF_ENERGY_CONSERVATION: boolean;
  112750. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  112751. SHEEN: boolean;
  112752. SHEEN_TEXTURE: boolean;
  112753. SHEEN_TEXTUREDIRECTUV: number;
  112754. SHEEN_LINKWITHALBEDO: boolean;
  112755. SUBSURFACE: boolean;
  112756. SS_REFRACTION: boolean;
  112757. SS_TRANSLUCENCY: boolean;
  112758. SS_SCATERRING: boolean;
  112759. SS_THICKNESSANDMASK_TEXTURE: boolean;
  112760. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  112761. SS_REFRACTIONMAP_3D: boolean;
  112762. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  112763. SS_LODINREFRACTIONALPHA: boolean;
  112764. SS_GAMMAREFRACTION: boolean;
  112765. SS_RGBDREFRACTION: boolean;
  112766. SS_LINEARSPECULARREFRACTION: boolean;
  112767. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  112768. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  112769. UNLIT: boolean;
  112770. DEBUGMODE: number;
  112771. /**
  112772. * Initializes the PBR Material defines.
  112773. */
  112774. constructor();
  112775. /**
  112776. * Resets the PBR Material defines.
  112777. */
  112778. reset(): void;
  112779. }
  112780. /**
  112781. * The Physically based material base class of BJS.
  112782. *
  112783. * This offers the main features of a standard PBR material.
  112784. * For more information, please refer to the documentation :
  112785. * https://doc.babylonjs.com/how_to/physically_based_rendering
  112786. */
  112787. export abstract class PBRBaseMaterial extends PushMaterial {
  112788. /**
  112789. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  112790. */
  112791. static readonly PBRMATERIAL_OPAQUE: number;
  112792. /**
  112793. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  112794. */
  112795. static readonly PBRMATERIAL_ALPHATEST: number;
  112796. /**
  112797. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112798. */
  112799. static readonly PBRMATERIAL_ALPHABLEND: number;
  112800. /**
  112801. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112802. * They are also discarded below the alpha cutoff threshold to improve performances.
  112803. */
  112804. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  112805. /**
  112806. * Defines the default value of how much AO map is occluding the analytical lights
  112807. * (point spot...).
  112808. */
  112809. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  112810. /**
  112811. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  112812. */
  112813. static readonly LIGHTFALLOFF_PHYSICAL: number;
  112814. /**
  112815. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  112816. * to enhance interoperability with other engines.
  112817. */
  112818. static readonly LIGHTFALLOFF_GLTF: number;
  112819. /**
  112820. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  112821. * to enhance interoperability with other materials.
  112822. */
  112823. static readonly LIGHTFALLOFF_STANDARD: number;
  112824. /**
  112825. * Intensity of the direct lights e.g. the four lights available in your scene.
  112826. * This impacts both the direct diffuse and specular highlights.
  112827. */
  112828. protected _directIntensity: number;
  112829. /**
  112830. * Intensity of the emissive part of the material.
  112831. * This helps controlling the emissive effect without modifying the emissive color.
  112832. */
  112833. protected _emissiveIntensity: number;
  112834. /**
  112835. * Intensity of the environment e.g. how much the environment will light the object
  112836. * either through harmonics for rough material or through the refelction for shiny ones.
  112837. */
  112838. protected _environmentIntensity: number;
  112839. /**
  112840. * This is a special control allowing the reduction of the specular highlights coming from the
  112841. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  112842. */
  112843. protected _specularIntensity: number;
  112844. /**
  112845. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  112846. */
  112847. private _lightingInfos;
  112848. /**
  112849. * Debug Control allowing disabling the bump map on this material.
  112850. */
  112851. protected _disableBumpMap: boolean;
  112852. /**
  112853. * AKA Diffuse Texture in standard nomenclature.
  112854. */
  112855. protected _albedoTexture: Nullable<BaseTexture>;
  112856. /**
  112857. * AKA Occlusion Texture in other nomenclature.
  112858. */
  112859. protected _ambientTexture: Nullable<BaseTexture>;
  112860. /**
  112861. * AKA Occlusion Texture Intensity in other nomenclature.
  112862. */
  112863. protected _ambientTextureStrength: number;
  112864. /**
  112865. * Defines how much the AO map is occluding the analytical lights (point spot...).
  112866. * 1 means it completely occludes it
  112867. * 0 mean it has no impact
  112868. */
  112869. protected _ambientTextureImpactOnAnalyticalLights: number;
  112870. /**
  112871. * Stores the alpha values in a texture.
  112872. */
  112873. protected _opacityTexture: Nullable<BaseTexture>;
  112874. /**
  112875. * Stores the reflection values in a texture.
  112876. */
  112877. protected _reflectionTexture: Nullable<BaseTexture>;
  112878. /**
  112879. * Stores the emissive values in a texture.
  112880. */
  112881. protected _emissiveTexture: Nullable<BaseTexture>;
  112882. /**
  112883. * AKA Specular texture in other nomenclature.
  112884. */
  112885. protected _reflectivityTexture: Nullable<BaseTexture>;
  112886. /**
  112887. * Used to switch from specular/glossiness to metallic/roughness workflow.
  112888. */
  112889. protected _metallicTexture: Nullable<BaseTexture>;
  112890. /**
  112891. * Specifies the metallic scalar of the metallic/roughness workflow.
  112892. * Can also be used to scale the metalness values of the metallic texture.
  112893. */
  112894. protected _metallic: Nullable<number>;
  112895. /**
  112896. * Specifies the roughness scalar of the metallic/roughness workflow.
  112897. * Can also be used to scale the roughness values of the metallic texture.
  112898. */
  112899. protected _roughness: Nullable<number>;
  112900. /**
  112901. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  112902. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  112903. */
  112904. protected _microSurfaceTexture: Nullable<BaseTexture>;
  112905. /**
  112906. * Stores surface normal data used to displace a mesh in a texture.
  112907. */
  112908. protected _bumpTexture: Nullable<BaseTexture>;
  112909. /**
  112910. * Stores the pre-calculated light information of a mesh in a texture.
  112911. */
  112912. protected _lightmapTexture: Nullable<BaseTexture>;
  112913. /**
  112914. * The color of a material in ambient lighting.
  112915. */
  112916. protected _ambientColor: Color3;
  112917. /**
  112918. * AKA Diffuse Color in other nomenclature.
  112919. */
  112920. protected _albedoColor: Color3;
  112921. /**
  112922. * AKA Specular Color in other nomenclature.
  112923. */
  112924. protected _reflectivityColor: Color3;
  112925. /**
  112926. * The color applied when light is reflected from a material.
  112927. */
  112928. protected _reflectionColor: Color3;
  112929. /**
  112930. * The color applied when light is emitted from a material.
  112931. */
  112932. protected _emissiveColor: Color3;
  112933. /**
  112934. * AKA Glossiness in other nomenclature.
  112935. */
  112936. protected _microSurface: number;
  112937. /**
  112938. * Specifies that the material will use the light map as a show map.
  112939. */
  112940. protected _useLightmapAsShadowmap: boolean;
  112941. /**
  112942. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  112943. * makes the reflect vector face the model (under horizon).
  112944. */
  112945. protected _useHorizonOcclusion: boolean;
  112946. /**
  112947. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  112948. * too much the area relying on ambient texture to define their ambient occlusion.
  112949. */
  112950. protected _useRadianceOcclusion: boolean;
  112951. /**
  112952. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  112953. */
  112954. protected _useAlphaFromAlbedoTexture: boolean;
  112955. /**
  112956. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  112957. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  112958. */
  112959. protected _useSpecularOverAlpha: boolean;
  112960. /**
  112961. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  112962. */
  112963. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  112964. /**
  112965. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  112966. */
  112967. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  112968. /**
  112969. * Specifies if the metallic texture contains the roughness information in its green channel.
  112970. */
  112971. protected _useRoughnessFromMetallicTextureGreen: boolean;
  112972. /**
  112973. * Specifies if the metallic texture contains the metallness information in its blue channel.
  112974. */
  112975. protected _useMetallnessFromMetallicTextureBlue: boolean;
  112976. /**
  112977. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  112978. */
  112979. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  112980. /**
  112981. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  112982. */
  112983. protected _useAmbientInGrayScale: boolean;
  112984. /**
  112985. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  112986. * The material will try to infer what glossiness each pixel should be.
  112987. */
  112988. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  112989. /**
  112990. * Defines the falloff type used in this material.
  112991. * It by default is Physical.
  112992. */
  112993. protected _lightFalloff: number;
  112994. /**
  112995. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  112996. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  112997. */
  112998. protected _useRadianceOverAlpha: boolean;
  112999. /**
  113000. * Allows using an object space normal map (instead of tangent space).
  113001. */
  113002. protected _useObjectSpaceNormalMap: boolean;
  113003. /**
  113004. * Allows using the bump map in parallax mode.
  113005. */
  113006. protected _useParallax: boolean;
  113007. /**
  113008. * Allows using the bump map in parallax occlusion mode.
  113009. */
  113010. protected _useParallaxOcclusion: boolean;
  113011. /**
  113012. * Controls the scale bias of the parallax mode.
  113013. */
  113014. protected _parallaxScaleBias: number;
  113015. /**
  113016. * If sets to true, disables all the lights affecting the material.
  113017. */
  113018. protected _disableLighting: boolean;
  113019. /**
  113020. * Number of Simultaneous lights allowed on the material.
  113021. */
  113022. protected _maxSimultaneousLights: number;
  113023. /**
  113024. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  113025. */
  113026. protected _invertNormalMapX: boolean;
  113027. /**
  113028. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  113029. */
  113030. protected _invertNormalMapY: boolean;
  113031. /**
  113032. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  113033. */
  113034. protected _twoSidedLighting: boolean;
  113035. /**
  113036. * Defines the alpha limits in alpha test mode.
  113037. */
  113038. protected _alphaCutOff: number;
  113039. /**
  113040. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  113041. */
  113042. protected _forceAlphaTest: boolean;
  113043. /**
  113044. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113045. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  113046. */
  113047. protected _useAlphaFresnel: boolean;
  113048. /**
  113049. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113050. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  113051. */
  113052. protected _useLinearAlphaFresnel: boolean;
  113053. /**
  113054. * The transparency mode of the material.
  113055. */
  113056. protected _transparencyMode: Nullable<number>;
  113057. /**
  113058. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  113059. * from cos thetav and roughness:
  113060. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  113061. */
  113062. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  113063. /**
  113064. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  113065. */
  113066. protected _forceIrradianceInFragment: boolean;
  113067. /**
  113068. * Force normal to face away from face.
  113069. */
  113070. protected _forceNormalForward: boolean;
  113071. /**
  113072. * Enables specular anti aliasing in the PBR shader.
  113073. * It will both interacts on the Geometry for analytical and IBL lighting.
  113074. * It also prefilter the roughness map based on the bump values.
  113075. */
  113076. protected _enableSpecularAntiAliasing: boolean;
  113077. /**
  113078. * Default configuration related to image processing available in the PBR Material.
  113079. */
  113080. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113081. /**
  113082. * Keep track of the image processing observer to allow dispose and replace.
  113083. */
  113084. private _imageProcessingObserver;
  113085. /**
  113086. * Attaches a new image processing configuration to the PBR Material.
  113087. * @param configuration
  113088. */
  113089. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  113090. /**
  113091. * Stores the available render targets.
  113092. */
  113093. private _renderTargets;
  113094. /**
  113095. * Sets the global ambient color for the material used in lighting calculations.
  113096. */
  113097. private _globalAmbientColor;
  113098. /**
  113099. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  113100. */
  113101. private _useLogarithmicDepth;
  113102. /**
  113103. * If set to true, no lighting calculations will be applied.
  113104. */
  113105. private _unlit;
  113106. private _debugMode;
  113107. /**
  113108. * @hidden
  113109. * This is reserved for the inspector.
  113110. * Defines the material debug mode.
  113111. * It helps seeing only some components of the material while troubleshooting.
  113112. */
  113113. debugMode: number;
  113114. /**
  113115. * @hidden
  113116. * This is reserved for the inspector.
  113117. * Specify from where on screen the debug mode should start.
  113118. * The value goes from -1 (full screen) to 1 (not visible)
  113119. * It helps with side by side comparison against the final render
  113120. * This defaults to -1
  113121. */
  113122. private debugLimit;
  113123. /**
  113124. * @hidden
  113125. * This is reserved for the inspector.
  113126. * As the default viewing range might not be enough (if the ambient is really small for instance)
  113127. * You can use the factor to better multiply the final value.
  113128. */
  113129. private debugFactor;
  113130. /**
  113131. * Defines the clear coat layer parameters for the material.
  113132. */
  113133. readonly clearCoat: PBRClearCoatConfiguration;
  113134. /**
  113135. * Defines the anisotropic parameters for the material.
  113136. */
  113137. readonly anisotropy: PBRAnisotropicConfiguration;
  113138. /**
  113139. * Defines the BRDF parameters for the material.
  113140. */
  113141. readonly brdf: PBRBRDFConfiguration;
  113142. /**
  113143. * Defines the Sheen parameters for the material.
  113144. */
  113145. readonly sheen: PBRSheenConfiguration;
  113146. /**
  113147. * Defines the SubSurface parameters for the material.
  113148. */
  113149. readonly subSurface: PBRSubSurfaceConfiguration;
  113150. /**
  113151. * Custom callback helping to override the default shader used in the material.
  113152. */
  113153. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  113154. protected _rebuildInParallel: boolean;
  113155. /**
  113156. * Instantiates a new PBRMaterial instance.
  113157. *
  113158. * @param name The material name
  113159. * @param scene The scene the material will be use in.
  113160. */
  113161. constructor(name: string, scene: Scene);
  113162. /**
  113163. * Gets a boolean indicating that current material needs to register RTT
  113164. */
  113165. readonly hasRenderTargetTextures: boolean;
  113166. /**
  113167. * Gets the name of the material class.
  113168. */
  113169. getClassName(): string;
  113170. /**
  113171. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  113172. */
  113173. /**
  113174. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  113175. */
  113176. useLogarithmicDepth: boolean;
  113177. /**
  113178. * Gets the current transparency mode.
  113179. */
  113180. /**
  113181. * Sets the transparency mode of the material.
  113182. *
  113183. * | Value | Type | Description |
  113184. * | ----- | ----------------------------------- | ----------- |
  113185. * | 0 | OPAQUE | |
  113186. * | 1 | ALPHATEST | |
  113187. * | 2 | ALPHABLEND | |
  113188. * | 3 | ALPHATESTANDBLEND | |
  113189. *
  113190. */
  113191. transparencyMode: Nullable<number>;
  113192. /**
  113193. * Returns true if alpha blending should be disabled.
  113194. */
  113195. private readonly _disableAlphaBlending;
  113196. /**
  113197. * Specifies whether or not this material should be rendered in alpha blend mode.
  113198. */
  113199. needAlphaBlending(): boolean;
  113200. /**
  113201. * Specifies if the mesh will require alpha blending.
  113202. * @param mesh - BJS mesh.
  113203. */
  113204. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  113205. /**
  113206. * Specifies whether or not this material should be rendered in alpha test mode.
  113207. */
  113208. needAlphaTesting(): boolean;
  113209. /**
  113210. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  113211. */
  113212. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  113213. /**
  113214. * Gets the texture used for the alpha test.
  113215. */
  113216. getAlphaTestTexture(): Nullable<BaseTexture>;
  113217. /**
  113218. * Specifies that the submesh is ready to be used.
  113219. * @param mesh - BJS mesh.
  113220. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  113221. * @param useInstances - Specifies that instances should be used.
  113222. * @returns - boolean indicating that the submesh is ready or not.
  113223. */
  113224. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113225. /**
  113226. * Specifies if the material uses metallic roughness workflow.
  113227. * @returns boolean specifiying if the material uses metallic roughness workflow.
  113228. */
  113229. isMetallicWorkflow(): boolean;
  113230. private _prepareEffect;
  113231. private _prepareDefines;
  113232. /**
  113233. * Force shader compilation
  113234. */
  113235. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  113236. clipPlane: boolean;
  113237. }>): void;
  113238. /**
  113239. * Initializes the uniform buffer layout for the shader.
  113240. */
  113241. buildUniformLayout(): void;
  113242. /**
  113243. * Unbinds the material from the mesh
  113244. */
  113245. unbind(): void;
  113246. /**
  113247. * Binds the submesh data.
  113248. * @param world - The world matrix.
  113249. * @param mesh - The BJS mesh.
  113250. * @param subMesh - A submesh of the BJS mesh.
  113251. */
  113252. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113253. /**
  113254. * Returns the animatable textures.
  113255. * @returns - Array of animatable textures.
  113256. */
  113257. getAnimatables(): IAnimatable[];
  113258. /**
  113259. * Returns the texture used for reflections.
  113260. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  113261. */
  113262. private _getReflectionTexture;
  113263. /**
  113264. * Returns an array of the actively used textures.
  113265. * @returns - Array of BaseTextures
  113266. */
  113267. getActiveTextures(): BaseTexture[];
  113268. /**
  113269. * Checks to see if a texture is used in the material.
  113270. * @param texture - Base texture to use.
  113271. * @returns - Boolean specifying if a texture is used in the material.
  113272. */
  113273. hasTexture(texture: BaseTexture): boolean;
  113274. /**
  113275. * Disposes the resources of the material.
  113276. * @param forceDisposeEffect - Forces the disposal of effects.
  113277. * @param forceDisposeTextures - Forces the disposal of all textures.
  113278. */
  113279. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  113280. }
  113281. }
  113282. declare module BABYLON {
  113283. /**
  113284. * The Physically based material of BJS.
  113285. *
  113286. * This offers the main features of a standard PBR material.
  113287. * For more information, please refer to the documentation :
  113288. * https://doc.babylonjs.com/how_to/physically_based_rendering
  113289. */
  113290. export class PBRMaterial extends PBRBaseMaterial {
  113291. /**
  113292. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  113293. */
  113294. static readonly PBRMATERIAL_OPAQUE: number;
  113295. /**
  113296. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  113297. */
  113298. static readonly PBRMATERIAL_ALPHATEST: number;
  113299. /**
  113300. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  113301. */
  113302. static readonly PBRMATERIAL_ALPHABLEND: number;
  113303. /**
  113304. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  113305. * They are also discarded below the alpha cutoff threshold to improve performances.
  113306. */
  113307. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  113308. /**
  113309. * Defines the default value of how much AO map is occluding the analytical lights
  113310. * (point spot...).
  113311. */
  113312. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  113313. /**
  113314. * Intensity of the direct lights e.g. the four lights available in your scene.
  113315. * This impacts both the direct diffuse and specular highlights.
  113316. */
  113317. directIntensity: number;
  113318. /**
  113319. * Intensity of the emissive part of the material.
  113320. * This helps controlling the emissive effect without modifying the emissive color.
  113321. */
  113322. emissiveIntensity: number;
  113323. /**
  113324. * Intensity of the environment e.g. how much the environment will light the object
  113325. * either through harmonics for rough material or through the refelction for shiny ones.
  113326. */
  113327. environmentIntensity: number;
  113328. /**
  113329. * This is a special control allowing the reduction of the specular highlights coming from the
  113330. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  113331. */
  113332. specularIntensity: number;
  113333. /**
  113334. * Debug Control allowing disabling the bump map on this material.
  113335. */
  113336. disableBumpMap: boolean;
  113337. /**
  113338. * AKA Diffuse Texture in standard nomenclature.
  113339. */
  113340. albedoTexture: BaseTexture;
  113341. /**
  113342. * AKA Occlusion Texture in other nomenclature.
  113343. */
  113344. ambientTexture: BaseTexture;
  113345. /**
  113346. * AKA Occlusion Texture Intensity in other nomenclature.
  113347. */
  113348. ambientTextureStrength: number;
  113349. /**
  113350. * Defines how much the AO map is occluding the analytical lights (point spot...).
  113351. * 1 means it completely occludes it
  113352. * 0 mean it has no impact
  113353. */
  113354. ambientTextureImpactOnAnalyticalLights: number;
  113355. /**
  113356. * Stores the alpha values in a texture.
  113357. */
  113358. opacityTexture: BaseTexture;
  113359. /**
  113360. * Stores the reflection values in a texture.
  113361. */
  113362. reflectionTexture: Nullable<BaseTexture>;
  113363. /**
  113364. * Stores the emissive values in a texture.
  113365. */
  113366. emissiveTexture: BaseTexture;
  113367. /**
  113368. * AKA Specular texture in other nomenclature.
  113369. */
  113370. reflectivityTexture: BaseTexture;
  113371. /**
  113372. * Used to switch from specular/glossiness to metallic/roughness workflow.
  113373. */
  113374. metallicTexture: BaseTexture;
  113375. /**
  113376. * Specifies the metallic scalar of the metallic/roughness workflow.
  113377. * Can also be used to scale the metalness values of the metallic texture.
  113378. */
  113379. metallic: Nullable<number>;
  113380. /**
  113381. * Specifies the roughness scalar of the metallic/roughness workflow.
  113382. * Can also be used to scale the roughness values of the metallic texture.
  113383. */
  113384. roughness: Nullable<number>;
  113385. /**
  113386. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  113387. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  113388. */
  113389. microSurfaceTexture: BaseTexture;
  113390. /**
  113391. * Stores surface normal data used to displace a mesh in a texture.
  113392. */
  113393. bumpTexture: BaseTexture;
  113394. /**
  113395. * Stores the pre-calculated light information of a mesh in a texture.
  113396. */
  113397. lightmapTexture: BaseTexture;
  113398. /**
  113399. * Stores the refracted light information in a texture.
  113400. */
  113401. refractionTexture: Nullable<BaseTexture>;
  113402. /**
  113403. * The color of a material in ambient lighting.
  113404. */
  113405. ambientColor: Color3;
  113406. /**
  113407. * AKA Diffuse Color in other nomenclature.
  113408. */
  113409. albedoColor: Color3;
  113410. /**
  113411. * AKA Specular Color in other nomenclature.
  113412. */
  113413. reflectivityColor: Color3;
  113414. /**
  113415. * The color reflected from the material.
  113416. */
  113417. reflectionColor: Color3;
  113418. /**
  113419. * The color emitted from the material.
  113420. */
  113421. emissiveColor: Color3;
  113422. /**
  113423. * AKA Glossiness in other nomenclature.
  113424. */
  113425. microSurface: number;
  113426. /**
  113427. * source material index of refraction (IOR)' / 'destination material IOR.
  113428. */
  113429. indexOfRefraction: number;
  113430. /**
  113431. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  113432. */
  113433. invertRefractionY: boolean;
  113434. /**
  113435. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  113436. * Materials half opaque for instance using refraction could benefit from this control.
  113437. */
  113438. linkRefractionWithTransparency: boolean;
  113439. /**
  113440. * If true, the light map contains occlusion information instead of lighting info.
  113441. */
  113442. useLightmapAsShadowmap: boolean;
  113443. /**
  113444. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  113445. */
  113446. useAlphaFromAlbedoTexture: boolean;
  113447. /**
  113448. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  113449. */
  113450. forceAlphaTest: boolean;
  113451. /**
  113452. * Defines the alpha limits in alpha test mode.
  113453. */
  113454. alphaCutOff: number;
  113455. /**
  113456. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  113457. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  113458. */
  113459. useSpecularOverAlpha: boolean;
  113460. /**
  113461. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  113462. */
  113463. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  113464. /**
  113465. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  113466. */
  113467. useRoughnessFromMetallicTextureAlpha: boolean;
  113468. /**
  113469. * Specifies if the metallic texture contains the roughness information in its green channel.
  113470. */
  113471. useRoughnessFromMetallicTextureGreen: boolean;
  113472. /**
  113473. * Specifies if the metallic texture contains the metallness information in its blue channel.
  113474. */
  113475. useMetallnessFromMetallicTextureBlue: boolean;
  113476. /**
  113477. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  113478. */
  113479. useAmbientOcclusionFromMetallicTextureRed: boolean;
  113480. /**
  113481. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  113482. */
  113483. useAmbientInGrayScale: boolean;
  113484. /**
  113485. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  113486. * The material will try to infer what glossiness each pixel should be.
  113487. */
  113488. useAutoMicroSurfaceFromReflectivityMap: boolean;
  113489. /**
  113490. * BJS is using an harcoded light falloff based on a manually sets up range.
  113491. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  113492. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  113493. */
  113494. /**
  113495. * BJS is using an harcoded light falloff based on a manually sets up range.
  113496. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  113497. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  113498. */
  113499. usePhysicalLightFalloff: boolean;
  113500. /**
  113501. * In order to support the falloff compatibility with gltf, a special mode has been added
  113502. * to reproduce the gltf light falloff.
  113503. */
  113504. /**
  113505. * In order to support the falloff compatibility with gltf, a special mode has been added
  113506. * to reproduce the gltf light falloff.
  113507. */
  113508. useGLTFLightFalloff: boolean;
  113509. /**
  113510. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  113511. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  113512. */
  113513. useRadianceOverAlpha: boolean;
  113514. /**
  113515. * Allows using an object space normal map (instead of tangent space).
  113516. */
  113517. useObjectSpaceNormalMap: boolean;
  113518. /**
  113519. * Allows using the bump map in parallax mode.
  113520. */
  113521. useParallax: boolean;
  113522. /**
  113523. * Allows using the bump map in parallax occlusion mode.
  113524. */
  113525. useParallaxOcclusion: boolean;
  113526. /**
  113527. * Controls the scale bias of the parallax mode.
  113528. */
  113529. parallaxScaleBias: number;
  113530. /**
  113531. * If sets to true, disables all the lights affecting the material.
  113532. */
  113533. disableLighting: boolean;
  113534. /**
  113535. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  113536. */
  113537. forceIrradianceInFragment: boolean;
  113538. /**
  113539. * Number of Simultaneous lights allowed on the material.
  113540. */
  113541. maxSimultaneousLights: number;
  113542. /**
  113543. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  113544. */
  113545. invertNormalMapX: boolean;
  113546. /**
  113547. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  113548. */
  113549. invertNormalMapY: boolean;
  113550. /**
  113551. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  113552. */
  113553. twoSidedLighting: boolean;
  113554. /**
  113555. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113556. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  113557. */
  113558. useAlphaFresnel: boolean;
  113559. /**
  113560. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113561. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  113562. */
  113563. useLinearAlphaFresnel: boolean;
  113564. /**
  113565. * Let user defines the brdf lookup texture used for IBL.
  113566. * A default 8bit version is embedded but you could point at :
  113567. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  113568. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  113569. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  113570. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  113571. */
  113572. environmentBRDFTexture: Nullable<BaseTexture>;
  113573. /**
  113574. * Force normal to face away from face.
  113575. */
  113576. forceNormalForward: boolean;
  113577. /**
  113578. * Enables specular anti aliasing in the PBR shader.
  113579. * It will both interacts on the Geometry for analytical and IBL lighting.
  113580. * It also prefilter the roughness map based on the bump values.
  113581. */
  113582. enableSpecularAntiAliasing: boolean;
  113583. /**
  113584. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  113585. * makes the reflect vector face the model (under horizon).
  113586. */
  113587. useHorizonOcclusion: boolean;
  113588. /**
  113589. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  113590. * too much the area relying on ambient texture to define their ambient occlusion.
  113591. */
  113592. useRadianceOcclusion: boolean;
  113593. /**
  113594. * If set to true, no lighting calculations will be applied.
  113595. */
  113596. unlit: boolean;
  113597. /**
  113598. * Gets the image processing configuration used either in this material.
  113599. */
  113600. /**
  113601. * Sets the Default image processing configuration used either in the this material.
  113602. *
  113603. * If sets to null, the scene one is in use.
  113604. */
  113605. imageProcessingConfiguration: ImageProcessingConfiguration;
  113606. /**
  113607. * Gets wether the color curves effect is enabled.
  113608. */
  113609. /**
  113610. * Sets wether the color curves effect is enabled.
  113611. */
  113612. cameraColorCurvesEnabled: boolean;
  113613. /**
  113614. * Gets wether the color grading effect is enabled.
  113615. */
  113616. /**
  113617. * Gets wether the color grading effect is enabled.
  113618. */
  113619. cameraColorGradingEnabled: boolean;
  113620. /**
  113621. * Gets wether tonemapping is enabled or not.
  113622. */
  113623. /**
  113624. * Sets wether tonemapping is enabled or not
  113625. */
  113626. cameraToneMappingEnabled: boolean;
  113627. /**
  113628. * The camera exposure used on this material.
  113629. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113630. * This corresponds to a photographic exposure.
  113631. */
  113632. /**
  113633. * The camera exposure used on this material.
  113634. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113635. * This corresponds to a photographic exposure.
  113636. */
  113637. cameraExposure: number;
  113638. /**
  113639. * Gets The camera contrast used on this material.
  113640. */
  113641. /**
  113642. * Sets The camera contrast used on this material.
  113643. */
  113644. cameraContrast: number;
  113645. /**
  113646. * Gets the Color Grading 2D Lookup Texture.
  113647. */
  113648. /**
  113649. * Sets the Color Grading 2D Lookup Texture.
  113650. */
  113651. cameraColorGradingTexture: Nullable<BaseTexture>;
  113652. /**
  113653. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113654. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113655. * 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;
  113656. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113657. */
  113658. /**
  113659. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113660. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113661. * 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;
  113662. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113663. */
  113664. cameraColorCurves: Nullable<ColorCurves>;
  113665. /**
  113666. * Instantiates a new PBRMaterial instance.
  113667. *
  113668. * @param name The material name
  113669. * @param scene The scene the material will be use in.
  113670. */
  113671. constructor(name: string, scene: Scene);
  113672. /**
  113673. * Returns the name of this material class.
  113674. */
  113675. getClassName(): string;
  113676. /**
  113677. * Makes a duplicate of the current material.
  113678. * @param name - name to use for the new material.
  113679. */
  113680. clone(name: string): PBRMaterial;
  113681. /**
  113682. * Serializes this PBR Material.
  113683. * @returns - An object with the serialized material.
  113684. */
  113685. serialize(): any;
  113686. /**
  113687. * Parses a PBR Material from a serialized object.
  113688. * @param source - Serialized object.
  113689. * @param scene - BJS scene instance.
  113690. * @param rootUrl - url for the scene object
  113691. * @returns - PBRMaterial
  113692. */
  113693. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  113694. }
  113695. }
  113696. declare module BABYLON {
  113697. /**
  113698. * Direct draw surface info
  113699. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  113700. */
  113701. export interface DDSInfo {
  113702. /**
  113703. * Width of the texture
  113704. */
  113705. width: number;
  113706. /**
  113707. * Width of the texture
  113708. */
  113709. height: number;
  113710. /**
  113711. * Number of Mipmaps for the texture
  113712. * @see https://en.wikipedia.org/wiki/Mipmap
  113713. */
  113714. mipmapCount: number;
  113715. /**
  113716. * If the textures format is a known fourCC format
  113717. * @see https://www.fourcc.org/
  113718. */
  113719. isFourCC: boolean;
  113720. /**
  113721. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  113722. */
  113723. isRGB: boolean;
  113724. /**
  113725. * If the texture is a lumincance format
  113726. */
  113727. isLuminance: boolean;
  113728. /**
  113729. * If this is a cube texture
  113730. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  113731. */
  113732. isCube: boolean;
  113733. /**
  113734. * If the texture is a compressed format eg. FOURCC_DXT1
  113735. */
  113736. isCompressed: boolean;
  113737. /**
  113738. * The dxgiFormat of the texture
  113739. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  113740. */
  113741. dxgiFormat: number;
  113742. /**
  113743. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  113744. */
  113745. textureType: number;
  113746. /**
  113747. * Sphericle polynomial created for the dds texture
  113748. */
  113749. sphericalPolynomial?: SphericalPolynomial;
  113750. }
  113751. /**
  113752. * Class used to provide DDS decompression tools
  113753. */
  113754. export class DDSTools {
  113755. /**
  113756. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  113757. */
  113758. static StoreLODInAlphaChannel: boolean;
  113759. /**
  113760. * Gets DDS information from an array buffer
  113761. * @param arrayBuffer defines the array buffer to read data from
  113762. * @returns the DDS information
  113763. */
  113764. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  113765. private static _FloatView;
  113766. private static _Int32View;
  113767. private static _ToHalfFloat;
  113768. private static _FromHalfFloat;
  113769. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  113770. private static _GetHalfFloatRGBAArrayBuffer;
  113771. private static _GetFloatRGBAArrayBuffer;
  113772. private static _GetFloatAsUIntRGBAArrayBuffer;
  113773. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  113774. private static _GetRGBAArrayBuffer;
  113775. private static _ExtractLongWordOrder;
  113776. private static _GetRGBArrayBuffer;
  113777. private static _GetLuminanceArrayBuffer;
  113778. /**
  113779. * Uploads DDS Levels to a Babylon Texture
  113780. * @hidden
  113781. */
  113782. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  113783. }
  113784. interface Engine {
  113785. /**
  113786. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  113787. * @param rootUrl defines the url where the file to load is located
  113788. * @param scene defines the current scene
  113789. * @param lodScale defines scale to apply to the mip map selection
  113790. * @param lodOffset defines offset to apply to the mip map selection
  113791. * @param onLoad defines an optional callback raised when the texture is loaded
  113792. * @param onError defines an optional callback raised if there is an issue to load the texture
  113793. * @param format defines the format of the data
  113794. * @param forcedExtension defines the extension to use to pick the right loader
  113795. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  113796. * @returns the cube texture as an InternalTexture
  113797. */
  113798. 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;
  113799. }
  113800. }
  113801. declare module BABYLON {
  113802. /**
  113803. * Implementation of the DDS Texture Loader.
  113804. * @hidden
  113805. */
  113806. export class _DDSTextureLoader implements IInternalTextureLoader {
  113807. /**
  113808. * Defines wether the loader supports cascade loading the different faces.
  113809. */
  113810. readonly supportCascades: boolean;
  113811. /**
  113812. * This returns if the loader support the current file information.
  113813. * @param extension defines the file extension of the file being loaded
  113814. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113815. * @param fallback defines the fallback internal texture if any
  113816. * @param isBase64 defines whether the texture is encoded as a base64
  113817. * @param isBuffer defines whether the texture data are stored as a buffer
  113818. * @returns true if the loader can load the specified file
  113819. */
  113820. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113821. /**
  113822. * Transform the url before loading if required.
  113823. * @param rootUrl the url of the texture
  113824. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113825. * @returns the transformed texture
  113826. */
  113827. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113828. /**
  113829. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113830. * @param rootUrl the url of the texture
  113831. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113832. * @returns the fallback texture
  113833. */
  113834. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113835. /**
  113836. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  113837. * @param data contains the texture data
  113838. * @param texture defines the BabylonJS internal texture
  113839. * @param createPolynomials will be true if polynomials have been requested
  113840. * @param onLoad defines the callback to trigger once the texture is ready
  113841. * @param onError defines the callback to trigger in case of error
  113842. */
  113843. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113844. /**
  113845. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113846. * @param data contains the texture data
  113847. * @param texture defines the BabylonJS internal texture
  113848. * @param callback defines the method to call once ready to upload
  113849. */
  113850. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113851. }
  113852. }
  113853. declare module BABYLON {
  113854. /**
  113855. * Implementation of the ENV Texture Loader.
  113856. * @hidden
  113857. */
  113858. export class _ENVTextureLoader implements IInternalTextureLoader {
  113859. /**
  113860. * Defines wether the loader supports cascade loading the different faces.
  113861. */
  113862. readonly supportCascades: boolean;
  113863. /**
  113864. * This returns if the loader support the current file information.
  113865. * @param extension defines the file extension of the file being loaded
  113866. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113867. * @param fallback defines the fallback internal texture if any
  113868. * @param isBase64 defines whether the texture is encoded as a base64
  113869. * @param isBuffer defines whether the texture data are stored as a buffer
  113870. * @returns true if the loader can load the specified file
  113871. */
  113872. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113873. /**
  113874. * Transform the url before loading if required.
  113875. * @param rootUrl the url of the texture
  113876. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113877. * @returns the transformed texture
  113878. */
  113879. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113880. /**
  113881. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113882. * @param rootUrl the url of the texture
  113883. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113884. * @returns the fallback texture
  113885. */
  113886. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113887. /**
  113888. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  113889. * @param data contains the texture data
  113890. * @param texture defines the BabylonJS internal texture
  113891. * @param createPolynomials will be true if polynomials have been requested
  113892. * @param onLoad defines the callback to trigger once the texture is ready
  113893. * @param onError defines the callback to trigger in case of error
  113894. */
  113895. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113896. /**
  113897. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113898. * @param data contains the texture data
  113899. * @param texture defines the BabylonJS internal texture
  113900. * @param callback defines the method to call once ready to upload
  113901. */
  113902. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113903. }
  113904. }
  113905. declare module BABYLON {
  113906. /**
  113907. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  113908. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  113909. */
  113910. export class KhronosTextureContainer {
  113911. /** contents of the KTX container file */
  113912. arrayBuffer: any;
  113913. private static HEADER_LEN;
  113914. private static COMPRESSED_2D;
  113915. private static COMPRESSED_3D;
  113916. private static TEX_2D;
  113917. private static TEX_3D;
  113918. /**
  113919. * Gets the openGL type
  113920. */
  113921. glType: number;
  113922. /**
  113923. * Gets the openGL type size
  113924. */
  113925. glTypeSize: number;
  113926. /**
  113927. * Gets the openGL format
  113928. */
  113929. glFormat: number;
  113930. /**
  113931. * Gets the openGL internal format
  113932. */
  113933. glInternalFormat: number;
  113934. /**
  113935. * Gets the base internal format
  113936. */
  113937. glBaseInternalFormat: number;
  113938. /**
  113939. * Gets image width in pixel
  113940. */
  113941. pixelWidth: number;
  113942. /**
  113943. * Gets image height in pixel
  113944. */
  113945. pixelHeight: number;
  113946. /**
  113947. * Gets image depth in pixels
  113948. */
  113949. pixelDepth: number;
  113950. /**
  113951. * Gets the number of array elements
  113952. */
  113953. numberOfArrayElements: number;
  113954. /**
  113955. * Gets the number of faces
  113956. */
  113957. numberOfFaces: number;
  113958. /**
  113959. * Gets the number of mipmap levels
  113960. */
  113961. numberOfMipmapLevels: number;
  113962. /**
  113963. * Gets the bytes of key value data
  113964. */
  113965. bytesOfKeyValueData: number;
  113966. /**
  113967. * Gets the load type
  113968. */
  113969. loadType: number;
  113970. /**
  113971. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  113972. */
  113973. isInvalid: boolean;
  113974. /**
  113975. * Creates a new KhronosTextureContainer
  113976. * @param arrayBuffer contents of the KTX container file
  113977. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  113978. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  113979. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  113980. */
  113981. constructor(
  113982. /** contents of the KTX container file */
  113983. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  113984. /**
  113985. * Uploads KTX content to a Babylon Texture.
  113986. * It is assumed that the texture has already been created & is currently bound
  113987. * @hidden
  113988. */
  113989. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  113990. private _upload2DCompressedLevels;
  113991. }
  113992. }
  113993. declare module BABYLON {
  113994. /**
  113995. * Implementation of the KTX Texture Loader.
  113996. * @hidden
  113997. */
  113998. export class _KTXTextureLoader implements IInternalTextureLoader {
  113999. /**
  114000. * Defines wether the loader supports cascade loading the different faces.
  114001. */
  114002. readonly supportCascades: boolean;
  114003. /**
  114004. * This returns if the loader support the current file information.
  114005. * @param extension defines the file extension of the file being loaded
  114006. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114007. * @param fallback defines the fallback internal texture if any
  114008. * @param isBase64 defines whether the texture is encoded as a base64
  114009. * @param isBuffer defines whether the texture data are stored as a buffer
  114010. * @returns true if the loader can load the specified file
  114011. */
  114012. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114013. /**
  114014. * Transform the url before loading if required.
  114015. * @param rootUrl the url of the texture
  114016. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114017. * @returns the transformed texture
  114018. */
  114019. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114020. /**
  114021. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114022. * @param rootUrl the url of the texture
  114023. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114024. * @returns the fallback texture
  114025. */
  114026. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114027. /**
  114028. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  114029. * @param data contains the texture data
  114030. * @param texture defines the BabylonJS internal texture
  114031. * @param createPolynomials will be true if polynomials have been requested
  114032. * @param onLoad defines the callback to trigger once the texture is ready
  114033. * @param onError defines the callback to trigger in case of error
  114034. */
  114035. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114036. /**
  114037. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114038. * @param data contains the texture data
  114039. * @param texture defines the BabylonJS internal texture
  114040. * @param callback defines the method to call once ready to upload
  114041. */
  114042. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  114043. }
  114044. }
  114045. declare module BABYLON {
  114046. /**
  114047. * Options for the default xr helper
  114048. */
  114049. export class WebXRDefaultExperienceOptions {
  114050. /**
  114051. * Floor meshes that should be used for teleporting
  114052. */
  114053. floorMeshes: Array<AbstractMesh>;
  114054. }
  114055. /**
  114056. * Default experience which provides a similar setup to the previous webVRExperience
  114057. */
  114058. export class WebXRDefaultExperience {
  114059. /**
  114060. * Base experience
  114061. */
  114062. baseExperience: WebXRExperienceHelper;
  114063. /**
  114064. * Input experience extension
  114065. */
  114066. input: WebXRInput;
  114067. /**
  114068. * Loads the controller models
  114069. */
  114070. controllerModelLoader: WebXRControllerModelLoader;
  114071. /**
  114072. * Enables laser pointer and selection
  114073. */
  114074. pointerSelection: WebXRControllerPointerSelection;
  114075. /**
  114076. * Enables teleportation
  114077. */
  114078. teleportation: WebXRControllerTeleportation;
  114079. /**
  114080. * Enables ui for enetering/exiting xr
  114081. */
  114082. enterExitUI: WebXREnterExitUI;
  114083. /**
  114084. * Default output canvas xr should render to
  114085. */
  114086. outputCanvas: WebXRManagedOutputCanvas;
  114087. /**
  114088. * Creates the default xr experience
  114089. * @param scene scene
  114090. * @param options options for basic configuration
  114091. * @returns resulting WebXRDefaultExperience
  114092. */
  114093. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  114094. private constructor();
  114095. /**
  114096. * DIsposes of the experience helper
  114097. */
  114098. dispose(): void;
  114099. }
  114100. }
  114101. declare module BABYLON {
  114102. /** @hidden */
  114103. export var _forceSceneHelpersToBundle: boolean;
  114104. interface Scene {
  114105. /**
  114106. * Creates a default light for the scene.
  114107. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  114108. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  114109. */
  114110. createDefaultLight(replace?: boolean): void;
  114111. /**
  114112. * Creates a default camera for the scene.
  114113. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  114114. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  114115. * @param replace has default false, when true replaces the active camera in the scene
  114116. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  114117. */
  114118. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  114119. /**
  114120. * Creates a default camera and a default light.
  114121. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  114122. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  114123. * @param replace has the default false, when true replaces the active camera/light in the scene
  114124. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  114125. */
  114126. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  114127. /**
  114128. * Creates a new sky box
  114129. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  114130. * @param environmentTexture defines the texture to use as environment texture
  114131. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  114132. * @param scale defines the overall scale of the skybox
  114133. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  114134. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  114135. * @returns a new mesh holding the sky box
  114136. */
  114137. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  114138. /**
  114139. * Creates a new environment
  114140. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  114141. * @param options defines the options you can use to configure the environment
  114142. * @returns the new EnvironmentHelper
  114143. */
  114144. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  114145. /**
  114146. * Creates a new VREXperienceHelper
  114147. * @see http://doc.babylonjs.com/how_to/webvr_helper
  114148. * @param webVROptions defines the options used to create the new VREXperienceHelper
  114149. * @returns a new VREXperienceHelper
  114150. */
  114151. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  114152. /**
  114153. * Creates a new WebXRDefaultExperience
  114154. * @see http://doc.babylonjs.com/how_to/webxr
  114155. * @param options experience options
  114156. * @returns a promise for a new WebXRDefaultExperience
  114157. */
  114158. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  114159. }
  114160. }
  114161. declare module BABYLON {
  114162. /**
  114163. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  114164. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  114165. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  114166. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  114167. */
  114168. export class VideoDome extends TransformNode {
  114169. /**
  114170. * Define the video source as a Monoscopic panoramic 360 video.
  114171. */
  114172. static readonly MODE_MONOSCOPIC: number;
  114173. /**
  114174. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  114175. */
  114176. static readonly MODE_TOPBOTTOM: number;
  114177. /**
  114178. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  114179. */
  114180. static readonly MODE_SIDEBYSIDE: number;
  114181. private _halfDome;
  114182. private _useDirectMapping;
  114183. /**
  114184. * The video texture being displayed on the sphere
  114185. */
  114186. protected _videoTexture: VideoTexture;
  114187. /**
  114188. * Gets the video texture being displayed on the sphere
  114189. */
  114190. readonly videoTexture: VideoTexture;
  114191. /**
  114192. * The skybox material
  114193. */
  114194. protected _material: BackgroundMaterial;
  114195. /**
  114196. * The surface used for the skybox
  114197. */
  114198. protected _mesh: Mesh;
  114199. /**
  114200. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  114201. */
  114202. private _halfDomeMask;
  114203. /**
  114204. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  114205. * Also see the options.resolution property.
  114206. */
  114207. fovMultiplier: number;
  114208. private _videoMode;
  114209. /**
  114210. * Gets or set the current video mode for the video. It can be:
  114211. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  114212. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  114213. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  114214. */
  114215. videoMode: number;
  114216. /**
  114217. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  114218. *
  114219. */
  114220. /**
  114221. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  114222. */
  114223. halfDome: boolean;
  114224. /**
  114225. * Oberserver used in Stereoscopic VR Mode.
  114226. */
  114227. private _onBeforeCameraRenderObserver;
  114228. /**
  114229. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  114230. * @param name Element's name, child elements will append suffixes for their own names.
  114231. * @param urlsOrVideo defines the url(s) or the video element to use
  114232. * @param options An object containing optional or exposed sub element properties
  114233. */
  114234. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  114235. resolution?: number;
  114236. clickToPlay?: boolean;
  114237. autoPlay?: boolean;
  114238. loop?: boolean;
  114239. size?: number;
  114240. poster?: string;
  114241. faceForward?: boolean;
  114242. useDirectMapping?: boolean;
  114243. halfDomeMode?: boolean;
  114244. }, scene: Scene);
  114245. private _changeVideoMode;
  114246. /**
  114247. * Releases resources associated with this node.
  114248. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114249. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114250. */
  114251. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114252. }
  114253. }
  114254. declare module BABYLON {
  114255. /**
  114256. * This class can be used to get instrumentation data from a Babylon engine
  114257. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114258. */
  114259. export class EngineInstrumentation implements IDisposable {
  114260. /**
  114261. * Define the instrumented engine.
  114262. */
  114263. engine: Engine;
  114264. private _captureGPUFrameTime;
  114265. private _gpuFrameTimeToken;
  114266. private _gpuFrameTime;
  114267. private _captureShaderCompilationTime;
  114268. private _shaderCompilationTime;
  114269. private _onBeginFrameObserver;
  114270. private _onEndFrameObserver;
  114271. private _onBeforeShaderCompilationObserver;
  114272. private _onAfterShaderCompilationObserver;
  114273. /**
  114274. * Gets the perf counter used for GPU frame time
  114275. */
  114276. readonly gpuFrameTimeCounter: PerfCounter;
  114277. /**
  114278. * Gets the GPU frame time capture status
  114279. */
  114280. /**
  114281. * Enable or disable the GPU frame time capture
  114282. */
  114283. captureGPUFrameTime: boolean;
  114284. /**
  114285. * Gets the perf counter used for shader compilation time
  114286. */
  114287. readonly shaderCompilationTimeCounter: PerfCounter;
  114288. /**
  114289. * Gets the shader compilation time capture status
  114290. */
  114291. /**
  114292. * Enable or disable the shader compilation time capture
  114293. */
  114294. captureShaderCompilationTime: boolean;
  114295. /**
  114296. * Instantiates a new engine instrumentation.
  114297. * This class can be used to get instrumentation data from a Babylon engine
  114298. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114299. * @param engine Defines the engine to instrument
  114300. */
  114301. constructor(
  114302. /**
  114303. * Define the instrumented engine.
  114304. */
  114305. engine: Engine);
  114306. /**
  114307. * Dispose and release associated resources.
  114308. */
  114309. dispose(): void;
  114310. }
  114311. }
  114312. declare module BABYLON {
  114313. /**
  114314. * This class can be used to get instrumentation data from a Babylon engine
  114315. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  114316. */
  114317. export class SceneInstrumentation implements IDisposable {
  114318. /**
  114319. * Defines the scene to instrument
  114320. */
  114321. scene: Scene;
  114322. private _captureActiveMeshesEvaluationTime;
  114323. private _activeMeshesEvaluationTime;
  114324. private _captureRenderTargetsRenderTime;
  114325. private _renderTargetsRenderTime;
  114326. private _captureFrameTime;
  114327. private _frameTime;
  114328. private _captureRenderTime;
  114329. private _renderTime;
  114330. private _captureInterFrameTime;
  114331. private _interFrameTime;
  114332. private _captureParticlesRenderTime;
  114333. private _particlesRenderTime;
  114334. private _captureSpritesRenderTime;
  114335. private _spritesRenderTime;
  114336. private _capturePhysicsTime;
  114337. private _physicsTime;
  114338. private _captureAnimationsTime;
  114339. private _animationsTime;
  114340. private _captureCameraRenderTime;
  114341. private _cameraRenderTime;
  114342. private _onBeforeActiveMeshesEvaluationObserver;
  114343. private _onAfterActiveMeshesEvaluationObserver;
  114344. private _onBeforeRenderTargetsRenderObserver;
  114345. private _onAfterRenderTargetsRenderObserver;
  114346. private _onAfterRenderObserver;
  114347. private _onBeforeDrawPhaseObserver;
  114348. private _onAfterDrawPhaseObserver;
  114349. private _onBeforeAnimationsObserver;
  114350. private _onBeforeParticlesRenderingObserver;
  114351. private _onAfterParticlesRenderingObserver;
  114352. private _onBeforeSpritesRenderingObserver;
  114353. private _onAfterSpritesRenderingObserver;
  114354. private _onBeforePhysicsObserver;
  114355. private _onAfterPhysicsObserver;
  114356. private _onAfterAnimationsObserver;
  114357. private _onBeforeCameraRenderObserver;
  114358. private _onAfterCameraRenderObserver;
  114359. /**
  114360. * Gets the perf counter used for active meshes evaluation time
  114361. */
  114362. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  114363. /**
  114364. * Gets the active meshes evaluation time capture status
  114365. */
  114366. /**
  114367. * Enable or disable the active meshes evaluation time capture
  114368. */
  114369. captureActiveMeshesEvaluationTime: boolean;
  114370. /**
  114371. * Gets the perf counter used for render targets render time
  114372. */
  114373. readonly renderTargetsRenderTimeCounter: PerfCounter;
  114374. /**
  114375. * Gets the render targets render time capture status
  114376. */
  114377. /**
  114378. * Enable or disable the render targets render time capture
  114379. */
  114380. captureRenderTargetsRenderTime: boolean;
  114381. /**
  114382. * Gets the perf counter used for particles render time
  114383. */
  114384. readonly particlesRenderTimeCounter: PerfCounter;
  114385. /**
  114386. * Gets the particles render time capture status
  114387. */
  114388. /**
  114389. * Enable or disable the particles render time capture
  114390. */
  114391. captureParticlesRenderTime: boolean;
  114392. /**
  114393. * Gets the perf counter used for sprites render time
  114394. */
  114395. readonly spritesRenderTimeCounter: PerfCounter;
  114396. /**
  114397. * Gets the sprites render time capture status
  114398. */
  114399. /**
  114400. * Enable or disable the sprites render time capture
  114401. */
  114402. captureSpritesRenderTime: boolean;
  114403. /**
  114404. * Gets the perf counter used for physics time
  114405. */
  114406. readonly physicsTimeCounter: PerfCounter;
  114407. /**
  114408. * Gets the physics time capture status
  114409. */
  114410. /**
  114411. * Enable or disable the physics time capture
  114412. */
  114413. capturePhysicsTime: boolean;
  114414. /**
  114415. * Gets the perf counter used for animations time
  114416. */
  114417. readonly animationsTimeCounter: PerfCounter;
  114418. /**
  114419. * Gets the animations time capture status
  114420. */
  114421. /**
  114422. * Enable or disable the animations time capture
  114423. */
  114424. captureAnimationsTime: boolean;
  114425. /**
  114426. * Gets the perf counter used for frame time capture
  114427. */
  114428. readonly frameTimeCounter: PerfCounter;
  114429. /**
  114430. * Gets the frame time capture status
  114431. */
  114432. /**
  114433. * Enable or disable the frame time capture
  114434. */
  114435. captureFrameTime: boolean;
  114436. /**
  114437. * Gets the perf counter used for inter-frames time capture
  114438. */
  114439. readonly interFrameTimeCounter: PerfCounter;
  114440. /**
  114441. * Gets the inter-frames time capture status
  114442. */
  114443. /**
  114444. * Enable or disable the inter-frames time capture
  114445. */
  114446. captureInterFrameTime: boolean;
  114447. /**
  114448. * Gets the perf counter used for render time capture
  114449. */
  114450. readonly renderTimeCounter: PerfCounter;
  114451. /**
  114452. * Gets the render time capture status
  114453. */
  114454. /**
  114455. * Enable or disable the render time capture
  114456. */
  114457. captureRenderTime: boolean;
  114458. /**
  114459. * Gets the perf counter used for camera render time capture
  114460. */
  114461. readonly cameraRenderTimeCounter: PerfCounter;
  114462. /**
  114463. * Gets the camera render time capture status
  114464. */
  114465. /**
  114466. * Enable or disable the camera render time capture
  114467. */
  114468. captureCameraRenderTime: boolean;
  114469. /**
  114470. * Gets the perf counter used for draw calls
  114471. */
  114472. readonly drawCallsCounter: PerfCounter;
  114473. /**
  114474. * Instantiates a new scene instrumentation.
  114475. * This class can be used to get instrumentation data from a Babylon engine
  114476. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  114477. * @param scene Defines the scene to instrument
  114478. */
  114479. constructor(
  114480. /**
  114481. * Defines the scene to instrument
  114482. */
  114483. scene: Scene);
  114484. /**
  114485. * Dispose and release associated resources.
  114486. */
  114487. dispose(): void;
  114488. }
  114489. }
  114490. declare module BABYLON {
  114491. /** @hidden */
  114492. export var glowMapGenerationPixelShader: {
  114493. name: string;
  114494. shader: string;
  114495. };
  114496. }
  114497. declare module BABYLON {
  114498. /** @hidden */
  114499. export var glowMapGenerationVertexShader: {
  114500. name: string;
  114501. shader: string;
  114502. };
  114503. }
  114504. declare module BABYLON {
  114505. /**
  114506. * Effect layer options. This helps customizing the behaviour
  114507. * of the effect layer.
  114508. */
  114509. export interface IEffectLayerOptions {
  114510. /**
  114511. * Multiplication factor apply to the canvas size to compute the render target size
  114512. * used to generated the objects (the smaller the faster).
  114513. */
  114514. mainTextureRatio: number;
  114515. /**
  114516. * Enforces a fixed size texture to ensure effect stability across devices.
  114517. */
  114518. mainTextureFixedSize?: number;
  114519. /**
  114520. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  114521. */
  114522. alphaBlendingMode: number;
  114523. /**
  114524. * The camera attached to the layer.
  114525. */
  114526. camera: Nullable<Camera>;
  114527. /**
  114528. * The rendering group to draw the layer in.
  114529. */
  114530. renderingGroupId: number;
  114531. }
  114532. /**
  114533. * The effect layer Helps adding post process effect blended with the main pass.
  114534. *
  114535. * This can be for instance use to generate glow or higlight effects on the scene.
  114536. *
  114537. * The effect layer class can not be used directly and is intented to inherited from to be
  114538. * customized per effects.
  114539. */
  114540. export abstract class EffectLayer {
  114541. private _vertexBuffers;
  114542. private _indexBuffer;
  114543. private _cachedDefines;
  114544. private _effectLayerMapGenerationEffect;
  114545. private _effectLayerOptions;
  114546. private _mergeEffect;
  114547. protected _scene: Scene;
  114548. protected _engine: Engine;
  114549. protected _maxSize: number;
  114550. protected _mainTextureDesiredSize: ISize;
  114551. protected _mainTexture: RenderTargetTexture;
  114552. protected _shouldRender: boolean;
  114553. protected _postProcesses: PostProcess[];
  114554. protected _textures: BaseTexture[];
  114555. protected _emissiveTextureAndColor: {
  114556. texture: Nullable<BaseTexture>;
  114557. color: Color4;
  114558. };
  114559. /**
  114560. * The name of the layer
  114561. */
  114562. name: string;
  114563. /**
  114564. * The clear color of the texture used to generate the glow map.
  114565. */
  114566. neutralColor: Color4;
  114567. /**
  114568. * Specifies wether the highlight layer is enabled or not.
  114569. */
  114570. isEnabled: boolean;
  114571. /**
  114572. * Gets the camera attached to the layer.
  114573. */
  114574. readonly camera: Nullable<Camera>;
  114575. /**
  114576. * Gets the rendering group id the layer should render in.
  114577. */
  114578. renderingGroupId: number;
  114579. /**
  114580. * An event triggered when the effect layer has been disposed.
  114581. */
  114582. onDisposeObservable: Observable<EffectLayer>;
  114583. /**
  114584. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  114585. */
  114586. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  114587. /**
  114588. * An event triggered when the generated texture is being merged in the scene.
  114589. */
  114590. onBeforeComposeObservable: Observable<EffectLayer>;
  114591. /**
  114592. * An event triggered when the generated texture has been merged in the scene.
  114593. */
  114594. onAfterComposeObservable: Observable<EffectLayer>;
  114595. /**
  114596. * An event triggered when the efffect layer changes its size.
  114597. */
  114598. onSizeChangedObservable: Observable<EffectLayer>;
  114599. /** @hidden */
  114600. static _SceneComponentInitialization: (scene: Scene) => void;
  114601. /**
  114602. * Instantiates a new effect Layer and references it in the scene.
  114603. * @param name The name of the layer
  114604. * @param scene The scene to use the layer in
  114605. */
  114606. constructor(
  114607. /** The Friendly of the effect in the scene */
  114608. name: string, scene: Scene);
  114609. /**
  114610. * Get the effect name of the layer.
  114611. * @return The effect name
  114612. */
  114613. abstract getEffectName(): string;
  114614. /**
  114615. * Checks for the readiness of the element composing the layer.
  114616. * @param subMesh the mesh to check for
  114617. * @param useInstances specify wether or not to use instances to render the mesh
  114618. * @return true if ready otherwise, false
  114619. */
  114620. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114621. /**
  114622. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  114623. * @returns true if the effect requires stencil during the main canvas render pass.
  114624. */
  114625. abstract needStencil(): boolean;
  114626. /**
  114627. * Create the merge effect. This is the shader use to blit the information back
  114628. * to the main canvas at the end of the scene rendering.
  114629. * @returns The effect containing the shader used to merge the effect on the main canvas
  114630. */
  114631. protected abstract _createMergeEffect(): Effect;
  114632. /**
  114633. * Creates the render target textures and post processes used in the effect layer.
  114634. */
  114635. protected abstract _createTextureAndPostProcesses(): void;
  114636. /**
  114637. * Implementation specific of rendering the generating effect on the main canvas.
  114638. * @param effect The effect used to render through
  114639. */
  114640. protected abstract _internalRender(effect: Effect): void;
  114641. /**
  114642. * Sets the required values for both the emissive texture and and the main color.
  114643. */
  114644. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  114645. /**
  114646. * Free any resources and references associated to a mesh.
  114647. * Internal use
  114648. * @param mesh The mesh to free.
  114649. */
  114650. abstract _disposeMesh(mesh: Mesh): void;
  114651. /**
  114652. * Serializes this layer (Glow or Highlight for example)
  114653. * @returns a serialized layer object
  114654. */
  114655. abstract serialize?(): any;
  114656. /**
  114657. * Initializes the effect layer with the required options.
  114658. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  114659. */
  114660. protected _init(options: Partial<IEffectLayerOptions>): void;
  114661. /**
  114662. * Generates the index buffer of the full screen quad blending to the main canvas.
  114663. */
  114664. private _generateIndexBuffer;
  114665. /**
  114666. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  114667. */
  114668. private _generateVertexBuffer;
  114669. /**
  114670. * Sets the main texture desired size which is the closest power of two
  114671. * of the engine canvas size.
  114672. */
  114673. private _setMainTextureSize;
  114674. /**
  114675. * Creates the main texture for the effect layer.
  114676. */
  114677. protected _createMainTexture(): void;
  114678. /**
  114679. * Adds specific effects defines.
  114680. * @param defines The defines to add specifics to.
  114681. */
  114682. protected _addCustomEffectDefines(defines: string[]): void;
  114683. /**
  114684. * Checks for the readiness of the element composing the layer.
  114685. * @param subMesh the mesh to check for
  114686. * @param useInstances specify wether or not to use instances to render the mesh
  114687. * @param emissiveTexture the associated emissive texture used to generate the glow
  114688. * @return true if ready otherwise, false
  114689. */
  114690. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  114691. /**
  114692. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  114693. */
  114694. render(): void;
  114695. /**
  114696. * Determine if a given mesh will be used in the current effect.
  114697. * @param mesh mesh to test
  114698. * @returns true if the mesh will be used
  114699. */
  114700. hasMesh(mesh: AbstractMesh): boolean;
  114701. /**
  114702. * Returns true if the layer contains information to display, otherwise false.
  114703. * @returns true if the glow layer should be rendered
  114704. */
  114705. shouldRender(): boolean;
  114706. /**
  114707. * Returns true if the mesh should render, otherwise false.
  114708. * @param mesh The mesh to render
  114709. * @returns true if it should render otherwise false
  114710. */
  114711. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  114712. /**
  114713. * Returns true if the mesh can be rendered, otherwise false.
  114714. * @param mesh The mesh to render
  114715. * @param material The material used on the mesh
  114716. * @returns true if it can be rendered otherwise false
  114717. */
  114718. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  114719. /**
  114720. * Returns true if the mesh should render, otherwise false.
  114721. * @param mesh The mesh to render
  114722. * @returns true if it should render otherwise false
  114723. */
  114724. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  114725. /**
  114726. * Renders the submesh passed in parameter to the generation map.
  114727. */
  114728. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  114729. /**
  114730. * Rebuild the required buffers.
  114731. * @hidden Internal use only.
  114732. */
  114733. _rebuild(): void;
  114734. /**
  114735. * Dispose only the render target textures and post process.
  114736. */
  114737. private _disposeTextureAndPostProcesses;
  114738. /**
  114739. * Dispose the highlight layer and free resources.
  114740. */
  114741. dispose(): void;
  114742. /**
  114743. * Gets the class name of the effect layer
  114744. * @returns the string with the class name of the effect layer
  114745. */
  114746. getClassName(): string;
  114747. /**
  114748. * Creates an effect layer from parsed effect layer data
  114749. * @param parsedEffectLayer defines effect layer data
  114750. * @param scene defines the current scene
  114751. * @param rootUrl defines the root URL containing the effect layer information
  114752. * @returns a parsed effect Layer
  114753. */
  114754. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  114755. }
  114756. }
  114757. declare module BABYLON {
  114758. interface AbstractScene {
  114759. /**
  114760. * The list of effect layers (highlights/glow) added to the scene
  114761. * @see http://doc.babylonjs.com/how_to/highlight_layer
  114762. * @see http://doc.babylonjs.com/how_to/glow_layer
  114763. */
  114764. effectLayers: Array<EffectLayer>;
  114765. /**
  114766. * Removes the given effect layer from this scene.
  114767. * @param toRemove defines the effect layer to remove
  114768. * @returns the index of the removed effect layer
  114769. */
  114770. removeEffectLayer(toRemove: EffectLayer): number;
  114771. /**
  114772. * Adds the given effect layer to this scene
  114773. * @param newEffectLayer defines the effect layer to add
  114774. */
  114775. addEffectLayer(newEffectLayer: EffectLayer): void;
  114776. }
  114777. /**
  114778. * Defines the layer scene component responsible to manage any effect layers
  114779. * in a given scene.
  114780. */
  114781. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  114782. /**
  114783. * The component name helpfull to identify the component in the list of scene components.
  114784. */
  114785. readonly name: string;
  114786. /**
  114787. * The scene the component belongs to.
  114788. */
  114789. scene: Scene;
  114790. private _engine;
  114791. private _renderEffects;
  114792. private _needStencil;
  114793. private _previousStencilState;
  114794. /**
  114795. * Creates a new instance of the component for the given scene
  114796. * @param scene Defines the scene to register the component in
  114797. */
  114798. constructor(scene: Scene);
  114799. /**
  114800. * Registers the component in a given scene
  114801. */
  114802. register(): void;
  114803. /**
  114804. * Rebuilds the elements related to this component in case of
  114805. * context lost for instance.
  114806. */
  114807. rebuild(): void;
  114808. /**
  114809. * Serializes the component data to the specified json object
  114810. * @param serializationObject The object to serialize to
  114811. */
  114812. serialize(serializationObject: any): void;
  114813. /**
  114814. * Adds all the elements from the container to the scene
  114815. * @param container the container holding the elements
  114816. */
  114817. addFromContainer(container: AbstractScene): void;
  114818. /**
  114819. * Removes all the elements in the container from the scene
  114820. * @param container contains the elements to remove
  114821. * @param dispose if the removed element should be disposed (default: false)
  114822. */
  114823. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114824. /**
  114825. * Disposes the component and the associated ressources.
  114826. */
  114827. dispose(): void;
  114828. private _isReadyForMesh;
  114829. private _renderMainTexture;
  114830. private _setStencil;
  114831. private _setStencilBack;
  114832. private _draw;
  114833. private _drawCamera;
  114834. private _drawRenderingGroup;
  114835. }
  114836. }
  114837. declare module BABYLON {
  114838. /** @hidden */
  114839. export var glowMapMergePixelShader: {
  114840. name: string;
  114841. shader: string;
  114842. };
  114843. }
  114844. declare module BABYLON {
  114845. /** @hidden */
  114846. export var glowMapMergeVertexShader: {
  114847. name: string;
  114848. shader: string;
  114849. };
  114850. }
  114851. declare module BABYLON {
  114852. interface AbstractScene {
  114853. /**
  114854. * Return a the first highlight layer of the scene with a given name.
  114855. * @param name The name of the highlight layer to look for.
  114856. * @return The highlight layer if found otherwise null.
  114857. */
  114858. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  114859. }
  114860. /**
  114861. * Glow layer options. This helps customizing the behaviour
  114862. * of the glow layer.
  114863. */
  114864. export interface IGlowLayerOptions {
  114865. /**
  114866. * Multiplication factor apply to the canvas size to compute the render target size
  114867. * used to generated the glowing objects (the smaller the faster).
  114868. */
  114869. mainTextureRatio: number;
  114870. /**
  114871. * Enforces a fixed size texture to ensure resize independant blur.
  114872. */
  114873. mainTextureFixedSize?: number;
  114874. /**
  114875. * How big is the kernel of the blur texture.
  114876. */
  114877. blurKernelSize: number;
  114878. /**
  114879. * The camera attached to the layer.
  114880. */
  114881. camera: Nullable<Camera>;
  114882. /**
  114883. * Enable MSAA by chosing the number of samples.
  114884. */
  114885. mainTextureSamples?: number;
  114886. /**
  114887. * The rendering group to draw the layer in.
  114888. */
  114889. renderingGroupId: number;
  114890. }
  114891. /**
  114892. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  114893. *
  114894. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  114895. * glowy meshes to your scene.
  114896. *
  114897. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  114898. */
  114899. export class GlowLayer extends EffectLayer {
  114900. /**
  114901. * Effect Name of the layer.
  114902. */
  114903. static readonly EffectName: string;
  114904. /**
  114905. * The default blur kernel size used for the glow.
  114906. */
  114907. static DefaultBlurKernelSize: number;
  114908. /**
  114909. * The default texture size ratio used for the glow.
  114910. */
  114911. static DefaultTextureRatio: number;
  114912. /**
  114913. * Sets the kernel size of the blur.
  114914. */
  114915. /**
  114916. * Gets the kernel size of the blur.
  114917. */
  114918. blurKernelSize: number;
  114919. /**
  114920. * Sets the glow intensity.
  114921. */
  114922. /**
  114923. * Gets the glow intensity.
  114924. */
  114925. intensity: number;
  114926. private _options;
  114927. private _intensity;
  114928. private _horizontalBlurPostprocess1;
  114929. private _verticalBlurPostprocess1;
  114930. private _horizontalBlurPostprocess2;
  114931. private _verticalBlurPostprocess2;
  114932. private _blurTexture1;
  114933. private _blurTexture2;
  114934. private _postProcesses1;
  114935. private _postProcesses2;
  114936. private _includedOnlyMeshes;
  114937. private _excludedMeshes;
  114938. /**
  114939. * Callback used to let the user override the color selection on a per mesh basis
  114940. */
  114941. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  114942. /**
  114943. * Callback used to let the user override the texture selection on a per mesh basis
  114944. */
  114945. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  114946. /**
  114947. * Instantiates a new glow Layer and references it to the scene.
  114948. * @param name The name of the layer
  114949. * @param scene The scene to use the layer in
  114950. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  114951. */
  114952. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  114953. /**
  114954. * Get the effect name of the layer.
  114955. * @return The effect name
  114956. */
  114957. getEffectName(): string;
  114958. /**
  114959. * Create the merge effect. This is the shader use to blit the information back
  114960. * to the main canvas at the end of the scene rendering.
  114961. */
  114962. protected _createMergeEffect(): Effect;
  114963. /**
  114964. * Creates the render target textures and post processes used in the glow layer.
  114965. */
  114966. protected _createTextureAndPostProcesses(): void;
  114967. /**
  114968. * Checks for the readiness of the element composing the layer.
  114969. * @param subMesh the mesh to check for
  114970. * @param useInstances specify wether or not to use instances to render the mesh
  114971. * @param emissiveTexture the associated emissive texture used to generate the glow
  114972. * @return true if ready otherwise, false
  114973. */
  114974. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114975. /**
  114976. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  114977. */
  114978. needStencil(): boolean;
  114979. /**
  114980. * Returns true if the mesh can be rendered, otherwise false.
  114981. * @param mesh The mesh to render
  114982. * @param material The material used on the mesh
  114983. * @returns true if it can be rendered otherwise false
  114984. */
  114985. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  114986. /**
  114987. * Implementation specific of rendering the generating effect on the main canvas.
  114988. * @param effect The effect used to render through
  114989. */
  114990. protected _internalRender(effect: Effect): void;
  114991. /**
  114992. * Sets the required values for both the emissive texture and and the main color.
  114993. */
  114994. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  114995. /**
  114996. * Returns true if the mesh should render, otherwise false.
  114997. * @param mesh The mesh to render
  114998. * @returns true if it should render otherwise false
  114999. */
  115000. protected _shouldRenderMesh(mesh: Mesh): boolean;
  115001. /**
  115002. * Adds specific effects defines.
  115003. * @param defines The defines to add specifics to.
  115004. */
  115005. protected _addCustomEffectDefines(defines: string[]): void;
  115006. /**
  115007. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  115008. * @param mesh The mesh to exclude from the glow layer
  115009. */
  115010. addExcludedMesh(mesh: Mesh): void;
  115011. /**
  115012. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  115013. * @param mesh The mesh to remove
  115014. */
  115015. removeExcludedMesh(mesh: Mesh): void;
  115016. /**
  115017. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  115018. * @param mesh The mesh to include in the glow layer
  115019. */
  115020. addIncludedOnlyMesh(mesh: Mesh): void;
  115021. /**
  115022. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  115023. * @param mesh The mesh to remove
  115024. */
  115025. removeIncludedOnlyMesh(mesh: Mesh): void;
  115026. /**
  115027. * Determine if a given mesh will be used in the glow layer
  115028. * @param mesh The mesh to test
  115029. * @returns true if the mesh will be highlighted by the current glow layer
  115030. */
  115031. hasMesh(mesh: AbstractMesh): boolean;
  115032. /**
  115033. * Free any resources and references associated to a mesh.
  115034. * Internal use
  115035. * @param mesh The mesh to free.
  115036. * @hidden
  115037. */
  115038. _disposeMesh(mesh: Mesh): void;
  115039. /**
  115040. * Gets the class name of the effect layer
  115041. * @returns the string with the class name of the effect layer
  115042. */
  115043. getClassName(): string;
  115044. /**
  115045. * Serializes this glow layer
  115046. * @returns a serialized glow layer object
  115047. */
  115048. serialize(): any;
  115049. /**
  115050. * Creates a Glow Layer from parsed glow layer data
  115051. * @param parsedGlowLayer defines glow layer data
  115052. * @param scene defines the current scene
  115053. * @param rootUrl defines the root URL containing the glow layer information
  115054. * @returns a parsed Glow Layer
  115055. */
  115056. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  115057. }
  115058. }
  115059. declare module BABYLON {
  115060. /** @hidden */
  115061. export var glowBlurPostProcessPixelShader: {
  115062. name: string;
  115063. shader: string;
  115064. };
  115065. }
  115066. declare module BABYLON {
  115067. interface AbstractScene {
  115068. /**
  115069. * Return a the first highlight layer of the scene with a given name.
  115070. * @param name The name of the highlight layer to look for.
  115071. * @return The highlight layer if found otherwise null.
  115072. */
  115073. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  115074. }
  115075. /**
  115076. * Highlight layer options. This helps customizing the behaviour
  115077. * of the highlight layer.
  115078. */
  115079. export interface IHighlightLayerOptions {
  115080. /**
  115081. * Multiplication factor apply to the canvas size to compute the render target size
  115082. * used to generated the glowing objects (the smaller the faster).
  115083. */
  115084. mainTextureRatio: number;
  115085. /**
  115086. * Enforces a fixed size texture to ensure resize independant blur.
  115087. */
  115088. mainTextureFixedSize?: number;
  115089. /**
  115090. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  115091. * of the picture to blur (the smaller the faster).
  115092. */
  115093. blurTextureSizeRatio: number;
  115094. /**
  115095. * How big in texel of the blur texture is the vertical blur.
  115096. */
  115097. blurVerticalSize: number;
  115098. /**
  115099. * How big in texel of the blur texture is the horizontal blur.
  115100. */
  115101. blurHorizontalSize: number;
  115102. /**
  115103. * Alpha blending mode used to apply the blur. Default is combine.
  115104. */
  115105. alphaBlendingMode: number;
  115106. /**
  115107. * The camera attached to the layer.
  115108. */
  115109. camera: Nullable<Camera>;
  115110. /**
  115111. * Should we display highlight as a solid stroke?
  115112. */
  115113. isStroke?: boolean;
  115114. /**
  115115. * The rendering group to draw the layer in.
  115116. */
  115117. renderingGroupId: number;
  115118. }
  115119. /**
  115120. * The highlight layer Helps adding a glow effect around a mesh.
  115121. *
  115122. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  115123. * glowy meshes to your scene.
  115124. *
  115125. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  115126. */
  115127. export class HighlightLayer extends EffectLayer {
  115128. name: string;
  115129. /**
  115130. * Effect Name of the highlight layer.
  115131. */
  115132. static readonly EffectName: string;
  115133. /**
  115134. * The neutral color used during the preparation of the glow effect.
  115135. * This is black by default as the blend operation is a blend operation.
  115136. */
  115137. static NeutralColor: Color4;
  115138. /**
  115139. * Stencil value used for glowing meshes.
  115140. */
  115141. static GlowingMeshStencilReference: number;
  115142. /**
  115143. * Stencil value used for the other meshes in the scene.
  115144. */
  115145. static NormalMeshStencilReference: number;
  115146. /**
  115147. * Specifies whether or not the inner glow is ACTIVE in the layer.
  115148. */
  115149. innerGlow: boolean;
  115150. /**
  115151. * Specifies whether or not the outer glow is ACTIVE in the layer.
  115152. */
  115153. outerGlow: boolean;
  115154. /**
  115155. * Specifies the horizontal size of the blur.
  115156. */
  115157. /**
  115158. * Gets the horizontal size of the blur.
  115159. */
  115160. blurHorizontalSize: number;
  115161. /**
  115162. * Specifies the vertical size of the blur.
  115163. */
  115164. /**
  115165. * Gets the vertical size of the blur.
  115166. */
  115167. blurVerticalSize: number;
  115168. /**
  115169. * An event triggered when the highlight layer is being blurred.
  115170. */
  115171. onBeforeBlurObservable: Observable<HighlightLayer>;
  115172. /**
  115173. * An event triggered when the highlight layer has been blurred.
  115174. */
  115175. onAfterBlurObservable: Observable<HighlightLayer>;
  115176. private _instanceGlowingMeshStencilReference;
  115177. private _options;
  115178. private _downSamplePostprocess;
  115179. private _horizontalBlurPostprocess;
  115180. private _verticalBlurPostprocess;
  115181. private _blurTexture;
  115182. private _meshes;
  115183. private _excludedMeshes;
  115184. /**
  115185. * Instantiates a new highlight Layer and references it to the scene..
  115186. * @param name The name of the layer
  115187. * @param scene The scene to use the layer in
  115188. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  115189. */
  115190. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  115191. /**
  115192. * Get the effect name of the layer.
  115193. * @return The effect name
  115194. */
  115195. getEffectName(): string;
  115196. /**
  115197. * Create the merge effect. This is the shader use to blit the information back
  115198. * to the main canvas at the end of the scene rendering.
  115199. */
  115200. protected _createMergeEffect(): Effect;
  115201. /**
  115202. * Creates the render target textures and post processes used in the highlight layer.
  115203. */
  115204. protected _createTextureAndPostProcesses(): void;
  115205. /**
  115206. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  115207. */
  115208. needStencil(): boolean;
  115209. /**
  115210. * Checks for the readiness of the element composing the layer.
  115211. * @param subMesh the mesh to check for
  115212. * @param useInstances specify wether or not to use instances to render the mesh
  115213. * @param emissiveTexture the associated emissive texture used to generate the glow
  115214. * @return true if ready otherwise, false
  115215. */
  115216. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  115217. /**
  115218. * Implementation specific of rendering the generating effect on the main canvas.
  115219. * @param effect The effect used to render through
  115220. */
  115221. protected _internalRender(effect: Effect): void;
  115222. /**
  115223. * Returns true if the layer contains information to display, otherwise false.
  115224. */
  115225. shouldRender(): boolean;
  115226. /**
  115227. * Returns true if the mesh should render, otherwise false.
  115228. * @param mesh The mesh to render
  115229. * @returns true if it should render otherwise false
  115230. */
  115231. protected _shouldRenderMesh(mesh: Mesh): boolean;
  115232. /**
  115233. * Sets the required values for both the emissive texture and and the main color.
  115234. */
  115235. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  115236. /**
  115237. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  115238. * @param mesh The mesh to exclude from the highlight layer
  115239. */
  115240. addExcludedMesh(mesh: Mesh): void;
  115241. /**
  115242. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  115243. * @param mesh The mesh to highlight
  115244. */
  115245. removeExcludedMesh(mesh: Mesh): void;
  115246. /**
  115247. * Determine if a given mesh will be highlighted by the current HighlightLayer
  115248. * @param mesh mesh to test
  115249. * @returns true if the mesh will be highlighted by the current HighlightLayer
  115250. */
  115251. hasMesh(mesh: AbstractMesh): boolean;
  115252. /**
  115253. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  115254. * @param mesh The mesh to highlight
  115255. * @param color The color of the highlight
  115256. * @param glowEmissiveOnly Extract the glow from the emissive texture
  115257. */
  115258. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  115259. /**
  115260. * Remove a mesh from the highlight layer in order to make it stop glowing.
  115261. * @param mesh The mesh to highlight
  115262. */
  115263. removeMesh(mesh: Mesh): void;
  115264. /**
  115265. * Force the stencil to the normal expected value for none glowing parts
  115266. */
  115267. private _defaultStencilReference;
  115268. /**
  115269. * Free any resources and references associated to a mesh.
  115270. * Internal use
  115271. * @param mesh The mesh to free.
  115272. * @hidden
  115273. */
  115274. _disposeMesh(mesh: Mesh): void;
  115275. /**
  115276. * Dispose the highlight layer and free resources.
  115277. */
  115278. dispose(): void;
  115279. /**
  115280. * Gets the class name of the effect layer
  115281. * @returns the string with the class name of the effect layer
  115282. */
  115283. getClassName(): string;
  115284. /**
  115285. * Serializes this Highlight layer
  115286. * @returns a serialized Highlight layer object
  115287. */
  115288. serialize(): any;
  115289. /**
  115290. * Creates a Highlight layer from parsed Highlight layer data
  115291. * @param parsedHightlightLayer defines the Highlight layer data
  115292. * @param scene defines the current scene
  115293. * @param rootUrl defines the root URL containing the Highlight layer information
  115294. * @returns a parsed Highlight layer
  115295. */
  115296. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  115297. }
  115298. }
  115299. declare module BABYLON {
  115300. interface AbstractScene {
  115301. /**
  115302. * The list of layers (background and foreground) of the scene
  115303. */
  115304. layers: Array<Layer>;
  115305. }
  115306. /**
  115307. * Defines the layer scene component responsible to manage any layers
  115308. * in a given scene.
  115309. */
  115310. export class LayerSceneComponent implements ISceneComponent {
  115311. /**
  115312. * The component name helpfull to identify the component in the list of scene components.
  115313. */
  115314. readonly name: string;
  115315. /**
  115316. * The scene the component belongs to.
  115317. */
  115318. scene: Scene;
  115319. private _engine;
  115320. /**
  115321. * Creates a new instance of the component for the given scene
  115322. * @param scene Defines the scene to register the component in
  115323. */
  115324. constructor(scene: Scene);
  115325. /**
  115326. * Registers the component in a given scene
  115327. */
  115328. register(): void;
  115329. /**
  115330. * Rebuilds the elements related to this component in case of
  115331. * context lost for instance.
  115332. */
  115333. rebuild(): void;
  115334. /**
  115335. * Disposes the component and the associated ressources.
  115336. */
  115337. dispose(): void;
  115338. private _draw;
  115339. private _drawCameraPredicate;
  115340. private _drawCameraBackground;
  115341. private _drawCameraForeground;
  115342. private _drawRenderTargetPredicate;
  115343. private _drawRenderTargetBackground;
  115344. private _drawRenderTargetForeground;
  115345. /**
  115346. * Adds all the elements from the container to the scene
  115347. * @param container the container holding the elements
  115348. */
  115349. addFromContainer(container: AbstractScene): void;
  115350. /**
  115351. * Removes all the elements in the container from the scene
  115352. * @param container contains the elements to remove
  115353. * @param dispose if the removed element should be disposed (default: false)
  115354. */
  115355. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115356. }
  115357. }
  115358. declare module BABYLON {
  115359. /** @hidden */
  115360. export var layerPixelShader: {
  115361. name: string;
  115362. shader: string;
  115363. };
  115364. }
  115365. declare module BABYLON {
  115366. /** @hidden */
  115367. export var layerVertexShader: {
  115368. name: string;
  115369. shader: string;
  115370. };
  115371. }
  115372. declare module BABYLON {
  115373. /**
  115374. * This represents a full screen 2d layer.
  115375. * This can be useful to display a picture in the background of your scene for instance.
  115376. * @see https://www.babylonjs-playground.com/#08A2BS#1
  115377. */
  115378. export class Layer {
  115379. /**
  115380. * Define the name of the layer.
  115381. */
  115382. name: string;
  115383. /**
  115384. * Define the texture the layer should display.
  115385. */
  115386. texture: Nullable<Texture>;
  115387. /**
  115388. * Is the layer in background or foreground.
  115389. */
  115390. isBackground: boolean;
  115391. /**
  115392. * Define the color of the layer (instead of texture).
  115393. */
  115394. color: Color4;
  115395. /**
  115396. * Define the scale of the layer in order to zoom in out of the texture.
  115397. */
  115398. scale: Vector2;
  115399. /**
  115400. * Define an offset for the layer in order to shift the texture.
  115401. */
  115402. offset: Vector2;
  115403. /**
  115404. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  115405. */
  115406. alphaBlendingMode: number;
  115407. /**
  115408. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  115409. * Alpha test will not mix with the background color in case of transparency.
  115410. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  115411. */
  115412. alphaTest: boolean;
  115413. /**
  115414. * Define a mask to restrict the layer to only some of the scene cameras.
  115415. */
  115416. layerMask: number;
  115417. /**
  115418. * Define the list of render target the layer is visible into.
  115419. */
  115420. renderTargetTextures: RenderTargetTexture[];
  115421. /**
  115422. * Define if the layer is only used in renderTarget or if it also
  115423. * renders in the main frame buffer of the canvas.
  115424. */
  115425. renderOnlyInRenderTargetTextures: boolean;
  115426. private _scene;
  115427. private _vertexBuffers;
  115428. private _indexBuffer;
  115429. private _effect;
  115430. private _alphaTestEffect;
  115431. /**
  115432. * An event triggered when the layer is disposed.
  115433. */
  115434. onDisposeObservable: Observable<Layer>;
  115435. private _onDisposeObserver;
  115436. /**
  115437. * Back compatibility with callback before the onDisposeObservable existed.
  115438. * The set callback will be triggered when the layer has been disposed.
  115439. */
  115440. onDispose: () => void;
  115441. /**
  115442. * An event triggered before rendering the scene
  115443. */
  115444. onBeforeRenderObservable: Observable<Layer>;
  115445. private _onBeforeRenderObserver;
  115446. /**
  115447. * Back compatibility with callback before the onBeforeRenderObservable existed.
  115448. * The set callback will be triggered just before rendering the layer.
  115449. */
  115450. onBeforeRender: () => void;
  115451. /**
  115452. * An event triggered after rendering the scene
  115453. */
  115454. onAfterRenderObservable: Observable<Layer>;
  115455. private _onAfterRenderObserver;
  115456. /**
  115457. * Back compatibility with callback before the onAfterRenderObservable existed.
  115458. * The set callback will be triggered just after rendering the layer.
  115459. */
  115460. onAfterRender: () => void;
  115461. /**
  115462. * Instantiates a new layer.
  115463. * This represents a full screen 2d layer.
  115464. * This can be useful to display a picture in the background of your scene for instance.
  115465. * @see https://www.babylonjs-playground.com/#08A2BS#1
  115466. * @param name Define the name of the layer in the scene
  115467. * @param imgUrl Define the url of the texture to display in the layer
  115468. * @param scene Define the scene the layer belongs to
  115469. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  115470. * @param color Defines a color for the layer
  115471. */
  115472. constructor(
  115473. /**
  115474. * Define the name of the layer.
  115475. */
  115476. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  115477. private _createIndexBuffer;
  115478. /** @hidden */
  115479. _rebuild(): void;
  115480. /**
  115481. * Renders the layer in the scene.
  115482. */
  115483. render(): void;
  115484. /**
  115485. * Disposes and releases the associated ressources.
  115486. */
  115487. dispose(): void;
  115488. }
  115489. }
  115490. declare module BABYLON {
  115491. /** @hidden */
  115492. export var lensFlarePixelShader: {
  115493. name: string;
  115494. shader: string;
  115495. };
  115496. }
  115497. declare module BABYLON {
  115498. /** @hidden */
  115499. export var lensFlareVertexShader: {
  115500. name: string;
  115501. shader: string;
  115502. };
  115503. }
  115504. declare module BABYLON {
  115505. /**
  115506. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  115507. * It is usually composed of several `lensFlare`.
  115508. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115509. */
  115510. export class LensFlareSystem {
  115511. /**
  115512. * Define the name of the lens flare system
  115513. */
  115514. name: string;
  115515. /**
  115516. * List of lens flares used in this system.
  115517. */
  115518. lensFlares: LensFlare[];
  115519. /**
  115520. * Define a limit from the border the lens flare can be visible.
  115521. */
  115522. borderLimit: number;
  115523. /**
  115524. * Define a viewport border we do not want to see the lens flare in.
  115525. */
  115526. viewportBorder: number;
  115527. /**
  115528. * Define a predicate which could limit the list of meshes able to occlude the effect.
  115529. */
  115530. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  115531. /**
  115532. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  115533. */
  115534. layerMask: number;
  115535. /**
  115536. * Define the id of the lens flare system in the scene.
  115537. * (equal to name by default)
  115538. */
  115539. id: string;
  115540. private _scene;
  115541. private _emitter;
  115542. private _vertexBuffers;
  115543. private _indexBuffer;
  115544. private _effect;
  115545. private _positionX;
  115546. private _positionY;
  115547. private _isEnabled;
  115548. /** @hidden */
  115549. static _SceneComponentInitialization: (scene: Scene) => void;
  115550. /**
  115551. * Instantiates a lens flare system.
  115552. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  115553. * It is usually composed of several `lensFlare`.
  115554. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115555. * @param name Define the name of the lens flare system in the scene
  115556. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  115557. * @param scene Define the scene the lens flare system belongs to
  115558. */
  115559. constructor(
  115560. /**
  115561. * Define the name of the lens flare system
  115562. */
  115563. name: string, emitter: any, scene: Scene);
  115564. /**
  115565. * Define if the lens flare system is enabled.
  115566. */
  115567. isEnabled: boolean;
  115568. /**
  115569. * Get the scene the effects belongs to.
  115570. * @returns the scene holding the lens flare system
  115571. */
  115572. getScene(): Scene;
  115573. /**
  115574. * Get the emitter of the lens flare system.
  115575. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  115576. * @returns the emitter of the lens flare system
  115577. */
  115578. getEmitter(): any;
  115579. /**
  115580. * Set the emitter of the lens flare system.
  115581. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  115582. * @param newEmitter Define the new emitter of the system
  115583. */
  115584. setEmitter(newEmitter: any): void;
  115585. /**
  115586. * Get the lens flare system emitter position.
  115587. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  115588. * @returns the position
  115589. */
  115590. getEmitterPosition(): Vector3;
  115591. /**
  115592. * @hidden
  115593. */
  115594. computeEffectivePosition(globalViewport: Viewport): boolean;
  115595. /** @hidden */
  115596. _isVisible(): boolean;
  115597. /**
  115598. * @hidden
  115599. */
  115600. render(): boolean;
  115601. /**
  115602. * Dispose and release the lens flare with its associated resources.
  115603. */
  115604. dispose(): void;
  115605. /**
  115606. * Parse a lens flare system from a JSON repressentation
  115607. * @param parsedLensFlareSystem Define the JSON to parse
  115608. * @param scene Define the scene the parsed system should be instantiated in
  115609. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  115610. * @returns the parsed system
  115611. */
  115612. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  115613. /**
  115614. * Serialize the current Lens Flare System into a JSON representation.
  115615. * @returns the serialized JSON
  115616. */
  115617. serialize(): any;
  115618. }
  115619. }
  115620. declare module BABYLON {
  115621. /**
  115622. * This represents one of the lens effect in a `lensFlareSystem`.
  115623. * It controls one of the indiviual texture used in the effect.
  115624. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115625. */
  115626. export class LensFlare {
  115627. /**
  115628. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  115629. */
  115630. size: number;
  115631. /**
  115632. * 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.
  115633. */
  115634. position: number;
  115635. /**
  115636. * Define the lens color.
  115637. */
  115638. color: Color3;
  115639. /**
  115640. * Define the lens texture.
  115641. */
  115642. texture: Nullable<Texture>;
  115643. /**
  115644. * Define the alpha mode to render this particular lens.
  115645. */
  115646. alphaMode: number;
  115647. private _system;
  115648. /**
  115649. * Creates a new Lens Flare.
  115650. * This represents one of the lens effect in a `lensFlareSystem`.
  115651. * It controls one of the indiviual texture used in the effect.
  115652. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115653. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  115654. * @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.
  115655. * @param color Define the lens color
  115656. * @param imgUrl Define the lens texture url
  115657. * @param system Define the `lensFlareSystem` this flare is part of
  115658. * @returns The newly created Lens Flare
  115659. */
  115660. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  115661. /**
  115662. * Instantiates a new Lens Flare.
  115663. * This represents one of the lens effect in a `lensFlareSystem`.
  115664. * It controls one of the indiviual texture used in the effect.
  115665. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115666. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  115667. * @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.
  115668. * @param color Define the lens color
  115669. * @param imgUrl Define the lens texture url
  115670. * @param system Define the `lensFlareSystem` this flare is part of
  115671. */
  115672. constructor(
  115673. /**
  115674. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  115675. */
  115676. size: number,
  115677. /**
  115678. * 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.
  115679. */
  115680. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  115681. /**
  115682. * Dispose and release the lens flare with its associated resources.
  115683. */
  115684. dispose(): void;
  115685. }
  115686. }
  115687. declare module BABYLON {
  115688. interface AbstractScene {
  115689. /**
  115690. * The list of lens flare system added to the scene
  115691. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115692. */
  115693. lensFlareSystems: Array<LensFlareSystem>;
  115694. /**
  115695. * Removes the given lens flare system from this scene.
  115696. * @param toRemove The lens flare system to remove
  115697. * @returns The index of the removed lens flare system
  115698. */
  115699. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  115700. /**
  115701. * Adds the given lens flare system to this scene
  115702. * @param newLensFlareSystem The lens flare system to add
  115703. */
  115704. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  115705. /**
  115706. * Gets a lens flare system using its name
  115707. * @param name defines the name to look for
  115708. * @returns the lens flare system or null if not found
  115709. */
  115710. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  115711. /**
  115712. * Gets a lens flare system using its id
  115713. * @param id defines the id to look for
  115714. * @returns the lens flare system or null if not found
  115715. */
  115716. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  115717. }
  115718. /**
  115719. * Defines the lens flare scene component responsible to manage any lens flares
  115720. * in a given scene.
  115721. */
  115722. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  115723. /**
  115724. * The component name helpfull to identify the component in the list of scene components.
  115725. */
  115726. readonly name: string;
  115727. /**
  115728. * The scene the component belongs to.
  115729. */
  115730. scene: Scene;
  115731. /**
  115732. * Creates a new instance of the component for the given scene
  115733. * @param scene Defines the scene to register the component in
  115734. */
  115735. constructor(scene: Scene);
  115736. /**
  115737. * Registers the component in a given scene
  115738. */
  115739. register(): void;
  115740. /**
  115741. * Rebuilds the elements related to this component in case of
  115742. * context lost for instance.
  115743. */
  115744. rebuild(): void;
  115745. /**
  115746. * Adds all the elements from the container to the scene
  115747. * @param container the container holding the elements
  115748. */
  115749. addFromContainer(container: AbstractScene): void;
  115750. /**
  115751. * Removes all the elements in the container from the scene
  115752. * @param container contains the elements to remove
  115753. * @param dispose if the removed element should be disposed (default: false)
  115754. */
  115755. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115756. /**
  115757. * Serializes the component data to the specified json object
  115758. * @param serializationObject The object to serialize to
  115759. */
  115760. serialize(serializationObject: any): void;
  115761. /**
  115762. * Disposes the component and the associated ressources.
  115763. */
  115764. dispose(): void;
  115765. private _draw;
  115766. }
  115767. }
  115768. declare module BABYLON {
  115769. /**
  115770. * Defines the shadow generator component responsible to manage any shadow generators
  115771. * in a given scene.
  115772. */
  115773. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  115774. /**
  115775. * The component name helpfull to identify the component in the list of scene components.
  115776. */
  115777. readonly name: string;
  115778. /**
  115779. * The scene the component belongs to.
  115780. */
  115781. scene: Scene;
  115782. /**
  115783. * Creates a new instance of the component for the given scene
  115784. * @param scene Defines the scene to register the component in
  115785. */
  115786. constructor(scene: Scene);
  115787. /**
  115788. * Registers the component in a given scene
  115789. */
  115790. register(): void;
  115791. /**
  115792. * Rebuilds the elements related to this component in case of
  115793. * context lost for instance.
  115794. */
  115795. rebuild(): void;
  115796. /**
  115797. * Serializes the component data to the specified json object
  115798. * @param serializationObject The object to serialize to
  115799. */
  115800. serialize(serializationObject: any): void;
  115801. /**
  115802. * Adds all the elements from the container to the scene
  115803. * @param container the container holding the elements
  115804. */
  115805. addFromContainer(container: AbstractScene): void;
  115806. /**
  115807. * Removes all the elements in the container from the scene
  115808. * @param container contains the elements to remove
  115809. * @param dispose if the removed element should be disposed (default: false)
  115810. */
  115811. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115812. /**
  115813. * Rebuilds the elements related to this component in case of
  115814. * context lost for instance.
  115815. */
  115816. dispose(): void;
  115817. private _gatherRenderTargets;
  115818. }
  115819. }
  115820. declare module BABYLON {
  115821. /**
  115822. * A point light is a light defined by an unique point in world space.
  115823. * The light is emitted in every direction from this point.
  115824. * A good example of a point light is a standard light bulb.
  115825. * Documentation: https://doc.babylonjs.com/babylon101/lights
  115826. */
  115827. export class PointLight extends ShadowLight {
  115828. private _shadowAngle;
  115829. /**
  115830. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115831. * This specifies what angle the shadow will use to be created.
  115832. *
  115833. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  115834. */
  115835. /**
  115836. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115837. * This specifies what angle the shadow will use to be created.
  115838. *
  115839. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  115840. */
  115841. shadowAngle: number;
  115842. /**
  115843. * Gets the direction if it has been set.
  115844. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115845. */
  115846. /**
  115847. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115848. */
  115849. direction: Vector3;
  115850. /**
  115851. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  115852. * A PointLight emits the light in every direction.
  115853. * It can cast shadows.
  115854. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  115855. * ```javascript
  115856. * var pointLight = new PointLight("pl", camera.position, scene);
  115857. * ```
  115858. * Documentation : https://doc.babylonjs.com/babylon101/lights
  115859. * @param name The light friendly name
  115860. * @param position The position of the point light in the scene
  115861. * @param scene The scene the lights belongs to
  115862. */
  115863. constructor(name: string, position: Vector3, scene: Scene);
  115864. /**
  115865. * Returns the string "PointLight"
  115866. * @returns the class name
  115867. */
  115868. getClassName(): string;
  115869. /**
  115870. * Returns the integer 0.
  115871. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  115872. */
  115873. getTypeID(): number;
  115874. /**
  115875. * Specifies wether or not the shadowmap should be a cube texture.
  115876. * @returns true if the shadowmap needs to be a cube texture.
  115877. */
  115878. needCube(): boolean;
  115879. /**
  115880. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  115881. * @param faceIndex The index of the face we are computed the direction to generate shadow
  115882. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  115883. */
  115884. getShadowDirection(faceIndex?: number): Vector3;
  115885. /**
  115886. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  115887. * - fov = PI / 2
  115888. * - aspect ratio : 1.0
  115889. * - z-near and far equal to the active camera minZ and maxZ.
  115890. * Returns the PointLight.
  115891. */
  115892. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  115893. protected _buildUniformLayout(): void;
  115894. /**
  115895. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  115896. * @param effect The effect to update
  115897. * @param lightIndex The index of the light in the effect to update
  115898. * @returns The point light
  115899. */
  115900. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  115901. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  115902. /**
  115903. * Prepares the list of defines specific to the light type.
  115904. * @param defines the list of defines
  115905. * @param lightIndex defines the index of the light for the effect
  115906. */
  115907. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  115908. }
  115909. }
  115910. declare module BABYLON {
  115911. /**
  115912. * Header information of HDR texture files.
  115913. */
  115914. export interface HDRInfo {
  115915. /**
  115916. * The height of the texture in pixels.
  115917. */
  115918. height: number;
  115919. /**
  115920. * The width of the texture in pixels.
  115921. */
  115922. width: number;
  115923. /**
  115924. * The index of the beginning of the data in the binary file.
  115925. */
  115926. dataPosition: number;
  115927. }
  115928. /**
  115929. * This groups tools to convert HDR texture to native colors array.
  115930. */
  115931. export class HDRTools {
  115932. private static Ldexp;
  115933. private static Rgbe2float;
  115934. private static readStringLine;
  115935. /**
  115936. * Reads header information from an RGBE texture stored in a native array.
  115937. * More information on this format are available here:
  115938. * https://en.wikipedia.org/wiki/RGBE_image_format
  115939. *
  115940. * @param uint8array The binary file stored in native array.
  115941. * @return The header information.
  115942. */
  115943. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  115944. /**
  115945. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  115946. * This RGBE texture needs to store the information as a panorama.
  115947. *
  115948. * More information on this format are available here:
  115949. * https://en.wikipedia.org/wiki/RGBE_image_format
  115950. *
  115951. * @param buffer The binary file stored in an array buffer.
  115952. * @param size The expected size of the extracted cubemap.
  115953. * @return The Cube Map information.
  115954. */
  115955. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  115956. /**
  115957. * Returns the pixels data extracted from an RGBE texture.
  115958. * This pixels will be stored left to right up to down in the R G B order in one array.
  115959. *
  115960. * More information on this format are available here:
  115961. * https://en.wikipedia.org/wiki/RGBE_image_format
  115962. *
  115963. * @param uint8array The binary file stored in an array buffer.
  115964. * @param hdrInfo The header information of the file.
  115965. * @return The pixels data in RGB right to left up to down order.
  115966. */
  115967. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  115968. private static RGBE_ReadPixels_RLE;
  115969. }
  115970. }
  115971. declare module BABYLON {
  115972. /**
  115973. * This represents a texture coming from an HDR input.
  115974. *
  115975. * The only supported format is currently panorama picture stored in RGBE format.
  115976. * Example of such files can be found on HDRLib: http://hdrlib.com/
  115977. */
  115978. export class HDRCubeTexture extends BaseTexture {
  115979. private static _facesMapping;
  115980. private _generateHarmonics;
  115981. private _noMipmap;
  115982. private _textureMatrix;
  115983. private _size;
  115984. private _onLoad;
  115985. private _onError;
  115986. /**
  115987. * The texture URL.
  115988. */
  115989. url: string;
  115990. /**
  115991. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  115992. */
  115993. coordinatesMode: number;
  115994. protected _isBlocking: boolean;
  115995. /**
  115996. * Sets wether or not the texture is blocking during loading.
  115997. */
  115998. /**
  115999. * Gets wether or not the texture is blocking during loading.
  116000. */
  116001. isBlocking: boolean;
  116002. protected _rotationY: number;
  116003. /**
  116004. * Sets texture matrix rotation angle around Y axis in radians.
  116005. */
  116006. /**
  116007. * Gets texture matrix rotation angle around Y axis radians.
  116008. */
  116009. rotationY: number;
  116010. /**
  116011. * Gets or sets the center of the bounding box associated with the cube texture
  116012. * It must define where the camera used to render the texture was set
  116013. */
  116014. boundingBoxPosition: Vector3;
  116015. private _boundingBoxSize;
  116016. /**
  116017. * Gets or sets the size of the bounding box associated with the cube texture
  116018. * When defined, the cubemap will switch to local mode
  116019. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  116020. * @example https://www.babylonjs-playground.com/#RNASML
  116021. */
  116022. boundingBoxSize: Vector3;
  116023. /**
  116024. * Instantiates an HDRTexture from the following parameters.
  116025. *
  116026. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  116027. * @param scene The scene the texture will be used in
  116028. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  116029. * @param noMipmap Forces to not generate the mipmap if true
  116030. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  116031. * @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)
  116032. * @param reserved Reserved flag for internal use.
  116033. */
  116034. 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>);
  116035. /**
  116036. * Get the current class name of the texture useful for serialization or dynamic coding.
  116037. * @returns "HDRCubeTexture"
  116038. */
  116039. getClassName(): string;
  116040. /**
  116041. * Occurs when the file is raw .hdr file.
  116042. */
  116043. private loadTexture;
  116044. clone(): HDRCubeTexture;
  116045. delayLoad(): void;
  116046. /**
  116047. * Get the texture reflection matrix used to rotate/transform the reflection.
  116048. * @returns the reflection matrix
  116049. */
  116050. getReflectionTextureMatrix(): Matrix;
  116051. /**
  116052. * Set the texture reflection matrix used to rotate/transform the reflection.
  116053. * @param value Define the reflection matrix to set
  116054. */
  116055. setReflectionTextureMatrix(value: Matrix): void;
  116056. /**
  116057. * Parses a JSON representation of an HDR Texture in order to create the texture
  116058. * @param parsedTexture Define the JSON representation
  116059. * @param scene Define the scene the texture should be created in
  116060. * @param rootUrl Define the root url in case we need to load relative dependencies
  116061. * @returns the newly created texture after parsing
  116062. */
  116063. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  116064. serialize(): any;
  116065. }
  116066. }
  116067. declare module BABYLON {
  116068. /**
  116069. * Class used to control physics engine
  116070. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  116071. */
  116072. export class PhysicsEngine implements IPhysicsEngine {
  116073. private _physicsPlugin;
  116074. /**
  116075. * Global value used to control the smallest number supported by the simulation
  116076. */
  116077. static Epsilon: number;
  116078. private _impostors;
  116079. private _joints;
  116080. /**
  116081. * Gets the gravity vector used by the simulation
  116082. */
  116083. gravity: Vector3;
  116084. /**
  116085. * Factory used to create the default physics plugin.
  116086. * @returns The default physics plugin
  116087. */
  116088. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  116089. /**
  116090. * Creates a new Physics Engine
  116091. * @param gravity defines the gravity vector used by the simulation
  116092. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  116093. */
  116094. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  116095. /**
  116096. * Sets the gravity vector used by the simulation
  116097. * @param gravity defines the gravity vector to use
  116098. */
  116099. setGravity(gravity: Vector3): void;
  116100. /**
  116101. * Set the time step of the physics engine.
  116102. * Default is 1/60.
  116103. * To slow it down, enter 1/600 for example.
  116104. * To speed it up, 1/30
  116105. * @param newTimeStep defines the new timestep to apply to this world.
  116106. */
  116107. setTimeStep(newTimeStep?: number): void;
  116108. /**
  116109. * Get the time step of the physics engine.
  116110. * @returns the current time step
  116111. */
  116112. getTimeStep(): number;
  116113. /**
  116114. * Release all resources
  116115. */
  116116. dispose(): void;
  116117. /**
  116118. * Gets the name of the current physics plugin
  116119. * @returns the name of the plugin
  116120. */
  116121. getPhysicsPluginName(): string;
  116122. /**
  116123. * Adding a new impostor for the impostor tracking.
  116124. * This will be done by the impostor itself.
  116125. * @param impostor the impostor to add
  116126. */
  116127. addImpostor(impostor: PhysicsImpostor): void;
  116128. /**
  116129. * Remove an impostor from the engine.
  116130. * This impostor and its mesh will not longer be updated by the physics engine.
  116131. * @param impostor the impostor to remove
  116132. */
  116133. removeImpostor(impostor: PhysicsImpostor): void;
  116134. /**
  116135. * Add a joint to the physics engine
  116136. * @param mainImpostor defines the main impostor to which the joint is added.
  116137. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  116138. * @param joint defines the joint that will connect both impostors.
  116139. */
  116140. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  116141. /**
  116142. * Removes a joint from the simulation
  116143. * @param mainImpostor defines the impostor used with the joint
  116144. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  116145. * @param joint defines the joint to remove
  116146. */
  116147. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  116148. /**
  116149. * Called by the scene. No need to call it.
  116150. * @param delta defines the timespam between frames
  116151. */
  116152. _step(delta: number): void;
  116153. /**
  116154. * Gets the current plugin used to run the simulation
  116155. * @returns current plugin
  116156. */
  116157. getPhysicsPlugin(): IPhysicsEnginePlugin;
  116158. /**
  116159. * Gets the list of physic impostors
  116160. * @returns an array of PhysicsImpostor
  116161. */
  116162. getImpostors(): Array<PhysicsImpostor>;
  116163. /**
  116164. * Gets the impostor for a physics enabled object
  116165. * @param object defines the object impersonated by the impostor
  116166. * @returns the PhysicsImpostor or null if not found
  116167. */
  116168. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  116169. /**
  116170. * Gets the impostor for a physics body object
  116171. * @param body defines physics body used by the impostor
  116172. * @returns the PhysicsImpostor or null if not found
  116173. */
  116174. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  116175. /**
  116176. * Does a raycast in the physics world
  116177. * @param from when should the ray start?
  116178. * @param to when should the ray end?
  116179. * @returns PhysicsRaycastResult
  116180. */
  116181. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116182. }
  116183. }
  116184. declare module BABYLON {
  116185. /** @hidden */
  116186. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  116187. private _useDeltaForWorldStep;
  116188. world: any;
  116189. name: string;
  116190. private _physicsMaterials;
  116191. private _fixedTimeStep;
  116192. private _cannonRaycastResult;
  116193. private _raycastResult;
  116194. private _physicsBodysToRemoveAfterStep;
  116195. BJSCANNON: any;
  116196. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  116197. setGravity(gravity: Vector3): void;
  116198. setTimeStep(timeStep: number): void;
  116199. getTimeStep(): number;
  116200. executeStep(delta: number): void;
  116201. private _removeMarkedPhysicsBodiesFromWorld;
  116202. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116203. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116204. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116205. private _processChildMeshes;
  116206. removePhysicsBody(impostor: PhysicsImpostor): void;
  116207. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116208. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116209. private _addMaterial;
  116210. private _checkWithEpsilon;
  116211. private _createShape;
  116212. private _createHeightmap;
  116213. private _minus90X;
  116214. private _plus90X;
  116215. private _tmpPosition;
  116216. private _tmpDeltaPosition;
  116217. private _tmpUnityRotation;
  116218. private _updatePhysicsBodyTransformation;
  116219. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116220. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116221. isSupported(): boolean;
  116222. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116223. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116224. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116225. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116226. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116227. getBodyMass(impostor: PhysicsImpostor): number;
  116228. getBodyFriction(impostor: PhysicsImpostor): number;
  116229. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116230. getBodyRestitution(impostor: PhysicsImpostor): number;
  116231. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116232. sleepBody(impostor: PhysicsImpostor): void;
  116233. wakeUpBody(impostor: PhysicsImpostor): void;
  116234. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  116235. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  116236. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  116237. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116238. getRadius(impostor: PhysicsImpostor): number;
  116239. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116240. dispose(): void;
  116241. private _extendNamespace;
  116242. /**
  116243. * Does a raycast in the physics world
  116244. * @param from when should the ray start?
  116245. * @param to when should the ray end?
  116246. * @returns PhysicsRaycastResult
  116247. */
  116248. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116249. }
  116250. }
  116251. declare module BABYLON {
  116252. /** @hidden */
  116253. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  116254. world: any;
  116255. name: string;
  116256. BJSOIMO: any;
  116257. private _raycastResult;
  116258. constructor(iterations?: number, oimoInjection?: any);
  116259. setGravity(gravity: Vector3): void;
  116260. setTimeStep(timeStep: number): void;
  116261. getTimeStep(): number;
  116262. private _tmpImpostorsArray;
  116263. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  116264. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116265. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116266. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116267. private _tmpPositionVector;
  116268. removePhysicsBody(impostor: PhysicsImpostor): void;
  116269. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116270. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116271. isSupported(): boolean;
  116272. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116273. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116274. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116275. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116276. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116277. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116278. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116279. getBodyMass(impostor: PhysicsImpostor): number;
  116280. getBodyFriction(impostor: PhysicsImpostor): number;
  116281. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116282. getBodyRestitution(impostor: PhysicsImpostor): number;
  116283. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116284. sleepBody(impostor: PhysicsImpostor): void;
  116285. wakeUpBody(impostor: PhysicsImpostor): void;
  116286. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  116287. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  116288. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  116289. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116290. getRadius(impostor: PhysicsImpostor): number;
  116291. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116292. dispose(): void;
  116293. /**
  116294. * Does a raycast in the physics world
  116295. * @param from when should the ray start?
  116296. * @param to when should the ray end?
  116297. * @returns PhysicsRaycastResult
  116298. */
  116299. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116300. }
  116301. }
  116302. declare module BABYLON {
  116303. /**
  116304. * Class containing static functions to help procedurally build meshes
  116305. */
  116306. export class RibbonBuilder {
  116307. /**
  116308. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  116309. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  116310. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  116311. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  116312. * * 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
  116313. * * 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
  116314. * * 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
  116315. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116316. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116317. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116318. * * 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
  116319. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  116320. * * 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
  116321. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  116322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116323. * @param name defines the name of the mesh
  116324. * @param options defines the options used to create the mesh
  116325. * @param scene defines the hosting scene
  116326. * @returns the ribbon mesh
  116327. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  116328. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116329. */
  116330. static CreateRibbon(name: string, options: {
  116331. pathArray: Vector3[][];
  116332. closeArray?: boolean;
  116333. closePath?: boolean;
  116334. offset?: number;
  116335. updatable?: boolean;
  116336. sideOrientation?: number;
  116337. frontUVs?: Vector4;
  116338. backUVs?: Vector4;
  116339. instance?: Mesh;
  116340. invertUV?: boolean;
  116341. uvs?: Vector2[];
  116342. colors?: Color4[];
  116343. }, scene?: Nullable<Scene>): Mesh;
  116344. }
  116345. }
  116346. declare module BABYLON {
  116347. /**
  116348. * Class containing static functions to help procedurally build meshes
  116349. */
  116350. export class ShapeBuilder {
  116351. /**
  116352. * 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.
  116353. * * 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.
  116354. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116355. * * 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.
  116356. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  116357. * * 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
  116358. * * 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
  116359. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  116360. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116361. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116362. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  116363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116364. * @param name defines the name of the mesh
  116365. * @param options defines the options used to create the mesh
  116366. * @param scene defines the hosting scene
  116367. * @returns the extruded shape mesh
  116368. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116369. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116370. */
  116371. static ExtrudeShape(name: string, options: {
  116372. shape: Vector3[];
  116373. path: Vector3[];
  116374. scale?: number;
  116375. rotation?: number;
  116376. cap?: number;
  116377. updatable?: boolean;
  116378. sideOrientation?: number;
  116379. frontUVs?: Vector4;
  116380. backUVs?: Vector4;
  116381. instance?: Mesh;
  116382. invertUV?: boolean;
  116383. }, scene?: Nullable<Scene>): Mesh;
  116384. /**
  116385. * Creates an custom extruded shape mesh.
  116386. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  116387. * * 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.
  116388. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116389. * * 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
  116390. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  116391. * * 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
  116392. * * It must returns a float value that will be the scale value applied to the shape on each path point
  116393. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  116394. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  116395. * * 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
  116396. * * 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
  116397. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  116398. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116399. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116400. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116402. * @param name defines the name of the mesh
  116403. * @param options defines the options used to create the mesh
  116404. * @param scene defines the hosting scene
  116405. * @returns the custom extruded shape mesh
  116406. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  116407. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116408. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116409. */
  116410. static ExtrudeShapeCustom(name: string, options: {
  116411. shape: Vector3[];
  116412. path: Vector3[];
  116413. scaleFunction?: any;
  116414. rotationFunction?: any;
  116415. ribbonCloseArray?: boolean;
  116416. ribbonClosePath?: boolean;
  116417. cap?: number;
  116418. updatable?: boolean;
  116419. sideOrientation?: number;
  116420. frontUVs?: Vector4;
  116421. backUVs?: Vector4;
  116422. instance?: Mesh;
  116423. invertUV?: boolean;
  116424. }, scene?: Nullable<Scene>): Mesh;
  116425. private static _ExtrudeShapeGeneric;
  116426. }
  116427. }
  116428. declare module BABYLON {
  116429. /**
  116430. * AmmoJS Physics plugin
  116431. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116432. * @see https://github.com/kripken/ammo.js/
  116433. */
  116434. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  116435. private _useDeltaForWorldStep;
  116436. /**
  116437. * Reference to the Ammo library
  116438. */
  116439. bjsAMMO: any;
  116440. /**
  116441. * Created ammoJS world which physics bodies are added to
  116442. */
  116443. world: any;
  116444. /**
  116445. * Name of the plugin
  116446. */
  116447. name: string;
  116448. private _timeStep;
  116449. private _fixedTimeStep;
  116450. private _maxSteps;
  116451. private _tmpQuaternion;
  116452. private _tmpAmmoTransform;
  116453. private _tmpAmmoQuaternion;
  116454. private _tmpAmmoConcreteContactResultCallback;
  116455. private _collisionConfiguration;
  116456. private _dispatcher;
  116457. private _overlappingPairCache;
  116458. private _solver;
  116459. private _softBodySolver;
  116460. private _tmpAmmoVectorA;
  116461. private _tmpAmmoVectorB;
  116462. private _tmpAmmoVectorC;
  116463. private _tmpAmmoVectorD;
  116464. private _tmpContactCallbackResult;
  116465. private _tmpAmmoVectorRCA;
  116466. private _tmpAmmoVectorRCB;
  116467. private _raycastResult;
  116468. private static readonly DISABLE_COLLISION_FLAG;
  116469. private static readonly KINEMATIC_FLAG;
  116470. private static readonly DISABLE_DEACTIVATION_FLAG;
  116471. /**
  116472. * Initializes the ammoJS plugin
  116473. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  116474. * @param ammoInjection can be used to inject your own ammo reference
  116475. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  116476. */
  116477. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  116478. /**
  116479. * Sets the gravity of the physics world (m/(s^2))
  116480. * @param gravity Gravity to set
  116481. */
  116482. setGravity(gravity: Vector3): void;
  116483. /**
  116484. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  116485. * @param timeStep timestep to use in seconds
  116486. */
  116487. setTimeStep(timeStep: number): void;
  116488. /**
  116489. * 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)
  116490. * @param fixedTimeStep fixedTimeStep to use in seconds
  116491. */
  116492. setFixedTimeStep(fixedTimeStep: number): void;
  116493. /**
  116494. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  116495. * @param maxSteps the maximum number of steps by the physics engine per frame
  116496. */
  116497. setMaxSteps(maxSteps: number): void;
  116498. /**
  116499. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  116500. * @returns the current timestep in seconds
  116501. */
  116502. getTimeStep(): number;
  116503. private _isImpostorInContact;
  116504. private _isImpostorPairInContact;
  116505. private _stepSimulation;
  116506. /**
  116507. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  116508. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  116509. * After the step the babylon meshes are set to the position of the physics imposters
  116510. * @param delta amount of time to step forward
  116511. * @param impostors array of imposters to update before/after the step
  116512. */
  116513. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  116514. /**
  116515. * Update babylon mesh to match physics world object
  116516. * @param impostor imposter to match
  116517. */
  116518. private _afterSoftStep;
  116519. /**
  116520. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  116521. * @param impostor imposter to match
  116522. */
  116523. private _ropeStep;
  116524. /**
  116525. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  116526. * @param impostor imposter to match
  116527. */
  116528. private _softbodyOrClothStep;
  116529. private _tmpVector;
  116530. private _tmpMatrix;
  116531. /**
  116532. * Applies an impulse on the imposter
  116533. * @param impostor imposter to apply impulse to
  116534. * @param force amount of force to be applied to the imposter
  116535. * @param contactPoint the location to apply the impulse on the imposter
  116536. */
  116537. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116538. /**
  116539. * Applies a force on the imposter
  116540. * @param impostor imposter to apply force
  116541. * @param force amount of force to be applied to the imposter
  116542. * @param contactPoint the location to apply the force on the imposter
  116543. */
  116544. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116545. /**
  116546. * Creates a physics body using the plugin
  116547. * @param impostor the imposter to create the physics body on
  116548. */
  116549. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116550. /**
  116551. * Removes the physics body from the imposter and disposes of the body's memory
  116552. * @param impostor imposter to remove the physics body from
  116553. */
  116554. removePhysicsBody(impostor: PhysicsImpostor): void;
  116555. /**
  116556. * Generates a joint
  116557. * @param impostorJoint the imposter joint to create the joint with
  116558. */
  116559. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116560. /**
  116561. * Removes a joint
  116562. * @param impostorJoint the imposter joint to remove the joint from
  116563. */
  116564. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116565. private _addMeshVerts;
  116566. /**
  116567. * Initialise the soft body vertices to match its object's (mesh) vertices
  116568. * Softbody vertices (nodes) are in world space and to match this
  116569. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  116570. * @param impostor to create the softbody for
  116571. */
  116572. private _softVertexData;
  116573. /**
  116574. * Create an impostor's soft body
  116575. * @param impostor to create the softbody for
  116576. */
  116577. private _createSoftbody;
  116578. /**
  116579. * Create cloth for an impostor
  116580. * @param impostor to create the softbody for
  116581. */
  116582. private _createCloth;
  116583. /**
  116584. * Create rope for an impostor
  116585. * @param impostor to create the softbody for
  116586. */
  116587. private _createRope;
  116588. private _addHullVerts;
  116589. private _createShape;
  116590. /**
  116591. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  116592. * @param impostor imposter containing the physics body and babylon object
  116593. */
  116594. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116595. /**
  116596. * Sets the babylon object's position/rotation from the physics body's position/rotation
  116597. * @param impostor imposter containing the physics body and babylon object
  116598. * @param newPosition new position
  116599. * @param newRotation new rotation
  116600. */
  116601. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116602. /**
  116603. * If this plugin is supported
  116604. * @returns true if its supported
  116605. */
  116606. isSupported(): boolean;
  116607. /**
  116608. * Sets the linear velocity of the physics body
  116609. * @param impostor imposter to set the velocity on
  116610. * @param velocity velocity to set
  116611. */
  116612. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116613. /**
  116614. * Sets the angular velocity of the physics body
  116615. * @param impostor imposter to set the velocity on
  116616. * @param velocity velocity to set
  116617. */
  116618. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116619. /**
  116620. * gets the linear velocity
  116621. * @param impostor imposter to get linear velocity from
  116622. * @returns linear velocity
  116623. */
  116624. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116625. /**
  116626. * gets the angular velocity
  116627. * @param impostor imposter to get angular velocity from
  116628. * @returns angular velocity
  116629. */
  116630. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116631. /**
  116632. * Sets the mass of physics body
  116633. * @param impostor imposter to set the mass on
  116634. * @param mass mass to set
  116635. */
  116636. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116637. /**
  116638. * Gets the mass of the physics body
  116639. * @param impostor imposter to get the mass from
  116640. * @returns mass
  116641. */
  116642. getBodyMass(impostor: PhysicsImpostor): number;
  116643. /**
  116644. * Gets friction of the impostor
  116645. * @param impostor impostor to get friction from
  116646. * @returns friction value
  116647. */
  116648. getBodyFriction(impostor: PhysicsImpostor): number;
  116649. /**
  116650. * Sets friction of the impostor
  116651. * @param impostor impostor to set friction on
  116652. * @param friction friction value
  116653. */
  116654. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116655. /**
  116656. * Gets restitution of the impostor
  116657. * @param impostor impostor to get restitution from
  116658. * @returns restitution value
  116659. */
  116660. getBodyRestitution(impostor: PhysicsImpostor): number;
  116661. /**
  116662. * Sets resitution of the impostor
  116663. * @param impostor impostor to set resitution on
  116664. * @param restitution resitution value
  116665. */
  116666. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116667. /**
  116668. * Gets pressure inside the impostor
  116669. * @param impostor impostor to get pressure from
  116670. * @returns pressure value
  116671. */
  116672. getBodyPressure(impostor: PhysicsImpostor): number;
  116673. /**
  116674. * Sets pressure inside a soft body impostor
  116675. * Cloth and rope must remain 0 pressure
  116676. * @param impostor impostor to set pressure on
  116677. * @param pressure pressure value
  116678. */
  116679. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  116680. /**
  116681. * Gets stiffness of the impostor
  116682. * @param impostor impostor to get stiffness from
  116683. * @returns pressure value
  116684. */
  116685. getBodyStiffness(impostor: PhysicsImpostor): number;
  116686. /**
  116687. * Sets stiffness of the impostor
  116688. * @param impostor impostor to set stiffness on
  116689. * @param stiffness stiffness value from 0 to 1
  116690. */
  116691. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  116692. /**
  116693. * Gets velocityIterations of the impostor
  116694. * @param impostor impostor to get velocity iterations from
  116695. * @returns velocityIterations value
  116696. */
  116697. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  116698. /**
  116699. * Sets velocityIterations of the impostor
  116700. * @param impostor impostor to set velocity iterations on
  116701. * @param velocityIterations velocityIterations value
  116702. */
  116703. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  116704. /**
  116705. * Gets positionIterations of the impostor
  116706. * @param impostor impostor to get position iterations from
  116707. * @returns positionIterations value
  116708. */
  116709. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  116710. /**
  116711. * Sets positionIterations of the impostor
  116712. * @param impostor impostor to set position on
  116713. * @param positionIterations positionIterations value
  116714. */
  116715. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  116716. /**
  116717. * Append an anchor to a cloth object
  116718. * @param impostor is the cloth impostor to add anchor to
  116719. * @param otherImpostor is the rigid impostor to anchor to
  116720. * @param width ratio across width from 0 to 1
  116721. * @param height ratio up height from 0 to 1
  116722. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  116723. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  116724. */
  116725. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  116726. /**
  116727. * Append an hook to a rope object
  116728. * @param impostor is the rope impostor to add hook to
  116729. * @param otherImpostor is the rigid impostor to hook to
  116730. * @param length ratio along the rope from 0 to 1
  116731. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  116732. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  116733. */
  116734. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  116735. /**
  116736. * Sleeps the physics body and stops it from being active
  116737. * @param impostor impostor to sleep
  116738. */
  116739. sleepBody(impostor: PhysicsImpostor): void;
  116740. /**
  116741. * Activates the physics body
  116742. * @param impostor impostor to activate
  116743. */
  116744. wakeUpBody(impostor: PhysicsImpostor): void;
  116745. /**
  116746. * Updates the distance parameters of the joint
  116747. * @param joint joint to update
  116748. * @param maxDistance maximum distance of the joint
  116749. * @param minDistance minimum distance of the joint
  116750. */
  116751. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  116752. /**
  116753. * Sets a motor on the joint
  116754. * @param joint joint to set motor on
  116755. * @param speed speed of the motor
  116756. * @param maxForce maximum force of the motor
  116757. * @param motorIndex index of the motor
  116758. */
  116759. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  116760. /**
  116761. * Sets the motors limit
  116762. * @param joint joint to set limit on
  116763. * @param upperLimit upper limit
  116764. * @param lowerLimit lower limit
  116765. */
  116766. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  116767. /**
  116768. * Syncs the position and rotation of a mesh with the impostor
  116769. * @param mesh mesh to sync
  116770. * @param impostor impostor to update the mesh with
  116771. */
  116772. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116773. /**
  116774. * Gets the radius of the impostor
  116775. * @param impostor impostor to get radius from
  116776. * @returns the radius
  116777. */
  116778. getRadius(impostor: PhysicsImpostor): number;
  116779. /**
  116780. * Gets the box size of the impostor
  116781. * @param impostor impostor to get box size from
  116782. * @param result the resulting box size
  116783. */
  116784. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116785. /**
  116786. * Disposes of the impostor
  116787. */
  116788. dispose(): void;
  116789. /**
  116790. * Does a raycast in the physics world
  116791. * @param from when should the ray start?
  116792. * @param to when should the ray end?
  116793. * @returns PhysicsRaycastResult
  116794. */
  116795. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116796. }
  116797. }
  116798. declare module BABYLON {
  116799. interface AbstractScene {
  116800. /**
  116801. * The list of reflection probes added to the scene
  116802. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  116803. */
  116804. reflectionProbes: Array<ReflectionProbe>;
  116805. /**
  116806. * Removes the given reflection probe from this scene.
  116807. * @param toRemove The reflection probe to remove
  116808. * @returns The index of the removed reflection probe
  116809. */
  116810. removeReflectionProbe(toRemove: ReflectionProbe): number;
  116811. /**
  116812. * Adds the given reflection probe to this scene.
  116813. * @param newReflectionProbe The reflection probe to add
  116814. */
  116815. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  116816. }
  116817. /**
  116818. * Class used to generate realtime reflection / refraction cube textures
  116819. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  116820. */
  116821. export class ReflectionProbe {
  116822. /** defines the name of the probe */
  116823. name: string;
  116824. private _scene;
  116825. private _renderTargetTexture;
  116826. private _projectionMatrix;
  116827. private _viewMatrix;
  116828. private _target;
  116829. private _add;
  116830. private _attachedMesh;
  116831. private _invertYAxis;
  116832. /** Gets or sets probe position (center of the cube map) */
  116833. position: Vector3;
  116834. /**
  116835. * Creates a new reflection probe
  116836. * @param name defines the name of the probe
  116837. * @param size defines the texture resolution (for each face)
  116838. * @param scene defines the hosting scene
  116839. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  116840. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  116841. */
  116842. constructor(
  116843. /** defines the name of the probe */
  116844. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  116845. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  116846. samples: number;
  116847. /** Gets or sets the refresh rate to use (on every frame by default) */
  116848. refreshRate: number;
  116849. /**
  116850. * Gets the hosting scene
  116851. * @returns a Scene
  116852. */
  116853. getScene(): Scene;
  116854. /** Gets the internal CubeTexture used to render to */
  116855. readonly cubeTexture: RenderTargetTexture;
  116856. /** Gets the list of meshes to render */
  116857. readonly renderList: Nullable<AbstractMesh[]>;
  116858. /**
  116859. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  116860. * @param mesh defines the mesh to attach to
  116861. */
  116862. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  116863. /**
  116864. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  116865. * @param renderingGroupId The rendering group id corresponding to its index
  116866. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  116867. */
  116868. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  116869. /**
  116870. * Clean all associated resources
  116871. */
  116872. dispose(): void;
  116873. /**
  116874. * Converts the reflection probe information to a readable string for debug purpose.
  116875. * @param fullDetails Supports for multiple levels of logging within scene loading
  116876. * @returns the human readable reflection probe info
  116877. */
  116878. toString(fullDetails?: boolean): string;
  116879. /**
  116880. * Get the class name of the relfection probe.
  116881. * @returns "ReflectionProbe"
  116882. */
  116883. getClassName(): string;
  116884. /**
  116885. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  116886. * @returns The JSON representation of the texture
  116887. */
  116888. serialize(): any;
  116889. /**
  116890. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  116891. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  116892. * @param scene Define the scene the parsed reflection probe should be instantiated in
  116893. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  116894. * @returns The parsed reflection probe if successful
  116895. */
  116896. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  116897. }
  116898. }
  116899. declare module BABYLON {
  116900. /** @hidden */
  116901. export var _BabylonLoaderRegistered: boolean;
  116902. }
  116903. declare module BABYLON {
  116904. /**
  116905. * The Physically based simple base material of BJS.
  116906. *
  116907. * This enables better naming and convention enforcements on top of the pbrMaterial.
  116908. * It is used as the base class for both the specGloss and metalRough conventions.
  116909. */
  116910. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  116911. /**
  116912. * Number of Simultaneous lights allowed on the material.
  116913. */
  116914. maxSimultaneousLights: number;
  116915. /**
  116916. * If sets to true, disables all the lights affecting the material.
  116917. */
  116918. disableLighting: boolean;
  116919. /**
  116920. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  116921. */
  116922. environmentTexture: BaseTexture;
  116923. /**
  116924. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  116925. */
  116926. invertNormalMapX: boolean;
  116927. /**
  116928. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  116929. */
  116930. invertNormalMapY: boolean;
  116931. /**
  116932. * Normal map used in the model.
  116933. */
  116934. normalTexture: BaseTexture;
  116935. /**
  116936. * Emissivie color used to self-illuminate the model.
  116937. */
  116938. emissiveColor: Color3;
  116939. /**
  116940. * Emissivie texture used to self-illuminate the model.
  116941. */
  116942. emissiveTexture: BaseTexture;
  116943. /**
  116944. * Occlusion Channel Strenght.
  116945. */
  116946. occlusionStrength: number;
  116947. /**
  116948. * Occlusion Texture of the material (adding extra occlusion effects).
  116949. */
  116950. occlusionTexture: BaseTexture;
  116951. /**
  116952. * Defines the alpha limits in alpha test mode.
  116953. */
  116954. alphaCutOff: number;
  116955. /**
  116956. * Gets the current double sided mode.
  116957. */
  116958. /**
  116959. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  116960. */
  116961. doubleSided: boolean;
  116962. /**
  116963. * Stores the pre-calculated light information of a mesh in a texture.
  116964. */
  116965. lightmapTexture: BaseTexture;
  116966. /**
  116967. * If true, the light map contains occlusion information instead of lighting info.
  116968. */
  116969. useLightmapAsShadowmap: boolean;
  116970. /**
  116971. * Instantiates a new PBRMaterial instance.
  116972. *
  116973. * @param name The material name
  116974. * @param scene The scene the material will be use in.
  116975. */
  116976. constructor(name: string, scene: Scene);
  116977. getClassName(): string;
  116978. }
  116979. }
  116980. declare module BABYLON {
  116981. /**
  116982. * The PBR material of BJS following the metal roughness convention.
  116983. *
  116984. * This fits to the PBR convention in the GLTF definition:
  116985. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  116986. */
  116987. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  116988. /**
  116989. * The base color has two different interpretations depending on the value of metalness.
  116990. * When the material is a metal, the base color is the specific measured reflectance value
  116991. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  116992. * of the material.
  116993. */
  116994. baseColor: Color3;
  116995. /**
  116996. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  116997. * well as opacity information in the alpha channel.
  116998. */
  116999. baseTexture: BaseTexture;
  117000. /**
  117001. * Specifies the metallic scalar value of the material.
  117002. * Can also be used to scale the metalness values of the metallic texture.
  117003. */
  117004. metallic: number;
  117005. /**
  117006. * Specifies the roughness scalar value of the material.
  117007. * Can also be used to scale the roughness values of the metallic texture.
  117008. */
  117009. roughness: number;
  117010. /**
  117011. * Texture containing both the metallic value in the B channel and the
  117012. * roughness value in the G channel to keep better precision.
  117013. */
  117014. metallicRoughnessTexture: BaseTexture;
  117015. /**
  117016. * Instantiates a new PBRMetalRoughnessMaterial instance.
  117017. *
  117018. * @param name The material name
  117019. * @param scene The scene the material will be use in.
  117020. */
  117021. constructor(name: string, scene: Scene);
  117022. /**
  117023. * Return the currrent class name of the material.
  117024. */
  117025. getClassName(): string;
  117026. /**
  117027. * Makes a duplicate of the current material.
  117028. * @param name - name to use for the new material.
  117029. */
  117030. clone(name: string): PBRMetallicRoughnessMaterial;
  117031. /**
  117032. * Serialize the material to a parsable JSON object.
  117033. */
  117034. serialize(): any;
  117035. /**
  117036. * Parses a JSON object correponding to the serialize function.
  117037. */
  117038. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  117039. }
  117040. }
  117041. declare module BABYLON {
  117042. /**
  117043. * The PBR material of BJS following the specular glossiness convention.
  117044. *
  117045. * This fits to the PBR convention in the GLTF definition:
  117046. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  117047. */
  117048. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  117049. /**
  117050. * Specifies the diffuse color of the material.
  117051. */
  117052. diffuseColor: Color3;
  117053. /**
  117054. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  117055. * channel.
  117056. */
  117057. diffuseTexture: BaseTexture;
  117058. /**
  117059. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  117060. */
  117061. specularColor: Color3;
  117062. /**
  117063. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  117064. */
  117065. glossiness: number;
  117066. /**
  117067. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  117068. */
  117069. specularGlossinessTexture: BaseTexture;
  117070. /**
  117071. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  117072. *
  117073. * @param name The material name
  117074. * @param scene The scene the material will be use in.
  117075. */
  117076. constructor(name: string, scene: Scene);
  117077. /**
  117078. * Return the currrent class name of the material.
  117079. */
  117080. getClassName(): string;
  117081. /**
  117082. * Makes a duplicate of the current material.
  117083. * @param name - name to use for the new material.
  117084. */
  117085. clone(name: string): PBRSpecularGlossinessMaterial;
  117086. /**
  117087. * Serialize the material to a parsable JSON object.
  117088. */
  117089. serialize(): any;
  117090. /**
  117091. * Parses a JSON object correponding to the serialize function.
  117092. */
  117093. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  117094. }
  117095. }
  117096. declare module BABYLON {
  117097. /**
  117098. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  117099. * It can help converting any input color in a desired output one. This can then be used to create effects
  117100. * from sepia, black and white to sixties or futuristic rendering...
  117101. *
  117102. * The only supported format is currently 3dl.
  117103. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  117104. */
  117105. export class ColorGradingTexture extends BaseTexture {
  117106. /**
  117107. * The current texture matrix. (will always be identity in color grading texture)
  117108. */
  117109. private _textureMatrix;
  117110. /**
  117111. * The texture URL.
  117112. */
  117113. url: string;
  117114. /**
  117115. * Empty line regex stored for GC.
  117116. */
  117117. private static _noneEmptyLineRegex;
  117118. private _engine;
  117119. /**
  117120. * Instantiates a ColorGradingTexture from the following parameters.
  117121. *
  117122. * @param url The location of the color gradind data (currently only supporting 3dl)
  117123. * @param scene The scene the texture will be used in
  117124. */
  117125. constructor(url: string, scene: Scene);
  117126. /**
  117127. * Returns the texture matrix used in most of the material.
  117128. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  117129. */
  117130. getTextureMatrix(): Matrix;
  117131. /**
  117132. * Occurs when the file being loaded is a .3dl LUT file.
  117133. */
  117134. private load3dlTexture;
  117135. /**
  117136. * Starts the loading process of the texture.
  117137. */
  117138. private loadTexture;
  117139. /**
  117140. * Clones the color gradind texture.
  117141. */
  117142. clone(): ColorGradingTexture;
  117143. /**
  117144. * Called during delayed load for textures.
  117145. */
  117146. delayLoad(): void;
  117147. /**
  117148. * Parses a color grading texture serialized by Babylon.
  117149. * @param parsedTexture The texture information being parsedTexture
  117150. * @param scene The scene to load the texture in
  117151. * @param rootUrl The root url of the data assets to load
  117152. * @return A color gradind texture
  117153. */
  117154. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  117155. /**
  117156. * Serializes the LUT texture to json format.
  117157. */
  117158. serialize(): any;
  117159. }
  117160. }
  117161. declare module BABYLON {
  117162. /**
  117163. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  117164. */
  117165. export class EquiRectangularCubeTexture extends BaseTexture {
  117166. /** The six faces of the cube. */
  117167. private static _FacesMapping;
  117168. private _noMipmap;
  117169. private _onLoad;
  117170. private _onError;
  117171. /** The size of the cubemap. */
  117172. private _size;
  117173. /** The buffer of the image. */
  117174. private _buffer;
  117175. /** The width of the input image. */
  117176. private _width;
  117177. /** The height of the input image. */
  117178. private _height;
  117179. /** The URL to the image. */
  117180. url: string;
  117181. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  117182. coordinatesMode: number;
  117183. /**
  117184. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  117185. * @param url The location of the image
  117186. * @param scene The scene the texture will be used in
  117187. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  117188. * @param noMipmap Forces to not generate the mipmap if true
  117189. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  117190. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  117191. * @param onLoad — defines a callback called when texture is loaded
  117192. * @param onError — defines a callback called if there is an error
  117193. */
  117194. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  117195. /**
  117196. * Load the image data, by putting the image on a canvas and extracting its buffer.
  117197. */
  117198. private loadImage;
  117199. /**
  117200. * Convert the image buffer into a cubemap and create a CubeTexture.
  117201. */
  117202. private loadTexture;
  117203. /**
  117204. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  117205. * @param buffer The ArrayBuffer that should be converted.
  117206. * @returns The buffer as Float32Array.
  117207. */
  117208. private getFloat32ArrayFromArrayBuffer;
  117209. /**
  117210. * Get the current class name of the texture useful for serialization or dynamic coding.
  117211. * @returns "EquiRectangularCubeTexture"
  117212. */
  117213. getClassName(): string;
  117214. /**
  117215. * Create a clone of the current EquiRectangularCubeTexture and return it.
  117216. * @returns A clone of the current EquiRectangularCubeTexture.
  117217. */
  117218. clone(): EquiRectangularCubeTexture;
  117219. }
  117220. }
  117221. declare module BABYLON {
  117222. /**
  117223. * Based on jsTGALoader - Javascript loader for TGA file
  117224. * By Vincent Thibault
  117225. * @see http://blog.robrowser.com/javascript-tga-loader.html
  117226. */
  117227. export class TGATools {
  117228. private static _TYPE_INDEXED;
  117229. private static _TYPE_RGB;
  117230. private static _TYPE_GREY;
  117231. private static _TYPE_RLE_INDEXED;
  117232. private static _TYPE_RLE_RGB;
  117233. private static _TYPE_RLE_GREY;
  117234. private static _ORIGIN_MASK;
  117235. private static _ORIGIN_SHIFT;
  117236. private static _ORIGIN_BL;
  117237. private static _ORIGIN_BR;
  117238. private static _ORIGIN_UL;
  117239. private static _ORIGIN_UR;
  117240. /**
  117241. * Gets the header of a TGA file
  117242. * @param data defines the TGA data
  117243. * @returns the header
  117244. */
  117245. static GetTGAHeader(data: Uint8Array): any;
  117246. /**
  117247. * Uploads TGA content to a Babylon Texture
  117248. * @hidden
  117249. */
  117250. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  117251. /** @hidden */
  117252. 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;
  117253. /** @hidden */
  117254. 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;
  117255. /** @hidden */
  117256. 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;
  117257. /** @hidden */
  117258. 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;
  117259. /** @hidden */
  117260. 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;
  117261. /** @hidden */
  117262. 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;
  117263. }
  117264. }
  117265. declare module BABYLON {
  117266. /**
  117267. * Implementation of the TGA Texture Loader.
  117268. * @hidden
  117269. */
  117270. export class _TGATextureLoader implements IInternalTextureLoader {
  117271. /**
  117272. * Defines wether the loader supports cascade loading the different faces.
  117273. */
  117274. readonly supportCascades: boolean;
  117275. /**
  117276. * This returns if the loader support the current file information.
  117277. * @param extension defines the file extension of the file being loaded
  117278. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117279. * @param fallback defines the fallback internal texture if any
  117280. * @param isBase64 defines whether the texture is encoded as a base64
  117281. * @param isBuffer defines whether the texture data are stored as a buffer
  117282. * @returns true if the loader can load the specified file
  117283. */
  117284. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117285. /**
  117286. * Transform the url before loading if required.
  117287. * @param rootUrl the url of the texture
  117288. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117289. * @returns the transformed texture
  117290. */
  117291. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117292. /**
  117293. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117294. * @param rootUrl the url of the texture
  117295. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117296. * @returns the fallback texture
  117297. */
  117298. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117299. /**
  117300. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117301. * @param data contains the texture data
  117302. * @param texture defines the BabylonJS internal texture
  117303. * @param createPolynomials will be true if polynomials have been requested
  117304. * @param onLoad defines the callback to trigger once the texture is ready
  117305. * @param onError defines the callback to trigger in case of error
  117306. */
  117307. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117308. /**
  117309. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117310. * @param data contains the texture data
  117311. * @param texture defines the BabylonJS internal texture
  117312. * @param callback defines the method to call once ready to upload
  117313. */
  117314. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117315. }
  117316. }
  117317. declare module BABYLON {
  117318. /**
  117319. * Info about the .basis files
  117320. */
  117321. class BasisFileInfo {
  117322. /**
  117323. * If the file has alpha
  117324. */
  117325. hasAlpha: boolean;
  117326. /**
  117327. * Info about each image of the basis file
  117328. */
  117329. images: Array<{
  117330. levels: Array<{
  117331. width: number;
  117332. height: number;
  117333. transcodedPixels: ArrayBufferView;
  117334. }>;
  117335. }>;
  117336. }
  117337. /**
  117338. * Result of transcoding a basis file
  117339. */
  117340. class TranscodeResult {
  117341. /**
  117342. * Info about the .basis file
  117343. */
  117344. fileInfo: BasisFileInfo;
  117345. /**
  117346. * Format to use when loading the file
  117347. */
  117348. format: number;
  117349. }
  117350. /**
  117351. * Configuration options for the Basis transcoder
  117352. */
  117353. export class BasisTranscodeConfiguration {
  117354. /**
  117355. * Supported compression formats used to determine the supported output format of the transcoder
  117356. */
  117357. supportedCompressionFormats?: {
  117358. /**
  117359. * etc1 compression format
  117360. */
  117361. etc1?: boolean;
  117362. /**
  117363. * s3tc compression format
  117364. */
  117365. s3tc?: boolean;
  117366. /**
  117367. * pvrtc compression format
  117368. */
  117369. pvrtc?: boolean;
  117370. /**
  117371. * etc2 compression format
  117372. */
  117373. etc2?: boolean;
  117374. };
  117375. /**
  117376. * If mipmap levels should be loaded for transcoded images (Default: true)
  117377. */
  117378. loadMipmapLevels?: boolean;
  117379. /**
  117380. * Index of a single image to load (Default: all images)
  117381. */
  117382. loadSingleImage?: number;
  117383. }
  117384. /**
  117385. * Used to load .Basis files
  117386. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  117387. */
  117388. export class BasisTools {
  117389. private static _IgnoreSupportedFormats;
  117390. /**
  117391. * URL to use when loading the basis transcoder
  117392. */
  117393. static JSModuleURL: string;
  117394. /**
  117395. * URL to use when loading the wasm module for the transcoder
  117396. */
  117397. static WasmModuleURL: string;
  117398. /**
  117399. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  117400. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  117401. * @returns internal format corresponding to the Basis format
  117402. */
  117403. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  117404. private static _WorkerPromise;
  117405. private static _Worker;
  117406. private static _actionId;
  117407. private static _CreateWorkerAsync;
  117408. /**
  117409. * Transcodes a loaded image file to compressed pixel data
  117410. * @param imageData image data to transcode
  117411. * @param config configuration options for the transcoding
  117412. * @returns a promise resulting in the transcoded image
  117413. */
  117414. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  117415. /**
  117416. * Loads a texture from the transcode result
  117417. * @param texture texture load to
  117418. * @param transcodeResult the result of transcoding the basis file to load from
  117419. */
  117420. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  117421. }
  117422. }
  117423. declare module BABYLON {
  117424. /**
  117425. * Loader for .basis file format
  117426. */
  117427. export class _BasisTextureLoader implements IInternalTextureLoader {
  117428. /**
  117429. * Defines whether the loader supports cascade loading the different faces.
  117430. */
  117431. readonly supportCascades: boolean;
  117432. /**
  117433. * This returns if the loader support the current file information.
  117434. * @param extension defines the file extension of the file being loaded
  117435. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117436. * @param fallback defines the fallback internal texture if any
  117437. * @param isBase64 defines whether the texture is encoded as a base64
  117438. * @param isBuffer defines whether the texture data are stored as a buffer
  117439. * @returns true if the loader can load the specified file
  117440. */
  117441. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117442. /**
  117443. * Transform the url before loading if required.
  117444. * @param rootUrl the url of the texture
  117445. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117446. * @returns the transformed texture
  117447. */
  117448. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117449. /**
  117450. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117451. * @param rootUrl the url of the texture
  117452. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117453. * @returns the fallback texture
  117454. */
  117455. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117456. /**
  117457. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  117458. * @param data contains the texture data
  117459. * @param texture defines the BabylonJS internal texture
  117460. * @param createPolynomials will be true if polynomials have been requested
  117461. * @param onLoad defines the callback to trigger once the texture is ready
  117462. * @param onError defines the callback to trigger in case of error
  117463. */
  117464. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117465. /**
  117466. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117467. * @param data contains the texture data
  117468. * @param texture defines the BabylonJS internal texture
  117469. * @param callback defines the method to call once ready to upload
  117470. */
  117471. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117472. }
  117473. }
  117474. declare module BABYLON {
  117475. /**
  117476. * 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.
  117477. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  117478. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  117479. */
  117480. export class CustomProceduralTexture extends ProceduralTexture {
  117481. private _animate;
  117482. private _time;
  117483. private _config;
  117484. private _texturePath;
  117485. /**
  117486. * Instantiates a new Custom Procedural Texture.
  117487. * 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.
  117488. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  117489. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  117490. * @param name Define the name of the texture
  117491. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  117492. * @param size Define the size of the texture to create
  117493. * @param scene Define the scene the texture belongs to
  117494. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  117495. * @param generateMipMaps Define if the texture should creates mip maps or not
  117496. */
  117497. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  117498. private _loadJson;
  117499. /**
  117500. * Is the texture ready to be used ? (rendered at least once)
  117501. * @returns true if ready, otherwise, false.
  117502. */
  117503. isReady(): boolean;
  117504. /**
  117505. * Render the texture to its associated render target.
  117506. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  117507. */
  117508. render(useCameraPostProcess?: boolean): void;
  117509. /**
  117510. * Update the list of dependant textures samplers in the shader.
  117511. */
  117512. updateTextures(): void;
  117513. /**
  117514. * Update the uniform values of the procedural texture in the shader.
  117515. */
  117516. updateShaderUniforms(): void;
  117517. /**
  117518. * Define if the texture animates or not.
  117519. */
  117520. animate: boolean;
  117521. }
  117522. }
  117523. declare module BABYLON {
  117524. /** @hidden */
  117525. export var noisePixelShader: {
  117526. name: string;
  117527. shader: string;
  117528. };
  117529. }
  117530. declare module BABYLON {
  117531. /**
  117532. * Class used to generate noise procedural textures
  117533. */
  117534. export class NoiseProceduralTexture extends ProceduralTexture {
  117535. private _time;
  117536. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  117537. brightness: number;
  117538. /** Defines the number of octaves to process */
  117539. octaves: number;
  117540. /** Defines the level of persistence (0.8 by default) */
  117541. persistence: number;
  117542. /** Gets or sets animation speed factor (default is 1) */
  117543. animationSpeedFactor: number;
  117544. /**
  117545. * Creates a new NoiseProceduralTexture
  117546. * @param name defines the name fo the texture
  117547. * @param size defines the size of the texture (default is 256)
  117548. * @param scene defines the hosting scene
  117549. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  117550. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  117551. */
  117552. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  117553. private _updateShaderUniforms;
  117554. protected _getDefines(): string;
  117555. /** Generate the current state of the procedural texture */
  117556. render(useCameraPostProcess?: boolean): void;
  117557. /**
  117558. * Serializes this noise procedural texture
  117559. * @returns a serialized noise procedural texture object
  117560. */
  117561. serialize(): any;
  117562. /**
  117563. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  117564. * @param parsedTexture defines parsed texture data
  117565. * @param scene defines the current scene
  117566. * @param rootUrl defines the root URL containing noise procedural texture information
  117567. * @returns a parsed NoiseProceduralTexture
  117568. */
  117569. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  117570. }
  117571. }
  117572. declare module BABYLON {
  117573. /**
  117574. * Raw cube texture where the raw buffers are passed in
  117575. */
  117576. export class RawCubeTexture extends CubeTexture {
  117577. /**
  117578. * Creates a cube texture where the raw buffers are passed in.
  117579. * @param scene defines the scene the texture is attached to
  117580. * @param data defines the array of data to use to create each face
  117581. * @param size defines the size of the textures
  117582. * @param format defines the format of the data
  117583. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  117584. * @param generateMipMaps defines if the engine should generate the mip levels
  117585. * @param invertY defines if data must be stored with Y axis inverted
  117586. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  117587. * @param compression defines the compression used (null by default)
  117588. */
  117589. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  117590. /**
  117591. * Updates the raw cube texture.
  117592. * @param data defines the data to store
  117593. * @param format defines the data format
  117594. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  117595. * @param invertY defines if data must be stored with Y axis inverted
  117596. * @param compression defines the compression used (null by default)
  117597. * @param level defines which level of the texture to update
  117598. */
  117599. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  117600. /**
  117601. * Updates a raw cube texture with RGBD encoded data.
  117602. * @param data defines the array of data [mipmap][face] to use to create each face
  117603. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  117604. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  117605. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  117606. * @returns a promsie that resolves when the operation is complete
  117607. */
  117608. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  117609. /**
  117610. * Clones the raw cube texture.
  117611. * @return a new cube texture
  117612. */
  117613. clone(): CubeTexture;
  117614. /** @hidden */
  117615. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  117616. }
  117617. }
  117618. declare module BABYLON {
  117619. /**
  117620. * Class used to store 3D textures containing user data
  117621. */
  117622. export class RawTexture3D extends Texture {
  117623. /** Gets or sets the texture format to use */
  117624. format: number;
  117625. private _engine;
  117626. /**
  117627. * Create a new RawTexture3D
  117628. * @param data defines the data of the texture
  117629. * @param width defines the width of the texture
  117630. * @param height defines the height of the texture
  117631. * @param depth defines the depth of the texture
  117632. * @param format defines the texture format to use
  117633. * @param scene defines the hosting scene
  117634. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  117635. * @param invertY defines if texture must be stored with Y axis inverted
  117636. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  117637. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  117638. */
  117639. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  117640. /** Gets or sets the texture format to use */
  117641. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  117642. /**
  117643. * Update the texture with new data
  117644. * @param data defines the data to store in the texture
  117645. */
  117646. update(data: ArrayBufferView): void;
  117647. }
  117648. }
  117649. declare module BABYLON {
  117650. /**
  117651. * Creates a refraction texture used by refraction channel of the standard material.
  117652. * It is like a mirror but to see through a material.
  117653. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117654. */
  117655. export class RefractionTexture extends RenderTargetTexture {
  117656. /**
  117657. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  117658. * 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.
  117659. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117660. */
  117661. refractionPlane: Plane;
  117662. /**
  117663. * Define how deep under the surface we should see.
  117664. */
  117665. depth: number;
  117666. /**
  117667. * Creates a refraction texture used by refraction channel of the standard material.
  117668. * It is like a mirror but to see through a material.
  117669. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117670. * @param name Define the texture name
  117671. * @param size Define the size of the underlying texture
  117672. * @param scene Define the scene the refraction belongs to
  117673. * @param generateMipMaps Define if we need to generate mips level for the refraction
  117674. */
  117675. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  117676. /**
  117677. * Clone the refraction texture.
  117678. * @returns the cloned texture
  117679. */
  117680. clone(): RefractionTexture;
  117681. /**
  117682. * Serialize the texture to a JSON representation you could use in Parse later on
  117683. * @returns the serialized JSON representation
  117684. */
  117685. serialize(): any;
  117686. }
  117687. }
  117688. declare module BABYLON {
  117689. /**
  117690. * Defines the options related to the creation of an HtmlElementTexture
  117691. */
  117692. export interface IHtmlElementTextureOptions {
  117693. /**
  117694. * Defines wether mip maps should be created or not.
  117695. */
  117696. generateMipMaps?: boolean;
  117697. /**
  117698. * Defines the sampling mode of the texture.
  117699. */
  117700. samplingMode?: number;
  117701. /**
  117702. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  117703. */
  117704. engine: Nullable<Engine>;
  117705. /**
  117706. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  117707. */
  117708. scene: Nullable<Scene>;
  117709. }
  117710. /**
  117711. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  117712. * To be as efficient as possible depending on your constraints nothing aside the first upload
  117713. * is automatically managed.
  117714. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  117715. * in your application.
  117716. *
  117717. * As the update is not automatic, you need to call them manually.
  117718. */
  117719. export class HtmlElementTexture extends BaseTexture {
  117720. /**
  117721. * The texture URL.
  117722. */
  117723. element: HTMLVideoElement | HTMLCanvasElement;
  117724. private static readonly DefaultOptions;
  117725. private _textureMatrix;
  117726. private _engine;
  117727. private _isVideo;
  117728. private _generateMipMaps;
  117729. private _samplingMode;
  117730. /**
  117731. * Instantiates a HtmlElementTexture from the following parameters.
  117732. *
  117733. * @param name Defines the name of the texture
  117734. * @param element Defines the video or canvas the texture is filled with
  117735. * @param options Defines the other none mandatory texture creation options
  117736. */
  117737. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  117738. private _createInternalTexture;
  117739. /**
  117740. * Returns the texture matrix used in most of the material.
  117741. */
  117742. getTextureMatrix(): Matrix;
  117743. /**
  117744. * Updates the content of the texture.
  117745. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  117746. */
  117747. update(invertY?: Nullable<boolean>): void;
  117748. }
  117749. }
  117750. declare module BABYLON {
  117751. /**
  117752. * Enum used to define the target of a block
  117753. */
  117754. export enum NodeMaterialBlockTargets {
  117755. /** Vertex shader */
  117756. Vertex = 1,
  117757. /** Fragment shader */
  117758. Fragment = 2,
  117759. /** Neutral */
  117760. Neutral = 4,
  117761. /** Vertex and Fragment */
  117762. VertexAndFragment = 3
  117763. }
  117764. }
  117765. declare module BABYLON {
  117766. /**
  117767. * Defines the kind of connection point for node based material
  117768. */
  117769. export enum NodeMaterialBlockConnectionPointTypes {
  117770. /** Float */
  117771. Float = 1,
  117772. /** Int */
  117773. Int = 2,
  117774. /** Vector2 */
  117775. Vector2 = 4,
  117776. /** Vector3 */
  117777. Vector3 = 8,
  117778. /** Vector4 */
  117779. Vector4 = 16,
  117780. /** Color3 */
  117781. Color3 = 32,
  117782. /** Color4 */
  117783. Color4 = 64,
  117784. /** Matrix */
  117785. Matrix = 128,
  117786. /** Detect type based on connection */
  117787. AutoDetect = 1024,
  117788. /** Output type that will be defined by input type */
  117789. BasedOnInput = 2048
  117790. }
  117791. }
  117792. declare module BABYLON {
  117793. /**
  117794. * Root class for all node material optimizers
  117795. */
  117796. export class NodeMaterialOptimizer {
  117797. /**
  117798. * Function used to optimize a NodeMaterial graph
  117799. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  117800. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  117801. */
  117802. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  117803. }
  117804. }
  117805. declare module BABYLON {
  117806. /**
  117807. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  117808. */
  117809. export class TransformBlock extends NodeMaterialBlock {
  117810. /**
  117811. * Defines the value to use to complement W value to transform it to a Vector4
  117812. */
  117813. complementW: number;
  117814. /**
  117815. * Defines the value to use to complement z value to transform it to a Vector4
  117816. */
  117817. complementZ: number;
  117818. /**
  117819. * Creates a new TransformBlock
  117820. * @param name defines the block name
  117821. */
  117822. constructor(name: string);
  117823. /**
  117824. * Gets the current class name
  117825. * @returns the class name
  117826. */
  117827. getClassName(): string;
  117828. /**
  117829. * Gets the vector input
  117830. */
  117831. readonly vector: NodeMaterialConnectionPoint;
  117832. /**
  117833. * Gets the output component
  117834. */
  117835. readonly output: NodeMaterialConnectionPoint;
  117836. /**
  117837. * Gets the matrix transform input
  117838. */
  117839. readonly transform: NodeMaterialConnectionPoint;
  117840. protected _buildBlock(state: NodeMaterialBuildState): this;
  117841. serialize(): any;
  117842. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117843. protected _dumpPropertiesCode(): string;
  117844. }
  117845. }
  117846. declare module BABYLON {
  117847. /**
  117848. * Block used to output the vertex position
  117849. */
  117850. export class VertexOutputBlock extends NodeMaterialBlock {
  117851. /**
  117852. * Creates a new VertexOutputBlock
  117853. * @param name defines the block name
  117854. */
  117855. constructor(name: string);
  117856. /**
  117857. * Gets the current class name
  117858. * @returns the class name
  117859. */
  117860. getClassName(): string;
  117861. /**
  117862. * Gets the vector input component
  117863. */
  117864. readonly vector: NodeMaterialConnectionPoint;
  117865. protected _buildBlock(state: NodeMaterialBuildState): this;
  117866. }
  117867. }
  117868. declare module BABYLON {
  117869. /**
  117870. * Block used to output the final color
  117871. */
  117872. export class FragmentOutputBlock extends NodeMaterialBlock {
  117873. /**
  117874. * Create a new FragmentOutputBlock
  117875. * @param name defines the block name
  117876. */
  117877. constructor(name: string);
  117878. /**
  117879. * Gets the current class name
  117880. * @returns the class name
  117881. */
  117882. getClassName(): string;
  117883. /**
  117884. * Gets the rgba input component
  117885. */
  117886. readonly rgba: NodeMaterialConnectionPoint;
  117887. /**
  117888. * Gets the rgb input component
  117889. */
  117890. readonly rgb: NodeMaterialConnectionPoint;
  117891. /**
  117892. * Gets the a input component
  117893. */
  117894. readonly a: NodeMaterialConnectionPoint;
  117895. protected _buildBlock(state: NodeMaterialBuildState): this;
  117896. }
  117897. }
  117898. declare module BABYLON {
  117899. /**
  117900. * Enum used to define system values e.g. values automatically provided by the system
  117901. */
  117902. export enum NodeMaterialSystemValues {
  117903. /** World */
  117904. World = 1,
  117905. /** View */
  117906. View = 2,
  117907. /** Projection */
  117908. Projection = 3,
  117909. /** ViewProjection */
  117910. ViewProjection = 4,
  117911. /** WorldView */
  117912. WorldView = 5,
  117913. /** WorldViewProjection */
  117914. WorldViewProjection = 6,
  117915. /** CameraPosition */
  117916. CameraPosition = 7,
  117917. /** Fog Color */
  117918. FogColor = 8
  117919. }
  117920. }
  117921. declare module BABYLON {
  117922. /**
  117923. * Block used to read a reflection texture from a sampler
  117924. */
  117925. export class ReflectionTextureBlock extends NodeMaterialBlock {
  117926. private _define3DName;
  117927. private _defineCubicName;
  117928. private _defineExplicitName;
  117929. private _defineProjectionName;
  117930. private _defineLocalCubicName;
  117931. private _defineSphericalName;
  117932. private _definePlanarName;
  117933. private _defineEquirectangularName;
  117934. private _defineMirroredEquirectangularFixedName;
  117935. private _defineEquirectangularFixedName;
  117936. private _defineSkyboxName;
  117937. private _cubeSamplerName;
  117938. private _2DSamplerName;
  117939. private _positionUVWName;
  117940. private _directionWName;
  117941. private _reflectionCoordsName;
  117942. private _reflection2DCoordsName;
  117943. private _reflectionColorName;
  117944. private _reflectionMatrixName;
  117945. /**
  117946. * Gets or sets the texture associated with the node
  117947. */
  117948. texture: Nullable<BaseTexture>;
  117949. /**
  117950. * Create a new TextureBlock
  117951. * @param name defines the block name
  117952. */
  117953. constructor(name: string);
  117954. /**
  117955. * Gets the current class name
  117956. * @returns the class name
  117957. */
  117958. getClassName(): string;
  117959. /**
  117960. * Gets the world position input component
  117961. */
  117962. readonly position: NodeMaterialConnectionPoint;
  117963. /**
  117964. * Gets the world position input component
  117965. */
  117966. readonly worldPosition: NodeMaterialConnectionPoint;
  117967. /**
  117968. * Gets the world normal input component
  117969. */
  117970. readonly worldNormal: NodeMaterialConnectionPoint;
  117971. /**
  117972. * Gets the world input component
  117973. */
  117974. readonly world: NodeMaterialConnectionPoint;
  117975. /**
  117976. * Gets the camera (or eye) position component
  117977. */
  117978. readonly cameraPosition: NodeMaterialConnectionPoint;
  117979. /**
  117980. * Gets the view input component
  117981. */
  117982. readonly view: NodeMaterialConnectionPoint;
  117983. /**
  117984. * Gets the rgb output component
  117985. */
  117986. readonly rgb: NodeMaterialConnectionPoint;
  117987. /**
  117988. * Gets the r output component
  117989. */
  117990. readonly r: NodeMaterialConnectionPoint;
  117991. /**
  117992. * Gets the g output component
  117993. */
  117994. readonly g: NodeMaterialConnectionPoint;
  117995. /**
  117996. * Gets the b output component
  117997. */
  117998. readonly b: NodeMaterialConnectionPoint;
  117999. autoConfigure(material: NodeMaterial): void;
  118000. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118001. isReady(): boolean;
  118002. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118003. private _injectVertexCode;
  118004. private _writeOutput;
  118005. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118006. serialize(): any;
  118007. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118008. }
  118009. }
  118010. declare module BABYLON {
  118011. /**
  118012. * Interface used to configure the node material editor
  118013. */
  118014. export interface INodeMaterialEditorOptions {
  118015. /** Define the URl to load node editor script */
  118016. editorURL?: string;
  118017. }
  118018. /** @hidden */
  118019. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  118020. /** BONES */
  118021. NUM_BONE_INFLUENCERS: number;
  118022. BonesPerMesh: number;
  118023. BONETEXTURE: boolean;
  118024. /** MORPH TARGETS */
  118025. MORPHTARGETS: boolean;
  118026. MORPHTARGETS_NORMAL: boolean;
  118027. MORPHTARGETS_TANGENT: boolean;
  118028. MORPHTARGETS_UV: boolean;
  118029. NUM_MORPH_INFLUENCERS: number;
  118030. /** IMAGE PROCESSING */
  118031. IMAGEPROCESSING: boolean;
  118032. VIGNETTE: boolean;
  118033. VIGNETTEBLENDMODEMULTIPLY: boolean;
  118034. VIGNETTEBLENDMODEOPAQUE: boolean;
  118035. TONEMAPPING: boolean;
  118036. TONEMAPPING_ACES: boolean;
  118037. CONTRAST: boolean;
  118038. EXPOSURE: boolean;
  118039. COLORCURVES: boolean;
  118040. COLORGRADING: boolean;
  118041. COLORGRADING3D: boolean;
  118042. SAMPLER3DGREENDEPTH: boolean;
  118043. SAMPLER3DBGRMAP: boolean;
  118044. IMAGEPROCESSINGPOSTPROCESS: boolean;
  118045. /** MISC. */
  118046. BUMPDIRECTUV: number;
  118047. constructor();
  118048. setValue(name: string, value: boolean): void;
  118049. }
  118050. /**
  118051. * Class used to configure NodeMaterial
  118052. */
  118053. export interface INodeMaterialOptions {
  118054. /**
  118055. * Defines if blocks should emit comments
  118056. */
  118057. emitComments: boolean;
  118058. }
  118059. /**
  118060. * Class used to create a node based material built by assembling shader blocks
  118061. */
  118062. export class NodeMaterial extends PushMaterial {
  118063. private static _BuildIdGenerator;
  118064. private _options;
  118065. private _vertexCompilationState;
  118066. private _fragmentCompilationState;
  118067. private _sharedData;
  118068. private _buildId;
  118069. private _buildWasSuccessful;
  118070. private _cachedWorldViewMatrix;
  118071. private _cachedWorldViewProjectionMatrix;
  118072. private _optimizers;
  118073. private _animationFrame;
  118074. /** Define the URl to load node editor script */
  118075. static EditorURL: string;
  118076. private BJSNODEMATERIALEDITOR;
  118077. /** Get the inspector from bundle or global */
  118078. private _getGlobalNodeMaterialEditor;
  118079. /**
  118080. * 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)
  118081. */
  118082. ignoreAlpha: boolean;
  118083. /**
  118084. * Defines the maximum number of lights that can be used in the material
  118085. */
  118086. maxSimultaneousLights: number;
  118087. /**
  118088. * Observable raised when the material is built
  118089. */
  118090. onBuildObservable: Observable<NodeMaterial>;
  118091. /**
  118092. * Gets or sets the root nodes of the material vertex shader
  118093. */
  118094. _vertexOutputNodes: NodeMaterialBlock[];
  118095. /**
  118096. * Gets or sets the root nodes of the material fragment (pixel) shader
  118097. */
  118098. _fragmentOutputNodes: NodeMaterialBlock[];
  118099. /** Gets or sets options to control the node material overall behavior */
  118100. options: INodeMaterialOptions;
  118101. /**
  118102. * Default configuration related to image processing available in the standard Material.
  118103. */
  118104. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118105. /**
  118106. * Gets the image processing configuration used either in this material.
  118107. */
  118108. /**
  118109. * Sets the Default image processing configuration used either in the this material.
  118110. *
  118111. * If sets to null, the scene one is in use.
  118112. */
  118113. imageProcessingConfiguration: ImageProcessingConfiguration;
  118114. /**
  118115. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  118116. */
  118117. attachedBlocks: NodeMaterialBlock[];
  118118. /**
  118119. * Create a new node based material
  118120. * @param name defines the material name
  118121. * @param scene defines the hosting scene
  118122. * @param options defines creation option
  118123. */
  118124. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  118125. /**
  118126. * Gets the current class name of the material e.g. "NodeMaterial"
  118127. * @returns the class name
  118128. */
  118129. getClassName(): string;
  118130. /**
  118131. * Keep track of the image processing observer to allow dispose and replace.
  118132. */
  118133. private _imageProcessingObserver;
  118134. /**
  118135. * Attaches a new image processing configuration to the Standard Material.
  118136. * @param configuration
  118137. */
  118138. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  118139. /**
  118140. * Get a block by its name
  118141. * @param name defines the name of the block to retrieve
  118142. * @returns the required block or null if not found
  118143. */
  118144. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  118145. /**
  118146. * Get a block by its name
  118147. * @param predicate defines the predicate used to find the good candidate
  118148. * @returns the required block or null if not found
  118149. */
  118150. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  118151. /**
  118152. * Get an input block by its name
  118153. * @param predicate defines the predicate used to find the good candidate
  118154. * @returns the required input block or null if not found
  118155. */
  118156. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  118157. /**
  118158. * Gets the list of input blocks attached to this material
  118159. * @returns an array of InputBlocks
  118160. */
  118161. getInputBlocks(): InputBlock[];
  118162. /**
  118163. * Adds a new optimizer to the list of optimizers
  118164. * @param optimizer defines the optimizers to add
  118165. * @returns the current material
  118166. */
  118167. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  118168. /**
  118169. * Remove an optimizer from the list of optimizers
  118170. * @param optimizer defines the optimizers to remove
  118171. * @returns the current material
  118172. */
  118173. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  118174. /**
  118175. * Add a new block to the list of output nodes
  118176. * @param node defines the node to add
  118177. * @returns the current material
  118178. */
  118179. addOutputNode(node: NodeMaterialBlock): this;
  118180. /**
  118181. * Remove a block from the list of root nodes
  118182. * @param node defines the node to remove
  118183. * @returns the current material
  118184. */
  118185. removeOutputNode(node: NodeMaterialBlock): this;
  118186. private _addVertexOutputNode;
  118187. private _removeVertexOutputNode;
  118188. private _addFragmentOutputNode;
  118189. private _removeFragmentOutputNode;
  118190. /**
  118191. * Specifies if the material will require alpha blending
  118192. * @returns a boolean specifying if alpha blending is needed
  118193. */
  118194. needAlphaBlending(): boolean;
  118195. /**
  118196. * Specifies if this material should be rendered in alpha test mode
  118197. * @returns a boolean specifying if an alpha test is needed.
  118198. */
  118199. needAlphaTesting(): boolean;
  118200. private _initializeBlock;
  118201. private _resetDualBlocks;
  118202. /**
  118203. * Build the material and generates the inner effect
  118204. * @param verbose defines if the build should log activity
  118205. */
  118206. build(verbose?: boolean): void;
  118207. /**
  118208. * Runs an otpimization phase to try to improve the shader code
  118209. */
  118210. optimize(): void;
  118211. private _prepareDefinesForAttributes;
  118212. /**
  118213. * Get if the submesh is ready to be used and all its information available.
  118214. * Child classes can use it to update shaders
  118215. * @param mesh defines the mesh to check
  118216. * @param subMesh defines which submesh to check
  118217. * @param useInstances specifies that instances should be used
  118218. * @returns a boolean indicating that the submesh is ready or not
  118219. */
  118220. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  118221. /**
  118222. * Get a string representing the shaders built by the current node graph
  118223. */
  118224. readonly compiledShaders: string;
  118225. /**
  118226. * Binds the world matrix to the material
  118227. * @param world defines the world transformation matrix
  118228. */
  118229. bindOnlyWorldMatrix(world: Matrix): void;
  118230. /**
  118231. * Binds the submesh to this material by preparing the effect and shader to draw
  118232. * @param world defines the world transformation matrix
  118233. * @param mesh defines the mesh containing the submesh
  118234. * @param subMesh defines the submesh to bind the material to
  118235. */
  118236. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  118237. /**
  118238. * Gets the active textures from the material
  118239. * @returns an array of textures
  118240. */
  118241. getActiveTextures(): BaseTexture[];
  118242. /**
  118243. * Gets the list of texture blocks
  118244. * @returns an array of texture blocks
  118245. */
  118246. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  118247. /**
  118248. * Specifies if the material uses a texture
  118249. * @param texture defines the texture to check against the material
  118250. * @returns a boolean specifying if the material uses the texture
  118251. */
  118252. hasTexture(texture: BaseTexture): boolean;
  118253. /**
  118254. * Disposes the material
  118255. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  118256. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  118257. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  118258. */
  118259. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  118260. /** Creates the node editor window. */
  118261. private _createNodeEditor;
  118262. /**
  118263. * Launch the node material editor
  118264. * @param config Define the configuration of the editor
  118265. * @return a promise fulfilled when the node editor is visible
  118266. */
  118267. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  118268. /**
  118269. * Clear the current material
  118270. */
  118271. clear(): void;
  118272. /**
  118273. * Clear the current material and set it to a default state
  118274. */
  118275. setToDefault(): void;
  118276. /**
  118277. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  118278. * @param url defines the url to load from
  118279. * @returns a promise that will fullfil when the material is fully loaded
  118280. */
  118281. loadAsync(url: string): Promise<unknown>;
  118282. private _gatherBlocks;
  118283. /**
  118284. * Generate a string containing the code declaration required to create an equivalent of this material
  118285. * @returns a string
  118286. */
  118287. generateCode(): string;
  118288. /**
  118289. * Serializes this material in a JSON representation
  118290. * @returns the serialized material object
  118291. */
  118292. serialize(): any;
  118293. private _restoreConnections;
  118294. /**
  118295. * Clear the current graph and load a new one from a serialization object
  118296. * @param source defines the JSON representation of the material
  118297. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118298. */
  118299. loadFromSerialization(source: any, rootUrl?: string): void;
  118300. /**
  118301. * Creates a node material from parsed material data
  118302. * @param source defines the JSON representation of the material
  118303. * @param scene defines the hosting scene
  118304. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118305. * @returns a new node material
  118306. */
  118307. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  118308. /**
  118309. * Creates a new node material set to default basic configuration
  118310. * @param name defines the name of the material
  118311. * @param scene defines the hosting scene
  118312. * @returns a new NodeMaterial
  118313. */
  118314. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  118315. }
  118316. }
  118317. declare module BABYLON {
  118318. /**
  118319. * Block used to read a texture from a sampler
  118320. */
  118321. export class TextureBlock extends NodeMaterialBlock {
  118322. private _defineName;
  118323. private _samplerName;
  118324. private _transformedUVName;
  118325. private _textureTransformName;
  118326. private _textureInfoName;
  118327. /**
  118328. * Gets or sets the texture associated with the node
  118329. */
  118330. texture: Nullable<Texture>;
  118331. /**
  118332. * Create a new TextureBlock
  118333. * @param name defines the block name
  118334. */
  118335. constructor(name: string);
  118336. /**
  118337. * Gets the current class name
  118338. * @returns the class name
  118339. */
  118340. getClassName(): string;
  118341. /**
  118342. * Gets the uv input component
  118343. */
  118344. readonly uv: NodeMaterialConnectionPoint;
  118345. /**
  118346. * Gets the rgba output component
  118347. */
  118348. readonly rgba: NodeMaterialConnectionPoint;
  118349. /**
  118350. * Gets the rgb output component
  118351. */
  118352. readonly rgb: NodeMaterialConnectionPoint;
  118353. /**
  118354. * Gets the r output component
  118355. */
  118356. readonly r: NodeMaterialConnectionPoint;
  118357. /**
  118358. * Gets the g output component
  118359. */
  118360. readonly g: NodeMaterialConnectionPoint;
  118361. /**
  118362. * Gets the b output component
  118363. */
  118364. readonly b: NodeMaterialConnectionPoint;
  118365. /**
  118366. * Gets the a output component
  118367. */
  118368. readonly a: NodeMaterialConnectionPoint;
  118369. readonly target: NodeMaterialBlockTargets;
  118370. autoConfigure(material: NodeMaterial): void;
  118371. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118372. isReady(): boolean;
  118373. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118374. private readonly _isMixed;
  118375. private _injectVertexCode;
  118376. private _writeOutput;
  118377. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118378. protected _dumpPropertiesCode(): string;
  118379. serialize(): any;
  118380. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118381. }
  118382. }
  118383. declare module BABYLON {
  118384. /**
  118385. * Class used to store shared data between 2 NodeMaterialBuildState
  118386. */
  118387. export class NodeMaterialBuildStateSharedData {
  118388. /**
  118389. * Gets the list of emitted varyings
  118390. */
  118391. temps: string[];
  118392. /**
  118393. * Gets the list of emitted varyings
  118394. */
  118395. varyings: string[];
  118396. /**
  118397. * Gets the varying declaration string
  118398. */
  118399. varyingDeclaration: string;
  118400. /**
  118401. * Input blocks
  118402. */
  118403. inputBlocks: InputBlock[];
  118404. /**
  118405. * Input blocks
  118406. */
  118407. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  118408. /**
  118409. * Bindable blocks (Blocks that need to set data to the effect)
  118410. */
  118411. bindableBlocks: NodeMaterialBlock[];
  118412. /**
  118413. * List of blocks that can provide a compilation fallback
  118414. */
  118415. blocksWithFallbacks: NodeMaterialBlock[];
  118416. /**
  118417. * List of blocks that can provide a define update
  118418. */
  118419. blocksWithDefines: NodeMaterialBlock[];
  118420. /**
  118421. * List of blocks that can provide a repeatable content
  118422. */
  118423. repeatableContentBlocks: NodeMaterialBlock[];
  118424. /**
  118425. * List of blocks that can provide a dynamic list of uniforms
  118426. */
  118427. dynamicUniformBlocks: NodeMaterialBlock[];
  118428. /**
  118429. * List of blocks that can block the isReady function for the material
  118430. */
  118431. blockingBlocks: NodeMaterialBlock[];
  118432. /**
  118433. * Gets the list of animated inputs
  118434. */
  118435. animatedInputs: InputBlock[];
  118436. /**
  118437. * Build Id used to avoid multiple recompilations
  118438. */
  118439. buildId: number;
  118440. /** List of emitted variables */
  118441. variableNames: {
  118442. [key: string]: number;
  118443. };
  118444. /** List of emitted defines */
  118445. defineNames: {
  118446. [key: string]: number;
  118447. };
  118448. /** Should emit comments? */
  118449. emitComments: boolean;
  118450. /** Emit build activity */
  118451. verbose: boolean;
  118452. /** Gets or sets the hosting scene */
  118453. scene: Scene;
  118454. /**
  118455. * Gets the compilation hints emitted at compilation time
  118456. */
  118457. hints: {
  118458. needWorldViewMatrix: boolean;
  118459. needWorldViewProjectionMatrix: boolean;
  118460. needAlphaBlending: boolean;
  118461. needAlphaTesting: boolean;
  118462. };
  118463. /**
  118464. * List of compilation checks
  118465. */
  118466. checks: {
  118467. emitVertex: boolean;
  118468. emitFragment: boolean;
  118469. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  118470. };
  118471. /** Creates a new shared data */
  118472. constructor();
  118473. /**
  118474. * Emits console errors and exceptions if there is a failing check
  118475. */
  118476. emitErrors(): void;
  118477. }
  118478. }
  118479. declare module BABYLON {
  118480. /**
  118481. * Class used to store node based material build state
  118482. */
  118483. export class NodeMaterialBuildState {
  118484. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  118485. supportUniformBuffers: boolean;
  118486. /**
  118487. * Gets the list of emitted attributes
  118488. */
  118489. attributes: string[];
  118490. /**
  118491. * Gets the list of emitted uniforms
  118492. */
  118493. uniforms: string[];
  118494. /**
  118495. * Gets the list of emitted uniform buffers
  118496. */
  118497. uniformBuffers: string[];
  118498. /**
  118499. * Gets the list of emitted samplers
  118500. */
  118501. samplers: string[];
  118502. /**
  118503. * Gets the list of emitted functions
  118504. */
  118505. functions: {
  118506. [key: string]: string;
  118507. };
  118508. /**
  118509. * Gets the list of emitted extensions
  118510. */
  118511. extensions: {
  118512. [key: string]: string;
  118513. };
  118514. /**
  118515. * Gets the target of the compilation state
  118516. */
  118517. target: NodeMaterialBlockTargets;
  118518. /**
  118519. * Gets the list of emitted counters
  118520. */
  118521. counters: {
  118522. [key: string]: number;
  118523. };
  118524. /**
  118525. * Shared data between multiple NodeMaterialBuildState instances
  118526. */
  118527. sharedData: NodeMaterialBuildStateSharedData;
  118528. /** @hidden */
  118529. _vertexState: NodeMaterialBuildState;
  118530. /** @hidden */
  118531. _attributeDeclaration: string;
  118532. /** @hidden */
  118533. _uniformDeclaration: string;
  118534. /** @hidden */
  118535. _samplerDeclaration: string;
  118536. /** @hidden */
  118537. _varyingTransfer: string;
  118538. private _repeatableContentAnchorIndex;
  118539. /** @hidden */
  118540. _builtCompilationString: string;
  118541. /**
  118542. * Gets the emitted compilation strings
  118543. */
  118544. compilationString: string;
  118545. /**
  118546. * Finalize the compilation strings
  118547. * @param state defines the current compilation state
  118548. */
  118549. finalize(state: NodeMaterialBuildState): void;
  118550. /** @hidden */
  118551. readonly _repeatableContentAnchor: string;
  118552. /** @hidden */
  118553. _getFreeVariableName(prefix: string): string;
  118554. /** @hidden */
  118555. _getFreeDefineName(prefix: string): string;
  118556. /** @hidden */
  118557. _excludeVariableName(name: string): void;
  118558. /** @hidden */
  118559. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  118560. /** @hidden */
  118561. _emitExtension(name: string, extension: string): void;
  118562. /** @hidden */
  118563. _emitFunction(name: string, code: string, comments: string): void;
  118564. /** @hidden */
  118565. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  118566. replaceStrings?: {
  118567. search: RegExp;
  118568. replace: string;
  118569. }[];
  118570. repeatKey?: string;
  118571. }): string;
  118572. /** @hidden */
  118573. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  118574. repeatKey?: string;
  118575. removeAttributes?: boolean;
  118576. removeUniforms?: boolean;
  118577. removeVaryings?: boolean;
  118578. removeIfDef?: boolean;
  118579. replaceStrings?: {
  118580. search: RegExp;
  118581. replace: string;
  118582. }[];
  118583. }, storeKey?: string): void;
  118584. /** @hidden */
  118585. _registerTempVariable(name: string): boolean;
  118586. /** @hidden */
  118587. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  118588. /** @hidden */
  118589. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  118590. }
  118591. }
  118592. declare module BABYLON {
  118593. /**
  118594. * Defines a block that can be used inside a node based material
  118595. */
  118596. export class NodeMaterialBlock {
  118597. private _buildId;
  118598. private _buildTarget;
  118599. private _target;
  118600. private _isFinalMerger;
  118601. private _isInput;
  118602. /** @hidden */
  118603. _codeVariableName: string;
  118604. /** @hidden */
  118605. _inputs: NodeMaterialConnectionPoint[];
  118606. /** @hidden */
  118607. _outputs: NodeMaterialConnectionPoint[];
  118608. /** @hidden */
  118609. _preparationId: number;
  118610. /**
  118611. * Gets or sets the name of the block
  118612. */
  118613. name: string;
  118614. /**
  118615. * Gets or sets the unique id of the node
  118616. */
  118617. uniqueId: number;
  118618. /**
  118619. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  118620. */
  118621. readonly isFinalMerger: boolean;
  118622. /**
  118623. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  118624. */
  118625. readonly isInput: boolean;
  118626. /**
  118627. * Gets or sets the build Id
  118628. */
  118629. buildId: number;
  118630. /**
  118631. * Gets or sets the target of the block
  118632. */
  118633. target: NodeMaterialBlockTargets;
  118634. /**
  118635. * Gets the list of input points
  118636. */
  118637. readonly inputs: NodeMaterialConnectionPoint[];
  118638. /** Gets the list of output points */
  118639. readonly outputs: NodeMaterialConnectionPoint[];
  118640. /**
  118641. * Find an input by its name
  118642. * @param name defines the name of the input to look for
  118643. * @returns the input or null if not found
  118644. */
  118645. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  118646. /**
  118647. * Find an output by its name
  118648. * @param name defines the name of the outputto look for
  118649. * @returns the output or null if not found
  118650. */
  118651. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  118652. /**
  118653. * Creates a new NodeMaterialBlock
  118654. * @param name defines the block name
  118655. * @param target defines the target of that block (Vertex by default)
  118656. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  118657. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  118658. */
  118659. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  118660. /**
  118661. * Initialize the block and prepare the context for build
  118662. * @param state defines the state that will be used for the build
  118663. */
  118664. initialize(state: NodeMaterialBuildState): void;
  118665. /**
  118666. * Bind data to effect. Will only be called for blocks with isBindable === true
  118667. * @param effect defines the effect to bind data to
  118668. * @param nodeMaterial defines the hosting NodeMaterial
  118669. * @param mesh defines the mesh that will be rendered
  118670. */
  118671. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118672. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  118673. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  118674. protected _writeFloat(value: number): string;
  118675. /**
  118676. * Gets the current class name e.g. "NodeMaterialBlock"
  118677. * @returns the class name
  118678. */
  118679. getClassName(): string;
  118680. /**
  118681. * Register a new input. Must be called inside a block constructor
  118682. * @param name defines the connection point name
  118683. * @param type defines the connection point type
  118684. * @param isOptional defines a boolean indicating that this input can be omitted
  118685. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  118686. * @returns the current block
  118687. */
  118688. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  118689. /**
  118690. * Register a new output. Must be called inside a block constructor
  118691. * @param name defines the connection point name
  118692. * @param type defines the connection point type
  118693. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  118694. * @returns the current block
  118695. */
  118696. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  118697. /**
  118698. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  118699. * @param forOutput defines an optional connection point to check compatibility with
  118700. * @returns the first available input or null
  118701. */
  118702. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  118703. /**
  118704. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  118705. * @param forBlock defines an optional block to check compatibility with
  118706. * @returns the first available input or null
  118707. */
  118708. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  118709. /**
  118710. * Gets the sibling of the given output
  118711. * @param current defines the current output
  118712. * @returns the next output in the list or null
  118713. */
  118714. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  118715. /**
  118716. * Connect current block with another block
  118717. * @param other defines the block to connect with
  118718. * @param options define the various options to help pick the right connections
  118719. * @returns the current block
  118720. */
  118721. connectTo(other: NodeMaterialBlock, options?: {
  118722. input?: string;
  118723. output?: string;
  118724. outputSwizzle?: string;
  118725. }): this | undefined;
  118726. protected _buildBlock(state: NodeMaterialBuildState): void;
  118727. /**
  118728. * Add uniforms, samplers and uniform buffers at compilation time
  118729. * @param state defines the state to update
  118730. * @param nodeMaterial defines the node material requesting the update
  118731. * @param defines defines the material defines to update
  118732. */
  118733. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118734. /**
  118735. * Add potential fallbacks if shader compilation fails
  118736. * @param mesh defines the mesh to be rendered
  118737. * @param fallbacks defines the current prioritized list of fallbacks
  118738. */
  118739. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  118740. /**
  118741. * Update defines for shader compilation
  118742. * @param mesh defines the mesh to be rendered
  118743. * @param nodeMaterial defines the node material requesting the update
  118744. * @param defines defines the material defines to update
  118745. * @param useInstances specifies that instances should be used
  118746. */
  118747. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118748. /**
  118749. * Lets the block try to connect some inputs automatically
  118750. * @param material defines the hosting NodeMaterial
  118751. */
  118752. autoConfigure(material: NodeMaterial): void;
  118753. /**
  118754. * Function called when a block is declared as repeatable content generator
  118755. * @param vertexShaderState defines the current compilation state for the vertex shader
  118756. * @param fragmentShaderState defines the current compilation state for the fragment shader
  118757. * @param mesh defines the mesh to be rendered
  118758. * @param defines defines the material defines to update
  118759. */
  118760. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  118761. /**
  118762. * Checks if the block is ready
  118763. * @param mesh defines the mesh to be rendered
  118764. * @param nodeMaterial defines the node material requesting the update
  118765. * @param defines defines the material defines to update
  118766. * @param useInstances specifies that instances should be used
  118767. * @returns true if the block is ready
  118768. */
  118769. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  118770. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  118771. private _processBuild;
  118772. /**
  118773. * Compile the current node and generate the shader code
  118774. * @param state defines the current compilation state (uniforms, samplers, current string)
  118775. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  118776. * @returns true if already built
  118777. */
  118778. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  118779. protected _inputRename(name: string): string;
  118780. protected _outputRename(name: string): string;
  118781. protected _dumpPropertiesCode(): string;
  118782. /** @hidden */
  118783. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  118784. /**
  118785. * Clone the current block to a new identical block
  118786. * @param scene defines the hosting scene
  118787. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118788. * @returns a copy of the current block
  118789. */
  118790. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  118791. /**
  118792. * Serializes this block in a JSON representation
  118793. * @returns the serialized block object
  118794. */
  118795. serialize(): any;
  118796. /** @hidden */
  118797. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118798. }
  118799. }
  118800. declare module BABYLON {
  118801. /**
  118802. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  118803. */
  118804. export enum NodeMaterialBlockConnectionPointMode {
  118805. /** Value is an uniform */
  118806. Uniform = 0,
  118807. /** Value is a mesh attribute */
  118808. Attribute = 1,
  118809. /** Value is a varying between vertex and fragment shaders */
  118810. Varying = 2,
  118811. /** Mode is undefined */
  118812. Undefined = 3
  118813. }
  118814. }
  118815. declare module BABYLON {
  118816. /**
  118817. * Enum defining the type of animations supported by InputBlock
  118818. */
  118819. export enum AnimatedInputBlockTypes {
  118820. /** No animation */
  118821. None = 0,
  118822. /** Time based animation. Will only work for floats */
  118823. Time = 1
  118824. }
  118825. }
  118826. declare module BABYLON {
  118827. /**
  118828. * Block used to expose an input value
  118829. */
  118830. export class InputBlock extends NodeMaterialBlock {
  118831. private _mode;
  118832. private _associatedVariableName;
  118833. private _storedValue;
  118834. private _valueCallback;
  118835. private _type;
  118836. private _animationType;
  118837. /** Gets or set a value used to limit the range of float values */
  118838. min: number;
  118839. /** Gets or set a value used to limit the range of float values */
  118840. max: number;
  118841. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  118842. matrixMode: number;
  118843. /** @hidden */
  118844. _systemValue: Nullable<NodeMaterialSystemValues>;
  118845. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  118846. visibleInInspector: boolean;
  118847. /**
  118848. * Gets or sets the connection point type (default is float)
  118849. */
  118850. readonly type: NodeMaterialBlockConnectionPointTypes;
  118851. /**
  118852. * Creates a new InputBlock
  118853. * @param name defines the block name
  118854. * @param target defines the target of that block (Vertex by default)
  118855. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  118856. */
  118857. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  118858. /**
  118859. * Gets the output component
  118860. */
  118861. readonly output: NodeMaterialConnectionPoint;
  118862. /**
  118863. * Set the source of this connection point to a vertex attribute
  118864. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  118865. * @returns the current connection point
  118866. */
  118867. setAsAttribute(attributeName?: string): InputBlock;
  118868. /**
  118869. * Set the source of this connection point to a system value
  118870. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  118871. * @returns the current connection point
  118872. */
  118873. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  118874. /**
  118875. * Gets or sets the value of that point.
  118876. * Please note that this value will be ignored if valueCallback is defined
  118877. */
  118878. value: any;
  118879. /**
  118880. * Gets or sets a callback used to get the value of that point.
  118881. * Please note that setting this value will force the connection point to ignore the value property
  118882. */
  118883. valueCallback: () => any;
  118884. /**
  118885. * Gets or sets the associated variable name in the shader
  118886. */
  118887. associatedVariableName: string;
  118888. /** Gets or sets the type of animation applied to the input */
  118889. animationType: AnimatedInputBlockTypes;
  118890. /**
  118891. * Gets a boolean indicating that this connection point not defined yet
  118892. */
  118893. readonly isUndefined: boolean;
  118894. /**
  118895. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  118896. * In this case the connection point name must be the name of the uniform to use.
  118897. * Can only be set on inputs
  118898. */
  118899. isUniform: boolean;
  118900. /**
  118901. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  118902. * In this case the connection point name must be the name of the attribute to use
  118903. * Can only be set on inputs
  118904. */
  118905. isAttribute: boolean;
  118906. /**
  118907. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  118908. * Can only be set on exit points
  118909. */
  118910. isVarying: boolean;
  118911. /**
  118912. * Gets a boolean indicating that the current connection point is a system value
  118913. */
  118914. readonly isSystemValue: boolean;
  118915. /**
  118916. * Gets or sets the current well known value or null if not defined as a system value
  118917. */
  118918. systemValue: Nullable<NodeMaterialSystemValues>;
  118919. /**
  118920. * Gets the current class name
  118921. * @returns the class name
  118922. */
  118923. getClassName(): string;
  118924. /**
  118925. * Animate the input if animationType !== None
  118926. * @param scene defines the rendering scene
  118927. */
  118928. animate(scene: Scene): void;
  118929. private _emitDefine;
  118930. initialize(state: NodeMaterialBuildState): void;
  118931. /**
  118932. * Set the input block to its default value (based on its type)
  118933. */
  118934. setDefaultValue(): void;
  118935. protected _dumpPropertiesCode(): string;
  118936. private _emit;
  118937. /** @hidden */
  118938. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  118939. /** @hidden */
  118940. _transmit(effect: Effect, scene: Scene): void;
  118941. protected _buildBlock(state: NodeMaterialBuildState): void;
  118942. serialize(): any;
  118943. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118944. }
  118945. }
  118946. declare module BABYLON {
  118947. /**
  118948. * Defines a connection point for a block
  118949. */
  118950. export class NodeMaterialConnectionPoint {
  118951. /** @hidden */
  118952. _ownerBlock: NodeMaterialBlock;
  118953. /** @hidden */
  118954. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  118955. private _endpoints;
  118956. private _associatedVariableName;
  118957. /** @hidden */
  118958. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  118959. /** @hidden */
  118960. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  118961. private _type;
  118962. /** @hidden */
  118963. _enforceAssociatedVariableName: boolean;
  118964. /**
  118965. * Gets or sets the additional types supported byt this connection point
  118966. */
  118967. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  118968. /**
  118969. * Gets or sets the associated variable name in the shader
  118970. */
  118971. associatedVariableName: string;
  118972. /**
  118973. * Gets or sets the connection point type (default is float)
  118974. */
  118975. type: NodeMaterialBlockConnectionPointTypes;
  118976. /**
  118977. * Gets or sets the connection point name
  118978. */
  118979. name: string;
  118980. /**
  118981. * Gets or sets a boolean indicating that this connection point can be omitted
  118982. */
  118983. isOptional: boolean;
  118984. /**
  118985. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  118986. */
  118987. define: string;
  118988. /** Gets or sets the target of that connection point */
  118989. target: NodeMaterialBlockTargets;
  118990. /**
  118991. * Gets a boolean indicating that the current point is connected
  118992. */
  118993. readonly isConnected: boolean;
  118994. /**
  118995. * Gets a boolean indicating that the current point is connected to an input block
  118996. */
  118997. readonly isConnectedToInputBlock: boolean;
  118998. /**
  118999. * Gets a the connected input block (if any)
  119000. */
  119001. readonly connectInputBlock: Nullable<InputBlock>;
  119002. /** Get the other side of the connection (if any) */
  119003. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  119004. /** Get the block that owns this connection point */
  119005. readonly ownerBlock: NodeMaterialBlock;
  119006. /** Get the block connected on the other side of this connection (if any) */
  119007. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  119008. /** Get the block connected on the endpoints of this connection (if any) */
  119009. readonly connectedBlocks: Array<NodeMaterialBlock>;
  119010. /** Gets the list of connected endpoints */
  119011. readonly endpoints: NodeMaterialConnectionPoint[];
  119012. /** Gets a boolean indicating if that output point is connected to at least one input */
  119013. readonly hasEndpoints: boolean;
  119014. /**
  119015. * Creates a new connection point
  119016. * @param name defines the connection point name
  119017. * @param ownerBlock defines the block hosting this connection point
  119018. */
  119019. constructor(name: string, ownerBlock: NodeMaterialBlock);
  119020. /**
  119021. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  119022. * @returns the class name
  119023. */
  119024. getClassName(): string;
  119025. /**
  119026. * Gets an boolean indicating if the current point can be connected to another point
  119027. * @param connectionPoint defines the other connection point
  119028. * @returns true if the connection is possible
  119029. */
  119030. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  119031. /**
  119032. * Connect this point to another connection point
  119033. * @param connectionPoint defines the other connection point
  119034. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  119035. * @returns the current connection point
  119036. */
  119037. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  119038. /**
  119039. * Disconnect this point from one of his endpoint
  119040. * @param endpoint defines the other connection point
  119041. * @returns the current connection point
  119042. */
  119043. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  119044. /**
  119045. * Serializes this point in a JSON representation
  119046. * @returns the serialized point object
  119047. */
  119048. serialize(): any;
  119049. }
  119050. }
  119051. declare module BABYLON {
  119052. /**
  119053. * Block used to add support for vertex skinning (bones)
  119054. */
  119055. export class BonesBlock extends NodeMaterialBlock {
  119056. /**
  119057. * Creates a new BonesBlock
  119058. * @param name defines the block name
  119059. */
  119060. constructor(name: string);
  119061. /**
  119062. * Initialize the block and prepare the context for build
  119063. * @param state defines the state that will be used for the build
  119064. */
  119065. initialize(state: NodeMaterialBuildState): void;
  119066. /**
  119067. * Gets the current class name
  119068. * @returns the class name
  119069. */
  119070. getClassName(): string;
  119071. /**
  119072. * Gets the matrix indices input component
  119073. */
  119074. readonly matricesIndices: NodeMaterialConnectionPoint;
  119075. /**
  119076. * Gets the matrix weights input component
  119077. */
  119078. readonly matricesWeights: NodeMaterialConnectionPoint;
  119079. /**
  119080. * Gets the extra matrix indices input component
  119081. */
  119082. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  119083. /**
  119084. * Gets the extra matrix weights input component
  119085. */
  119086. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  119087. /**
  119088. * Gets the world input component
  119089. */
  119090. readonly world: NodeMaterialConnectionPoint;
  119091. /**
  119092. * Gets the output component
  119093. */
  119094. readonly output: NodeMaterialConnectionPoint;
  119095. autoConfigure(material: NodeMaterial): void;
  119096. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  119097. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119098. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119099. protected _buildBlock(state: NodeMaterialBuildState): this;
  119100. }
  119101. }
  119102. declare module BABYLON {
  119103. /**
  119104. * Block used to add support for instances
  119105. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  119106. */
  119107. export class InstancesBlock extends NodeMaterialBlock {
  119108. /**
  119109. * Creates a new InstancesBlock
  119110. * @param name defines the block name
  119111. */
  119112. constructor(name: string);
  119113. /**
  119114. * Gets the current class name
  119115. * @returns the class name
  119116. */
  119117. getClassName(): string;
  119118. /**
  119119. * Gets the first world row input component
  119120. */
  119121. readonly world0: NodeMaterialConnectionPoint;
  119122. /**
  119123. * Gets the second world row input component
  119124. */
  119125. readonly world1: NodeMaterialConnectionPoint;
  119126. /**
  119127. * Gets the third world row input component
  119128. */
  119129. readonly world2: NodeMaterialConnectionPoint;
  119130. /**
  119131. * Gets the forth world row input component
  119132. */
  119133. readonly world3: NodeMaterialConnectionPoint;
  119134. /**
  119135. * Gets the world input component
  119136. */
  119137. readonly world: NodeMaterialConnectionPoint;
  119138. /**
  119139. * Gets the output component
  119140. */
  119141. readonly output: NodeMaterialConnectionPoint;
  119142. autoConfigure(material: NodeMaterial): void;
  119143. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  119144. protected _buildBlock(state: NodeMaterialBuildState): this;
  119145. }
  119146. }
  119147. declare module BABYLON {
  119148. /**
  119149. * Block used to add morph targets support to vertex shader
  119150. */
  119151. export class MorphTargetsBlock extends NodeMaterialBlock {
  119152. private _repeatableContentAnchor;
  119153. private _repeatebleContentGenerated;
  119154. /**
  119155. * Create a new MorphTargetsBlock
  119156. * @param name defines the block name
  119157. */
  119158. constructor(name: string);
  119159. /**
  119160. * Gets the current class name
  119161. * @returns the class name
  119162. */
  119163. getClassName(): string;
  119164. /**
  119165. * Gets the position input component
  119166. */
  119167. readonly position: NodeMaterialConnectionPoint;
  119168. /**
  119169. * Gets the normal input component
  119170. */
  119171. readonly normal: NodeMaterialConnectionPoint;
  119172. /**
  119173. * Gets the tangent input component
  119174. */
  119175. readonly tangent: NodeMaterialConnectionPoint;
  119176. /**
  119177. * Gets the tangent input component
  119178. */
  119179. readonly uv: NodeMaterialConnectionPoint;
  119180. /**
  119181. * Gets the position output component
  119182. */
  119183. readonly positionOutput: NodeMaterialConnectionPoint;
  119184. /**
  119185. * Gets the normal output component
  119186. */
  119187. readonly normalOutput: NodeMaterialConnectionPoint;
  119188. /**
  119189. * Gets the tangent output component
  119190. */
  119191. readonly tangentOutput: NodeMaterialConnectionPoint;
  119192. /**
  119193. * Gets the tangent output component
  119194. */
  119195. readonly uvOutput: NodeMaterialConnectionPoint;
  119196. initialize(state: NodeMaterialBuildState): void;
  119197. autoConfigure(material: NodeMaterial): void;
  119198. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119199. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119200. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  119201. protected _buildBlock(state: NodeMaterialBuildState): this;
  119202. }
  119203. }
  119204. declare module BABYLON {
  119205. /**
  119206. * Block used to get data information from a light
  119207. */
  119208. export class LightInformationBlock extends NodeMaterialBlock {
  119209. private _lightDataDefineName;
  119210. private _lightColorDefineName;
  119211. /**
  119212. * Gets or sets the light associated with this block
  119213. */
  119214. light: Nullable<Light>;
  119215. /**
  119216. * Creates a new LightInformationBlock
  119217. * @param name defines the block name
  119218. */
  119219. constructor(name: string);
  119220. /**
  119221. * Gets the current class name
  119222. * @returns the class name
  119223. */
  119224. getClassName(): string;
  119225. /**
  119226. * Gets the world position input component
  119227. */
  119228. readonly worldPosition: NodeMaterialConnectionPoint;
  119229. /**
  119230. * Gets the direction output component
  119231. */
  119232. readonly direction: NodeMaterialConnectionPoint;
  119233. /**
  119234. * Gets the direction output component
  119235. */
  119236. readonly color: NodeMaterialConnectionPoint;
  119237. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119238. protected _buildBlock(state: NodeMaterialBuildState): this;
  119239. serialize(): any;
  119240. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119241. }
  119242. }
  119243. declare module BABYLON {
  119244. /**
  119245. * Block used to add an alpha test in the fragment shader
  119246. */
  119247. export class AlphaTestBlock extends NodeMaterialBlock {
  119248. /**
  119249. * Gets or sets the alpha value where alpha testing happens
  119250. */
  119251. alphaCutOff: number;
  119252. /**
  119253. * Create a new AlphaTestBlock
  119254. * @param name defines the block name
  119255. */
  119256. constructor(name: string);
  119257. /**
  119258. * Gets the current class name
  119259. * @returns the class name
  119260. */
  119261. getClassName(): string;
  119262. /**
  119263. * Gets the color input component
  119264. */
  119265. readonly color: NodeMaterialConnectionPoint;
  119266. /**
  119267. * Gets the alpha input component
  119268. */
  119269. readonly alpha: NodeMaterialConnectionPoint;
  119270. protected _buildBlock(state: NodeMaterialBuildState): this;
  119271. protected _dumpPropertiesCode(): string;
  119272. serialize(): any;
  119273. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119274. }
  119275. }
  119276. declare module BABYLON {
  119277. /**
  119278. * Block used to add image processing support to fragment shader
  119279. */
  119280. export class ImageProcessingBlock extends NodeMaterialBlock {
  119281. /**
  119282. * Create a new ImageProcessingBlock
  119283. * @param name defines the block name
  119284. */
  119285. constructor(name: string);
  119286. /**
  119287. * Gets the current class name
  119288. * @returns the class name
  119289. */
  119290. getClassName(): string;
  119291. /**
  119292. * Gets the color input component
  119293. */
  119294. readonly color: NodeMaterialConnectionPoint;
  119295. /**
  119296. * Gets the output component
  119297. */
  119298. readonly output: NodeMaterialConnectionPoint;
  119299. /**
  119300. * Initialize the block and prepare the context for build
  119301. * @param state defines the state that will be used for the build
  119302. */
  119303. initialize(state: NodeMaterialBuildState): void;
  119304. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  119305. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119306. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119307. protected _buildBlock(state: NodeMaterialBuildState): this;
  119308. }
  119309. }
  119310. declare module BABYLON {
  119311. /**
  119312. * Block used to pertub normals based on a normal map
  119313. */
  119314. export class PerturbNormalBlock extends NodeMaterialBlock {
  119315. private _tangentSpaceParameterName;
  119316. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  119317. invertX: boolean;
  119318. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  119319. invertY: boolean;
  119320. /**
  119321. * Create a new PerturbNormalBlock
  119322. * @param name defines the block name
  119323. */
  119324. constructor(name: string);
  119325. /**
  119326. * Gets the current class name
  119327. * @returns the class name
  119328. */
  119329. getClassName(): string;
  119330. /**
  119331. * Gets the world position input component
  119332. */
  119333. readonly worldPosition: NodeMaterialConnectionPoint;
  119334. /**
  119335. * Gets the world normal input component
  119336. */
  119337. readonly worldNormal: NodeMaterialConnectionPoint;
  119338. /**
  119339. * Gets the uv input component
  119340. */
  119341. readonly uv: NodeMaterialConnectionPoint;
  119342. /**
  119343. * Gets the normal map color input component
  119344. */
  119345. readonly normalMapColor: NodeMaterialConnectionPoint;
  119346. /**
  119347. * Gets the strength input component
  119348. */
  119349. readonly strength: NodeMaterialConnectionPoint;
  119350. /**
  119351. * Gets the output component
  119352. */
  119353. readonly output: NodeMaterialConnectionPoint;
  119354. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119355. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119356. autoConfigure(material: NodeMaterial): void;
  119357. protected _buildBlock(state: NodeMaterialBuildState): this;
  119358. protected _dumpPropertiesCode(): string;
  119359. serialize(): any;
  119360. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119361. }
  119362. }
  119363. declare module BABYLON {
  119364. /**
  119365. * Block used to add support for scene fog
  119366. */
  119367. export class FogBlock extends NodeMaterialBlock {
  119368. private _fogDistanceName;
  119369. private _fogParameters;
  119370. /**
  119371. * Create a new FogBlock
  119372. * @param name defines the block name
  119373. */
  119374. constructor(name: string);
  119375. /**
  119376. * Gets the current class name
  119377. * @returns the class name
  119378. */
  119379. getClassName(): string;
  119380. /**
  119381. * Gets the world position input component
  119382. */
  119383. readonly worldPosition: NodeMaterialConnectionPoint;
  119384. /**
  119385. * Gets the view input component
  119386. */
  119387. readonly view: NodeMaterialConnectionPoint;
  119388. /**
  119389. * Gets the color input component
  119390. */
  119391. readonly input: NodeMaterialConnectionPoint;
  119392. /**
  119393. * Gets the fog color input component
  119394. */
  119395. readonly fogColor: NodeMaterialConnectionPoint;
  119396. /**
  119397. * Gets the output component
  119398. */
  119399. readonly output: NodeMaterialConnectionPoint;
  119400. autoConfigure(material: NodeMaterial): void;
  119401. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119402. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119403. protected _buildBlock(state: NodeMaterialBuildState): this;
  119404. }
  119405. }
  119406. declare module BABYLON {
  119407. /**
  119408. * Block used to add light in the fragment shader
  119409. */
  119410. export class LightBlock extends NodeMaterialBlock {
  119411. private _lightId;
  119412. /**
  119413. * Gets or sets the light associated with this block
  119414. */
  119415. light: Nullable<Light>;
  119416. /**
  119417. * Create a new LightBlock
  119418. * @param name defines the block name
  119419. */
  119420. constructor(name: string);
  119421. /**
  119422. * Gets the current class name
  119423. * @returns the class name
  119424. */
  119425. getClassName(): string;
  119426. /**
  119427. * Gets the world position input component
  119428. */
  119429. readonly worldPosition: NodeMaterialConnectionPoint;
  119430. /**
  119431. * Gets the world normal input component
  119432. */
  119433. readonly worldNormal: NodeMaterialConnectionPoint;
  119434. /**
  119435. * Gets the camera (or eye) position component
  119436. */
  119437. readonly cameraPosition: NodeMaterialConnectionPoint;
  119438. /**
  119439. * Gets the diffuse output component
  119440. */
  119441. readonly diffuseOutput: NodeMaterialConnectionPoint;
  119442. /**
  119443. * Gets the specular output component
  119444. */
  119445. readonly specularOutput: NodeMaterialConnectionPoint;
  119446. autoConfigure(material: NodeMaterial): void;
  119447. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119448. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119449. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119450. private _injectVertexCode;
  119451. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119452. serialize(): any;
  119453. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119454. }
  119455. }
  119456. declare module BABYLON {
  119457. /**
  119458. * Block used to multiply 2 values
  119459. */
  119460. export class MultiplyBlock extends NodeMaterialBlock {
  119461. /**
  119462. * Creates a new MultiplyBlock
  119463. * @param name defines the block name
  119464. */
  119465. constructor(name: string);
  119466. /**
  119467. * Gets the current class name
  119468. * @returns the class name
  119469. */
  119470. getClassName(): string;
  119471. /**
  119472. * Gets the left operand input component
  119473. */
  119474. readonly left: NodeMaterialConnectionPoint;
  119475. /**
  119476. * Gets the right operand input component
  119477. */
  119478. readonly right: NodeMaterialConnectionPoint;
  119479. /**
  119480. * Gets the output component
  119481. */
  119482. readonly output: NodeMaterialConnectionPoint;
  119483. protected _buildBlock(state: NodeMaterialBuildState): this;
  119484. }
  119485. }
  119486. declare module BABYLON {
  119487. /**
  119488. * Block used to add 2 vectors
  119489. */
  119490. export class AddBlock extends NodeMaterialBlock {
  119491. /**
  119492. * Creates a new AddBlock
  119493. * @param name defines the block name
  119494. */
  119495. constructor(name: string);
  119496. /**
  119497. * Gets the current class name
  119498. * @returns the class name
  119499. */
  119500. getClassName(): string;
  119501. /**
  119502. * Gets the left operand input component
  119503. */
  119504. readonly left: NodeMaterialConnectionPoint;
  119505. /**
  119506. * Gets the right operand input component
  119507. */
  119508. readonly right: NodeMaterialConnectionPoint;
  119509. /**
  119510. * Gets the output component
  119511. */
  119512. readonly output: NodeMaterialConnectionPoint;
  119513. protected _buildBlock(state: NodeMaterialBuildState): this;
  119514. }
  119515. }
  119516. declare module BABYLON {
  119517. /**
  119518. * Block used to scale a vector by a float
  119519. */
  119520. export class ScaleBlock extends NodeMaterialBlock {
  119521. /**
  119522. * Creates a new ScaleBlock
  119523. * @param name defines the block name
  119524. */
  119525. constructor(name: string);
  119526. /**
  119527. * Gets the current class name
  119528. * @returns the class name
  119529. */
  119530. getClassName(): string;
  119531. /**
  119532. * Gets the input component
  119533. */
  119534. readonly input: NodeMaterialConnectionPoint;
  119535. /**
  119536. * Gets the factor input component
  119537. */
  119538. readonly factor: NodeMaterialConnectionPoint;
  119539. /**
  119540. * Gets the output component
  119541. */
  119542. readonly output: NodeMaterialConnectionPoint;
  119543. protected _buildBlock(state: NodeMaterialBuildState): this;
  119544. }
  119545. }
  119546. declare module BABYLON {
  119547. /**
  119548. * Block used to clamp a float
  119549. */
  119550. export class ClampBlock extends NodeMaterialBlock {
  119551. /** Gets or sets the minimum range */
  119552. minimum: number;
  119553. /** Gets or sets the maximum range */
  119554. maximum: number;
  119555. /**
  119556. * Creates a new ClampBlock
  119557. * @param name defines the block name
  119558. */
  119559. constructor(name: string);
  119560. /**
  119561. * Gets the current class name
  119562. * @returns the class name
  119563. */
  119564. getClassName(): string;
  119565. /**
  119566. * Gets the value input component
  119567. */
  119568. readonly value: NodeMaterialConnectionPoint;
  119569. /**
  119570. * Gets the output component
  119571. */
  119572. readonly output: NodeMaterialConnectionPoint;
  119573. protected _buildBlock(state: NodeMaterialBuildState): this;
  119574. protected _dumpPropertiesCode(): string;
  119575. serialize(): any;
  119576. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119577. }
  119578. }
  119579. declare module BABYLON {
  119580. /**
  119581. * Block used to apply a cross product between 2 vectors
  119582. */
  119583. export class CrossBlock extends NodeMaterialBlock {
  119584. /**
  119585. * Creates a new CrossBlock
  119586. * @param name defines the block name
  119587. */
  119588. constructor(name: string);
  119589. /**
  119590. * Gets the current class name
  119591. * @returns the class name
  119592. */
  119593. getClassName(): string;
  119594. /**
  119595. * Gets the left operand input component
  119596. */
  119597. readonly left: NodeMaterialConnectionPoint;
  119598. /**
  119599. * Gets the right operand input component
  119600. */
  119601. readonly right: NodeMaterialConnectionPoint;
  119602. /**
  119603. * Gets the output component
  119604. */
  119605. readonly output: NodeMaterialConnectionPoint;
  119606. protected _buildBlock(state: NodeMaterialBuildState): this;
  119607. }
  119608. }
  119609. declare module BABYLON {
  119610. /**
  119611. * Block used to apply a dot product between 2 vectors
  119612. */
  119613. export class DotBlock extends NodeMaterialBlock {
  119614. /**
  119615. * Creates a new DotBlock
  119616. * @param name defines the block name
  119617. */
  119618. constructor(name: string);
  119619. /**
  119620. * Gets the current class name
  119621. * @returns the class name
  119622. */
  119623. getClassName(): string;
  119624. /**
  119625. * Gets the left operand input component
  119626. */
  119627. readonly left: NodeMaterialConnectionPoint;
  119628. /**
  119629. * Gets the right operand input component
  119630. */
  119631. readonly right: NodeMaterialConnectionPoint;
  119632. /**
  119633. * Gets the output component
  119634. */
  119635. readonly output: NodeMaterialConnectionPoint;
  119636. protected _buildBlock(state: NodeMaterialBuildState): this;
  119637. }
  119638. }
  119639. declare module BABYLON {
  119640. /**
  119641. * Block used to remap a float from a range to a new one
  119642. */
  119643. export class RemapBlock extends NodeMaterialBlock {
  119644. /**
  119645. * Gets or sets the source range
  119646. */
  119647. sourceRange: Vector2;
  119648. /**
  119649. * Gets or sets the target range
  119650. */
  119651. targetRange: Vector2;
  119652. /**
  119653. * Creates a new RemapBlock
  119654. * @param name defines the block name
  119655. */
  119656. constructor(name: string);
  119657. /**
  119658. * Gets the current class name
  119659. * @returns the class name
  119660. */
  119661. getClassName(): string;
  119662. /**
  119663. * Gets the input component
  119664. */
  119665. readonly input: NodeMaterialConnectionPoint;
  119666. /**
  119667. * Gets the source min input component
  119668. */
  119669. readonly sourceMin: NodeMaterialConnectionPoint;
  119670. /**
  119671. * Gets the source max input component
  119672. */
  119673. readonly sourceMax: NodeMaterialConnectionPoint;
  119674. /**
  119675. * Gets the target min input component
  119676. */
  119677. readonly targetMin: NodeMaterialConnectionPoint;
  119678. /**
  119679. * Gets the target max input component
  119680. */
  119681. readonly targetMax: NodeMaterialConnectionPoint;
  119682. /**
  119683. * Gets the output component
  119684. */
  119685. readonly output: NodeMaterialConnectionPoint;
  119686. protected _buildBlock(state: NodeMaterialBuildState): this;
  119687. protected _dumpPropertiesCode(): string;
  119688. serialize(): any;
  119689. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119690. }
  119691. }
  119692. declare module BABYLON {
  119693. /**
  119694. * Block used to normalize a vector
  119695. */
  119696. export class NormalizeBlock extends NodeMaterialBlock {
  119697. /**
  119698. * Creates a new NormalizeBlock
  119699. * @param name defines the block name
  119700. */
  119701. constructor(name: string);
  119702. /**
  119703. * Gets the current class name
  119704. * @returns the class name
  119705. */
  119706. getClassName(): string;
  119707. /**
  119708. * Gets the input component
  119709. */
  119710. readonly input: NodeMaterialConnectionPoint;
  119711. /**
  119712. * Gets the output component
  119713. */
  119714. readonly output: NodeMaterialConnectionPoint;
  119715. protected _buildBlock(state: NodeMaterialBuildState): this;
  119716. }
  119717. }
  119718. declare module BABYLON {
  119719. /**
  119720. * Operations supported by the Trigonometry block
  119721. */
  119722. export enum TrigonometryBlockOperations {
  119723. /** Cos */
  119724. Cos = 0,
  119725. /** Sin */
  119726. Sin = 1,
  119727. /** Abs */
  119728. Abs = 2,
  119729. /** Exp */
  119730. Exp = 3,
  119731. /** Exp2 */
  119732. Exp2 = 4,
  119733. /** Round */
  119734. Round = 5,
  119735. /** Floor */
  119736. Floor = 6,
  119737. /** Ceiling */
  119738. Ceiling = 7,
  119739. /** Square root */
  119740. Sqrt = 8
  119741. }
  119742. /**
  119743. * Block used to apply trigonometry operation to floats
  119744. */
  119745. export class TrigonometryBlock extends NodeMaterialBlock {
  119746. /**
  119747. * Gets or sets the operation applied by the block
  119748. */
  119749. operation: TrigonometryBlockOperations;
  119750. /**
  119751. * Creates a new TrigonometryBlock
  119752. * @param name defines the block name
  119753. */
  119754. constructor(name: string);
  119755. /**
  119756. * Gets the current class name
  119757. * @returns the class name
  119758. */
  119759. getClassName(): string;
  119760. /**
  119761. * Gets the input component
  119762. */
  119763. readonly input: NodeMaterialConnectionPoint;
  119764. /**
  119765. * Gets the output component
  119766. */
  119767. readonly output: NodeMaterialConnectionPoint;
  119768. protected _buildBlock(state: NodeMaterialBuildState): this;
  119769. serialize(): any;
  119770. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119771. }
  119772. }
  119773. declare module BABYLON {
  119774. /**
  119775. * Block used to create a Color3/4 out of individual inputs (one for each component)
  119776. */
  119777. export class ColorMergerBlock extends NodeMaterialBlock {
  119778. /**
  119779. * Create a new ColorMergerBlock
  119780. * @param name defines the block name
  119781. */
  119782. constructor(name: string);
  119783. /**
  119784. * Gets the current class name
  119785. * @returns the class name
  119786. */
  119787. getClassName(): string;
  119788. /**
  119789. * Gets the r component (input)
  119790. */
  119791. readonly r: NodeMaterialConnectionPoint;
  119792. /**
  119793. * Gets the g component (input)
  119794. */
  119795. readonly g: NodeMaterialConnectionPoint;
  119796. /**
  119797. * Gets the b component (input)
  119798. */
  119799. readonly b: NodeMaterialConnectionPoint;
  119800. /**
  119801. * Gets the a component (input)
  119802. */
  119803. readonly a: NodeMaterialConnectionPoint;
  119804. /**
  119805. * Gets the rgba component (output)
  119806. */
  119807. readonly rgba: NodeMaterialConnectionPoint;
  119808. /**
  119809. * Gets the rgb component (output)
  119810. */
  119811. readonly rgb: NodeMaterialConnectionPoint;
  119812. protected _buildBlock(state: NodeMaterialBuildState): this;
  119813. }
  119814. }
  119815. declare module BABYLON {
  119816. /**
  119817. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  119818. */
  119819. export class VectorMergerBlock extends NodeMaterialBlock {
  119820. /**
  119821. * Create a new VectorMergerBlock
  119822. * @param name defines the block name
  119823. */
  119824. constructor(name: string);
  119825. /**
  119826. * Gets the current class name
  119827. * @returns the class name
  119828. */
  119829. getClassName(): string;
  119830. /**
  119831. * Gets the x component (input)
  119832. */
  119833. readonly x: NodeMaterialConnectionPoint;
  119834. /**
  119835. * Gets the y component (input)
  119836. */
  119837. readonly y: NodeMaterialConnectionPoint;
  119838. /**
  119839. * Gets the z component (input)
  119840. */
  119841. readonly z: NodeMaterialConnectionPoint;
  119842. /**
  119843. * Gets the w component (input)
  119844. */
  119845. readonly w: NodeMaterialConnectionPoint;
  119846. /**
  119847. * Gets the xyzw component (output)
  119848. */
  119849. readonly xyzw: NodeMaterialConnectionPoint;
  119850. /**
  119851. * Gets the xyz component (output)
  119852. */
  119853. readonly xyz: NodeMaterialConnectionPoint;
  119854. /**
  119855. * Gets the xy component (output)
  119856. */
  119857. readonly xy: NodeMaterialConnectionPoint;
  119858. protected _buildBlock(state: NodeMaterialBuildState): this;
  119859. }
  119860. }
  119861. declare module BABYLON {
  119862. /**
  119863. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  119864. */
  119865. export class ColorSplitterBlock extends NodeMaterialBlock {
  119866. /**
  119867. * Create a new ColorSplitterBlock
  119868. * @param name defines the block name
  119869. */
  119870. constructor(name: string);
  119871. /**
  119872. * Gets the current class name
  119873. * @returns the class name
  119874. */
  119875. getClassName(): string;
  119876. /**
  119877. * Gets the rgba component (input)
  119878. */
  119879. readonly rgba: NodeMaterialConnectionPoint;
  119880. /**
  119881. * Gets the rgb component (input)
  119882. */
  119883. readonly rgbIn: NodeMaterialConnectionPoint;
  119884. /**
  119885. * Gets the rgb component (output)
  119886. */
  119887. readonly rgbOut: NodeMaterialConnectionPoint;
  119888. /**
  119889. * Gets the r component (output)
  119890. */
  119891. readonly r: NodeMaterialConnectionPoint;
  119892. /**
  119893. * Gets the g component (output)
  119894. */
  119895. readonly g: NodeMaterialConnectionPoint;
  119896. /**
  119897. * Gets the b component (output)
  119898. */
  119899. readonly b: NodeMaterialConnectionPoint;
  119900. /**
  119901. * Gets the a component (output)
  119902. */
  119903. readonly a: NodeMaterialConnectionPoint;
  119904. protected _inputRename(name: string): string;
  119905. protected _outputRename(name: string): string;
  119906. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119907. }
  119908. }
  119909. declare module BABYLON {
  119910. /**
  119911. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  119912. */
  119913. export class VectorSplitterBlock extends NodeMaterialBlock {
  119914. /**
  119915. * Create a new VectorSplitterBlock
  119916. * @param name defines the block name
  119917. */
  119918. constructor(name: string);
  119919. /**
  119920. * Gets the current class name
  119921. * @returns the class name
  119922. */
  119923. getClassName(): string;
  119924. /**
  119925. * Gets the xyzw component (input)
  119926. */
  119927. readonly xyzw: NodeMaterialConnectionPoint;
  119928. /**
  119929. * Gets the xyz component (input)
  119930. */
  119931. readonly xyzIn: NodeMaterialConnectionPoint;
  119932. /**
  119933. * Gets the xy component (input)
  119934. */
  119935. readonly xyIn: NodeMaterialConnectionPoint;
  119936. /**
  119937. * Gets the xyz component (output)
  119938. */
  119939. readonly xyzOut: NodeMaterialConnectionPoint;
  119940. /**
  119941. * Gets the xy component (output)
  119942. */
  119943. readonly xyOut: NodeMaterialConnectionPoint;
  119944. /**
  119945. * Gets the x component (output)
  119946. */
  119947. readonly x: NodeMaterialConnectionPoint;
  119948. /**
  119949. * Gets the y component (output)
  119950. */
  119951. readonly y: NodeMaterialConnectionPoint;
  119952. /**
  119953. * Gets the z component (output)
  119954. */
  119955. readonly z: NodeMaterialConnectionPoint;
  119956. /**
  119957. * Gets the w component (output)
  119958. */
  119959. readonly w: NodeMaterialConnectionPoint;
  119960. protected _inputRename(name: string): string;
  119961. protected _outputRename(name: string): string;
  119962. protected _buildBlock(state: NodeMaterialBuildState): this;
  119963. }
  119964. }
  119965. declare module BABYLON {
  119966. /**
  119967. * Block used to lerp 2 values
  119968. */
  119969. export class LerpBlock extends NodeMaterialBlock {
  119970. /**
  119971. * Creates a new LerpBlock
  119972. * @param name defines the block name
  119973. */
  119974. constructor(name: string);
  119975. /**
  119976. * Gets the current class name
  119977. * @returns the class name
  119978. */
  119979. getClassName(): string;
  119980. /**
  119981. * Gets the left operand input component
  119982. */
  119983. readonly left: NodeMaterialConnectionPoint;
  119984. /**
  119985. * Gets the right operand input component
  119986. */
  119987. readonly right: NodeMaterialConnectionPoint;
  119988. /**
  119989. * Gets the gradient operand input component
  119990. */
  119991. readonly gradient: NodeMaterialConnectionPoint;
  119992. /**
  119993. * Gets the output component
  119994. */
  119995. readonly output: NodeMaterialConnectionPoint;
  119996. protected _buildBlock(state: NodeMaterialBuildState): this;
  119997. }
  119998. }
  119999. declare module BABYLON {
  120000. /**
  120001. * Block used to divide 2 vectors
  120002. */
  120003. export class DivideBlock extends NodeMaterialBlock {
  120004. /**
  120005. * Creates a new DivideBlock
  120006. * @param name defines the block name
  120007. */
  120008. constructor(name: string);
  120009. /**
  120010. * Gets the current class name
  120011. * @returns the class name
  120012. */
  120013. getClassName(): string;
  120014. /**
  120015. * Gets the left operand input component
  120016. */
  120017. readonly left: NodeMaterialConnectionPoint;
  120018. /**
  120019. * Gets the right operand input component
  120020. */
  120021. readonly right: NodeMaterialConnectionPoint;
  120022. /**
  120023. * Gets the output component
  120024. */
  120025. readonly output: NodeMaterialConnectionPoint;
  120026. protected _buildBlock(state: NodeMaterialBuildState): this;
  120027. }
  120028. }
  120029. declare module BABYLON {
  120030. /**
  120031. * Block used to subtract 2 vectors
  120032. */
  120033. export class SubtractBlock extends NodeMaterialBlock {
  120034. /**
  120035. * Creates a new SubtractBlock
  120036. * @param name defines the block name
  120037. */
  120038. constructor(name: string);
  120039. /**
  120040. * Gets the current class name
  120041. * @returns the class name
  120042. */
  120043. getClassName(): string;
  120044. /**
  120045. * Gets the left operand input component
  120046. */
  120047. readonly left: NodeMaterialConnectionPoint;
  120048. /**
  120049. * Gets the right operand input component
  120050. */
  120051. readonly right: NodeMaterialConnectionPoint;
  120052. /**
  120053. * Gets the output component
  120054. */
  120055. readonly output: NodeMaterialConnectionPoint;
  120056. protected _buildBlock(state: NodeMaterialBuildState): this;
  120057. }
  120058. }
  120059. declare module BABYLON {
  120060. /**
  120061. * Block used to step a value
  120062. */
  120063. export class StepBlock extends NodeMaterialBlock {
  120064. /**
  120065. * Creates a new AddBlock
  120066. * @param name defines the block name
  120067. */
  120068. constructor(name: string);
  120069. /**
  120070. * Gets the current class name
  120071. * @returns the class name
  120072. */
  120073. getClassName(): string;
  120074. /**
  120075. * Gets the value operand input component
  120076. */
  120077. readonly value: NodeMaterialConnectionPoint;
  120078. /**
  120079. * Gets the edge operand input component
  120080. */
  120081. readonly edge: NodeMaterialConnectionPoint;
  120082. /**
  120083. * Gets the output component
  120084. */
  120085. readonly output: NodeMaterialConnectionPoint;
  120086. protected _buildBlock(state: NodeMaterialBuildState): this;
  120087. }
  120088. }
  120089. declare module BABYLON {
  120090. /**
  120091. * Block used to get the opposite (1 - x) of a value
  120092. */
  120093. export class OneMinusBlock extends NodeMaterialBlock {
  120094. /**
  120095. * Creates a new OneMinusBlock
  120096. * @param name defines the block name
  120097. */
  120098. constructor(name: string);
  120099. /**
  120100. * Gets the current class name
  120101. * @returns the class name
  120102. */
  120103. getClassName(): string;
  120104. /**
  120105. * Gets the input component
  120106. */
  120107. readonly input: NodeMaterialConnectionPoint;
  120108. /**
  120109. * Gets the output component
  120110. */
  120111. readonly output: NodeMaterialConnectionPoint;
  120112. protected _buildBlock(state: NodeMaterialBuildState): this;
  120113. }
  120114. }
  120115. declare module BABYLON {
  120116. /**
  120117. * Block used to get the view direction
  120118. */
  120119. export class ViewDirectionBlock extends NodeMaterialBlock {
  120120. /**
  120121. * Creates a new ViewDirectionBlock
  120122. * @param name defines the block name
  120123. */
  120124. constructor(name: string);
  120125. /**
  120126. * Gets the current class name
  120127. * @returns the class name
  120128. */
  120129. getClassName(): string;
  120130. /**
  120131. * Gets the world position component
  120132. */
  120133. readonly worldPosition: NodeMaterialConnectionPoint;
  120134. /**
  120135. * Gets the camera position component
  120136. */
  120137. readonly cameraPosition: NodeMaterialConnectionPoint;
  120138. /**
  120139. * Gets the output component
  120140. */
  120141. readonly output: NodeMaterialConnectionPoint;
  120142. autoConfigure(material: NodeMaterial): void;
  120143. protected _buildBlock(state: NodeMaterialBuildState): this;
  120144. }
  120145. }
  120146. declare module BABYLON {
  120147. /**
  120148. * Block used to compute fresnel value
  120149. */
  120150. export class FresnelBlock extends NodeMaterialBlock {
  120151. /**
  120152. * Create a new FresnelBlock
  120153. * @param name defines the block name
  120154. */
  120155. constructor(name: string);
  120156. /**
  120157. * Gets the current class name
  120158. * @returns the class name
  120159. */
  120160. getClassName(): string;
  120161. /**
  120162. * Gets the world normal input component
  120163. */
  120164. readonly worldNormal: NodeMaterialConnectionPoint;
  120165. /**
  120166. * Gets the view direction input component
  120167. */
  120168. readonly viewDirection: NodeMaterialConnectionPoint;
  120169. /**
  120170. * Gets the bias input component
  120171. */
  120172. readonly bias: NodeMaterialConnectionPoint;
  120173. /**
  120174. * Gets the camera (or eye) position component
  120175. */
  120176. readonly power: NodeMaterialConnectionPoint;
  120177. /**
  120178. * Gets the fresnel output component
  120179. */
  120180. readonly fresnel: NodeMaterialConnectionPoint;
  120181. autoConfigure(material: NodeMaterial): void;
  120182. protected _buildBlock(state: NodeMaterialBuildState): this;
  120183. }
  120184. }
  120185. declare module BABYLON {
  120186. /**
  120187. * Block used to get the max of 2 values
  120188. */
  120189. export class MaxBlock extends NodeMaterialBlock {
  120190. /**
  120191. * Creates a new MaxBlock
  120192. * @param name defines the block name
  120193. */
  120194. constructor(name: string);
  120195. /**
  120196. * Gets the current class name
  120197. * @returns the class name
  120198. */
  120199. getClassName(): string;
  120200. /**
  120201. * Gets the left operand input component
  120202. */
  120203. readonly left: NodeMaterialConnectionPoint;
  120204. /**
  120205. * Gets the right operand input component
  120206. */
  120207. readonly right: NodeMaterialConnectionPoint;
  120208. /**
  120209. * Gets the output component
  120210. */
  120211. readonly output: NodeMaterialConnectionPoint;
  120212. protected _buildBlock(state: NodeMaterialBuildState): this;
  120213. }
  120214. }
  120215. declare module BABYLON {
  120216. /**
  120217. * Block used to get the min of 2 values
  120218. */
  120219. export class MinBlock extends NodeMaterialBlock {
  120220. /**
  120221. * Creates a new MinBlock
  120222. * @param name defines the block name
  120223. */
  120224. constructor(name: string);
  120225. /**
  120226. * Gets the current class name
  120227. * @returns the class name
  120228. */
  120229. getClassName(): string;
  120230. /**
  120231. * Gets the left operand input component
  120232. */
  120233. readonly left: NodeMaterialConnectionPoint;
  120234. /**
  120235. * Gets the right operand input component
  120236. */
  120237. readonly right: NodeMaterialConnectionPoint;
  120238. /**
  120239. * Gets the output component
  120240. */
  120241. readonly output: NodeMaterialConnectionPoint;
  120242. protected _buildBlock(state: NodeMaterialBuildState): this;
  120243. }
  120244. }
  120245. declare module BABYLON {
  120246. /**
  120247. * Block used to get the distance between 2 values
  120248. */
  120249. export class DistanceBlock extends NodeMaterialBlock {
  120250. /**
  120251. * Creates a new DistanceBlock
  120252. * @param name defines the block name
  120253. */
  120254. constructor(name: string);
  120255. /**
  120256. * Gets the current class name
  120257. * @returns the class name
  120258. */
  120259. getClassName(): string;
  120260. /**
  120261. * Gets the left operand input component
  120262. */
  120263. readonly left: NodeMaterialConnectionPoint;
  120264. /**
  120265. * Gets the right operand input component
  120266. */
  120267. readonly right: NodeMaterialConnectionPoint;
  120268. /**
  120269. * Gets the output component
  120270. */
  120271. readonly output: NodeMaterialConnectionPoint;
  120272. protected _buildBlock(state: NodeMaterialBuildState): this;
  120273. }
  120274. }
  120275. declare module BABYLON {
  120276. /**
  120277. * Block used to get the length of a vector
  120278. */
  120279. export class LengthBlock extends NodeMaterialBlock {
  120280. /**
  120281. * Creates a new LengthBlock
  120282. * @param name defines the block name
  120283. */
  120284. constructor(name: string);
  120285. /**
  120286. * Gets the current class name
  120287. * @returns the class name
  120288. */
  120289. getClassName(): string;
  120290. /**
  120291. * Gets the value input component
  120292. */
  120293. readonly value: NodeMaterialConnectionPoint;
  120294. /**
  120295. * Gets the output component
  120296. */
  120297. readonly output: NodeMaterialConnectionPoint;
  120298. protected _buildBlock(state: NodeMaterialBuildState): this;
  120299. }
  120300. }
  120301. declare module BABYLON {
  120302. /**
  120303. * Block used to get negative version of a value (i.e. x * -1)
  120304. */
  120305. export class NegateBlock extends NodeMaterialBlock {
  120306. /**
  120307. * Creates a new NegateBlock
  120308. * @param name defines the block name
  120309. */
  120310. constructor(name: string);
  120311. /**
  120312. * Gets the current class name
  120313. * @returns the class name
  120314. */
  120315. getClassName(): string;
  120316. /**
  120317. * Gets the value input component
  120318. */
  120319. readonly value: NodeMaterialConnectionPoint;
  120320. /**
  120321. * Gets the output component
  120322. */
  120323. readonly output: NodeMaterialConnectionPoint;
  120324. protected _buildBlock(state: NodeMaterialBuildState): this;
  120325. }
  120326. }
  120327. declare module BABYLON {
  120328. /**
  120329. * Effect Render Options
  120330. */
  120331. export interface IEffectRendererOptions {
  120332. /**
  120333. * Defines the vertices positions.
  120334. */
  120335. positions?: number[];
  120336. /**
  120337. * Defines the indices.
  120338. */
  120339. indices?: number[];
  120340. }
  120341. /**
  120342. * Helper class to render one or more effects
  120343. */
  120344. export class EffectRenderer {
  120345. private engine;
  120346. private static _DefaultOptions;
  120347. private _vertexBuffers;
  120348. private _indexBuffer;
  120349. private _ringBufferIndex;
  120350. private _ringScreenBuffer;
  120351. private _fullscreenViewport;
  120352. private _getNextFrameBuffer;
  120353. /**
  120354. * Creates an effect renderer
  120355. * @param engine the engine to use for rendering
  120356. * @param options defines the options of the effect renderer
  120357. */
  120358. constructor(engine: Engine, options?: IEffectRendererOptions);
  120359. /**
  120360. * Sets the current viewport in normalized coordinates 0-1
  120361. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  120362. */
  120363. setViewport(viewport?: Viewport): void;
  120364. /**
  120365. * Binds the embedded attributes buffer to the effect.
  120366. * @param effect Defines the effect to bind the attributes for
  120367. */
  120368. bindBuffers(effect: Effect): void;
  120369. /**
  120370. * Sets the current effect wrapper to use during draw.
  120371. * The effect needs to be ready before calling this api.
  120372. * This also sets the default full screen position attribute.
  120373. * @param effectWrapper Defines the effect to draw with
  120374. */
  120375. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  120376. /**
  120377. * Draws a full screen quad.
  120378. */
  120379. draw(): void;
  120380. /**
  120381. * renders one or more effects to a specified texture
  120382. * @param effectWrappers list of effects to renderer
  120383. * @param outputTexture texture to draw to, if null it will render to the screen
  120384. */
  120385. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  120386. /**
  120387. * Disposes of the effect renderer
  120388. */
  120389. dispose(): void;
  120390. }
  120391. /**
  120392. * Options to create an EffectWrapper
  120393. */
  120394. interface EffectWrapperCreationOptions {
  120395. /**
  120396. * Engine to use to create the effect
  120397. */
  120398. engine: Engine;
  120399. /**
  120400. * Fragment shader for the effect
  120401. */
  120402. fragmentShader: string;
  120403. /**
  120404. * Vertex shader for the effect
  120405. */
  120406. vertexShader?: string;
  120407. /**
  120408. * Attributes to use in the shader
  120409. */
  120410. attributeNames?: Array<string>;
  120411. /**
  120412. * Uniforms to use in the shader
  120413. */
  120414. uniformNames?: Array<string>;
  120415. /**
  120416. * Texture sampler names to use in the shader
  120417. */
  120418. samplerNames?: Array<string>;
  120419. /**
  120420. * The friendly name of the effect displayed in Spector.
  120421. */
  120422. name?: string;
  120423. }
  120424. /**
  120425. * Wraps an effect to be used for rendering
  120426. */
  120427. export class EffectWrapper {
  120428. /**
  120429. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  120430. */
  120431. onApplyObservable: Observable<{}>;
  120432. /**
  120433. * The underlying effect
  120434. */
  120435. effect: Effect;
  120436. /**
  120437. * Creates an effect to be renderer
  120438. * @param creationOptions options to create the effect
  120439. */
  120440. constructor(creationOptions: EffectWrapperCreationOptions);
  120441. /**
  120442. * Disposes of the effect wrapper
  120443. */
  120444. dispose(): void;
  120445. }
  120446. }
  120447. declare module BABYLON {
  120448. /**
  120449. * Helper class to push actions to a pool of workers.
  120450. */
  120451. export class WorkerPool implements IDisposable {
  120452. private _workerInfos;
  120453. private _pendingActions;
  120454. /**
  120455. * Constructor
  120456. * @param workers Array of workers to use for actions
  120457. */
  120458. constructor(workers: Array<Worker>);
  120459. /**
  120460. * Terminates all workers and clears any pending actions.
  120461. */
  120462. dispose(): void;
  120463. /**
  120464. * Pushes an action to the worker pool. If all the workers are active, the action will be
  120465. * pended until a worker has completed its action.
  120466. * @param action The action to perform. Call onComplete when the action is complete.
  120467. */
  120468. push(action: (worker: Worker, onComplete: () => void) => void): void;
  120469. private _execute;
  120470. }
  120471. }
  120472. declare module BABYLON {
  120473. /**
  120474. * Configuration for Draco compression
  120475. */
  120476. export interface IDracoCompressionConfiguration {
  120477. /**
  120478. * Configuration for the decoder.
  120479. */
  120480. decoder: {
  120481. /**
  120482. * The url to the WebAssembly module.
  120483. */
  120484. wasmUrl?: string;
  120485. /**
  120486. * The url to the WebAssembly binary.
  120487. */
  120488. wasmBinaryUrl?: string;
  120489. /**
  120490. * The url to the fallback JavaScript module.
  120491. */
  120492. fallbackUrl?: string;
  120493. };
  120494. }
  120495. /**
  120496. * Draco compression (https://google.github.io/draco/)
  120497. *
  120498. * This class wraps the Draco module.
  120499. *
  120500. * **Encoder**
  120501. *
  120502. * The encoder is not currently implemented.
  120503. *
  120504. * **Decoder**
  120505. *
  120506. * 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.
  120507. *
  120508. * To update the configuration, use the following code:
  120509. * ```javascript
  120510. * DracoCompression.Configuration = {
  120511. * decoder: {
  120512. * wasmUrl: "<url to the WebAssembly library>",
  120513. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  120514. * fallbackUrl: "<url to the fallback JavaScript library>",
  120515. * }
  120516. * };
  120517. * ```
  120518. *
  120519. * 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.
  120520. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  120521. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  120522. *
  120523. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  120524. * ```javascript
  120525. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  120526. * ```
  120527. *
  120528. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  120529. */
  120530. export class DracoCompression implements IDisposable {
  120531. private _workerPoolPromise?;
  120532. private _decoderModulePromise?;
  120533. /**
  120534. * The configuration. Defaults to the following urls:
  120535. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  120536. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  120537. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  120538. */
  120539. static Configuration: IDracoCompressionConfiguration;
  120540. /**
  120541. * Returns true if the decoder configuration is available.
  120542. */
  120543. static readonly DecoderAvailable: boolean;
  120544. /**
  120545. * Default number of workers to create when creating the draco compression object.
  120546. */
  120547. static DefaultNumWorkers: number;
  120548. private static GetDefaultNumWorkers;
  120549. private static _Default;
  120550. /**
  120551. * Default instance for the draco compression object.
  120552. */
  120553. static readonly Default: DracoCompression;
  120554. /**
  120555. * Constructor
  120556. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  120557. */
  120558. constructor(numWorkers?: number);
  120559. /**
  120560. * Stop all async operations and release resources.
  120561. */
  120562. dispose(): void;
  120563. /**
  120564. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  120565. * @returns a promise that resolves when ready
  120566. */
  120567. whenReadyAsync(): Promise<void>;
  120568. /**
  120569. * Decode Draco compressed mesh data to vertex data.
  120570. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  120571. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  120572. * @returns A promise that resolves with the decoded vertex data
  120573. */
  120574. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  120575. [kind: string]: number;
  120576. }): Promise<VertexData>;
  120577. }
  120578. }
  120579. declare module BABYLON {
  120580. /**
  120581. * Class for building Constructive Solid Geometry
  120582. */
  120583. export class CSG {
  120584. private polygons;
  120585. /**
  120586. * The world matrix
  120587. */
  120588. matrix: Matrix;
  120589. /**
  120590. * Stores the position
  120591. */
  120592. position: Vector3;
  120593. /**
  120594. * Stores the rotation
  120595. */
  120596. rotation: Vector3;
  120597. /**
  120598. * Stores the rotation quaternion
  120599. */
  120600. rotationQuaternion: Nullable<Quaternion>;
  120601. /**
  120602. * Stores the scaling vector
  120603. */
  120604. scaling: Vector3;
  120605. /**
  120606. * Convert the Mesh to CSG
  120607. * @param mesh The Mesh to convert to CSG
  120608. * @returns A new CSG from the Mesh
  120609. */
  120610. static FromMesh(mesh: Mesh): CSG;
  120611. /**
  120612. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  120613. * @param polygons Polygons used to construct a CSG solid
  120614. */
  120615. private static FromPolygons;
  120616. /**
  120617. * Clones, or makes a deep copy, of the CSG
  120618. * @returns A new CSG
  120619. */
  120620. clone(): CSG;
  120621. /**
  120622. * Unions this CSG with another CSG
  120623. * @param csg The CSG to union against this CSG
  120624. * @returns The unioned CSG
  120625. */
  120626. union(csg: CSG): CSG;
  120627. /**
  120628. * Unions this CSG with another CSG in place
  120629. * @param csg The CSG to union against this CSG
  120630. */
  120631. unionInPlace(csg: CSG): void;
  120632. /**
  120633. * Subtracts this CSG with another CSG
  120634. * @param csg The CSG to subtract against this CSG
  120635. * @returns A new CSG
  120636. */
  120637. subtract(csg: CSG): CSG;
  120638. /**
  120639. * Subtracts this CSG with another CSG in place
  120640. * @param csg The CSG to subtact against this CSG
  120641. */
  120642. subtractInPlace(csg: CSG): void;
  120643. /**
  120644. * Intersect this CSG with another CSG
  120645. * @param csg The CSG to intersect against this CSG
  120646. * @returns A new CSG
  120647. */
  120648. intersect(csg: CSG): CSG;
  120649. /**
  120650. * Intersects this CSG with another CSG in place
  120651. * @param csg The CSG to intersect against this CSG
  120652. */
  120653. intersectInPlace(csg: CSG): void;
  120654. /**
  120655. * Return a new CSG solid with solid and empty space switched. This solid is
  120656. * not modified.
  120657. * @returns A new CSG solid with solid and empty space switched
  120658. */
  120659. inverse(): CSG;
  120660. /**
  120661. * Inverses the CSG in place
  120662. */
  120663. inverseInPlace(): void;
  120664. /**
  120665. * This is used to keep meshes transformations so they can be restored
  120666. * when we build back a Babylon Mesh
  120667. * NB : All CSG operations are performed in world coordinates
  120668. * @param csg The CSG to copy the transform attributes from
  120669. * @returns This CSG
  120670. */
  120671. copyTransformAttributes(csg: CSG): CSG;
  120672. /**
  120673. * Build Raw mesh from CSG
  120674. * Coordinates here are in world space
  120675. * @param name The name of the mesh geometry
  120676. * @param scene The Scene
  120677. * @param keepSubMeshes Specifies if the submeshes should be kept
  120678. * @returns A new Mesh
  120679. */
  120680. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  120681. /**
  120682. * Build Mesh from CSG taking material and transforms into account
  120683. * @param name The name of the Mesh
  120684. * @param material The material of the Mesh
  120685. * @param scene The Scene
  120686. * @param keepSubMeshes Specifies if submeshes should be kept
  120687. * @returns The new Mesh
  120688. */
  120689. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  120690. }
  120691. }
  120692. declare module BABYLON {
  120693. /**
  120694. * Class used to create a trail following a mesh
  120695. */
  120696. export class TrailMesh extends Mesh {
  120697. private _generator;
  120698. private _autoStart;
  120699. private _running;
  120700. private _diameter;
  120701. private _length;
  120702. private _sectionPolygonPointsCount;
  120703. private _sectionVectors;
  120704. private _sectionNormalVectors;
  120705. private _beforeRenderObserver;
  120706. /**
  120707. * @constructor
  120708. * @param name The value used by scene.getMeshByName() to do a lookup.
  120709. * @param generator The mesh to generate a trail.
  120710. * @param scene The scene to add this mesh to.
  120711. * @param diameter Diameter of trailing mesh. Default is 1.
  120712. * @param length Length of trailing mesh. Default is 60.
  120713. * @param autoStart Automatically start trailing mesh. Default true.
  120714. */
  120715. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  120716. /**
  120717. * "TrailMesh"
  120718. * @returns "TrailMesh"
  120719. */
  120720. getClassName(): string;
  120721. private _createMesh;
  120722. /**
  120723. * Start trailing mesh.
  120724. */
  120725. start(): void;
  120726. /**
  120727. * Stop trailing mesh.
  120728. */
  120729. stop(): void;
  120730. /**
  120731. * Update trailing mesh geometry.
  120732. */
  120733. update(): void;
  120734. /**
  120735. * Returns a new TrailMesh object.
  120736. * @param name is a string, the name given to the new mesh
  120737. * @param newGenerator use new generator object for cloned trail mesh
  120738. * @returns a new mesh
  120739. */
  120740. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  120741. /**
  120742. * Serializes this trail mesh
  120743. * @param serializationObject object to write serialization to
  120744. */
  120745. serialize(serializationObject: any): void;
  120746. /**
  120747. * Parses a serialized trail mesh
  120748. * @param parsedMesh the serialized mesh
  120749. * @param scene the scene to create the trail mesh in
  120750. * @returns the created trail mesh
  120751. */
  120752. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  120753. }
  120754. }
  120755. declare module BABYLON {
  120756. /**
  120757. * Class containing static functions to help procedurally build meshes
  120758. */
  120759. export class TiledBoxBuilder {
  120760. /**
  120761. * Creates a box mesh
  120762. * 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)
  120763. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  120764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120765. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120767. * @param name defines the name of the mesh
  120768. * @param options defines the options used to create the mesh
  120769. * @param scene defines the hosting scene
  120770. * @returns the box mesh
  120771. */
  120772. static CreateTiledBox(name: string, options: {
  120773. pattern?: number;
  120774. width?: number;
  120775. height?: number;
  120776. depth?: number;
  120777. tileSize?: number;
  120778. tileWidth?: number;
  120779. tileHeight?: number;
  120780. alignHorizontal?: number;
  120781. alignVertical?: number;
  120782. faceUV?: Vector4[];
  120783. faceColors?: Color4[];
  120784. sideOrientation?: number;
  120785. updatable?: boolean;
  120786. }, scene?: Nullable<Scene>): Mesh;
  120787. }
  120788. }
  120789. declare module BABYLON {
  120790. /**
  120791. * Class containing static functions to help procedurally build meshes
  120792. */
  120793. export class TorusKnotBuilder {
  120794. /**
  120795. * Creates a torus knot mesh
  120796. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  120797. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  120798. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  120799. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  120800. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120801. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120802. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120803. * @param name defines the name of the mesh
  120804. * @param options defines the options used to create the mesh
  120805. * @param scene defines the hosting scene
  120806. * @returns the torus knot mesh
  120807. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  120808. */
  120809. static CreateTorusKnot(name: string, options: {
  120810. radius?: number;
  120811. tube?: number;
  120812. radialSegments?: number;
  120813. tubularSegments?: number;
  120814. p?: number;
  120815. q?: number;
  120816. updatable?: boolean;
  120817. sideOrientation?: number;
  120818. frontUVs?: Vector4;
  120819. backUVs?: Vector4;
  120820. }, scene: any): Mesh;
  120821. }
  120822. }
  120823. declare module BABYLON {
  120824. /**
  120825. * Polygon
  120826. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  120827. */
  120828. export class Polygon {
  120829. /**
  120830. * Creates a rectangle
  120831. * @param xmin bottom X coord
  120832. * @param ymin bottom Y coord
  120833. * @param xmax top X coord
  120834. * @param ymax top Y coord
  120835. * @returns points that make the resulting rectation
  120836. */
  120837. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  120838. /**
  120839. * Creates a circle
  120840. * @param radius radius of circle
  120841. * @param cx scale in x
  120842. * @param cy scale in y
  120843. * @param numberOfSides number of sides that make up the circle
  120844. * @returns points that make the resulting circle
  120845. */
  120846. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  120847. /**
  120848. * Creates a polygon from input string
  120849. * @param input Input polygon data
  120850. * @returns the parsed points
  120851. */
  120852. static Parse(input: string): Vector2[];
  120853. /**
  120854. * Starts building a polygon from x and y coordinates
  120855. * @param x x coordinate
  120856. * @param y y coordinate
  120857. * @returns the started path2
  120858. */
  120859. static StartingAt(x: number, y: number): Path2;
  120860. }
  120861. /**
  120862. * Builds a polygon
  120863. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  120864. */
  120865. export class PolygonMeshBuilder {
  120866. private _points;
  120867. private _outlinepoints;
  120868. private _holes;
  120869. private _name;
  120870. private _scene;
  120871. private _epoints;
  120872. private _eholes;
  120873. private _addToepoint;
  120874. /**
  120875. * Babylon reference to the earcut plugin.
  120876. */
  120877. bjsEarcut: any;
  120878. /**
  120879. * Creates a PolygonMeshBuilder
  120880. * @param name name of the builder
  120881. * @param contours Path of the polygon
  120882. * @param scene scene to add to when creating the mesh
  120883. * @param earcutInjection can be used to inject your own earcut reference
  120884. */
  120885. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  120886. /**
  120887. * Adds a whole within the polygon
  120888. * @param hole Array of points defining the hole
  120889. * @returns this
  120890. */
  120891. addHole(hole: Vector2[]): PolygonMeshBuilder;
  120892. /**
  120893. * Creates the polygon
  120894. * @param updatable If the mesh should be updatable
  120895. * @param depth The depth of the mesh created
  120896. * @returns the created mesh
  120897. */
  120898. build(updatable?: boolean, depth?: number): Mesh;
  120899. /**
  120900. * Creates the polygon
  120901. * @param depth The depth of the mesh created
  120902. * @returns the created VertexData
  120903. */
  120904. buildVertexData(depth?: number): VertexData;
  120905. /**
  120906. * Adds a side to the polygon
  120907. * @param positions points that make the polygon
  120908. * @param normals normals of the polygon
  120909. * @param uvs uvs of the polygon
  120910. * @param indices indices of the polygon
  120911. * @param bounds bounds of the polygon
  120912. * @param points points of the polygon
  120913. * @param depth depth of the polygon
  120914. * @param flip flip of the polygon
  120915. */
  120916. private addSide;
  120917. }
  120918. }
  120919. declare module BABYLON {
  120920. /**
  120921. * Class containing static functions to help procedurally build meshes
  120922. */
  120923. export class PolygonBuilder {
  120924. /**
  120925. * Creates a polygon mesh
  120926. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  120927. * * 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
  120928. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  120929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120930. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  120931. * * Remember you can only change the shape positions, not their number when updating a polygon
  120932. * @param name defines the name of the mesh
  120933. * @param options defines the options used to create the mesh
  120934. * @param scene defines the hosting scene
  120935. * @param earcutInjection can be used to inject your own earcut reference
  120936. * @returns the polygon mesh
  120937. */
  120938. static CreatePolygon(name: string, options: {
  120939. shape: Vector3[];
  120940. holes?: Vector3[][];
  120941. depth?: number;
  120942. faceUV?: Vector4[];
  120943. faceColors?: Color4[];
  120944. updatable?: boolean;
  120945. sideOrientation?: number;
  120946. frontUVs?: Vector4;
  120947. backUVs?: Vector4;
  120948. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  120949. /**
  120950. * Creates an extruded polygon mesh, with depth in the Y direction.
  120951. * * 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)
  120952. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  120953. * @param name defines the name of the mesh
  120954. * @param options defines the options used to create the mesh
  120955. * @param scene defines the hosting scene
  120956. * @param earcutInjection can be used to inject your own earcut reference
  120957. * @returns the polygon mesh
  120958. */
  120959. static ExtrudePolygon(name: string, options: {
  120960. shape: Vector3[];
  120961. holes?: Vector3[][];
  120962. depth?: number;
  120963. faceUV?: Vector4[];
  120964. faceColors?: Color4[];
  120965. updatable?: boolean;
  120966. sideOrientation?: number;
  120967. frontUVs?: Vector4;
  120968. backUVs?: Vector4;
  120969. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  120970. }
  120971. }
  120972. declare module BABYLON {
  120973. /**
  120974. * Class containing static functions to help procedurally build meshes
  120975. */
  120976. export class LatheBuilder {
  120977. /**
  120978. * Creates lathe mesh.
  120979. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  120980. * * 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
  120981. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  120982. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  120983. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  120984. * * 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
  120985. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  120986. * * 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
  120987. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120988. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120989. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120991. * @param name defines the name of the mesh
  120992. * @param options defines the options used to create the mesh
  120993. * @param scene defines the hosting scene
  120994. * @returns the lathe mesh
  120995. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  120996. */
  120997. static CreateLathe(name: string, options: {
  120998. shape: Vector3[];
  120999. radius?: number;
  121000. tessellation?: number;
  121001. clip?: number;
  121002. arc?: number;
  121003. closed?: boolean;
  121004. updatable?: boolean;
  121005. sideOrientation?: number;
  121006. frontUVs?: Vector4;
  121007. backUVs?: Vector4;
  121008. cap?: number;
  121009. invertUV?: boolean;
  121010. }, scene?: Nullable<Scene>): Mesh;
  121011. }
  121012. }
  121013. declare module BABYLON {
  121014. /**
  121015. * Class containing static functions to help procedurally build meshes
  121016. */
  121017. export class TiledPlaneBuilder {
  121018. /**
  121019. * Creates a tiled plane mesh
  121020. * * The parameter `pattern` will, depending on value, do nothing or
  121021. * * * flip (reflect about central vertical) alternate tiles across and up
  121022. * * * flip every tile on alternate rows
  121023. * * * rotate (180 degs) alternate tiles across and up
  121024. * * * rotate every tile on alternate rows
  121025. * * * flip and rotate alternate tiles across and up
  121026. * * * flip and rotate every tile on alternate rows
  121027. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  121028. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  121029. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121030. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  121031. * * 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)
  121032. * * 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)
  121033. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  121034. * @param name defines the name of the mesh
  121035. * @param options defines the options used to create the mesh
  121036. * @param scene defines the hosting scene
  121037. * @returns the box mesh
  121038. */
  121039. static CreateTiledPlane(name: string, options: {
  121040. pattern?: number;
  121041. tileSize?: number;
  121042. tileWidth?: number;
  121043. tileHeight?: number;
  121044. size?: number;
  121045. width?: number;
  121046. height?: number;
  121047. alignHorizontal?: number;
  121048. alignVertical?: number;
  121049. sideOrientation?: number;
  121050. frontUVs?: Vector4;
  121051. backUVs?: Vector4;
  121052. updatable?: boolean;
  121053. }, scene?: Nullable<Scene>): Mesh;
  121054. }
  121055. }
  121056. declare module BABYLON {
  121057. /**
  121058. * Class containing static functions to help procedurally build meshes
  121059. */
  121060. export class TubeBuilder {
  121061. /**
  121062. * Creates a tube mesh.
  121063. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121064. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  121065. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  121066. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  121067. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  121068. * * 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)
  121069. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  121070. * * 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
  121071. * * 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
  121072. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121073. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121074. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121076. * @param name defines the name of the mesh
  121077. * @param options defines the options used to create the mesh
  121078. * @param scene defines the hosting scene
  121079. * @returns the tube mesh
  121080. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121081. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  121082. */
  121083. static CreateTube(name: string, options: {
  121084. path: Vector3[];
  121085. radius?: number;
  121086. tessellation?: number;
  121087. radiusFunction?: {
  121088. (i: number, distance: number): number;
  121089. };
  121090. cap?: number;
  121091. arc?: number;
  121092. updatable?: boolean;
  121093. sideOrientation?: number;
  121094. frontUVs?: Vector4;
  121095. backUVs?: Vector4;
  121096. instance?: Mesh;
  121097. invertUV?: boolean;
  121098. }, scene?: Nullable<Scene>): Mesh;
  121099. }
  121100. }
  121101. declare module BABYLON {
  121102. /**
  121103. * Class containing static functions to help procedurally build meshes
  121104. */
  121105. export class IcoSphereBuilder {
  121106. /**
  121107. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  121108. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  121109. * * 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`)
  121110. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  121111. * * 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
  121112. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121113. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121115. * @param name defines the name of the mesh
  121116. * @param options defines the options used to create the mesh
  121117. * @param scene defines the hosting scene
  121118. * @returns the icosahedron mesh
  121119. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  121120. */
  121121. static CreateIcoSphere(name: string, options: {
  121122. radius?: number;
  121123. radiusX?: number;
  121124. radiusY?: number;
  121125. radiusZ?: number;
  121126. flat?: boolean;
  121127. subdivisions?: number;
  121128. sideOrientation?: number;
  121129. frontUVs?: Vector4;
  121130. backUVs?: Vector4;
  121131. updatable?: boolean;
  121132. }, scene?: Nullable<Scene>): Mesh;
  121133. }
  121134. }
  121135. declare module BABYLON {
  121136. /**
  121137. * Class containing static functions to help procedurally build meshes
  121138. */
  121139. export class DecalBuilder {
  121140. /**
  121141. * Creates a decal mesh.
  121142. * 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
  121143. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  121144. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  121145. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  121146. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  121147. * @param name defines the name of the mesh
  121148. * @param sourceMesh defines the mesh where the decal must be applied
  121149. * @param options defines the options used to create the mesh
  121150. * @param scene defines the hosting scene
  121151. * @returns the decal mesh
  121152. * @see https://doc.babylonjs.com/how_to/decals
  121153. */
  121154. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  121155. position?: Vector3;
  121156. normal?: Vector3;
  121157. size?: Vector3;
  121158. angle?: number;
  121159. }): Mesh;
  121160. }
  121161. }
  121162. declare module BABYLON {
  121163. /**
  121164. * Class containing static functions to help procedurally build meshes
  121165. */
  121166. export class MeshBuilder {
  121167. /**
  121168. * Creates a box mesh
  121169. * * The parameter `size` sets the size (float) of each box side (default 1)
  121170. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  121171. * * 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)
  121172. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121173. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121174. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121176. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  121177. * @param name defines the name of the mesh
  121178. * @param options defines the options used to create the mesh
  121179. * @param scene defines the hosting scene
  121180. * @returns the box mesh
  121181. */
  121182. static CreateBox(name: string, options: {
  121183. size?: number;
  121184. width?: number;
  121185. height?: number;
  121186. depth?: number;
  121187. faceUV?: Vector4[];
  121188. faceColors?: Color4[];
  121189. sideOrientation?: number;
  121190. frontUVs?: Vector4;
  121191. backUVs?: Vector4;
  121192. updatable?: boolean;
  121193. }, scene?: Nullable<Scene>): Mesh;
  121194. /**
  121195. * Creates a tiled box mesh
  121196. * * faceTiles sets the pattern, tile size and number of tiles for a face
  121197. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121198. * @param name defines the name of the mesh
  121199. * @param options defines the options used to create the mesh
  121200. * @param scene defines the hosting scene
  121201. * @returns the tiled box mesh
  121202. */
  121203. static CreateTiledBox(name: string, options: {
  121204. pattern?: number;
  121205. size?: number;
  121206. width?: number;
  121207. height?: number;
  121208. depth: number;
  121209. tileSize?: number;
  121210. tileWidth?: number;
  121211. tileHeight?: number;
  121212. faceUV?: Vector4[];
  121213. faceColors?: Color4[];
  121214. alignHorizontal?: number;
  121215. alignVertical?: number;
  121216. sideOrientation?: number;
  121217. updatable?: boolean;
  121218. }, scene?: Nullable<Scene>): Mesh;
  121219. /**
  121220. * Creates a sphere mesh
  121221. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  121222. * * 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`)
  121223. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  121224. * * 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
  121225. * * 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)
  121226. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121227. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121229. * @param name defines the name of the mesh
  121230. * @param options defines the options used to create the mesh
  121231. * @param scene defines the hosting scene
  121232. * @returns the sphere mesh
  121233. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  121234. */
  121235. static CreateSphere(name: string, options: {
  121236. segments?: number;
  121237. diameter?: number;
  121238. diameterX?: number;
  121239. diameterY?: number;
  121240. diameterZ?: number;
  121241. arc?: number;
  121242. slice?: number;
  121243. sideOrientation?: number;
  121244. frontUVs?: Vector4;
  121245. backUVs?: Vector4;
  121246. updatable?: boolean;
  121247. }, scene?: Nullable<Scene>): Mesh;
  121248. /**
  121249. * Creates a plane polygonal mesh. By default, this is a disc
  121250. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  121251. * * 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
  121252. * * 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
  121253. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121254. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121256. * @param name defines the name of the mesh
  121257. * @param options defines the options used to create the mesh
  121258. * @param scene defines the hosting scene
  121259. * @returns the plane polygonal mesh
  121260. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  121261. */
  121262. static CreateDisc(name: string, options: {
  121263. radius?: number;
  121264. tessellation?: number;
  121265. arc?: number;
  121266. updatable?: boolean;
  121267. sideOrientation?: number;
  121268. frontUVs?: Vector4;
  121269. backUVs?: Vector4;
  121270. }, scene?: Nullable<Scene>): Mesh;
  121271. /**
  121272. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  121273. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  121274. * * 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`)
  121275. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  121276. * * 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
  121277. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121278. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121279. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121280. * @param name defines the name of the mesh
  121281. * @param options defines the options used to create the mesh
  121282. * @param scene defines the hosting scene
  121283. * @returns the icosahedron mesh
  121284. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  121285. */
  121286. static CreateIcoSphere(name: string, options: {
  121287. radius?: number;
  121288. radiusX?: number;
  121289. radiusY?: number;
  121290. radiusZ?: number;
  121291. flat?: boolean;
  121292. subdivisions?: number;
  121293. sideOrientation?: number;
  121294. frontUVs?: Vector4;
  121295. backUVs?: Vector4;
  121296. updatable?: boolean;
  121297. }, scene?: Nullable<Scene>): Mesh;
  121298. /**
  121299. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121300. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  121301. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  121302. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  121303. * * 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
  121304. * * 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
  121305. * * 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
  121306. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121307. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121308. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121309. * * 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
  121310. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  121311. * * 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
  121312. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  121313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121314. * @param name defines the name of the mesh
  121315. * @param options defines the options used to create the mesh
  121316. * @param scene defines the hosting scene
  121317. * @returns the ribbon mesh
  121318. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  121319. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121320. */
  121321. static CreateRibbon(name: string, options: {
  121322. pathArray: Vector3[][];
  121323. closeArray?: boolean;
  121324. closePath?: boolean;
  121325. offset?: number;
  121326. updatable?: boolean;
  121327. sideOrientation?: number;
  121328. frontUVs?: Vector4;
  121329. backUVs?: Vector4;
  121330. instance?: Mesh;
  121331. invertUV?: boolean;
  121332. uvs?: Vector2[];
  121333. colors?: Color4[];
  121334. }, scene?: Nullable<Scene>): Mesh;
  121335. /**
  121336. * Creates a cylinder or a cone mesh
  121337. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  121338. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  121339. * * 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.
  121340. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  121341. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  121342. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  121343. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  121344. * * 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).
  121345. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  121346. * * 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).
  121347. * * 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
  121348. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  121349. * * 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
  121350. * * 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.
  121351. * * If `enclose` is false, a ring surface is one element.
  121352. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  121353. * * 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
  121354. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121355. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121357. * @param name defines the name of the mesh
  121358. * @param options defines the options used to create the mesh
  121359. * @param scene defines the hosting scene
  121360. * @returns the cylinder mesh
  121361. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  121362. */
  121363. static CreateCylinder(name: string, options: {
  121364. height?: number;
  121365. diameterTop?: number;
  121366. diameterBottom?: number;
  121367. diameter?: number;
  121368. tessellation?: number;
  121369. subdivisions?: number;
  121370. arc?: number;
  121371. faceColors?: Color4[];
  121372. faceUV?: Vector4[];
  121373. updatable?: boolean;
  121374. hasRings?: boolean;
  121375. enclose?: boolean;
  121376. cap?: number;
  121377. sideOrientation?: number;
  121378. frontUVs?: Vector4;
  121379. backUVs?: Vector4;
  121380. }, scene?: Nullable<Scene>): Mesh;
  121381. /**
  121382. * Creates a torus mesh
  121383. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  121384. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  121385. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  121386. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121387. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121389. * @param name defines the name of the mesh
  121390. * @param options defines the options used to create the mesh
  121391. * @param scene defines the hosting scene
  121392. * @returns the torus mesh
  121393. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  121394. */
  121395. static CreateTorus(name: string, options: {
  121396. diameter?: number;
  121397. thickness?: number;
  121398. tessellation?: number;
  121399. updatable?: boolean;
  121400. sideOrientation?: number;
  121401. frontUVs?: Vector4;
  121402. backUVs?: Vector4;
  121403. }, scene?: Nullable<Scene>): Mesh;
  121404. /**
  121405. * Creates a torus knot mesh
  121406. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  121407. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  121408. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  121409. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  121410. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121411. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121412. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121413. * @param name defines the name of the mesh
  121414. * @param options defines the options used to create the mesh
  121415. * @param scene defines the hosting scene
  121416. * @returns the torus knot mesh
  121417. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  121418. */
  121419. static CreateTorusKnot(name: string, options: {
  121420. radius?: number;
  121421. tube?: number;
  121422. radialSegments?: number;
  121423. tubularSegments?: number;
  121424. p?: number;
  121425. q?: number;
  121426. updatable?: boolean;
  121427. sideOrientation?: number;
  121428. frontUVs?: Vector4;
  121429. backUVs?: Vector4;
  121430. }, scene?: Nullable<Scene>): Mesh;
  121431. /**
  121432. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  121433. * * 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
  121434. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  121435. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  121436. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  121437. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  121438. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  121439. * * 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
  121440. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  121441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121442. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  121443. * @param name defines the name of the new line system
  121444. * @param options defines the options used to create the line system
  121445. * @param scene defines the hosting scene
  121446. * @returns a new line system mesh
  121447. */
  121448. static CreateLineSystem(name: string, options: {
  121449. lines: Vector3[][];
  121450. updatable?: boolean;
  121451. instance?: Nullable<LinesMesh>;
  121452. colors?: Nullable<Color4[][]>;
  121453. useVertexAlpha?: boolean;
  121454. }, scene: Nullable<Scene>): LinesMesh;
  121455. /**
  121456. * Creates a line mesh
  121457. * 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
  121458. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121459. * * The parameter `points` is an array successive Vector3
  121460. * * 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
  121461. * * The optional parameter `colors` is an array of successive Color4, one per line point
  121462. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  121463. * * When updating an instance, remember that only point positions can change, not the number of points
  121464. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121465. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  121466. * @param name defines the name of the new line system
  121467. * @param options defines the options used to create the line system
  121468. * @param scene defines the hosting scene
  121469. * @returns a new line mesh
  121470. */
  121471. static CreateLines(name: string, options: {
  121472. points: Vector3[];
  121473. updatable?: boolean;
  121474. instance?: Nullable<LinesMesh>;
  121475. colors?: Color4[];
  121476. useVertexAlpha?: boolean;
  121477. }, scene?: Nullable<Scene>): LinesMesh;
  121478. /**
  121479. * Creates a dashed line mesh
  121480. * * 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
  121481. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121482. * * The parameter `points` is an array successive Vector3
  121483. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  121484. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  121485. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  121486. * * 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
  121487. * * When updating an instance, remember that only point positions can change, not the number of points
  121488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121489. * @param name defines the name of the mesh
  121490. * @param options defines the options used to create the mesh
  121491. * @param scene defines the hosting scene
  121492. * @returns the dashed line mesh
  121493. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  121494. */
  121495. static CreateDashedLines(name: string, options: {
  121496. points: Vector3[];
  121497. dashSize?: number;
  121498. gapSize?: number;
  121499. dashNb?: number;
  121500. updatable?: boolean;
  121501. instance?: LinesMesh;
  121502. }, scene?: Nullable<Scene>): LinesMesh;
  121503. /**
  121504. * 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.
  121505. * * 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.
  121506. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121507. * * 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.
  121508. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  121509. * * 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
  121510. * * 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
  121511. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  121512. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121513. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121514. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  121515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121516. * @param name defines the name of the mesh
  121517. * @param options defines the options used to create the mesh
  121518. * @param scene defines the hosting scene
  121519. * @returns the extruded shape mesh
  121520. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121521. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121522. */
  121523. static ExtrudeShape(name: string, options: {
  121524. shape: Vector3[];
  121525. path: Vector3[];
  121526. scale?: number;
  121527. rotation?: number;
  121528. cap?: number;
  121529. updatable?: boolean;
  121530. sideOrientation?: number;
  121531. frontUVs?: Vector4;
  121532. backUVs?: Vector4;
  121533. instance?: Mesh;
  121534. invertUV?: boolean;
  121535. }, scene?: Nullable<Scene>): Mesh;
  121536. /**
  121537. * Creates an custom extruded shape mesh.
  121538. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  121539. * * 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.
  121540. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121541. * * 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
  121542. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  121543. * * 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
  121544. * * It must returns a float value that will be the scale value applied to the shape on each path point
  121545. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  121546. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  121547. * * 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
  121548. * * 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
  121549. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  121550. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121551. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121552. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121554. * @param name defines the name of the mesh
  121555. * @param options defines the options used to create the mesh
  121556. * @param scene defines the hosting scene
  121557. * @returns the custom extruded shape mesh
  121558. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  121559. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121560. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121561. */
  121562. static ExtrudeShapeCustom(name: string, options: {
  121563. shape: Vector3[];
  121564. path: Vector3[];
  121565. scaleFunction?: any;
  121566. rotationFunction?: any;
  121567. ribbonCloseArray?: boolean;
  121568. ribbonClosePath?: boolean;
  121569. cap?: number;
  121570. updatable?: boolean;
  121571. sideOrientation?: number;
  121572. frontUVs?: Vector4;
  121573. backUVs?: Vector4;
  121574. instance?: Mesh;
  121575. invertUV?: boolean;
  121576. }, scene?: Nullable<Scene>): Mesh;
  121577. /**
  121578. * Creates lathe mesh.
  121579. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  121580. * * 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
  121581. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  121582. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  121583. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  121584. * * 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
  121585. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  121586. * * 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
  121587. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121588. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121589. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121591. * @param name defines the name of the mesh
  121592. * @param options defines the options used to create the mesh
  121593. * @param scene defines the hosting scene
  121594. * @returns the lathe mesh
  121595. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  121596. */
  121597. static CreateLathe(name: string, options: {
  121598. shape: Vector3[];
  121599. radius?: number;
  121600. tessellation?: number;
  121601. clip?: number;
  121602. arc?: number;
  121603. closed?: boolean;
  121604. updatable?: boolean;
  121605. sideOrientation?: number;
  121606. frontUVs?: Vector4;
  121607. backUVs?: Vector4;
  121608. cap?: number;
  121609. invertUV?: boolean;
  121610. }, scene?: Nullable<Scene>): Mesh;
  121611. /**
  121612. * Creates a tiled plane mesh
  121613. * * You can set a limited pattern arrangement with the tiles
  121614. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121615. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121617. * @param name defines the name of the mesh
  121618. * @param options defines the options used to create the mesh
  121619. * @param scene defines the hosting scene
  121620. * @returns the plane mesh
  121621. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  121622. */
  121623. static CreateTiledPlane(name: string, options: {
  121624. pattern?: number;
  121625. tileSize?: number;
  121626. tileWidth?: number;
  121627. tileHeight?: number;
  121628. size?: number;
  121629. width?: number;
  121630. height?: number;
  121631. alignHorizontal?: number;
  121632. alignVertical?: number;
  121633. sideOrientation?: number;
  121634. frontUVs?: Vector4;
  121635. backUVs?: Vector4;
  121636. updatable?: boolean;
  121637. }, scene?: Nullable<Scene>): Mesh;
  121638. /**
  121639. * Creates a plane mesh
  121640. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  121641. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  121642. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  121643. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121644. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121645. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121646. * @param name defines the name of the mesh
  121647. * @param options defines the options used to create the mesh
  121648. * @param scene defines the hosting scene
  121649. * @returns the plane mesh
  121650. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  121651. */
  121652. static CreatePlane(name: string, options: {
  121653. size?: number;
  121654. width?: number;
  121655. height?: number;
  121656. sideOrientation?: number;
  121657. frontUVs?: Vector4;
  121658. backUVs?: Vector4;
  121659. updatable?: boolean;
  121660. sourcePlane?: Plane;
  121661. }, scene?: Nullable<Scene>): Mesh;
  121662. /**
  121663. * Creates a ground mesh
  121664. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  121665. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  121666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121667. * @param name defines the name of the mesh
  121668. * @param options defines the options used to create the mesh
  121669. * @param scene defines the hosting scene
  121670. * @returns the ground mesh
  121671. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  121672. */
  121673. static CreateGround(name: string, options: {
  121674. width?: number;
  121675. height?: number;
  121676. subdivisions?: number;
  121677. subdivisionsX?: number;
  121678. subdivisionsY?: number;
  121679. updatable?: boolean;
  121680. }, scene?: Nullable<Scene>): Mesh;
  121681. /**
  121682. * Creates a tiled ground mesh
  121683. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  121684. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  121685. * * 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
  121686. * * 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
  121687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121688. * @param name defines the name of the mesh
  121689. * @param options defines the options used to create the mesh
  121690. * @param scene defines the hosting scene
  121691. * @returns the tiled ground mesh
  121692. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  121693. */
  121694. static CreateTiledGround(name: string, options: {
  121695. xmin: number;
  121696. zmin: number;
  121697. xmax: number;
  121698. zmax: number;
  121699. subdivisions?: {
  121700. w: number;
  121701. h: number;
  121702. };
  121703. precision?: {
  121704. w: number;
  121705. h: number;
  121706. };
  121707. updatable?: boolean;
  121708. }, scene?: Nullable<Scene>): Mesh;
  121709. /**
  121710. * Creates a ground mesh from a height map
  121711. * * The parameter `url` sets the URL of the height map image resource.
  121712. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  121713. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  121714. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  121715. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  121716. * * 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.
  121717. * * 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).
  121718. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  121719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121720. * @param name defines the name of the mesh
  121721. * @param url defines the url to the height map
  121722. * @param options defines the options used to create the mesh
  121723. * @param scene defines the hosting scene
  121724. * @returns the ground mesh
  121725. * @see https://doc.babylonjs.com/babylon101/height_map
  121726. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  121727. */
  121728. static CreateGroundFromHeightMap(name: string, url: string, options: {
  121729. width?: number;
  121730. height?: number;
  121731. subdivisions?: number;
  121732. minHeight?: number;
  121733. maxHeight?: number;
  121734. colorFilter?: Color3;
  121735. alphaFilter?: number;
  121736. updatable?: boolean;
  121737. onReady?: (mesh: GroundMesh) => void;
  121738. }, scene?: Nullable<Scene>): GroundMesh;
  121739. /**
  121740. * Creates a polygon mesh
  121741. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  121742. * * 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
  121743. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  121744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121745. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  121746. * * Remember you can only change the shape positions, not their number when updating a polygon
  121747. * @param name defines the name of the mesh
  121748. * @param options defines the options used to create the mesh
  121749. * @param scene defines the hosting scene
  121750. * @param earcutInjection can be used to inject your own earcut reference
  121751. * @returns the polygon mesh
  121752. */
  121753. static CreatePolygon(name: string, options: {
  121754. shape: Vector3[];
  121755. holes?: Vector3[][];
  121756. depth?: number;
  121757. faceUV?: Vector4[];
  121758. faceColors?: Color4[];
  121759. updatable?: boolean;
  121760. sideOrientation?: number;
  121761. frontUVs?: Vector4;
  121762. backUVs?: Vector4;
  121763. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121764. /**
  121765. * Creates an extruded polygon mesh, with depth in the Y direction.
  121766. * * 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)
  121767. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121768. * @param name defines the name of the mesh
  121769. * @param options defines the options used to create the mesh
  121770. * @param scene defines the hosting scene
  121771. * @param earcutInjection can be used to inject your own earcut reference
  121772. * @returns the polygon mesh
  121773. */
  121774. static ExtrudePolygon(name: string, options: {
  121775. shape: Vector3[];
  121776. holes?: Vector3[][];
  121777. depth?: number;
  121778. faceUV?: Vector4[];
  121779. faceColors?: Color4[];
  121780. updatable?: boolean;
  121781. sideOrientation?: number;
  121782. frontUVs?: Vector4;
  121783. backUVs?: Vector4;
  121784. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121785. /**
  121786. * Creates a tube mesh.
  121787. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121788. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  121789. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  121790. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  121791. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  121792. * * 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)
  121793. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  121794. * * 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
  121795. * * 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
  121796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121797. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121798. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121800. * @param name defines the name of the mesh
  121801. * @param options defines the options used to create the mesh
  121802. * @param scene defines the hosting scene
  121803. * @returns the tube mesh
  121804. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121805. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  121806. */
  121807. static CreateTube(name: string, options: {
  121808. path: Vector3[];
  121809. radius?: number;
  121810. tessellation?: number;
  121811. radiusFunction?: {
  121812. (i: number, distance: number): number;
  121813. };
  121814. cap?: number;
  121815. arc?: number;
  121816. updatable?: boolean;
  121817. sideOrientation?: number;
  121818. frontUVs?: Vector4;
  121819. backUVs?: Vector4;
  121820. instance?: Mesh;
  121821. invertUV?: boolean;
  121822. }, scene?: Nullable<Scene>): Mesh;
  121823. /**
  121824. * Creates a polyhedron mesh
  121825. * * 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
  121826. * * The parameter `size` (positive float, default 1) sets the polygon size
  121827. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  121828. * * 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`
  121829. * * 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
  121830. * * 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)`)
  121831. * * 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
  121832. * * 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
  121833. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121834. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121835. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121836. * @param name defines the name of the mesh
  121837. * @param options defines the options used to create the mesh
  121838. * @param scene defines the hosting scene
  121839. * @returns the polyhedron mesh
  121840. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  121841. */
  121842. static CreatePolyhedron(name: string, options: {
  121843. type?: number;
  121844. size?: number;
  121845. sizeX?: number;
  121846. sizeY?: number;
  121847. sizeZ?: number;
  121848. custom?: any;
  121849. faceUV?: Vector4[];
  121850. faceColors?: Color4[];
  121851. flat?: boolean;
  121852. updatable?: boolean;
  121853. sideOrientation?: number;
  121854. frontUVs?: Vector4;
  121855. backUVs?: Vector4;
  121856. }, scene?: Nullable<Scene>): Mesh;
  121857. /**
  121858. * Creates a decal mesh.
  121859. * 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
  121860. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  121861. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  121862. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  121863. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  121864. * @param name defines the name of the mesh
  121865. * @param sourceMesh defines the mesh where the decal must be applied
  121866. * @param options defines the options used to create the mesh
  121867. * @param scene defines the hosting scene
  121868. * @returns the decal mesh
  121869. * @see https://doc.babylonjs.com/how_to/decals
  121870. */
  121871. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  121872. position?: Vector3;
  121873. normal?: Vector3;
  121874. size?: Vector3;
  121875. angle?: number;
  121876. }): Mesh;
  121877. }
  121878. }
  121879. declare module BABYLON {
  121880. /**
  121881. * A simplifier interface for future simplification implementations
  121882. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121883. */
  121884. export interface ISimplifier {
  121885. /**
  121886. * Simplification of a given mesh according to the given settings.
  121887. * Since this requires computation, it is assumed that the function runs async.
  121888. * @param settings The settings of the simplification, including quality and distance
  121889. * @param successCallback A callback that will be called after the mesh was simplified.
  121890. * @param errorCallback in case of an error, this callback will be called. optional.
  121891. */
  121892. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  121893. }
  121894. /**
  121895. * Expected simplification settings.
  121896. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  121897. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121898. */
  121899. export interface ISimplificationSettings {
  121900. /**
  121901. * Gets or sets the expected quality
  121902. */
  121903. quality: number;
  121904. /**
  121905. * Gets or sets the distance when this optimized version should be used
  121906. */
  121907. distance: number;
  121908. /**
  121909. * Gets an already optimized mesh
  121910. */
  121911. optimizeMesh?: boolean;
  121912. }
  121913. /**
  121914. * Class used to specify simplification options
  121915. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121916. */
  121917. export class SimplificationSettings implements ISimplificationSettings {
  121918. /** expected quality */
  121919. quality: number;
  121920. /** distance when this optimized version should be used */
  121921. distance: number;
  121922. /** already optimized mesh */
  121923. optimizeMesh?: boolean | undefined;
  121924. /**
  121925. * Creates a SimplificationSettings
  121926. * @param quality expected quality
  121927. * @param distance distance when this optimized version should be used
  121928. * @param optimizeMesh already optimized mesh
  121929. */
  121930. constructor(
  121931. /** expected quality */
  121932. quality: number,
  121933. /** distance when this optimized version should be used */
  121934. distance: number,
  121935. /** already optimized mesh */
  121936. optimizeMesh?: boolean | undefined);
  121937. }
  121938. /**
  121939. * Interface used to define a simplification task
  121940. */
  121941. export interface ISimplificationTask {
  121942. /**
  121943. * Array of settings
  121944. */
  121945. settings: Array<ISimplificationSettings>;
  121946. /**
  121947. * Simplification type
  121948. */
  121949. simplificationType: SimplificationType;
  121950. /**
  121951. * Mesh to simplify
  121952. */
  121953. mesh: Mesh;
  121954. /**
  121955. * Callback called on success
  121956. */
  121957. successCallback?: () => void;
  121958. /**
  121959. * Defines if parallel processing can be used
  121960. */
  121961. parallelProcessing: boolean;
  121962. }
  121963. /**
  121964. * Queue used to order the simplification tasks
  121965. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121966. */
  121967. export class SimplificationQueue {
  121968. private _simplificationArray;
  121969. /**
  121970. * Gets a boolean indicating that the process is still running
  121971. */
  121972. running: boolean;
  121973. /**
  121974. * Creates a new queue
  121975. */
  121976. constructor();
  121977. /**
  121978. * Adds a new simplification task
  121979. * @param task defines a task to add
  121980. */
  121981. addTask(task: ISimplificationTask): void;
  121982. /**
  121983. * Execute next task
  121984. */
  121985. executeNext(): void;
  121986. /**
  121987. * Execute a simplification task
  121988. * @param task defines the task to run
  121989. */
  121990. runSimplification(task: ISimplificationTask): void;
  121991. private getSimplifier;
  121992. }
  121993. /**
  121994. * The implemented types of simplification
  121995. * At the moment only Quadratic Error Decimation is implemented
  121996. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121997. */
  121998. export enum SimplificationType {
  121999. /** Quadratic error decimation */
  122000. QUADRATIC = 0
  122001. }
  122002. }
  122003. declare module BABYLON {
  122004. interface Scene {
  122005. /** @hidden (Backing field) */
  122006. _simplificationQueue: SimplificationQueue;
  122007. /**
  122008. * Gets or sets the simplification queue attached to the scene
  122009. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122010. */
  122011. simplificationQueue: SimplificationQueue;
  122012. }
  122013. interface Mesh {
  122014. /**
  122015. * Simplify the mesh according to the given array of settings.
  122016. * Function will return immediately and will simplify async
  122017. * @param settings a collection of simplification settings
  122018. * @param parallelProcessing should all levels calculate parallel or one after the other
  122019. * @param simplificationType the type of simplification to run
  122020. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  122021. * @returns the current mesh
  122022. */
  122023. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  122024. }
  122025. /**
  122026. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  122027. * created in a scene
  122028. */
  122029. export class SimplicationQueueSceneComponent implements ISceneComponent {
  122030. /**
  122031. * The component name helpfull to identify the component in the list of scene components.
  122032. */
  122033. readonly name: string;
  122034. /**
  122035. * The scene the component belongs to.
  122036. */
  122037. scene: Scene;
  122038. /**
  122039. * Creates a new instance of the component for the given scene
  122040. * @param scene Defines the scene to register the component in
  122041. */
  122042. constructor(scene: Scene);
  122043. /**
  122044. * Registers the component in a given scene
  122045. */
  122046. register(): void;
  122047. /**
  122048. * Rebuilds the elements related to this component in case of
  122049. * context lost for instance.
  122050. */
  122051. rebuild(): void;
  122052. /**
  122053. * Disposes the component and the associated ressources
  122054. */
  122055. dispose(): void;
  122056. private _beforeCameraUpdate;
  122057. }
  122058. }
  122059. declare module BABYLON {
  122060. /**
  122061. * Navigation plugin interface to add navigation constrained by a navigation mesh
  122062. */
  122063. export interface INavigationEnginePlugin {
  122064. /**
  122065. * plugin name
  122066. */
  122067. name: string;
  122068. /**
  122069. * Creates a navigation mesh
  122070. * @param meshes array of all the geometry used to compute the navigatio mesh
  122071. * @param parameters bunch of parameters used to filter geometry
  122072. */
  122073. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  122074. /**
  122075. * Create a navigation mesh debug mesh
  122076. * @param scene is where the mesh will be added
  122077. * @returns debug display mesh
  122078. */
  122079. createDebugNavMesh(scene: Scene): Mesh;
  122080. /**
  122081. * Get a navigation mesh constrained position, closest to the parameter position
  122082. * @param position world position
  122083. * @returns the closest point to position constrained by the navigation mesh
  122084. */
  122085. getClosestPoint(position: Vector3): Vector3;
  122086. /**
  122087. * Get a navigation mesh constrained position, within a particular radius
  122088. * @param position world position
  122089. * @param maxRadius the maximum distance to the constrained world position
  122090. * @returns the closest point to position constrained by the navigation mesh
  122091. */
  122092. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  122093. /**
  122094. * Compute the final position from a segment made of destination-position
  122095. * @param position world position
  122096. * @param destination world position
  122097. * @returns the resulting point along the navmesh
  122098. */
  122099. moveAlong(position: Vector3, destination: Vector3): Vector3;
  122100. /**
  122101. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  122102. * @param start world position
  122103. * @param end world position
  122104. * @returns array containing world position composing the path
  122105. */
  122106. computePath(start: Vector3, end: Vector3): Vector3[];
  122107. /**
  122108. * If this plugin is supported
  122109. * @returns true if plugin is supported
  122110. */
  122111. isSupported(): boolean;
  122112. /**
  122113. * Create a new Crowd so you can add agents
  122114. * @param maxAgents the maximum agent count in the crowd
  122115. * @param maxAgentRadius the maximum radius an agent can have
  122116. * @param scene to attach the crowd to
  122117. * @returns the crowd you can add agents to
  122118. */
  122119. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  122120. /**
  122121. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122122. * The queries will try to find a solution within those bounds
  122123. * default is (1,1,1)
  122124. * @param extent x,y,z value that define the extent around the queries point of reference
  122125. */
  122126. setDefaultQueryExtent(extent: Vector3): void;
  122127. /**
  122128. * Get the Bounding box extent specified by setDefaultQueryExtent
  122129. * @returns the box extent values
  122130. */
  122131. getDefaultQueryExtent(): Vector3;
  122132. /**
  122133. * Release all resources
  122134. */
  122135. dispose(): void;
  122136. }
  122137. /**
  122138. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  122139. */
  122140. export interface ICrowd {
  122141. /**
  122142. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  122143. * You can attach anything to that node. The node position is updated in the scene update tick.
  122144. * @param pos world position that will be constrained by the navigation mesh
  122145. * @param parameters agent parameters
  122146. * @param transform hooked to the agent that will be update by the scene
  122147. * @returns agent index
  122148. */
  122149. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  122150. /**
  122151. * Returns the agent position in world space
  122152. * @param index agent index returned by addAgent
  122153. * @returns world space position
  122154. */
  122155. getAgentPosition(index: number): Vector3;
  122156. /**
  122157. * Gets the agent velocity in world space
  122158. * @param index agent index returned by addAgent
  122159. * @returns world space velocity
  122160. */
  122161. getAgentVelocity(index: number): Vector3;
  122162. /**
  122163. * remove a particular agent previously created
  122164. * @param index agent index returned by addAgent
  122165. */
  122166. removeAgent(index: number): void;
  122167. /**
  122168. * get the list of all agents attached to this crowd
  122169. * @returns list of agent indices
  122170. */
  122171. getAgents(): number[];
  122172. /**
  122173. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  122174. * @param deltaTime in seconds
  122175. */
  122176. update(deltaTime: number): void;
  122177. /**
  122178. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  122179. * @param index agent index returned by addAgent
  122180. * @param destination targeted world position
  122181. */
  122182. agentGoto(index: number, destination: Vector3): void;
  122183. /**
  122184. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122185. * The queries will try to find a solution within those bounds
  122186. * default is (1,1,1)
  122187. * @param extent x,y,z value that define the extent around the queries point of reference
  122188. */
  122189. setDefaultQueryExtent(extent: Vector3): void;
  122190. /**
  122191. * Get the Bounding box extent specified by setDefaultQueryExtent
  122192. * @returns the box extent values
  122193. */
  122194. getDefaultQueryExtent(): Vector3;
  122195. /**
  122196. * Release all resources
  122197. */
  122198. dispose(): void;
  122199. }
  122200. /**
  122201. * Configures an agent
  122202. */
  122203. export interface IAgentParameters {
  122204. /**
  122205. * Agent radius. [Limit: >= 0]
  122206. */
  122207. radius: number;
  122208. /**
  122209. * Agent height. [Limit: > 0]
  122210. */
  122211. height: number;
  122212. /**
  122213. * Maximum allowed acceleration. [Limit: >= 0]
  122214. */
  122215. maxAcceleration: number;
  122216. /**
  122217. * Maximum allowed speed. [Limit: >= 0]
  122218. */
  122219. maxSpeed: number;
  122220. /**
  122221. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  122222. */
  122223. collisionQueryRange: number;
  122224. /**
  122225. * The path visibility optimization range. [Limit: > 0]
  122226. */
  122227. pathOptimizationRange: number;
  122228. /**
  122229. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  122230. */
  122231. separationWeight: number;
  122232. }
  122233. /**
  122234. * Configures the navigation mesh creation
  122235. */
  122236. export interface INavMeshParameters {
  122237. /**
  122238. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  122239. */
  122240. cs: number;
  122241. /**
  122242. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  122243. */
  122244. ch: number;
  122245. /**
  122246. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  122247. */
  122248. walkableSlopeAngle: number;
  122249. /**
  122250. * Minimum floor to 'ceiling' height that will still allow the floor area to
  122251. * be considered walkable. [Limit: >= 3] [Units: vx]
  122252. */
  122253. walkableHeight: number;
  122254. /**
  122255. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  122256. */
  122257. walkableClimb: number;
  122258. /**
  122259. * The distance to erode/shrink the walkable area of the heightfield away from
  122260. * obstructions. [Limit: >=0] [Units: vx]
  122261. */
  122262. walkableRadius: number;
  122263. /**
  122264. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  122265. */
  122266. maxEdgeLen: number;
  122267. /**
  122268. * The maximum distance a simplfied contour's border edges should deviate
  122269. * the original raw contour. [Limit: >=0] [Units: vx]
  122270. */
  122271. maxSimplificationError: number;
  122272. /**
  122273. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  122274. */
  122275. minRegionArea: number;
  122276. /**
  122277. * Any regions with a span count smaller than this value will, if possible,
  122278. * be merged with larger regions. [Limit: >=0] [Units: vx]
  122279. */
  122280. mergeRegionArea: number;
  122281. /**
  122282. * The maximum number of vertices allowed for polygons generated during the
  122283. * contour to polygon conversion process. [Limit: >= 3]
  122284. */
  122285. maxVertsPerPoly: number;
  122286. /**
  122287. * Sets the sampling distance to use when generating the detail mesh.
  122288. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  122289. */
  122290. detailSampleDist: number;
  122291. /**
  122292. * The maximum distance the detail mesh surface should deviate from heightfield
  122293. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  122294. */
  122295. detailSampleMaxError: number;
  122296. }
  122297. }
  122298. declare module BABYLON {
  122299. /**
  122300. * RecastJS navigation plugin
  122301. */
  122302. export class RecastJSPlugin implements INavigationEnginePlugin {
  122303. /**
  122304. * Reference to the Recast library
  122305. */
  122306. bjsRECAST: any;
  122307. /**
  122308. * plugin name
  122309. */
  122310. name: string;
  122311. /**
  122312. * the first navmesh created. We might extend this to support multiple navmeshes
  122313. */
  122314. navMesh: any;
  122315. /**
  122316. * Initializes the recastJS plugin
  122317. * @param recastInjection can be used to inject your own recast reference
  122318. */
  122319. constructor(recastInjection?: any);
  122320. /**
  122321. * Creates a navigation mesh
  122322. * @param meshes array of all the geometry used to compute the navigatio mesh
  122323. * @param parameters bunch of parameters used to filter geometry
  122324. */
  122325. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  122326. /**
  122327. * Create a navigation mesh debug mesh
  122328. * @param scene is where the mesh will be added
  122329. * @returns debug display mesh
  122330. */
  122331. createDebugNavMesh(scene: Scene): Mesh;
  122332. /**
  122333. * Get a navigation mesh constrained position, closest to the parameter position
  122334. * @param position world position
  122335. * @returns the closest point to position constrained by the navigation mesh
  122336. */
  122337. getClosestPoint(position: Vector3): Vector3;
  122338. /**
  122339. * Get a navigation mesh constrained position, within a particular radius
  122340. * @param position world position
  122341. * @param maxRadius the maximum distance to the constrained world position
  122342. * @returns the closest point to position constrained by the navigation mesh
  122343. */
  122344. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  122345. /**
  122346. * Compute the final position from a segment made of destination-position
  122347. * @param position world position
  122348. * @param destination world position
  122349. * @returns the resulting point along the navmesh
  122350. */
  122351. moveAlong(position: Vector3, destination: Vector3): Vector3;
  122352. /**
  122353. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  122354. * @param start world position
  122355. * @param end world position
  122356. * @returns array containing world position composing the path
  122357. */
  122358. computePath(start: Vector3, end: Vector3): Vector3[];
  122359. /**
  122360. * Create a new Crowd so you can add agents
  122361. * @param maxAgents the maximum agent count in the crowd
  122362. * @param maxAgentRadius the maximum radius an agent can have
  122363. * @param scene to attach the crowd to
  122364. * @returns the crowd you can add agents to
  122365. */
  122366. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  122367. /**
  122368. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122369. * The queries will try to find a solution within those bounds
  122370. * default is (1,1,1)
  122371. * @param extent x,y,z value that define the extent around the queries point of reference
  122372. */
  122373. setDefaultQueryExtent(extent: Vector3): void;
  122374. /**
  122375. * Get the Bounding box extent specified by setDefaultQueryExtent
  122376. * @returns the box extent values
  122377. */
  122378. getDefaultQueryExtent(): Vector3;
  122379. /**
  122380. * Disposes
  122381. */
  122382. dispose(): void;
  122383. /**
  122384. * If this plugin is supported
  122385. * @returns true if plugin is supported
  122386. */
  122387. isSupported(): boolean;
  122388. }
  122389. /**
  122390. * Recast detour crowd implementation
  122391. */
  122392. export class RecastJSCrowd implements ICrowd {
  122393. /**
  122394. * Recast/detour plugin
  122395. */
  122396. bjsRECASTPlugin: RecastJSPlugin;
  122397. /**
  122398. * Link to the detour crowd
  122399. */
  122400. recastCrowd: any;
  122401. /**
  122402. * One transform per agent
  122403. */
  122404. transforms: TransformNode[];
  122405. /**
  122406. * All agents created
  122407. */
  122408. agents: number[];
  122409. /**
  122410. * Link to the scene is kept to unregister the crowd from the scene
  122411. */
  122412. private _scene;
  122413. /**
  122414. * Observer for crowd updates
  122415. */
  122416. private _onBeforeAnimationsObserver;
  122417. /**
  122418. * Constructor
  122419. * @param plugin recastJS plugin
  122420. * @param maxAgents the maximum agent count in the crowd
  122421. * @param maxAgentRadius the maximum radius an agent can have
  122422. * @param scene to attach the crowd to
  122423. * @returns the crowd you can add agents to
  122424. */
  122425. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  122426. /**
  122427. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  122428. * You can attach anything to that node. The node position is updated in the scene update tick.
  122429. * @param pos world position that will be constrained by the navigation mesh
  122430. * @param parameters agent parameters
  122431. * @param transform hooked to the agent that will be update by the scene
  122432. * @returns agent index
  122433. */
  122434. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  122435. /**
  122436. * Returns the agent position in world space
  122437. * @param index agent index returned by addAgent
  122438. * @returns world space position
  122439. */
  122440. getAgentPosition(index: number): Vector3;
  122441. /**
  122442. * Returns the agent velocity in world space
  122443. * @param index agent index returned by addAgent
  122444. * @returns world space velocity
  122445. */
  122446. getAgentVelocity(index: number): Vector3;
  122447. /**
  122448. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  122449. * @param index agent index returned by addAgent
  122450. * @param destination targeted world position
  122451. */
  122452. agentGoto(index: number, destination: Vector3): void;
  122453. /**
  122454. * remove a particular agent previously created
  122455. * @param index agent index returned by addAgent
  122456. */
  122457. removeAgent(index: number): void;
  122458. /**
  122459. * get the list of all agents attached to this crowd
  122460. * @returns list of agent indices
  122461. */
  122462. getAgents(): number[];
  122463. /**
  122464. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  122465. * @param deltaTime in seconds
  122466. */
  122467. update(deltaTime: number): void;
  122468. /**
  122469. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122470. * The queries will try to find a solution within those bounds
  122471. * default is (1,1,1)
  122472. * @param extent x,y,z value that define the extent around the queries point of reference
  122473. */
  122474. setDefaultQueryExtent(extent: Vector3): void;
  122475. /**
  122476. * Get the Bounding box extent specified by setDefaultQueryExtent
  122477. * @returns the box extent values
  122478. */
  122479. getDefaultQueryExtent(): Vector3;
  122480. /**
  122481. * Release all resources
  122482. */
  122483. dispose(): void;
  122484. }
  122485. }
  122486. declare module BABYLON {
  122487. /**
  122488. * Class used to enable access to IndexedDB
  122489. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  122490. */
  122491. export class Database implements IOfflineProvider {
  122492. private _callbackManifestChecked;
  122493. private _currentSceneUrl;
  122494. private _db;
  122495. private _enableSceneOffline;
  122496. private _enableTexturesOffline;
  122497. private _manifestVersionFound;
  122498. private _mustUpdateRessources;
  122499. private _hasReachedQuota;
  122500. private _isSupported;
  122501. private _idbFactory;
  122502. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  122503. private static IsUASupportingBlobStorage;
  122504. /**
  122505. * Gets a boolean indicating if Database storate is enabled (off by default)
  122506. */
  122507. static IDBStorageEnabled: boolean;
  122508. /**
  122509. * Gets a boolean indicating if scene must be saved in the database
  122510. */
  122511. readonly enableSceneOffline: boolean;
  122512. /**
  122513. * Gets a boolean indicating if textures must be saved in the database
  122514. */
  122515. readonly enableTexturesOffline: boolean;
  122516. /**
  122517. * Creates a new Database
  122518. * @param urlToScene defines the url to load the scene
  122519. * @param callbackManifestChecked defines the callback to use when manifest is checked
  122520. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  122521. */
  122522. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  122523. private static _ParseURL;
  122524. private static _ReturnFullUrlLocation;
  122525. private _checkManifestFile;
  122526. /**
  122527. * Open the database and make it available
  122528. * @param successCallback defines the callback to call on success
  122529. * @param errorCallback defines the callback to call on error
  122530. */
  122531. open(successCallback: () => void, errorCallback: () => void): void;
  122532. /**
  122533. * Loads an image from the database
  122534. * @param url defines the url to load from
  122535. * @param image defines the target DOM image
  122536. */
  122537. loadImage(url: string, image: HTMLImageElement): void;
  122538. private _loadImageFromDBAsync;
  122539. private _saveImageIntoDBAsync;
  122540. private _checkVersionFromDB;
  122541. private _loadVersionFromDBAsync;
  122542. private _saveVersionIntoDBAsync;
  122543. /**
  122544. * Loads a file from database
  122545. * @param url defines the URL to load from
  122546. * @param sceneLoaded defines a callback to call on success
  122547. * @param progressCallBack defines a callback to call when progress changed
  122548. * @param errorCallback defines a callback to call on error
  122549. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  122550. */
  122551. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  122552. private _loadFileAsync;
  122553. private _saveFileAsync;
  122554. /**
  122555. * Validates if xhr data is correct
  122556. * @param xhr defines the request to validate
  122557. * @param dataType defines the expected data type
  122558. * @returns true if data is correct
  122559. */
  122560. private static _ValidateXHRData;
  122561. }
  122562. }
  122563. declare module BABYLON {
  122564. /** @hidden */
  122565. export var gpuUpdateParticlesPixelShader: {
  122566. name: string;
  122567. shader: string;
  122568. };
  122569. }
  122570. declare module BABYLON {
  122571. /** @hidden */
  122572. export var gpuUpdateParticlesVertexShader: {
  122573. name: string;
  122574. shader: string;
  122575. };
  122576. }
  122577. declare module BABYLON {
  122578. /** @hidden */
  122579. export var clipPlaneFragmentDeclaration2: {
  122580. name: string;
  122581. shader: string;
  122582. };
  122583. }
  122584. declare module BABYLON {
  122585. /** @hidden */
  122586. export var gpuRenderParticlesPixelShader: {
  122587. name: string;
  122588. shader: string;
  122589. };
  122590. }
  122591. declare module BABYLON {
  122592. /** @hidden */
  122593. export var clipPlaneVertexDeclaration2: {
  122594. name: string;
  122595. shader: string;
  122596. };
  122597. }
  122598. declare module BABYLON {
  122599. /** @hidden */
  122600. export var gpuRenderParticlesVertexShader: {
  122601. name: string;
  122602. shader: string;
  122603. };
  122604. }
  122605. declare module BABYLON {
  122606. /**
  122607. * This represents a GPU particle system in Babylon
  122608. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  122609. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  122610. */
  122611. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  122612. /**
  122613. * The layer mask we are rendering the particles through.
  122614. */
  122615. layerMask: number;
  122616. private _capacity;
  122617. private _activeCount;
  122618. private _currentActiveCount;
  122619. private _accumulatedCount;
  122620. private _renderEffect;
  122621. private _updateEffect;
  122622. private _buffer0;
  122623. private _buffer1;
  122624. private _spriteBuffer;
  122625. private _updateVAO;
  122626. private _renderVAO;
  122627. private _targetIndex;
  122628. private _sourceBuffer;
  122629. private _targetBuffer;
  122630. private _engine;
  122631. private _currentRenderId;
  122632. private _started;
  122633. private _stopped;
  122634. private _timeDelta;
  122635. private _randomTexture;
  122636. private _randomTexture2;
  122637. private _attributesStrideSize;
  122638. private _updateEffectOptions;
  122639. private _randomTextureSize;
  122640. private _actualFrame;
  122641. private readonly _rawTextureWidth;
  122642. /**
  122643. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  122644. */
  122645. static readonly IsSupported: boolean;
  122646. /**
  122647. * An event triggered when the system is disposed.
  122648. */
  122649. onDisposeObservable: Observable<GPUParticleSystem>;
  122650. /**
  122651. * Gets the maximum number of particles active at the same time.
  122652. * @returns The max number of active particles.
  122653. */
  122654. getCapacity(): number;
  122655. /**
  122656. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  122657. * to override the particles.
  122658. */
  122659. forceDepthWrite: boolean;
  122660. /**
  122661. * Gets or set the number of active particles
  122662. */
  122663. activeParticleCount: number;
  122664. private _preWarmDone;
  122665. /**
  122666. * Is this system ready to be used/rendered
  122667. * @return true if the system is ready
  122668. */
  122669. isReady(): boolean;
  122670. /**
  122671. * Gets if the system has been started. (Note: this will still be true after stop is called)
  122672. * @returns True if it has been started, otherwise false.
  122673. */
  122674. isStarted(): boolean;
  122675. /**
  122676. * Starts the particle system and begins to emit
  122677. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  122678. */
  122679. start(delay?: number): void;
  122680. /**
  122681. * Stops the particle system.
  122682. */
  122683. stop(): void;
  122684. /**
  122685. * Remove all active particles
  122686. */
  122687. reset(): void;
  122688. /**
  122689. * Returns the string "GPUParticleSystem"
  122690. * @returns a string containing the class name
  122691. */
  122692. getClassName(): string;
  122693. private _colorGradientsTexture;
  122694. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  122695. /**
  122696. * Adds a new color gradient
  122697. * @param gradient defines the gradient to use (between 0 and 1)
  122698. * @param color1 defines the color to affect to the specified gradient
  122699. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  122700. * @returns the current particle system
  122701. */
  122702. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  122703. /**
  122704. * Remove a specific color gradient
  122705. * @param gradient defines the gradient to remove
  122706. * @returns the current particle system
  122707. */
  122708. removeColorGradient(gradient: number): GPUParticleSystem;
  122709. private _angularSpeedGradientsTexture;
  122710. private _sizeGradientsTexture;
  122711. private _velocityGradientsTexture;
  122712. private _limitVelocityGradientsTexture;
  122713. private _dragGradientsTexture;
  122714. private _addFactorGradient;
  122715. /**
  122716. * Adds a new size gradient
  122717. * @param gradient defines the gradient to use (between 0 and 1)
  122718. * @param factor defines the size factor to affect to the specified gradient
  122719. * @returns the current particle system
  122720. */
  122721. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  122722. /**
  122723. * Remove a specific size gradient
  122724. * @param gradient defines the gradient to remove
  122725. * @returns the current particle system
  122726. */
  122727. removeSizeGradient(gradient: number): GPUParticleSystem;
  122728. /**
  122729. * Adds a new angular speed gradient
  122730. * @param gradient defines the gradient to use (between 0 and 1)
  122731. * @param factor defines the angular speed to affect to the specified gradient
  122732. * @returns the current particle system
  122733. */
  122734. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  122735. /**
  122736. * Remove a specific angular speed gradient
  122737. * @param gradient defines the gradient to remove
  122738. * @returns the current particle system
  122739. */
  122740. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  122741. /**
  122742. * Adds a new velocity gradient
  122743. * @param gradient defines the gradient to use (between 0 and 1)
  122744. * @param factor defines the velocity to affect to the specified gradient
  122745. * @returns the current particle system
  122746. */
  122747. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  122748. /**
  122749. * Remove a specific velocity gradient
  122750. * @param gradient defines the gradient to remove
  122751. * @returns the current particle system
  122752. */
  122753. removeVelocityGradient(gradient: number): GPUParticleSystem;
  122754. /**
  122755. * Adds a new limit velocity gradient
  122756. * @param gradient defines the gradient to use (between 0 and 1)
  122757. * @param factor defines the limit velocity value to affect to the specified gradient
  122758. * @returns the current particle system
  122759. */
  122760. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  122761. /**
  122762. * Remove a specific limit velocity gradient
  122763. * @param gradient defines the gradient to remove
  122764. * @returns the current particle system
  122765. */
  122766. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  122767. /**
  122768. * Adds a new drag gradient
  122769. * @param gradient defines the gradient to use (between 0 and 1)
  122770. * @param factor defines the drag value to affect to the specified gradient
  122771. * @returns the current particle system
  122772. */
  122773. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  122774. /**
  122775. * Remove a specific drag gradient
  122776. * @param gradient defines the gradient to remove
  122777. * @returns the current particle system
  122778. */
  122779. removeDragGradient(gradient: number): GPUParticleSystem;
  122780. /**
  122781. * Not supported by GPUParticleSystem
  122782. * @param gradient defines the gradient to use (between 0 and 1)
  122783. * @param factor defines the emit rate value to affect to the specified gradient
  122784. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122785. * @returns the current particle system
  122786. */
  122787. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  122788. /**
  122789. * Not supported by GPUParticleSystem
  122790. * @param gradient defines the gradient to remove
  122791. * @returns the current particle system
  122792. */
  122793. removeEmitRateGradient(gradient: number): IParticleSystem;
  122794. /**
  122795. * Not supported by GPUParticleSystem
  122796. * @param gradient defines the gradient to use (between 0 and 1)
  122797. * @param factor defines the start size value to affect to the specified gradient
  122798. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122799. * @returns the current particle system
  122800. */
  122801. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  122802. /**
  122803. * Not supported by GPUParticleSystem
  122804. * @param gradient defines the gradient to remove
  122805. * @returns the current particle system
  122806. */
  122807. removeStartSizeGradient(gradient: number): IParticleSystem;
  122808. /**
  122809. * Not supported by GPUParticleSystem
  122810. * @param gradient defines the gradient to use (between 0 and 1)
  122811. * @param min defines the color remap minimal range
  122812. * @param max defines the color remap maximal range
  122813. * @returns the current particle system
  122814. */
  122815. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  122816. /**
  122817. * Not supported by GPUParticleSystem
  122818. * @param gradient defines the gradient to remove
  122819. * @returns the current particle system
  122820. */
  122821. removeColorRemapGradient(): IParticleSystem;
  122822. /**
  122823. * Not supported by GPUParticleSystem
  122824. * @param gradient defines the gradient to use (between 0 and 1)
  122825. * @param min defines the alpha remap minimal range
  122826. * @param max defines the alpha remap maximal range
  122827. * @returns the current particle system
  122828. */
  122829. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  122830. /**
  122831. * Not supported by GPUParticleSystem
  122832. * @param gradient defines the gradient to remove
  122833. * @returns the current particle system
  122834. */
  122835. removeAlphaRemapGradient(): IParticleSystem;
  122836. /**
  122837. * Not supported by GPUParticleSystem
  122838. * @param gradient defines the gradient to use (between 0 and 1)
  122839. * @param color defines the color to affect to the specified gradient
  122840. * @returns the current particle system
  122841. */
  122842. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  122843. /**
  122844. * Not supported by GPUParticleSystem
  122845. * @param gradient defines the gradient to remove
  122846. * @returns the current particle system
  122847. */
  122848. removeRampGradient(): IParticleSystem;
  122849. /**
  122850. * Not supported by GPUParticleSystem
  122851. * @returns the list of ramp gradients
  122852. */
  122853. getRampGradients(): Nullable<Array<Color3Gradient>>;
  122854. /**
  122855. * Not supported by GPUParticleSystem
  122856. * Gets or sets a boolean indicating that ramp gradients must be used
  122857. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  122858. */
  122859. useRampGradients: boolean;
  122860. /**
  122861. * Not supported by GPUParticleSystem
  122862. * @param gradient defines the gradient to use (between 0 and 1)
  122863. * @param factor defines the life time factor to affect to the specified gradient
  122864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122865. * @returns the current particle system
  122866. */
  122867. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  122868. /**
  122869. * Not supported by GPUParticleSystem
  122870. * @param gradient defines the gradient to remove
  122871. * @returns the current particle system
  122872. */
  122873. removeLifeTimeGradient(gradient: number): IParticleSystem;
  122874. /**
  122875. * Instantiates a GPU particle system.
  122876. * 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.
  122877. * @param name The name of the particle system
  122878. * @param options The options used to create the system
  122879. * @param scene The scene the particle system belongs to
  122880. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  122881. */
  122882. constructor(name: string, options: Partial<{
  122883. capacity: number;
  122884. randomTextureSize: number;
  122885. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  122886. protected _reset(): void;
  122887. private _createUpdateVAO;
  122888. private _createRenderVAO;
  122889. private _initialize;
  122890. /** @hidden */
  122891. _recreateUpdateEffect(): void;
  122892. /** @hidden */
  122893. _recreateRenderEffect(): void;
  122894. /**
  122895. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  122896. * @param preWarm defines if we are in the pre-warmimg phase
  122897. */
  122898. animate(preWarm?: boolean): void;
  122899. private _createFactorGradientTexture;
  122900. private _createSizeGradientTexture;
  122901. private _createAngularSpeedGradientTexture;
  122902. private _createVelocityGradientTexture;
  122903. private _createLimitVelocityGradientTexture;
  122904. private _createDragGradientTexture;
  122905. private _createColorGradientTexture;
  122906. /**
  122907. * Renders the particle system in its current state
  122908. * @param preWarm defines if the system should only update the particles but not render them
  122909. * @returns the current number of particles
  122910. */
  122911. render(preWarm?: boolean): number;
  122912. /**
  122913. * Rebuilds the particle system
  122914. */
  122915. rebuild(): void;
  122916. private _releaseBuffers;
  122917. private _releaseVAOs;
  122918. /**
  122919. * Disposes the particle system and free the associated resources
  122920. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  122921. */
  122922. dispose(disposeTexture?: boolean): void;
  122923. /**
  122924. * Clones the particle system.
  122925. * @param name The name of the cloned object
  122926. * @param newEmitter The new emitter to use
  122927. * @returns the cloned particle system
  122928. */
  122929. clone(name: string, newEmitter: any): GPUParticleSystem;
  122930. /**
  122931. * Serializes the particle system to a JSON object.
  122932. * @returns the JSON object
  122933. */
  122934. serialize(): any;
  122935. /**
  122936. * Parses a JSON object to create a GPU particle system.
  122937. * @param parsedParticleSystem The JSON object to parse
  122938. * @param scene The scene to create the particle system in
  122939. * @param rootUrl The root url to use to load external dependencies like texture
  122940. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  122941. * @returns the parsed GPU particle system
  122942. */
  122943. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  122944. }
  122945. }
  122946. declare module BABYLON {
  122947. /**
  122948. * Represents a set of particle systems working together to create a specific effect
  122949. */
  122950. export class ParticleSystemSet implements IDisposable {
  122951. private _emitterCreationOptions;
  122952. private _emitterNode;
  122953. /**
  122954. * Gets the particle system list
  122955. */
  122956. systems: IParticleSystem[];
  122957. /**
  122958. * Gets the emitter node used with this set
  122959. */
  122960. readonly emitterNode: Nullable<TransformNode>;
  122961. /**
  122962. * Creates a new emitter mesh as a sphere
  122963. * @param options defines the options used to create the sphere
  122964. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  122965. * @param scene defines the hosting scene
  122966. */
  122967. setEmitterAsSphere(options: {
  122968. diameter: number;
  122969. segments: number;
  122970. color: Color3;
  122971. }, renderingGroupId: number, scene: Scene): void;
  122972. /**
  122973. * Starts all particle systems of the set
  122974. * @param emitter defines an optional mesh to use as emitter for the particle systems
  122975. */
  122976. start(emitter?: AbstractMesh): void;
  122977. /**
  122978. * Release all associated resources
  122979. */
  122980. dispose(): void;
  122981. /**
  122982. * Serialize the set into a JSON compatible object
  122983. * @returns a JSON compatible representation of the set
  122984. */
  122985. serialize(): any;
  122986. /**
  122987. * Parse a new ParticleSystemSet from a serialized source
  122988. * @param data defines a JSON compatible representation of the set
  122989. * @param scene defines the hosting scene
  122990. * @param gpu defines if we want GPU particles or CPU particles
  122991. * @returns a new ParticleSystemSet
  122992. */
  122993. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  122994. }
  122995. }
  122996. declare module BABYLON {
  122997. /**
  122998. * This class is made for on one-liner static method to help creating particle system set.
  122999. */
  123000. export class ParticleHelper {
  123001. /**
  123002. * Gets or sets base Assets URL
  123003. */
  123004. static BaseAssetsUrl: string;
  123005. /**
  123006. * Create a default particle system that you can tweak
  123007. * @param emitter defines the emitter to use
  123008. * @param capacity defines the system capacity (default is 500 particles)
  123009. * @param scene defines the hosting scene
  123010. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  123011. * @returns the new Particle system
  123012. */
  123013. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  123014. /**
  123015. * This is the main static method (one-liner) of this helper to create different particle systems
  123016. * @param type This string represents the type to the particle system to create
  123017. * @param scene The scene where the particle system should live
  123018. * @param gpu If the system will use gpu
  123019. * @returns the ParticleSystemSet created
  123020. */
  123021. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  123022. /**
  123023. * Static function used to export a particle system to a ParticleSystemSet variable.
  123024. * Please note that the emitter shape is not exported
  123025. * @param systems defines the particle systems to export
  123026. * @returns the created particle system set
  123027. */
  123028. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  123029. }
  123030. }
  123031. declare module BABYLON {
  123032. interface Engine {
  123033. /**
  123034. * Create an effect to use with particle systems.
  123035. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  123036. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  123037. * @param uniformsNames defines a list of attribute names
  123038. * @param samplers defines an array of string used to represent textures
  123039. * @param defines defines the string containing the defines to use to compile the shaders
  123040. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  123041. * @param onCompiled defines a function to call when the effect creation is successful
  123042. * @param onError defines a function to call when the effect creation has failed
  123043. * @returns the new Effect
  123044. */
  123045. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  123046. }
  123047. interface Mesh {
  123048. /**
  123049. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  123050. * @returns an array of IParticleSystem
  123051. */
  123052. getEmittedParticleSystems(): IParticleSystem[];
  123053. /**
  123054. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  123055. * @returns an array of IParticleSystem
  123056. */
  123057. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  123058. }
  123059. /**
  123060. * @hidden
  123061. */
  123062. export var _IDoNeedToBeInTheBuild: number;
  123063. }
  123064. declare module BABYLON {
  123065. interface Scene {
  123066. /** @hidden (Backing field) */
  123067. _physicsEngine: Nullable<IPhysicsEngine>;
  123068. /**
  123069. * Gets the current physics engine
  123070. * @returns a IPhysicsEngine or null if none attached
  123071. */
  123072. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  123073. /**
  123074. * Enables physics to the current scene
  123075. * @param gravity defines the scene's gravity for the physics engine
  123076. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  123077. * @return a boolean indicating if the physics engine was initialized
  123078. */
  123079. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  123080. /**
  123081. * Disables and disposes the physics engine associated with the scene
  123082. */
  123083. disablePhysicsEngine(): void;
  123084. /**
  123085. * Gets a boolean indicating if there is an active physics engine
  123086. * @returns a boolean indicating if there is an active physics engine
  123087. */
  123088. isPhysicsEnabled(): boolean;
  123089. /**
  123090. * Deletes a physics compound impostor
  123091. * @param compound defines the compound to delete
  123092. */
  123093. deleteCompoundImpostor(compound: any): void;
  123094. /**
  123095. * An event triggered when physic simulation is about to be run
  123096. */
  123097. onBeforePhysicsObservable: Observable<Scene>;
  123098. /**
  123099. * An event triggered when physic simulation has been done
  123100. */
  123101. onAfterPhysicsObservable: Observable<Scene>;
  123102. }
  123103. interface AbstractMesh {
  123104. /** @hidden */
  123105. _physicsImpostor: Nullable<PhysicsImpostor>;
  123106. /**
  123107. * Gets or sets impostor used for physic simulation
  123108. * @see http://doc.babylonjs.com/features/physics_engine
  123109. */
  123110. physicsImpostor: Nullable<PhysicsImpostor>;
  123111. /**
  123112. * Gets the current physics impostor
  123113. * @see http://doc.babylonjs.com/features/physics_engine
  123114. * @returns a physics impostor or null
  123115. */
  123116. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  123117. /** Apply a physic impulse to the mesh
  123118. * @param force defines the force to apply
  123119. * @param contactPoint defines where to apply the force
  123120. * @returns the current mesh
  123121. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  123122. */
  123123. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  123124. /**
  123125. * Creates a physic joint between two meshes
  123126. * @param otherMesh defines the other mesh to use
  123127. * @param pivot1 defines the pivot to use on this mesh
  123128. * @param pivot2 defines the pivot to use on the other mesh
  123129. * @param options defines additional options (can be plugin dependent)
  123130. * @returns the current mesh
  123131. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  123132. */
  123133. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  123134. /** @hidden */
  123135. _disposePhysicsObserver: Nullable<Observer<Node>>;
  123136. }
  123137. /**
  123138. * Defines the physics engine scene component responsible to manage a physics engine
  123139. */
  123140. export class PhysicsEngineSceneComponent implements ISceneComponent {
  123141. /**
  123142. * The component name helpful to identify the component in the list of scene components.
  123143. */
  123144. readonly name: string;
  123145. /**
  123146. * The scene the component belongs to.
  123147. */
  123148. scene: Scene;
  123149. /**
  123150. * Creates a new instance of the component for the given scene
  123151. * @param scene Defines the scene to register the component in
  123152. */
  123153. constructor(scene: Scene);
  123154. /**
  123155. * Registers the component in a given scene
  123156. */
  123157. register(): void;
  123158. /**
  123159. * Rebuilds the elements related to this component in case of
  123160. * context lost for instance.
  123161. */
  123162. rebuild(): void;
  123163. /**
  123164. * Disposes the component and the associated ressources
  123165. */
  123166. dispose(): void;
  123167. }
  123168. }
  123169. declare module BABYLON {
  123170. /**
  123171. * A helper for physics simulations
  123172. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123173. */
  123174. export class PhysicsHelper {
  123175. private _scene;
  123176. private _physicsEngine;
  123177. /**
  123178. * Initializes the Physics helper
  123179. * @param scene Babylon.js scene
  123180. */
  123181. constructor(scene: Scene);
  123182. /**
  123183. * Applies a radial explosion impulse
  123184. * @param origin the origin of the explosion
  123185. * @param radiusOrEventOptions the radius or the options of radial explosion
  123186. * @param strength the explosion strength
  123187. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123188. * @returns A physics radial explosion event, or null
  123189. */
  123190. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  123191. /**
  123192. * Applies a radial explosion force
  123193. * @param origin the origin of the explosion
  123194. * @param radiusOrEventOptions the radius or the options of radial explosion
  123195. * @param strength the explosion strength
  123196. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123197. * @returns A physics radial explosion event, or null
  123198. */
  123199. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  123200. /**
  123201. * Creates a gravitational field
  123202. * @param origin the origin of the explosion
  123203. * @param radiusOrEventOptions the radius or the options of radial explosion
  123204. * @param strength the explosion strength
  123205. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123206. * @returns A physics gravitational field event, or null
  123207. */
  123208. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  123209. /**
  123210. * Creates a physics updraft event
  123211. * @param origin the origin of the updraft
  123212. * @param radiusOrEventOptions the radius or the options of the updraft
  123213. * @param strength the strength of the updraft
  123214. * @param height the height of the updraft
  123215. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  123216. * @returns A physics updraft event, or null
  123217. */
  123218. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  123219. /**
  123220. * Creates a physics vortex event
  123221. * @param origin the of the vortex
  123222. * @param radiusOrEventOptions the radius or the options of the vortex
  123223. * @param strength the strength of the vortex
  123224. * @param height the height of the vortex
  123225. * @returns a Physics vortex event, or null
  123226. * A physics vortex event or null
  123227. */
  123228. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  123229. }
  123230. /**
  123231. * Represents a physics radial explosion event
  123232. */
  123233. class PhysicsRadialExplosionEvent {
  123234. private _scene;
  123235. private _options;
  123236. private _sphere;
  123237. private _dataFetched;
  123238. /**
  123239. * Initializes a radial explosioin event
  123240. * @param _scene BabylonJS scene
  123241. * @param _options The options for the vortex event
  123242. */
  123243. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  123244. /**
  123245. * Returns the data related to the radial explosion event (sphere).
  123246. * @returns The radial explosion event data
  123247. */
  123248. getData(): PhysicsRadialExplosionEventData;
  123249. /**
  123250. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  123251. * @param impostor A physics imposter
  123252. * @param origin the origin of the explosion
  123253. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  123254. */
  123255. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  123256. /**
  123257. * Triggers affecterd impostors callbacks
  123258. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  123259. */
  123260. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  123261. /**
  123262. * Disposes the sphere.
  123263. * @param force Specifies if the sphere should be disposed by force
  123264. */
  123265. dispose(force?: boolean): void;
  123266. /*** Helpers ***/
  123267. private _prepareSphere;
  123268. private _intersectsWithSphere;
  123269. }
  123270. /**
  123271. * Represents a gravitational field event
  123272. */
  123273. class PhysicsGravitationalFieldEvent {
  123274. private _physicsHelper;
  123275. private _scene;
  123276. private _origin;
  123277. private _options;
  123278. private _tickCallback;
  123279. private _sphere;
  123280. private _dataFetched;
  123281. /**
  123282. * Initializes the physics gravitational field event
  123283. * @param _physicsHelper A physics helper
  123284. * @param _scene BabylonJS scene
  123285. * @param _origin The origin position of the gravitational field event
  123286. * @param _options The options for the vortex event
  123287. */
  123288. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  123289. /**
  123290. * Returns the data related to the gravitational field event (sphere).
  123291. * @returns A gravitational field event
  123292. */
  123293. getData(): PhysicsGravitationalFieldEventData;
  123294. /**
  123295. * Enables the gravitational field.
  123296. */
  123297. enable(): void;
  123298. /**
  123299. * Disables the gravitational field.
  123300. */
  123301. disable(): void;
  123302. /**
  123303. * Disposes the sphere.
  123304. * @param force The force to dispose from the gravitational field event
  123305. */
  123306. dispose(force?: boolean): void;
  123307. private _tick;
  123308. }
  123309. /**
  123310. * Represents a physics updraft event
  123311. */
  123312. class PhysicsUpdraftEvent {
  123313. private _scene;
  123314. private _origin;
  123315. private _options;
  123316. private _physicsEngine;
  123317. private _originTop;
  123318. private _originDirection;
  123319. private _tickCallback;
  123320. private _cylinder;
  123321. private _cylinderPosition;
  123322. private _dataFetched;
  123323. /**
  123324. * Initializes the physics updraft event
  123325. * @param _scene BabylonJS scene
  123326. * @param _origin The origin position of the updraft
  123327. * @param _options The options for the updraft event
  123328. */
  123329. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  123330. /**
  123331. * Returns the data related to the updraft event (cylinder).
  123332. * @returns A physics updraft event
  123333. */
  123334. getData(): PhysicsUpdraftEventData;
  123335. /**
  123336. * Enables the updraft.
  123337. */
  123338. enable(): void;
  123339. /**
  123340. * Disables the updraft.
  123341. */
  123342. disable(): void;
  123343. /**
  123344. * Disposes the cylinder.
  123345. * @param force Specifies if the updraft should be disposed by force
  123346. */
  123347. dispose(force?: boolean): void;
  123348. private getImpostorHitData;
  123349. private _tick;
  123350. /*** Helpers ***/
  123351. private _prepareCylinder;
  123352. private _intersectsWithCylinder;
  123353. }
  123354. /**
  123355. * Represents a physics vortex event
  123356. */
  123357. class PhysicsVortexEvent {
  123358. private _scene;
  123359. private _origin;
  123360. private _options;
  123361. private _physicsEngine;
  123362. private _originTop;
  123363. private _tickCallback;
  123364. private _cylinder;
  123365. private _cylinderPosition;
  123366. private _dataFetched;
  123367. /**
  123368. * Initializes the physics vortex event
  123369. * @param _scene The BabylonJS scene
  123370. * @param _origin The origin position of the vortex
  123371. * @param _options The options for the vortex event
  123372. */
  123373. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  123374. /**
  123375. * Returns the data related to the vortex event (cylinder).
  123376. * @returns The physics vortex event data
  123377. */
  123378. getData(): PhysicsVortexEventData;
  123379. /**
  123380. * Enables the vortex.
  123381. */
  123382. enable(): void;
  123383. /**
  123384. * Disables the cortex.
  123385. */
  123386. disable(): void;
  123387. /**
  123388. * Disposes the sphere.
  123389. * @param force
  123390. */
  123391. dispose(force?: boolean): void;
  123392. private getImpostorHitData;
  123393. private _tick;
  123394. /*** Helpers ***/
  123395. private _prepareCylinder;
  123396. private _intersectsWithCylinder;
  123397. }
  123398. /**
  123399. * Options fot the radial explosion event
  123400. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123401. */
  123402. export class PhysicsRadialExplosionEventOptions {
  123403. /**
  123404. * The radius of the sphere for the radial explosion.
  123405. */
  123406. radius: number;
  123407. /**
  123408. * The strenth of the explosion.
  123409. */
  123410. strength: number;
  123411. /**
  123412. * The strenght of the force in correspondence to the distance of the affected object
  123413. */
  123414. falloff: PhysicsRadialImpulseFalloff;
  123415. /**
  123416. * Sphere options for the radial explosion.
  123417. */
  123418. sphere: {
  123419. segments: number;
  123420. diameter: number;
  123421. };
  123422. /**
  123423. * Sphere options for the radial explosion.
  123424. */
  123425. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  123426. }
  123427. /**
  123428. * Options fot the updraft event
  123429. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123430. */
  123431. export class PhysicsUpdraftEventOptions {
  123432. /**
  123433. * The radius of the cylinder for the vortex
  123434. */
  123435. radius: number;
  123436. /**
  123437. * The strenth of the updraft.
  123438. */
  123439. strength: number;
  123440. /**
  123441. * The height of the cylinder for the updraft.
  123442. */
  123443. height: number;
  123444. /**
  123445. * The mode for the the updraft.
  123446. */
  123447. updraftMode: PhysicsUpdraftMode;
  123448. }
  123449. /**
  123450. * Options fot the vortex event
  123451. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123452. */
  123453. export class PhysicsVortexEventOptions {
  123454. /**
  123455. * The radius of the cylinder for the vortex
  123456. */
  123457. radius: number;
  123458. /**
  123459. * The strenth of the vortex.
  123460. */
  123461. strength: number;
  123462. /**
  123463. * The height of the cylinder for the vortex.
  123464. */
  123465. height: number;
  123466. /**
  123467. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  123468. */
  123469. centripetalForceThreshold: number;
  123470. /**
  123471. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  123472. */
  123473. centripetalForceMultiplier: number;
  123474. /**
  123475. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  123476. */
  123477. centrifugalForceMultiplier: number;
  123478. /**
  123479. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  123480. */
  123481. updraftForceMultiplier: number;
  123482. }
  123483. /**
  123484. * The strenght of the force in correspondence to the distance of the affected object
  123485. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123486. */
  123487. export enum PhysicsRadialImpulseFalloff {
  123488. /** Defines that impulse is constant in strength across it's whole radius */
  123489. Constant = 0,
  123490. /** Defines that impulse gets weaker if it's further from the origin */
  123491. Linear = 1
  123492. }
  123493. /**
  123494. * The strength of the force in correspondence to the distance of the affected object
  123495. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123496. */
  123497. export enum PhysicsUpdraftMode {
  123498. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  123499. Center = 0,
  123500. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  123501. Perpendicular = 1
  123502. }
  123503. /**
  123504. * Interface for a physics hit data
  123505. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123506. */
  123507. export interface PhysicsHitData {
  123508. /**
  123509. * The force applied at the contact point
  123510. */
  123511. force: Vector3;
  123512. /**
  123513. * The contact point
  123514. */
  123515. contactPoint: Vector3;
  123516. /**
  123517. * The distance from the origin to the contact point
  123518. */
  123519. distanceFromOrigin: number;
  123520. }
  123521. /**
  123522. * Interface for radial explosion event data
  123523. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123524. */
  123525. export interface PhysicsRadialExplosionEventData {
  123526. /**
  123527. * A sphere used for the radial explosion event
  123528. */
  123529. sphere: Mesh;
  123530. }
  123531. /**
  123532. * Interface for gravitational field event data
  123533. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123534. */
  123535. export interface PhysicsGravitationalFieldEventData {
  123536. /**
  123537. * A sphere mesh used for the gravitational field event
  123538. */
  123539. sphere: Mesh;
  123540. }
  123541. /**
  123542. * Interface for updraft event data
  123543. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123544. */
  123545. export interface PhysicsUpdraftEventData {
  123546. /**
  123547. * A cylinder used for the updraft event
  123548. */
  123549. cylinder: Mesh;
  123550. }
  123551. /**
  123552. * Interface for vortex event data
  123553. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123554. */
  123555. export interface PhysicsVortexEventData {
  123556. /**
  123557. * A cylinder used for the vortex event
  123558. */
  123559. cylinder: Mesh;
  123560. }
  123561. /**
  123562. * Interface for an affected physics impostor
  123563. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123564. */
  123565. export interface PhysicsAffectedImpostorWithData {
  123566. /**
  123567. * The impostor affected by the effect
  123568. */
  123569. impostor: PhysicsImpostor;
  123570. /**
  123571. * The data about the hit/horce from the explosion
  123572. */
  123573. hitData: PhysicsHitData;
  123574. }
  123575. }
  123576. declare module BABYLON {
  123577. /** @hidden */
  123578. export var blackAndWhitePixelShader: {
  123579. name: string;
  123580. shader: string;
  123581. };
  123582. }
  123583. declare module BABYLON {
  123584. /**
  123585. * Post process used to render in black and white
  123586. */
  123587. export class BlackAndWhitePostProcess extends PostProcess {
  123588. /**
  123589. * Linear about to convert he result to black and white (default: 1)
  123590. */
  123591. degree: number;
  123592. /**
  123593. * Creates a black and white post process
  123594. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  123595. * @param name The name of the effect.
  123596. * @param options The required width/height ratio to downsize to before computing the render pass.
  123597. * @param camera The camera to apply the render pass to.
  123598. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123599. * @param engine The engine which the post process will be applied. (default: current engine)
  123600. * @param reusable If the post process can be reused on the same frame. (default: false)
  123601. */
  123602. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  123603. }
  123604. }
  123605. declare module BABYLON {
  123606. /**
  123607. * This represents a set of one or more post processes in Babylon.
  123608. * A post process can be used to apply a shader to a texture after it is rendered.
  123609. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  123610. */
  123611. export class PostProcessRenderEffect {
  123612. private _postProcesses;
  123613. private _getPostProcesses;
  123614. private _singleInstance;
  123615. private _cameras;
  123616. private _indicesForCamera;
  123617. /**
  123618. * Name of the effect
  123619. * @hidden
  123620. */
  123621. _name: string;
  123622. /**
  123623. * Instantiates a post process render effect.
  123624. * A post process can be used to apply a shader to a texture after it is rendered.
  123625. * @param engine The engine the effect is tied to
  123626. * @param name The name of the effect
  123627. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  123628. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  123629. */
  123630. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  123631. /**
  123632. * Checks if all the post processes in the effect are supported.
  123633. */
  123634. readonly isSupported: boolean;
  123635. /**
  123636. * Updates the current state of the effect
  123637. * @hidden
  123638. */
  123639. _update(): void;
  123640. /**
  123641. * Attaches the effect on cameras
  123642. * @param cameras The camera to attach to.
  123643. * @hidden
  123644. */
  123645. _attachCameras(cameras: Camera): void;
  123646. /**
  123647. * Attaches the effect on cameras
  123648. * @param cameras The camera to attach to.
  123649. * @hidden
  123650. */
  123651. _attachCameras(cameras: Camera[]): void;
  123652. /**
  123653. * Detaches the effect on cameras
  123654. * @param cameras The camera to detatch from.
  123655. * @hidden
  123656. */
  123657. _detachCameras(cameras: Camera): void;
  123658. /**
  123659. * Detatches the effect on cameras
  123660. * @param cameras The camera to detatch from.
  123661. * @hidden
  123662. */
  123663. _detachCameras(cameras: Camera[]): void;
  123664. /**
  123665. * Enables the effect on given cameras
  123666. * @param cameras The camera to enable.
  123667. * @hidden
  123668. */
  123669. _enable(cameras: Camera): void;
  123670. /**
  123671. * Enables the effect on given cameras
  123672. * @param cameras The camera to enable.
  123673. * @hidden
  123674. */
  123675. _enable(cameras: Nullable<Camera[]>): void;
  123676. /**
  123677. * Disables the effect on the given cameras
  123678. * @param cameras The camera to disable.
  123679. * @hidden
  123680. */
  123681. _disable(cameras: Camera): void;
  123682. /**
  123683. * Disables the effect on the given cameras
  123684. * @param cameras The camera to disable.
  123685. * @hidden
  123686. */
  123687. _disable(cameras: Nullable<Camera[]>): void;
  123688. /**
  123689. * Gets a list of the post processes contained in the effect.
  123690. * @param camera The camera to get the post processes on.
  123691. * @returns The list of the post processes in the effect.
  123692. */
  123693. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  123694. }
  123695. }
  123696. declare module BABYLON {
  123697. /** @hidden */
  123698. export var extractHighlightsPixelShader: {
  123699. name: string;
  123700. shader: string;
  123701. };
  123702. }
  123703. declare module BABYLON {
  123704. /**
  123705. * 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.
  123706. */
  123707. export class ExtractHighlightsPostProcess extends PostProcess {
  123708. /**
  123709. * The luminance threshold, pixels below this value will be set to black.
  123710. */
  123711. threshold: number;
  123712. /** @hidden */
  123713. _exposure: number;
  123714. /**
  123715. * Post process which has the input texture to be used when performing highlight extraction
  123716. * @hidden
  123717. */
  123718. _inputPostProcess: Nullable<PostProcess>;
  123719. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123720. }
  123721. }
  123722. declare module BABYLON {
  123723. /** @hidden */
  123724. export var bloomMergePixelShader: {
  123725. name: string;
  123726. shader: string;
  123727. };
  123728. }
  123729. declare module BABYLON {
  123730. /**
  123731. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  123732. */
  123733. export class BloomMergePostProcess extends PostProcess {
  123734. /** Weight of the bloom to be added to the original input. */
  123735. weight: number;
  123736. /**
  123737. * Creates a new instance of @see BloomMergePostProcess
  123738. * @param name The name of the effect.
  123739. * @param originalFromInput Post process which's input will be used for the merge.
  123740. * @param blurred Blurred highlights post process which's output will be used.
  123741. * @param weight Weight of the bloom to be added to the original input.
  123742. * @param options The required width/height ratio to downsize to before computing the render pass.
  123743. * @param camera The camera to apply the render pass to.
  123744. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123745. * @param engine The engine which the post process will be applied. (default: current engine)
  123746. * @param reusable If the post process can be reused on the same frame. (default: false)
  123747. * @param textureType Type of textures used when performing the post process. (default: 0)
  123748. * @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)
  123749. */
  123750. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  123751. /** Weight of the bloom to be added to the original input. */
  123752. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123753. }
  123754. }
  123755. declare module BABYLON {
  123756. /**
  123757. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  123758. */
  123759. export class BloomEffect extends PostProcessRenderEffect {
  123760. private bloomScale;
  123761. /**
  123762. * @hidden Internal
  123763. */
  123764. _effects: Array<PostProcess>;
  123765. /**
  123766. * @hidden Internal
  123767. */
  123768. _downscale: ExtractHighlightsPostProcess;
  123769. private _blurX;
  123770. private _blurY;
  123771. private _merge;
  123772. /**
  123773. * The luminance threshold to find bright areas of the image to bloom.
  123774. */
  123775. threshold: number;
  123776. /**
  123777. * The strength of the bloom.
  123778. */
  123779. weight: number;
  123780. /**
  123781. * Specifies the size of the bloom blur kernel, relative to the final output size
  123782. */
  123783. kernel: number;
  123784. /**
  123785. * Creates a new instance of @see BloomEffect
  123786. * @param scene The scene the effect belongs to.
  123787. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  123788. * @param bloomKernel The size of the kernel to be used when applying the blur.
  123789. * @param bloomWeight The the strength of bloom.
  123790. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  123791. * @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)
  123792. */
  123793. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  123794. /**
  123795. * Disposes each of the internal effects for a given camera.
  123796. * @param camera The camera to dispose the effect on.
  123797. */
  123798. disposeEffects(camera: Camera): void;
  123799. /**
  123800. * @hidden Internal
  123801. */
  123802. _updateEffects(): void;
  123803. /**
  123804. * Internal
  123805. * @returns if all the contained post processes are ready.
  123806. * @hidden
  123807. */
  123808. _isReady(): boolean;
  123809. }
  123810. }
  123811. declare module BABYLON {
  123812. /** @hidden */
  123813. export var chromaticAberrationPixelShader: {
  123814. name: string;
  123815. shader: string;
  123816. };
  123817. }
  123818. declare module BABYLON {
  123819. /**
  123820. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  123821. */
  123822. export class ChromaticAberrationPostProcess extends PostProcess {
  123823. /**
  123824. * The amount of seperation of rgb channels (default: 30)
  123825. */
  123826. aberrationAmount: number;
  123827. /**
  123828. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  123829. */
  123830. radialIntensity: number;
  123831. /**
  123832. * 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))
  123833. */
  123834. direction: Vector2;
  123835. /**
  123836. * 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))
  123837. */
  123838. centerPosition: Vector2;
  123839. /**
  123840. * Creates a new instance ChromaticAberrationPostProcess
  123841. * @param name The name of the effect.
  123842. * @param screenWidth The width of the screen to apply the effect on.
  123843. * @param screenHeight The height of the screen to apply the effect on.
  123844. * @param options The required width/height ratio to downsize to before computing the render pass.
  123845. * @param camera The camera to apply the render pass to.
  123846. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123847. * @param engine The engine which the post process will be applied. (default: current engine)
  123848. * @param reusable If the post process can be reused on the same frame. (default: false)
  123849. * @param textureType Type of textures used when performing the post process. (default: 0)
  123850. * @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)
  123851. */
  123852. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123853. }
  123854. }
  123855. declare module BABYLON {
  123856. /** @hidden */
  123857. export var circleOfConfusionPixelShader: {
  123858. name: string;
  123859. shader: string;
  123860. };
  123861. }
  123862. declare module BABYLON {
  123863. /**
  123864. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  123865. */
  123866. export class CircleOfConfusionPostProcess extends PostProcess {
  123867. /**
  123868. * 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.
  123869. */
  123870. lensSize: number;
  123871. /**
  123872. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  123873. */
  123874. fStop: number;
  123875. /**
  123876. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  123877. */
  123878. focusDistance: number;
  123879. /**
  123880. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  123881. */
  123882. focalLength: number;
  123883. private _depthTexture;
  123884. /**
  123885. * Creates a new instance CircleOfConfusionPostProcess
  123886. * @param name The name of the effect.
  123887. * @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.
  123888. * @param options The required width/height ratio to downsize to before computing the render pass.
  123889. * @param camera The camera to apply the render pass to.
  123890. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123891. * @param engine The engine which the post process will be applied. (default: current engine)
  123892. * @param reusable If the post process can be reused on the same frame. (default: false)
  123893. * @param textureType Type of textures used when performing the post process. (default: 0)
  123894. * @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)
  123895. */
  123896. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123897. /**
  123898. * 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.
  123899. */
  123900. depthTexture: RenderTargetTexture;
  123901. }
  123902. }
  123903. declare module BABYLON {
  123904. /** @hidden */
  123905. export var colorCorrectionPixelShader: {
  123906. name: string;
  123907. shader: string;
  123908. };
  123909. }
  123910. declare module BABYLON {
  123911. /**
  123912. *
  123913. * This post-process allows the modification of rendered colors by using
  123914. * a 'look-up table' (LUT). This effect is also called Color Grading.
  123915. *
  123916. * The object needs to be provided an url to a texture containing the color
  123917. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  123918. * Use an image editing software to tweak the LUT to match your needs.
  123919. *
  123920. * For an example of a color LUT, see here:
  123921. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  123922. * For explanations on color grading, see here:
  123923. * @see http://udn.epicgames.com/Three/ColorGrading.html
  123924. *
  123925. */
  123926. export class ColorCorrectionPostProcess extends PostProcess {
  123927. private _colorTableTexture;
  123928. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  123929. }
  123930. }
  123931. declare module BABYLON {
  123932. /** @hidden */
  123933. export var convolutionPixelShader: {
  123934. name: string;
  123935. shader: string;
  123936. };
  123937. }
  123938. declare module BABYLON {
  123939. /**
  123940. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  123941. * input texture to perform effects such as edge detection or sharpening
  123942. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  123943. */
  123944. export class ConvolutionPostProcess extends PostProcess {
  123945. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  123946. kernel: number[];
  123947. /**
  123948. * Creates a new instance ConvolutionPostProcess
  123949. * @param name The name of the effect.
  123950. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  123951. * @param options The required width/height ratio to downsize to before computing the render pass.
  123952. * @param camera The camera to apply the render pass to.
  123953. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123954. * @param engine The engine which the post process will be applied. (default: current engine)
  123955. * @param reusable If the post process can be reused on the same frame. (default: false)
  123956. * @param textureType Type of textures used when performing the post process. (default: 0)
  123957. */
  123958. constructor(name: string,
  123959. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  123960. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  123961. /**
  123962. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123963. */
  123964. static EdgeDetect0Kernel: number[];
  123965. /**
  123966. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123967. */
  123968. static EdgeDetect1Kernel: number[];
  123969. /**
  123970. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123971. */
  123972. static EdgeDetect2Kernel: number[];
  123973. /**
  123974. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123975. */
  123976. static SharpenKernel: number[];
  123977. /**
  123978. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123979. */
  123980. static EmbossKernel: number[];
  123981. /**
  123982. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123983. */
  123984. static GaussianKernel: number[];
  123985. }
  123986. }
  123987. declare module BABYLON {
  123988. /**
  123989. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  123990. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  123991. * based on samples that have a large difference in distance than the center pixel.
  123992. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  123993. */
  123994. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  123995. direction: Vector2;
  123996. /**
  123997. * Creates a new instance CircleOfConfusionPostProcess
  123998. * @param name The name of the effect.
  123999. * @param scene The scene the effect belongs to.
  124000. * @param direction The direction the blur should be applied.
  124001. * @param kernel The size of the kernel used to blur.
  124002. * @param options The required width/height ratio to downsize to before computing the render pass.
  124003. * @param camera The camera to apply the render pass to.
  124004. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  124005. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  124006. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124007. * @param engine The engine which the post process will be applied. (default: current engine)
  124008. * @param reusable If the post process can be reused on the same frame. (default: false)
  124009. * @param textureType Type of textures used when performing the post process. (default: 0)
  124010. * @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)
  124011. */
  124012. 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);
  124013. }
  124014. }
  124015. declare module BABYLON {
  124016. /** @hidden */
  124017. export var depthOfFieldMergePixelShader: {
  124018. name: string;
  124019. shader: string;
  124020. };
  124021. }
  124022. declare module BABYLON {
  124023. /**
  124024. * Options to be set when merging outputs from the default pipeline.
  124025. */
  124026. export class DepthOfFieldMergePostProcessOptions {
  124027. /**
  124028. * The original image to merge on top of
  124029. */
  124030. originalFromInput: PostProcess;
  124031. /**
  124032. * Parameters to perform the merge of the depth of field effect
  124033. */
  124034. depthOfField?: {
  124035. circleOfConfusion: PostProcess;
  124036. blurSteps: Array<PostProcess>;
  124037. };
  124038. /**
  124039. * Parameters to perform the merge of bloom effect
  124040. */
  124041. bloom?: {
  124042. blurred: PostProcess;
  124043. weight: number;
  124044. };
  124045. }
  124046. /**
  124047. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  124048. */
  124049. export class DepthOfFieldMergePostProcess extends PostProcess {
  124050. private blurSteps;
  124051. /**
  124052. * Creates a new instance of DepthOfFieldMergePostProcess
  124053. * @param name The name of the effect.
  124054. * @param originalFromInput Post process which's input will be used for the merge.
  124055. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  124056. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  124057. * @param options The required width/height ratio to downsize to before computing the render pass.
  124058. * @param camera The camera to apply the render pass to.
  124059. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124060. * @param engine The engine which the post process will be applied. (default: current engine)
  124061. * @param reusable If the post process can be reused on the same frame. (default: false)
  124062. * @param textureType Type of textures used when performing the post process. (default: 0)
  124063. * @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)
  124064. */
  124065. 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);
  124066. /**
  124067. * Updates the effect with the current post process compile time values and recompiles the shader.
  124068. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  124069. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  124070. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  124071. * @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
  124072. * @param onCompiled Called when the shader has been compiled.
  124073. * @param onError Called if there is an error when compiling a shader.
  124074. */
  124075. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  124076. }
  124077. }
  124078. declare module BABYLON {
  124079. /**
  124080. * Specifies the level of max blur that should be applied when using the depth of field effect
  124081. */
  124082. export enum DepthOfFieldEffectBlurLevel {
  124083. /**
  124084. * Subtle blur
  124085. */
  124086. Low = 0,
  124087. /**
  124088. * Medium blur
  124089. */
  124090. Medium = 1,
  124091. /**
  124092. * Large blur
  124093. */
  124094. High = 2
  124095. }
  124096. /**
  124097. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  124098. */
  124099. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  124100. private _circleOfConfusion;
  124101. /**
  124102. * @hidden Internal, blurs from high to low
  124103. */
  124104. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  124105. private _depthOfFieldBlurY;
  124106. private _dofMerge;
  124107. /**
  124108. * @hidden Internal post processes in depth of field effect
  124109. */
  124110. _effects: Array<PostProcess>;
  124111. /**
  124112. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  124113. */
  124114. focalLength: number;
  124115. /**
  124116. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  124117. */
  124118. fStop: number;
  124119. /**
  124120. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  124121. */
  124122. focusDistance: number;
  124123. /**
  124124. * 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.
  124125. */
  124126. lensSize: number;
  124127. /**
  124128. * Creates a new instance DepthOfFieldEffect
  124129. * @param scene The scene the effect belongs to.
  124130. * @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.
  124131. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  124132. * @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)
  124133. */
  124134. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  124135. /**
  124136. * Get the current class name of the current effet
  124137. * @returns "DepthOfFieldEffect"
  124138. */
  124139. getClassName(): string;
  124140. /**
  124141. * 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.
  124142. */
  124143. depthTexture: RenderTargetTexture;
  124144. /**
  124145. * Disposes each of the internal effects for a given camera.
  124146. * @param camera The camera to dispose the effect on.
  124147. */
  124148. disposeEffects(camera: Camera): void;
  124149. /**
  124150. * @hidden Internal
  124151. */
  124152. _updateEffects(): void;
  124153. /**
  124154. * Internal
  124155. * @returns if all the contained post processes are ready.
  124156. * @hidden
  124157. */
  124158. _isReady(): boolean;
  124159. }
  124160. }
  124161. declare module BABYLON {
  124162. /** @hidden */
  124163. export var displayPassPixelShader: {
  124164. name: string;
  124165. shader: string;
  124166. };
  124167. }
  124168. declare module BABYLON {
  124169. /**
  124170. * DisplayPassPostProcess which produces an output the same as it's input
  124171. */
  124172. export class DisplayPassPostProcess extends PostProcess {
  124173. /**
  124174. * Creates the DisplayPassPostProcess
  124175. * @param name The name of the effect.
  124176. * @param options The required width/height ratio to downsize to before computing the render pass.
  124177. * @param camera The camera to apply the render pass to.
  124178. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124179. * @param engine The engine which the post process will be applied. (default: current engine)
  124180. * @param reusable If the post process can be reused on the same frame. (default: false)
  124181. */
  124182. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124183. }
  124184. }
  124185. declare module BABYLON {
  124186. /** @hidden */
  124187. export var filterPixelShader: {
  124188. name: string;
  124189. shader: string;
  124190. };
  124191. }
  124192. declare module BABYLON {
  124193. /**
  124194. * Applies a kernel filter to the image
  124195. */
  124196. export class FilterPostProcess extends PostProcess {
  124197. /** The matrix to be applied to the image */
  124198. kernelMatrix: Matrix;
  124199. /**
  124200. *
  124201. * @param name The name of the effect.
  124202. * @param kernelMatrix The matrix to be applied to the image
  124203. * @param options The required width/height ratio to downsize to before computing the render pass.
  124204. * @param camera The camera to apply the render pass to.
  124205. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124206. * @param engine The engine which the post process will be applied. (default: current engine)
  124207. * @param reusable If the post process can be reused on the same frame. (default: false)
  124208. */
  124209. constructor(name: string,
  124210. /** The matrix to be applied to the image */
  124211. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124212. }
  124213. }
  124214. declare module BABYLON {
  124215. /** @hidden */
  124216. export var fxaaPixelShader: {
  124217. name: string;
  124218. shader: string;
  124219. };
  124220. }
  124221. declare module BABYLON {
  124222. /** @hidden */
  124223. export var fxaaVertexShader: {
  124224. name: string;
  124225. shader: string;
  124226. };
  124227. }
  124228. declare module BABYLON {
  124229. /**
  124230. * Fxaa post process
  124231. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  124232. */
  124233. export class FxaaPostProcess extends PostProcess {
  124234. /** @hidden */
  124235. texelWidth: number;
  124236. /** @hidden */
  124237. texelHeight: number;
  124238. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124239. private _getDefines;
  124240. }
  124241. }
  124242. declare module BABYLON {
  124243. /** @hidden */
  124244. export var grainPixelShader: {
  124245. name: string;
  124246. shader: string;
  124247. };
  124248. }
  124249. declare module BABYLON {
  124250. /**
  124251. * The GrainPostProcess adds noise to the image at mid luminance levels
  124252. */
  124253. export class GrainPostProcess extends PostProcess {
  124254. /**
  124255. * The intensity of the grain added (default: 30)
  124256. */
  124257. intensity: number;
  124258. /**
  124259. * If the grain should be randomized on every frame
  124260. */
  124261. animated: boolean;
  124262. /**
  124263. * Creates a new instance of @see GrainPostProcess
  124264. * @param name The name of the effect.
  124265. * @param options The required width/height ratio to downsize to before computing the render pass.
  124266. * @param camera The camera to apply the render pass to.
  124267. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124268. * @param engine The engine which the post process will be applied. (default: current engine)
  124269. * @param reusable If the post process can be reused on the same frame. (default: false)
  124270. * @param textureType Type of textures used when performing the post process. (default: 0)
  124271. * @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)
  124272. */
  124273. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124274. }
  124275. }
  124276. declare module BABYLON {
  124277. /** @hidden */
  124278. export var highlightsPixelShader: {
  124279. name: string;
  124280. shader: string;
  124281. };
  124282. }
  124283. declare module BABYLON {
  124284. /**
  124285. * Extracts highlights from the image
  124286. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  124287. */
  124288. export class HighlightsPostProcess extends PostProcess {
  124289. /**
  124290. * Extracts highlights from the image
  124291. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  124292. * @param name The name of the effect.
  124293. * @param options The required width/height ratio to downsize to before computing the render pass.
  124294. * @param camera The camera to apply the render pass to.
  124295. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124296. * @param engine The engine which the post process will be applied. (default: current engine)
  124297. * @param reusable If the post process can be reused on the same frame. (default: false)
  124298. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  124299. */
  124300. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124301. }
  124302. }
  124303. declare module BABYLON {
  124304. /** @hidden */
  124305. export var mrtFragmentDeclaration: {
  124306. name: string;
  124307. shader: string;
  124308. };
  124309. }
  124310. declare module BABYLON {
  124311. /** @hidden */
  124312. export var geometryPixelShader: {
  124313. name: string;
  124314. shader: string;
  124315. };
  124316. }
  124317. declare module BABYLON {
  124318. /** @hidden */
  124319. export var geometryVertexShader: {
  124320. name: string;
  124321. shader: string;
  124322. };
  124323. }
  124324. declare module BABYLON {
  124325. /** @hidden */
  124326. interface ISavedTransformationMatrix {
  124327. world: Matrix;
  124328. viewProjection: Matrix;
  124329. }
  124330. /**
  124331. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  124332. */
  124333. export class GeometryBufferRenderer {
  124334. /**
  124335. * Constant used to retrieve the position texture index in the G-Buffer textures array
  124336. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  124337. */
  124338. static readonly POSITION_TEXTURE_TYPE: number;
  124339. /**
  124340. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  124341. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  124342. */
  124343. static readonly VELOCITY_TEXTURE_TYPE: number;
  124344. /**
  124345. * Dictionary used to store the previous transformation matrices of each rendered mesh
  124346. * in order to compute objects velocities when enableVelocity is set to "true"
  124347. * @hidden
  124348. */
  124349. _previousTransformationMatrices: {
  124350. [index: number]: ISavedTransformationMatrix;
  124351. };
  124352. /**
  124353. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  124354. * in order to compute objects velocities when enableVelocity is set to "true"
  124355. * @hidden
  124356. */
  124357. _previousBonesTransformationMatrices: {
  124358. [index: number]: Float32Array;
  124359. };
  124360. /**
  124361. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  124362. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  124363. */
  124364. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  124365. private _scene;
  124366. private _multiRenderTarget;
  124367. private _ratio;
  124368. private _enablePosition;
  124369. private _enableVelocity;
  124370. private _positionIndex;
  124371. private _velocityIndex;
  124372. protected _effect: Effect;
  124373. protected _cachedDefines: string;
  124374. /**
  124375. * Set the render list (meshes to be rendered) used in the G buffer.
  124376. */
  124377. renderList: Mesh[];
  124378. /**
  124379. * Gets wether or not G buffer are supported by the running hardware.
  124380. * This requires draw buffer supports
  124381. */
  124382. readonly isSupported: boolean;
  124383. /**
  124384. * Returns the index of the given texture type in the G-Buffer textures array
  124385. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  124386. * @returns the index of the given texture type in the G-Buffer textures array
  124387. */
  124388. getTextureIndex(textureType: number): number;
  124389. /**
  124390. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  124391. */
  124392. /**
  124393. * Sets whether or not objects positions are enabled for the G buffer.
  124394. */
  124395. enablePosition: boolean;
  124396. /**
  124397. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  124398. */
  124399. /**
  124400. * Sets wether or not objects velocities are enabled for the G buffer.
  124401. */
  124402. enableVelocity: boolean;
  124403. /**
  124404. * Gets the scene associated with the buffer.
  124405. */
  124406. readonly scene: Scene;
  124407. /**
  124408. * Gets the ratio used by the buffer during its creation.
  124409. * How big is the buffer related to the main canvas.
  124410. */
  124411. readonly ratio: number;
  124412. /** @hidden */
  124413. static _SceneComponentInitialization: (scene: Scene) => void;
  124414. /**
  124415. * Creates a new G Buffer for the scene
  124416. * @param scene The scene the buffer belongs to
  124417. * @param ratio How big is the buffer related to the main canvas.
  124418. */
  124419. constructor(scene: Scene, ratio?: number);
  124420. /**
  124421. * Checks wether everything is ready to render a submesh to the G buffer.
  124422. * @param subMesh the submesh to check readiness for
  124423. * @param useInstances is the mesh drawn using instance or not
  124424. * @returns true if ready otherwise false
  124425. */
  124426. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  124427. /**
  124428. * Gets the current underlying G Buffer.
  124429. * @returns the buffer
  124430. */
  124431. getGBuffer(): MultiRenderTarget;
  124432. /**
  124433. * Gets the number of samples used to render the buffer (anti aliasing).
  124434. */
  124435. /**
  124436. * Sets the number of samples used to render the buffer (anti aliasing).
  124437. */
  124438. samples: number;
  124439. /**
  124440. * Disposes the renderer and frees up associated resources.
  124441. */
  124442. dispose(): void;
  124443. protected _createRenderTargets(): void;
  124444. private _copyBonesTransformationMatrices;
  124445. }
  124446. }
  124447. declare module BABYLON {
  124448. interface Scene {
  124449. /** @hidden (Backing field) */
  124450. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  124451. /**
  124452. * Gets or Sets the current geometry buffer associated to the scene.
  124453. */
  124454. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  124455. /**
  124456. * Enables a GeometryBufferRender and associates it with the scene
  124457. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  124458. * @returns the GeometryBufferRenderer
  124459. */
  124460. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  124461. /**
  124462. * Disables the GeometryBufferRender associated with the scene
  124463. */
  124464. disableGeometryBufferRenderer(): void;
  124465. }
  124466. /**
  124467. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  124468. * in several rendering techniques.
  124469. */
  124470. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  124471. /**
  124472. * The component name helpful to identify the component in the list of scene components.
  124473. */
  124474. readonly name: string;
  124475. /**
  124476. * The scene the component belongs to.
  124477. */
  124478. scene: Scene;
  124479. /**
  124480. * Creates a new instance of the component for the given scene
  124481. * @param scene Defines the scene to register the component in
  124482. */
  124483. constructor(scene: Scene);
  124484. /**
  124485. * Registers the component in a given scene
  124486. */
  124487. register(): void;
  124488. /**
  124489. * Rebuilds the elements related to this component in case of
  124490. * context lost for instance.
  124491. */
  124492. rebuild(): void;
  124493. /**
  124494. * Disposes the component and the associated ressources
  124495. */
  124496. dispose(): void;
  124497. private _gatherRenderTargets;
  124498. }
  124499. }
  124500. declare module BABYLON {
  124501. /** @hidden */
  124502. export var motionBlurPixelShader: {
  124503. name: string;
  124504. shader: string;
  124505. };
  124506. }
  124507. declare module BABYLON {
  124508. /**
  124509. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  124510. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  124511. * As an example, all you have to do is to create the post-process:
  124512. * var mb = new BABYLON.MotionBlurPostProcess(
  124513. * 'mb', // The name of the effect.
  124514. * scene, // The scene containing the objects to blur according to their velocity.
  124515. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  124516. * camera // The camera to apply the render pass to.
  124517. * );
  124518. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  124519. */
  124520. export class MotionBlurPostProcess extends PostProcess {
  124521. /**
  124522. * Defines how much the image is blurred by the movement. Default value is equal to 1
  124523. */
  124524. motionStrength: number;
  124525. /**
  124526. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  124527. */
  124528. /**
  124529. * Sets the number of iterations to be used for motion blur quality
  124530. */
  124531. motionBlurSamples: number;
  124532. private _motionBlurSamples;
  124533. private _geometryBufferRenderer;
  124534. /**
  124535. * Creates a new instance MotionBlurPostProcess
  124536. * @param name The name of the effect.
  124537. * @param scene The scene containing the objects to blur according to their velocity.
  124538. * @param options The required width/height ratio to downsize to before computing the render pass.
  124539. * @param camera The camera to apply the render pass to.
  124540. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124541. * @param engine The engine which the post process will be applied. (default: current engine)
  124542. * @param reusable If the post process can be reused on the same frame. (default: false)
  124543. * @param textureType Type of textures used when performing the post process. (default: 0)
  124544. * @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)
  124545. */
  124546. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124547. /**
  124548. * Excludes the given skinned mesh from computing bones velocities.
  124549. * 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.
  124550. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  124551. */
  124552. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  124553. /**
  124554. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  124555. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  124556. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  124557. */
  124558. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  124559. /**
  124560. * Disposes the post process.
  124561. * @param camera The camera to dispose the post process on.
  124562. */
  124563. dispose(camera?: Camera): void;
  124564. }
  124565. }
  124566. declare module BABYLON {
  124567. /** @hidden */
  124568. export var refractionPixelShader: {
  124569. name: string;
  124570. shader: string;
  124571. };
  124572. }
  124573. declare module BABYLON {
  124574. /**
  124575. * Post process which applies a refractin texture
  124576. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  124577. */
  124578. export class RefractionPostProcess extends PostProcess {
  124579. /** the base color of the refraction (used to taint the rendering) */
  124580. color: Color3;
  124581. /** simulated refraction depth */
  124582. depth: number;
  124583. /** the coefficient of the base color (0 to remove base color tainting) */
  124584. colorLevel: number;
  124585. private _refTexture;
  124586. private _ownRefractionTexture;
  124587. /**
  124588. * Gets or sets the refraction texture
  124589. * Please note that you are responsible for disposing the texture if you set it manually
  124590. */
  124591. refractionTexture: Texture;
  124592. /**
  124593. * Initializes the RefractionPostProcess
  124594. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  124595. * @param name The name of the effect.
  124596. * @param refractionTextureUrl Url of the refraction texture to use
  124597. * @param color the base color of the refraction (used to taint the rendering)
  124598. * @param depth simulated refraction depth
  124599. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  124600. * @param camera The camera to apply the render pass to.
  124601. * @param options The required width/height ratio to downsize to before computing the render pass.
  124602. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124603. * @param engine The engine which the post process will be applied. (default: current engine)
  124604. * @param reusable If the post process can be reused on the same frame. (default: false)
  124605. */
  124606. constructor(name: string, refractionTextureUrl: string,
  124607. /** the base color of the refraction (used to taint the rendering) */
  124608. color: Color3,
  124609. /** simulated refraction depth */
  124610. depth: number,
  124611. /** the coefficient of the base color (0 to remove base color tainting) */
  124612. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124613. /**
  124614. * Disposes of the post process
  124615. * @param camera Camera to dispose post process on
  124616. */
  124617. dispose(camera: Camera): void;
  124618. }
  124619. }
  124620. declare module BABYLON {
  124621. /** @hidden */
  124622. export var sharpenPixelShader: {
  124623. name: string;
  124624. shader: string;
  124625. };
  124626. }
  124627. declare module BABYLON {
  124628. /**
  124629. * The SharpenPostProcess applies a sharpen kernel to every pixel
  124630. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  124631. */
  124632. export class SharpenPostProcess extends PostProcess {
  124633. /**
  124634. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  124635. */
  124636. colorAmount: number;
  124637. /**
  124638. * How much sharpness should be applied (default: 0.3)
  124639. */
  124640. edgeAmount: number;
  124641. /**
  124642. * Creates a new instance ConvolutionPostProcess
  124643. * @param name The name of the effect.
  124644. * @param options The required width/height ratio to downsize to before computing the render pass.
  124645. * @param camera The camera to apply the render pass to.
  124646. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124647. * @param engine The engine which the post process will be applied. (default: current engine)
  124648. * @param reusable If the post process can be reused on the same frame. (default: false)
  124649. * @param textureType Type of textures used when performing the post process. (default: 0)
  124650. * @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)
  124651. */
  124652. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124653. }
  124654. }
  124655. declare module BABYLON {
  124656. /**
  124657. * PostProcessRenderPipeline
  124658. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124659. */
  124660. export class PostProcessRenderPipeline {
  124661. private engine;
  124662. private _renderEffects;
  124663. private _renderEffectsForIsolatedPass;
  124664. /**
  124665. * List of inspectable custom properties (used by the Inspector)
  124666. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  124667. */
  124668. inspectableCustomProperties: IInspectable[];
  124669. /**
  124670. * @hidden
  124671. */
  124672. protected _cameras: Camera[];
  124673. /** @hidden */
  124674. _name: string;
  124675. /**
  124676. * Gets pipeline name
  124677. */
  124678. readonly name: string;
  124679. /**
  124680. * Initializes a PostProcessRenderPipeline
  124681. * @param engine engine to add the pipeline to
  124682. * @param name name of the pipeline
  124683. */
  124684. constructor(engine: Engine, name: string);
  124685. /**
  124686. * Gets the class name
  124687. * @returns "PostProcessRenderPipeline"
  124688. */
  124689. getClassName(): string;
  124690. /**
  124691. * If all the render effects in the pipeline are supported
  124692. */
  124693. readonly isSupported: boolean;
  124694. /**
  124695. * Adds an effect to the pipeline
  124696. * @param renderEffect the effect to add
  124697. */
  124698. addEffect(renderEffect: PostProcessRenderEffect): void;
  124699. /** @hidden */
  124700. _rebuild(): void;
  124701. /** @hidden */
  124702. _enableEffect(renderEffectName: string, cameras: Camera): void;
  124703. /** @hidden */
  124704. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  124705. /** @hidden */
  124706. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  124707. /** @hidden */
  124708. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  124709. /** @hidden */
  124710. _attachCameras(cameras: Camera, unique: boolean): void;
  124711. /** @hidden */
  124712. _attachCameras(cameras: Camera[], unique: boolean): void;
  124713. /** @hidden */
  124714. _detachCameras(cameras: Camera): void;
  124715. /** @hidden */
  124716. _detachCameras(cameras: Nullable<Camera[]>): void;
  124717. /** @hidden */
  124718. _update(): void;
  124719. /** @hidden */
  124720. _reset(): void;
  124721. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  124722. /**
  124723. * Disposes of the pipeline
  124724. */
  124725. dispose(): void;
  124726. }
  124727. }
  124728. declare module BABYLON {
  124729. /**
  124730. * PostProcessRenderPipelineManager class
  124731. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124732. */
  124733. export class PostProcessRenderPipelineManager {
  124734. private _renderPipelines;
  124735. /**
  124736. * Initializes a PostProcessRenderPipelineManager
  124737. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124738. */
  124739. constructor();
  124740. /**
  124741. * Gets the list of supported render pipelines
  124742. */
  124743. readonly supportedPipelines: PostProcessRenderPipeline[];
  124744. /**
  124745. * Adds a pipeline to the manager
  124746. * @param renderPipeline The pipeline to add
  124747. */
  124748. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  124749. /**
  124750. * Attaches a camera to the pipeline
  124751. * @param renderPipelineName The name of the pipeline to attach to
  124752. * @param cameras the camera to attach
  124753. * @param unique if the camera can be attached multiple times to the pipeline
  124754. */
  124755. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  124756. /**
  124757. * Detaches a camera from the pipeline
  124758. * @param renderPipelineName The name of the pipeline to detach from
  124759. * @param cameras the camera to detach
  124760. */
  124761. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  124762. /**
  124763. * Enables an effect by name on a pipeline
  124764. * @param renderPipelineName the name of the pipeline to enable the effect in
  124765. * @param renderEffectName the name of the effect to enable
  124766. * @param cameras the cameras that the effect should be enabled on
  124767. */
  124768. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  124769. /**
  124770. * Disables an effect by name on a pipeline
  124771. * @param renderPipelineName the name of the pipeline to disable the effect in
  124772. * @param renderEffectName the name of the effect to disable
  124773. * @param cameras the cameras that the effect should be disabled on
  124774. */
  124775. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  124776. /**
  124777. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  124778. */
  124779. update(): void;
  124780. /** @hidden */
  124781. _rebuild(): void;
  124782. /**
  124783. * Disposes of the manager and pipelines
  124784. */
  124785. dispose(): void;
  124786. }
  124787. }
  124788. declare module BABYLON {
  124789. interface Scene {
  124790. /** @hidden (Backing field) */
  124791. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  124792. /**
  124793. * Gets the postprocess render pipeline manager
  124794. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124795. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  124796. */
  124797. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  124798. }
  124799. /**
  124800. * Defines the Render Pipeline scene component responsible to rendering pipelines
  124801. */
  124802. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  124803. /**
  124804. * The component name helpfull to identify the component in the list of scene components.
  124805. */
  124806. readonly name: string;
  124807. /**
  124808. * The scene the component belongs to.
  124809. */
  124810. scene: Scene;
  124811. /**
  124812. * Creates a new instance of the component for the given scene
  124813. * @param scene Defines the scene to register the component in
  124814. */
  124815. constructor(scene: Scene);
  124816. /**
  124817. * Registers the component in a given scene
  124818. */
  124819. register(): void;
  124820. /**
  124821. * Rebuilds the elements related to this component in case of
  124822. * context lost for instance.
  124823. */
  124824. rebuild(): void;
  124825. /**
  124826. * Disposes the component and the associated ressources
  124827. */
  124828. dispose(): void;
  124829. private _gatherRenderTargets;
  124830. }
  124831. }
  124832. declare module BABYLON {
  124833. /**
  124834. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  124835. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  124836. */
  124837. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  124838. private _scene;
  124839. private _camerasToBeAttached;
  124840. /**
  124841. * ID of the sharpen post process,
  124842. */
  124843. private readonly SharpenPostProcessId;
  124844. /**
  124845. * @ignore
  124846. * ID of the image processing post process;
  124847. */
  124848. readonly ImageProcessingPostProcessId: string;
  124849. /**
  124850. * @ignore
  124851. * ID of the Fast Approximate Anti-Aliasing post process;
  124852. */
  124853. readonly FxaaPostProcessId: string;
  124854. /**
  124855. * ID of the chromatic aberration post process,
  124856. */
  124857. private readonly ChromaticAberrationPostProcessId;
  124858. /**
  124859. * ID of the grain post process
  124860. */
  124861. private readonly GrainPostProcessId;
  124862. /**
  124863. * Sharpen post process which will apply a sharpen convolution to enhance edges
  124864. */
  124865. sharpen: SharpenPostProcess;
  124866. private _sharpenEffect;
  124867. private bloom;
  124868. /**
  124869. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  124870. */
  124871. depthOfField: DepthOfFieldEffect;
  124872. /**
  124873. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  124874. */
  124875. fxaa: FxaaPostProcess;
  124876. /**
  124877. * Image post processing pass used to perform operations such as tone mapping or color grading.
  124878. */
  124879. imageProcessing: ImageProcessingPostProcess;
  124880. /**
  124881. * Chromatic aberration post process which will shift rgb colors in the image
  124882. */
  124883. chromaticAberration: ChromaticAberrationPostProcess;
  124884. private _chromaticAberrationEffect;
  124885. /**
  124886. * Grain post process which add noise to the image
  124887. */
  124888. grain: GrainPostProcess;
  124889. private _grainEffect;
  124890. /**
  124891. * Glow post process which adds a glow to emissive areas of the image
  124892. */
  124893. private _glowLayer;
  124894. /**
  124895. * Animations which can be used to tweak settings over a period of time
  124896. */
  124897. animations: Animation[];
  124898. private _imageProcessingConfigurationObserver;
  124899. private _sharpenEnabled;
  124900. private _bloomEnabled;
  124901. private _depthOfFieldEnabled;
  124902. private _depthOfFieldBlurLevel;
  124903. private _fxaaEnabled;
  124904. private _imageProcessingEnabled;
  124905. private _defaultPipelineTextureType;
  124906. private _bloomScale;
  124907. private _chromaticAberrationEnabled;
  124908. private _grainEnabled;
  124909. private _buildAllowed;
  124910. /**
  124911. * Gets active scene
  124912. */
  124913. readonly scene: Scene;
  124914. /**
  124915. * Enable or disable the sharpen process from the pipeline
  124916. */
  124917. sharpenEnabled: boolean;
  124918. private _resizeObserver;
  124919. private _hardwareScaleLevel;
  124920. private _bloomKernel;
  124921. /**
  124922. * Specifies the size of the bloom blur kernel, relative to the final output size
  124923. */
  124924. bloomKernel: number;
  124925. /**
  124926. * Specifies the weight of the bloom in the final rendering
  124927. */
  124928. private _bloomWeight;
  124929. /**
  124930. * Specifies the luma threshold for the area that will be blurred by the bloom
  124931. */
  124932. private _bloomThreshold;
  124933. private _hdr;
  124934. /**
  124935. * The strength of the bloom.
  124936. */
  124937. bloomWeight: number;
  124938. /**
  124939. * The strength of the bloom.
  124940. */
  124941. bloomThreshold: number;
  124942. /**
  124943. * The scale of the bloom, lower value will provide better performance.
  124944. */
  124945. bloomScale: number;
  124946. /**
  124947. * Enable or disable the bloom from the pipeline
  124948. */
  124949. bloomEnabled: boolean;
  124950. private _rebuildBloom;
  124951. /**
  124952. * If the depth of field is enabled.
  124953. */
  124954. depthOfFieldEnabled: boolean;
  124955. /**
  124956. * Blur level of the depth of field effect. (Higher blur will effect performance)
  124957. */
  124958. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  124959. /**
  124960. * If the anti aliasing is enabled.
  124961. */
  124962. fxaaEnabled: boolean;
  124963. private _samples;
  124964. /**
  124965. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  124966. */
  124967. samples: number;
  124968. /**
  124969. * If image processing is enabled.
  124970. */
  124971. imageProcessingEnabled: boolean;
  124972. /**
  124973. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  124974. */
  124975. glowLayerEnabled: boolean;
  124976. /**
  124977. * Gets the glow layer (or null if not defined)
  124978. */
  124979. readonly glowLayer: Nullable<GlowLayer>;
  124980. /**
  124981. * Enable or disable the chromaticAberration process from the pipeline
  124982. */
  124983. chromaticAberrationEnabled: boolean;
  124984. /**
  124985. * Enable or disable the grain process from the pipeline
  124986. */
  124987. grainEnabled: boolean;
  124988. /**
  124989. * @constructor
  124990. * @param name - The rendering pipeline name (default: "")
  124991. * @param hdr - If high dynamic range textures should be used (default: true)
  124992. * @param scene - The scene linked to this pipeline (default: the last created scene)
  124993. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  124994. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  124995. */
  124996. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  124997. /**
  124998. * Get the class name
  124999. * @returns "DefaultRenderingPipeline"
  125000. */
  125001. getClassName(): string;
  125002. /**
  125003. * Force the compilation of the entire pipeline.
  125004. */
  125005. prepare(): void;
  125006. private _hasCleared;
  125007. private _prevPostProcess;
  125008. private _prevPrevPostProcess;
  125009. private _setAutoClearAndTextureSharing;
  125010. private _depthOfFieldSceneObserver;
  125011. private _buildPipeline;
  125012. private _disposePostProcesses;
  125013. /**
  125014. * Adds a camera to the pipeline
  125015. * @param camera the camera to be added
  125016. */
  125017. addCamera(camera: Camera): void;
  125018. /**
  125019. * Removes a camera from the pipeline
  125020. * @param camera the camera to remove
  125021. */
  125022. removeCamera(camera: Camera): void;
  125023. /**
  125024. * Dispose of the pipeline and stop all post processes
  125025. */
  125026. dispose(): void;
  125027. /**
  125028. * Serialize the rendering pipeline (Used when exporting)
  125029. * @returns the serialized object
  125030. */
  125031. serialize(): any;
  125032. /**
  125033. * Parse the serialized pipeline
  125034. * @param source Source pipeline.
  125035. * @param scene The scene to load the pipeline to.
  125036. * @param rootUrl The URL of the serialized pipeline.
  125037. * @returns An instantiated pipeline from the serialized object.
  125038. */
  125039. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  125040. }
  125041. }
  125042. declare module BABYLON {
  125043. /** @hidden */
  125044. export var lensHighlightsPixelShader: {
  125045. name: string;
  125046. shader: string;
  125047. };
  125048. }
  125049. declare module BABYLON {
  125050. /** @hidden */
  125051. export var depthOfFieldPixelShader: {
  125052. name: string;
  125053. shader: string;
  125054. };
  125055. }
  125056. declare module BABYLON {
  125057. /**
  125058. * BABYLON.JS Chromatic Aberration GLSL Shader
  125059. * Author: Olivier Guyot
  125060. * Separates very slightly R, G and B colors on the edges of the screen
  125061. * Inspired by Francois Tarlier & Martins Upitis
  125062. */
  125063. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  125064. /**
  125065. * @ignore
  125066. * The chromatic aberration PostProcess id in the pipeline
  125067. */
  125068. LensChromaticAberrationEffect: string;
  125069. /**
  125070. * @ignore
  125071. * The highlights enhancing PostProcess id in the pipeline
  125072. */
  125073. HighlightsEnhancingEffect: string;
  125074. /**
  125075. * @ignore
  125076. * The depth-of-field PostProcess id in the pipeline
  125077. */
  125078. LensDepthOfFieldEffect: string;
  125079. private _scene;
  125080. private _depthTexture;
  125081. private _grainTexture;
  125082. private _chromaticAberrationPostProcess;
  125083. private _highlightsPostProcess;
  125084. private _depthOfFieldPostProcess;
  125085. private _edgeBlur;
  125086. private _grainAmount;
  125087. private _chromaticAberration;
  125088. private _distortion;
  125089. private _highlightsGain;
  125090. private _highlightsThreshold;
  125091. private _dofDistance;
  125092. private _dofAperture;
  125093. private _dofDarken;
  125094. private _dofPentagon;
  125095. private _blurNoise;
  125096. /**
  125097. * @constructor
  125098. *
  125099. * Effect parameters are as follow:
  125100. * {
  125101. * chromatic_aberration: number; // from 0 to x (1 for realism)
  125102. * edge_blur: number; // from 0 to x (1 for realism)
  125103. * distortion: number; // from 0 to x (1 for realism)
  125104. * grain_amount: number; // from 0 to 1
  125105. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  125106. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  125107. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  125108. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  125109. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  125110. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  125111. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  125112. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  125113. * }
  125114. * Note: if an effect parameter is unset, effect is disabled
  125115. *
  125116. * @param name The rendering pipeline name
  125117. * @param parameters - An object containing all parameters (see above)
  125118. * @param scene The scene linked to this pipeline
  125119. * @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)
  125120. * @param cameras The array of cameras that the rendering pipeline will be attached to
  125121. */
  125122. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  125123. /**
  125124. * Get the class name
  125125. * @returns "LensRenderingPipeline"
  125126. */
  125127. getClassName(): string;
  125128. /**
  125129. * Gets associated scene
  125130. */
  125131. readonly scene: Scene;
  125132. /**
  125133. * Gets or sets the edge blur
  125134. */
  125135. edgeBlur: number;
  125136. /**
  125137. * Gets or sets the grain amount
  125138. */
  125139. grainAmount: number;
  125140. /**
  125141. * Gets or sets the chromatic aberration amount
  125142. */
  125143. chromaticAberration: number;
  125144. /**
  125145. * Gets or sets the depth of field aperture
  125146. */
  125147. dofAperture: number;
  125148. /**
  125149. * Gets or sets the edge distortion
  125150. */
  125151. edgeDistortion: number;
  125152. /**
  125153. * Gets or sets the depth of field distortion
  125154. */
  125155. dofDistortion: number;
  125156. /**
  125157. * Gets or sets the darken out of focus amount
  125158. */
  125159. darkenOutOfFocus: number;
  125160. /**
  125161. * Gets or sets a boolean indicating if blur noise is enabled
  125162. */
  125163. blurNoise: boolean;
  125164. /**
  125165. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  125166. */
  125167. pentagonBokeh: boolean;
  125168. /**
  125169. * Gets or sets the highlight grain amount
  125170. */
  125171. highlightsGain: number;
  125172. /**
  125173. * Gets or sets the highlight threshold
  125174. */
  125175. highlightsThreshold: number;
  125176. /**
  125177. * Sets the amount of blur at the edges
  125178. * @param amount blur amount
  125179. */
  125180. setEdgeBlur(amount: number): void;
  125181. /**
  125182. * Sets edge blur to 0
  125183. */
  125184. disableEdgeBlur(): void;
  125185. /**
  125186. * Sets the amout of grain
  125187. * @param amount Amount of grain
  125188. */
  125189. setGrainAmount(amount: number): void;
  125190. /**
  125191. * Set grain amount to 0
  125192. */
  125193. disableGrain(): void;
  125194. /**
  125195. * Sets the chromatic aberration amount
  125196. * @param amount amount of chromatic aberration
  125197. */
  125198. setChromaticAberration(amount: number): void;
  125199. /**
  125200. * Sets chromatic aberration amount to 0
  125201. */
  125202. disableChromaticAberration(): void;
  125203. /**
  125204. * Sets the EdgeDistortion amount
  125205. * @param amount amount of EdgeDistortion
  125206. */
  125207. setEdgeDistortion(amount: number): void;
  125208. /**
  125209. * Sets edge distortion to 0
  125210. */
  125211. disableEdgeDistortion(): void;
  125212. /**
  125213. * Sets the FocusDistance amount
  125214. * @param amount amount of FocusDistance
  125215. */
  125216. setFocusDistance(amount: number): void;
  125217. /**
  125218. * Disables depth of field
  125219. */
  125220. disableDepthOfField(): void;
  125221. /**
  125222. * Sets the Aperture amount
  125223. * @param amount amount of Aperture
  125224. */
  125225. setAperture(amount: number): void;
  125226. /**
  125227. * Sets the DarkenOutOfFocus amount
  125228. * @param amount amount of DarkenOutOfFocus
  125229. */
  125230. setDarkenOutOfFocus(amount: number): void;
  125231. private _pentagonBokehIsEnabled;
  125232. /**
  125233. * Creates a pentagon bokeh effect
  125234. */
  125235. enablePentagonBokeh(): void;
  125236. /**
  125237. * Disables the pentagon bokeh effect
  125238. */
  125239. disablePentagonBokeh(): void;
  125240. /**
  125241. * Enables noise blur
  125242. */
  125243. enableNoiseBlur(): void;
  125244. /**
  125245. * Disables noise blur
  125246. */
  125247. disableNoiseBlur(): void;
  125248. /**
  125249. * Sets the HighlightsGain amount
  125250. * @param amount amount of HighlightsGain
  125251. */
  125252. setHighlightsGain(amount: number): void;
  125253. /**
  125254. * Sets the HighlightsThreshold amount
  125255. * @param amount amount of HighlightsThreshold
  125256. */
  125257. setHighlightsThreshold(amount: number): void;
  125258. /**
  125259. * Disables highlights
  125260. */
  125261. disableHighlights(): void;
  125262. /**
  125263. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  125264. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  125265. */
  125266. dispose(disableDepthRender?: boolean): void;
  125267. private _createChromaticAberrationPostProcess;
  125268. private _createHighlightsPostProcess;
  125269. private _createDepthOfFieldPostProcess;
  125270. private _createGrainTexture;
  125271. }
  125272. }
  125273. declare module BABYLON {
  125274. /** @hidden */
  125275. export var ssao2PixelShader: {
  125276. name: string;
  125277. shader: string;
  125278. };
  125279. }
  125280. declare module BABYLON {
  125281. /** @hidden */
  125282. export var ssaoCombinePixelShader: {
  125283. name: string;
  125284. shader: string;
  125285. };
  125286. }
  125287. declare module BABYLON {
  125288. /**
  125289. * Render pipeline to produce ssao effect
  125290. */
  125291. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  125292. /**
  125293. * @ignore
  125294. * The PassPostProcess id in the pipeline that contains the original scene color
  125295. */
  125296. SSAOOriginalSceneColorEffect: string;
  125297. /**
  125298. * @ignore
  125299. * The SSAO PostProcess id in the pipeline
  125300. */
  125301. SSAORenderEffect: string;
  125302. /**
  125303. * @ignore
  125304. * The horizontal blur PostProcess id in the pipeline
  125305. */
  125306. SSAOBlurHRenderEffect: string;
  125307. /**
  125308. * @ignore
  125309. * The vertical blur PostProcess id in the pipeline
  125310. */
  125311. SSAOBlurVRenderEffect: string;
  125312. /**
  125313. * @ignore
  125314. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  125315. */
  125316. SSAOCombineRenderEffect: string;
  125317. /**
  125318. * The output strength of the SSAO post-process. Default value is 1.0.
  125319. */
  125320. totalStrength: number;
  125321. /**
  125322. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  125323. */
  125324. maxZ: number;
  125325. /**
  125326. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  125327. */
  125328. minZAspect: number;
  125329. private _samples;
  125330. /**
  125331. * Number of samples used for the SSAO calculations. Default value is 8
  125332. */
  125333. samples: number;
  125334. private _textureSamples;
  125335. /**
  125336. * Number of samples to use for antialiasing
  125337. */
  125338. textureSamples: number;
  125339. /**
  125340. * Ratio object used for SSAO ratio and blur ratio
  125341. */
  125342. private _ratio;
  125343. /**
  125344. * Dynamically generated sphere sampler.
  125345. */
  125346. private _sampleSphere;
  125347. /**
  125348. * Blur filter offsets
  125349. */
  125350. private _samplerOffsets;
  125351. private _expensiveBlur;
  125352. /**
  125353. * If bilateral blur should be used
  125354. */
  125355. expensiveBlur: boolean;
  125356. /**
  125357. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  125358. */
  125359. radius: number;
  125360. /**
  125361. * The base color of the SSAO post-process
  125362. * The final result is "base + ssao" between [0, 1]
  125363. */
  125364. base: number;
  125365. /**
  125366. * Support test.
  125367. */
  125368. static readonly IsSupported: boolean;
  125369. private _scene;
  125370. private _depthTexture;
  125371. private _normalTexture;
  125372. private _randomTexture;
  125373. private _originalColorPostProcess;
  125374. private _ssaoPostProcess;
  125375. private _blurHPostProcess;
  125376. private _blurVPostProcess;
  125377. private _ssaoCombinePostProcess;
  125378. private _firstUpdate;
  125379. /**
  125380. * Gets active scene
  125381. */
  125382. readonly scene: Scene;
  125383. /**
  125384. * @constructor
  125385. * @param name The rendering pipeline name
  125386. * @param scene The scene linked to this pipeline
  125387. * @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 }
  125388. * @param cameras The array of cameras that the rendering pipeline will be attached to
  125389. */
  125390. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  125391. /**
  125392. * Get the class name
  125393. * @returns "SSAO2RenderingPipeline"
  125394. */
  125395. getClassName(): string;
  125396. /**
  125397. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  125398. */
  125399. dispose(disableGeometryBufferRenderer?: boolean): void;
  125400. private _createBlurPostProcess;
  125401. /** @hidden */
  125402. _rebuild(): void;
  125403. private _bits;
  125404. private _radicalInverse_VdC;
  125405. private _hammersley;
  125406. private _hemisphereSample_uniform;
  125407. private _generateHemisphere;
  125408. private _createSSAOPostProcess;
  125409. private _createSSAOCombinePostProcess;
  125410. private _createRandomTexture;
  125411. /**
  125412. * Serialize the rendering pipeline (Used when exporting)
  125413. * @returns the serialized object
  125414. */
  125415. serialize(): any;
  125416. /**
  125417. * Parse the serialized pipeline
  125418. * @param source Source pipeline.
  125419. * @param scene The scene to load the pipeline to.
  125420. * @param rootUrl The URL of the serialized pipeline.
  125421. * @returns An instantiated pipeline from the serialized object.
  125422. */
  125423. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  125424. }
  125425. }
  125426. declare module BABYLON {
  125427. /** @hidden */
  125428. export var ssaoPixelShader: {
  125429. name: string;
  125430. shader: string;
  125431. };
  125432. }
  125433. declare module BABYLON {
  125434. /**
  125435. * Render pipeline to produce ssao effect
  125436. */
  125437. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  125438. /**
  125439. * @ignore
  125440. * The PassPostProcess id in the pipeline that contains the original scene color
  125441. */
  125442. SSAOOriginalSceneColorEffect: string;
  125443. /**
  125444. * @ignore
  125445. * The SSAO PostProcess id in the pipeline
  125446. */
  125447. SSAORenderEffect: string;
  125448. /**
  125449. * @ignore
  125450. * The horizontal blur PostProcess id in the pipeline
  125451. */
  125452. SSAOBlurHRenderEffect: string;
  125453. /**
  125454. * @ignore
  125455. * The vertical blur PostProcess id in the pipeline
  125456. */
  125457. SSAOBlurVRenderEffect: string;
  125458. /**
  125459. * @ignore
  125460. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  125461. */
  125462. SSAOCombineRenderEffect: string;
  125463. /**
  125464. * The output strength of the SSAO post-process. Default value is 1.0.
  125465. */
  125466. totalStrength: number;
  125467. /**
  125468. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  125469. */
  125470. radius: number;
  125471. /**
  125472. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  125473. * Must not be equal to fallOff and superior to fallOff.
  125474. * Default value is 0.0075
  125475. */
  125476. area: number;
  125477. /**
  125478. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  125479. * Must not be equal to area and inferior to area.
  125480. * Default value is 0.000001
  125481. */
  125482. fallOff: number;
  125483. /**
  125484. * The base color of the SSAO post-process
  125485. * The final result is "base + ssao" between [0, 1]
  125486. */
  125487. base: number;
  125488. private _scene;
  125489. private _depthTexture;
  125490. private _randomTexture;
  125491. private _originalColorPostProcess;
  125492. private _ssaoPostProcess;
  125493. private _blurHPostProcess;
  125494. private _blurVPostProcess;
  125495. private _ssaoCombinePostProcess;
  125496. private _firstUpdate;
  125497. /**
  125498. * Gets active scene
  125499. */
  125500. readonly scene: Scene;
  125501. /**
  125502. * @constructor
  125503. * @param name - The rendering pipeline name
  125504. * @param scene - The scene linked to this pipeline
  125505. * @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 }
  125506. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  125507. */
  125508. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  125509. /**
  125510. * Get the class name
  125511. * @returns "SSAORenderingPipeline"
  125512. */
  125513. getClassName(): string;
  125514. /**
  125515. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  125516. */
  125517. dispose(disableDepthRender?: boolean): void;
  125518. private _createBlurPostProcess;
  125519. /** @hidden */
  125520. _rebuild(): void;
  125521. private _createSSAOPostProcess;
  125522. private _createSSAOCombinePostProcess;
  125523. private _createRandomTexture;
  125524. }
  125525. }
  125526. declare module BABYLON {
  125527. /** @hidden */
  125528. export var standardPixelShader: {
  125529. name: string;
  125530. shader: string;
  125531. };
  125532. }
  125533. declare module BABYLON {
  125534. /**
  125535. * Standard rendering pipeline
  125536. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  125537. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  125538. */
  125539. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  125540. /**
  125541. * Public members
  125542. */
  125543. /**
  125544. * Post-process which contains the original scene color before the pipeline applies all the effects
  125545. */
  125546. originalPostProcess: Nullable<PostProcess>;
  125547. /**
  125548. * Post-process used to down scale an image x4
  125549. */
  125550. downSampleX4PostProcess: Nullable<PostProcess>;
  125551. /**
  125552. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  125553. */
  125554. brightPassPostProcess: Nullable<PostProcess>;
  125555. /**
  125556. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  125557. */
  125558. blurHPostProcesses: PostProcess[];
  125559. /**
  125560. * Post-process array storing all the vertical blur post-processes used by the pipeline
  125561. */
  125562. blurVPostProcesses: PostProcess[];
  125563. /**
  125564. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  125565. */
  125566. textureAdderPostProcess: Nullable<PostProcess>;
  125567. /**
  125568. * Post-process used to create volumetric lighting effect
  125569. */
  125570. volumetricLightPostProcess: Nullable<PostProcess>;
  125571. /**
  125572. * Post-process used to smooth the previous volumetric light post-process on the X axis
  125573. */
  125574. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  125575. /**
  125576. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  125577. */
  125578. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  125579. /**
  125580. * Post-process used to merge the volumetric light effect and the real scene color
  125581. */
  125582. volumetricLightMergePostProces: Nullable<PostProcess>;
  125583. /**
  125584. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  125585. */
  125586. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  125587. /**
  125588. * Base post-process used to calculate the average luminance of the final image for HDR
  125589. */
  125590. luminancePostProcess: Nullable<PostProcess>;
  125591. /**
  125592. * Post-processes used to create down sample post-processes in order to get
  125593. * the average luminance of the final image for HDR
  125594. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  125595. */
  125596. luminanceDownSamplePostProcesses: PostProcess[];
  125597. /**
  125598. * Post-process used to create a HDR effect (light adaptation)
  125599. */
  125600. hdrPostProcess: Nullable<PostProcess>;
  125601. /**
  125602. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  125603. */
  125604. textureAdderFinalPostProcess: Nullable<PostProcess>;
  125605. /**
  125606. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  125607. */
  125608. lensFlareFinalPostProcess: Nullable<PostProcess>;
  125609. /**
  125610. * Post-process used to merge the final HDR post-process and the real scene color
  125611. */
  125612. hdrFinalPostProcess: Nullable<PostProcess>;
  125613. /**
  125614. * Post-process used to create a lens flare effect
  125615. */
  125616. lensFlarePostProcess: Nullable<PostProcess>;
  125617. /**
  125618. * Post-process that merges the result of the lens flare post-process and the real scene color
  125619. */
  125620. lensFlareComposePostProcess: Nullable<PostProcess>;
  125621. /**
  125622. * Post-process used to create a motion blur effect
  125623. */
  125624. motionBlurPostProcess: Nullable<PostProcess>;
  125625. /**
  125626. * Post-process used to create a depth of field effect
  125627. */
  125628. depthOfFieldPostProcess: Nullable<PostProcess>;
  125629. /**
  125630. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  125631. */
  125632. fxaaPostProcess: Nullable<FxaaPostProcess>;
  125633. /**
  125634. * Represents the brightness threshold in order to configure the illuminated surfaces
  125635. */
  125636. brightThreshold: number;
  125637. /**
  125638. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  125639. */
  125640. blurWidth: number;
  125641. /**
  125642. * Sets if the blur for highlighted surfaces must be only horizontal
  125643. */
  125644. horizontalBlur: boolean;
  125645. /**
  125646. * Gets the overall exposure used by the pipeline
  125647. */
  125648. /**
  125649. * Sets the overall exposure used by the pipeline
  125650. */
  125651. exposure: number;
  125652. /**
  125653. * Texture used typically to simulate "dirty" on camera lens
  125654. */
  125655. lensTexture: Nullable<Texture>;
  125656. /**
  125657. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  125658. */
  125659. volumetricLightCoefficient: number;
  125660. /**
  125661. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  125662. */
  125663. volumetricLightPower: number;
  125664. /**
  125665. * Used the set the blur intensity to smooth the volumetric lights
  125666. */
  125667. volumetricLightBlurScale: number;
  125668. /**
  125669. * Light (spot or directional) used to generate the volumetric lights rays
  125670. * The source light must have a shadow generate so the pipeline can get its
  125671. * depth map
  125672. */
  125673. sourceLight: Nullable<SpotLight | DirectionalLight>;
  125674. /**
  125675. * For eye adaptation, represents the minimum luminance the eye can see
  125676. */
  125677. hdrMinimumLuminance: number;
  125678. /**
  125679. * For eye adaptation, represents the decrease luminance speed
  125680. */
  125681. hdrDecreaseRate: number;
  125682. /**
  125683. * For eye adaptation, represents the increase luminance speed
  125684. */
  125685. hdrIncreaseRate: number;
  125686. /**
  125687. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  125688. */
  125689. /**
  125690. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  125691. */
  125692. hdrAutoExposure: boolean;
  125693. /**
  125694. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  125695. */
  125696. lensColorTexture: Nullable<Texture>;
  125697. /**
  125698. * The overall strengh for the lens flare effect
  125699. */
  125700. lensFlareStrength: number;
  125701. /**
  125702. * Dispersion coefficient for lens flare ghosts
  125703. */
  125704. lensFlareGhostDispersal: number;
  125705. /**
  125706. * Main lens flare halo width
  125707. */
  125708. lensFlareHaloWidth: number;
  125709. /**
  125710. * Based on the lens distortion effect, defines how much the lens flare result
  125711. * is distorted
  125712. */
  125713. lensFlareDistortionStrength: number;
  125714. /**
  125715. * Configures the blur intensity used for for lens flare (halo)
  125716. */
  125717. lensFlareBlurWidth: number;
  125718. /**
  125719. * Lens star texture must be used to simulate rays on the flares and is available
  125720. * in the documentation
  125721. */
  125722. lensStarTexture: Nullable<Texture>;
  125723. /**
  125724. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  125725. * flare effect by taking account of the dirt texture
  125726. */
  125727. lensFlareDirtTexture: Nullable<Texture>;
  125728. /**
  125729. * Represents the focal length for the depth of field effect
  125730. */
  125731. depthOfFieldDistance: number;
  125732. /**
  125733. * Represents the blur intensity for the blurred part of the depth of field effect
  125734. */
  125735. depthOfFieldBlurWidth: number;
  125736. /**
  125737. * Gets how much the image is blurred by the movement while using the motion blur post-process
  125738. */
  125739. /**
  125740. * Sets how much the image is blurred by the movement while using the motion blur post-process
  125741. */
  125742. motionStrength: number;
  125743. /**
  125744. * Gets wether or not the motion blur post-process is object based or screen based.
  125745. */
  125746. /**
  125747. * Sets wether or not the motion blur post-process should be object based or screen based
  125748. */
  125749. objectBasedMotionBlur: boolean;
  125750. /**
  125751. * List of animations for the pipeline (IAnimatable implementation)
  125752. */
  125753. animations: Animation[];
  125754. /**
  125755. * Private members
  125756. */
  125757. private _scene;
  125758. private _currentDepthOfFieldSource;
  125759. private _basePostProcess;
  125760. private _fixedExposure;
  125761. private _currentExposure;
  125762. private _hdrAutoExposure;
  125763. private _hdrCurrentLuminance;
  125764. private _motionStrength;
  125765. private _isObjectBasedMotionBlur;
  125766. private _floatTextureType;
  125767. private _camerasToBeAttached;
  125768. private _ratio;
  125769. private _bloomEnabled;
  125770. private _depthOfFieldEnabled;
  125771. private _vlsEnabled;
  125772. private _lensFlareEnabled;
  125773. private _hdrEnabled;
  125774. private _motionBlurEnabled;
  125775. private _fxaaEnabled;
  125776. private _motionBlurSamples;
  125777. private _volumetricLightStepsCount;
  125778. private _samples;
  125779. /**
  125780. * @ignore
  125781. * Specifies if the bloom pipeline is enabled
  125782. */
  125783. BloomEnabled: boolean;
  125784. /**
  125785. * @ignore
  125786. * Specifies if the depth of field pipeline is enabed
  125787. */
  125788. DepthOfFieldEnabled: boolean;
  125789. /**
  125790. * @ignore
  125791. * Specifies if the lens flare pipeline is enabed
  125792. */
  125793. LensFlareEnabled: boolean;
  125794. /**
  125795. * @ignore
  125796. * Specifies if the HDR pipeline is enabled
  125797. */
  125798. HDREnabled: boolean;
  125799. /**
  125800. * @ignore
  125801. * Specifies if the volumetric lights scattering effect is enabled
  125802. */
  125803. VLSEnabled: boolean;
  125804. /**
  125805. * @ignore
  125806. * Specifies if the motion blur effect is enabled
  125807. */
  125808. MotionBlurEnabled: boolean;
  125809. /**
  125810. * Specifies if anti-aliasing is enabled
  125811. */
  125812. fxaaEnabled: boolean;
  125813. /**
  125814. * Specifies the number of steps used to calculate the volumetric lights
  125815. * Typically in interval [50, 200]
  125816. */
  125817. volumetricLightStepsCount: number;
  125818. /**
  125819. * Specifies the number of samples used for the motion blur effect
  125820. * Typically in interval [16, 64]
  125821. */
  125822. motionBlurSamples: number;
  125823. /**
  125824. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  125825. */
  125826. samples: number;
  125827. /**
  125828. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  125829. * @constructor
  125830. * @param name The rendering pipeline name
  125831. * @param scene The scene linked to this pipeline
  125832. * @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)
  125833. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  125834. * @param cameras The array of cameras that the rendering pipeline will be attached to
  125835. */
  125836. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  125837. private _buildPipeline;
  125838. private _createDownSampleX4PostProcess;
  125839. private _createBrightPassPostProcess;
  125840. private _createBlurPostProcesses;
  125841. private _createTextureAdderPostProcess;
  125842. private _createVolumetricLightPostProcess;
  125843. private _createLuminancePostProcesses;
  125844. private _createHdrPostProcess;
  125845. private _createLensFlarePostProcess;
  125846. private _createDepthOfFieldPostProcess;
  125847. private _createMotionBlurPostProcess;
  125848. private _getDepthTexture;
  125849. private _disposePostProcesses;
  125850. /**
  125851. * Dispose of the pipeline and stop all post processes
  125852. */
  125853. dispose(): void;
  125854. /**
  125855. * Serialize the rendering pipeline (Used when exporting)
  125856. * @returns the serialized object
  125857. */
  125858. serialize(): any;
  125859. /**
  125860. * Parse the serialized pipeline
  125861. * @param source Source pipeline.
  125862. * @param scene The scene to load the pipeline to.
  125863. * @param rootUrl The URL of the serialized pipeline.
  125864. * @returns An instantiated pipeline from the serialized object.
  125865. */
  125866. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  125867. /**
  125868. * Luminance steps
  125869. */
  125870. static LuminanceSteps: number;
  125871. }
  125872. }
  125873. declare module BABYLON {
  125874. /** @hidden */
  125875. export var tonemapPixelShader: {
  125876. name: string;
  125877. shader: string;
  125878. };
  125879. }
  125880. declare module BABYLON {
  125881. /** Defines operator used for tonemapping */
  125882. export enum TonemappingOperator {
  125883. /** Hable */
  125884. Hable = 0,
  125885. /** Reinhard */
  125886. Reinhard = 1,
  125887. /** HejiDawson */
  125888. HejiDawson = 2,
  125889. /** Photographic */
  125890. Photographic = 3
  125891. }
  125892. /**
  125893. * Defines a post process to apply tone mapping
  125894. */
  125895. export class TonemapPostProcess extends PostProcess {
  125896. private _operator;
  125897. /** Defines the required exposure adjustement */
  125898. exposureAdjustment: number;
  125899. /**
  125900. * Creates a new TonemapPostProcess
  125901. * @param name defines the name of the postprocess
  125902. * @param _operator defines the operator to use
  125903. * @param exposureAdjustment defines the required exposure adjustement
  125904. * @param camera defines the camera to use (can be null)
  125905. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  125906. * @param engine defines the hosting engine (can be ignore if camera is set)
  125907. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  125908. */
  125909. constructor(name: string, _operator: TonemappingOperator,
  125910. /** Defines the required exposure adjustement */
  125911. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  125912. }
  125913. }
  125914. declare module BABYLON {
  125915. /** @hidden */
  125916. export var depthVertexShader: {
  125917. name: string;
  125918. shader: string;
  125919. };
  125920. }
  125921. declare module BABYLON {
  125922. /** @hidden */
  125923. export var volumetricLightScatteringPixelShader: {
  125924. name: string;
  125925. shader: string;
  125926. };
  125927. }
  125928. declare module BABYLON {
  125929. /** @hidden */
  125930. export var volumetricLightScatteringPassVertexShader: {
  125931. name: string;
  125932. shader: string;
  125933. };
  125934. }
  125935. declare module BABYLON {
  125936. /** @hidden */
  125937. export var volumetricLightScatteringPassPixelShader: {
  125938. name: string;
  125939. shader: string;
  125940. };
  125941. }
  125942. declare module BABYLON {
  125943. /**
  125944. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  125945. */
  125946. export class VolumetricLightScatteringPostProcess extends PostProcess {
  125947. private _volumetricLightScatteringPass;
  125948. private _volumetricLightScatteringRTT;
  125949. private _viewPort;
  125950. private _screenCoordinates;
  125951. private _cachedDefines;
  125952. /**
  125953. * If not undefined, the mesh position is computed from the attached node position
  125954. */
  125955. attachedNode: {
  125956. position: Vector3;
  125957. };
  125958. /**
  125959. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  125960. */
  125961. customMeshPosition: Vector3;
  125962. /**
  125963. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  125964. */
  125965. useCustomMeshPosition: boolean;
  125966. /**
  125967. * If the post-process should inverse the light scattering direction
  125968. */
  125969. invert: boolean;
  125970. /**
  125971. * The internal mesh used by the post-process
  125972. */
  125973. mesh: Mesh;
  125974. /**
  125975. * @hidden
  125976. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  125977. */
  125978. useDiffuseColor: boolean;
  125979. /**
  125980. * Array containing the excluded meshes not rendered in the internal pass
  125981. */
  125982. excludedMeshes: AbstractMesh[];
  125983. /**
  125984. * Controls the overall intensity of the post-process
  125985. */
  125986. exposure: number;
  125987. /**
  125988. * Dissipates each sample's contribution in range [0, 1]
  125989. */
  125990. decay: number;
  125991. /**
  125992. * Controls the overall intensity of each sample
  125993. */
  125994. weight: number;
  125995. /**
  125996. * Controls the density of each sample
  125997. */
  125998. density: number;
  125999. /**
  126000. * @constructor
  126001. * @param name The post-process name
  126002. * @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)
  126003. * @param camera The camera that the post-process will be attached to
  126004. * @param mesh The mesh used to create the light scattering
  126005. * @param samples The post-process quality, default 100
  126006. * @param samplingModeThe post-process filtering mode
  126007. * @param engine The babylon engine
  126008. * @param reusable If the post-process is reusable
  126009. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  126010. */
  126011. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  126012. /**
  126013. * Returns the string "VolumetricLightScatteringPostProcess"
  126014. * @returns "VolumetricLightScatteringPostProcess"
  126015. */
  126016. getClassName(): string;
  126017. private _isReady;
  126018. /**
  126019. * Sets the new light position for light scattering effect
  126020. * @param position The new custom light position
  126021. */
  126022. setCustomMeshPosition(position: Vector3): void;
  126023. /**
  126024. * Returns the light position for light scattering effect
  126025. * @return Vector3 The custom light position
  126026. */
  126027. getCustomMeshPosition(): Vector3;
  126028. /**
  126029. * Disposes the internal assets and detaches the post-process from the camera
  126030. */
  126031. dispose(camera: Camera): void;
  126032. /**
  126033. * Returns the render target texture used by the post-process
  126034. * @return the render target texture used by the post-process
  126035. */
  126036. getPass(): RenderTargetTexture;
  126037. private _meshExcluded;
  126038. private _createPass;
  126039. private _updateMeshScreenCoordinates;
  126040. /**
  126041. * Creates a default mesh for the Volumeric Light Scattering post-process
  126042. * @param name The mesh name
  126043. * @param scene The scene where to create the mesh
  126044. * @return the default mesh
  126045. */
  126046. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  126047. }
  126048. }
  126049. declare module BABYLON {
  126050. interface Scene {
  126051. /** @hidden (Backing field) */
  126052. _boundingBoxRenderer: BoundingBoxRenderer;
  126053. /** @hidden (Backing field) */
  126054. _forceShowBoundingBoxes: boolean;
  126055. /**
  126056. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  126057. */
  126058. forceShowBoundingBoxes: boolean;
  126059. /**
  126060. * Gets the bounding box renderer associated with the scene
  126061. * @returns a BoundingBoxRenderer
  126062. */
  126063. getBoundingBoxRenderer(): BoundingBoxRenderer;
  126064. }
  126065. interface AbstractMesh {
  126066. /** @hidden (Backing field) */
  126067. _showBoundingBox: boolean;
  126068. /**
  126069. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  126070. */
  126071. showBoundingBox: boolean;
  126072. }
  126073. /**
  126074. * Component responsible of rendering the bounding box of the meshes in a scene.
  126075. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  126076. */
  126077. export class BoundingBoxRenderer implements ISceneComponent {
  126078. /**
  126079. * The component name helpfull to identify the component in the list of scene components.
  126080. */
  126081. readonly name: string;
  126082. /**
  126083. * The scene the component belongs to.
  126084. */
  126085. scene: Scene;
  126086. /**
  126087. * Color of the bounding box lines placed in front of an object
  126088. */
  126089. frontColor: Color3;
  126090. /**
  126091. * Color of the bounding box lines placed behind an object
  126092. */
  126093. backColor: Color3;
  126094. /**
  126095. * Defines if the renderer should show the back lines or not
  126096. */
  126097. showBackLines: boolean;
  126098. /**
  126099. * @hidden
  126100. */
  126101. renderList: SmartArray<BoundingBox>;
  126102. private _colorShader;
  126103. private _vertexBuffers;
  126104. private _indexBuffer;
  126105. private _fillIndexBuffer;
  126106. private _fillIndexData;
  126107. /**
  126108. * Instantiates a new bounding box renderer in a scene.
  126109. * @param scene the scene the renderer renders in
  126110. */
  126111. constructor(scene: Scene);
  126112. /**
  126113. * Registers the component in a given scene
  126114. */
  126115. register(): void;
  126116. private _evaluateSubMesh;
  126117. private _activeMesh;
  126118. private _prepareRessources;
  126119. private _createIndexBuffer;
  126120. /**
  126121. * Rebuilds the elements related to this component in case of
  126122. * context lost for instance.
  126123. */
  126124. rebuild(): void;
  126125. /**
  126126. * @hidden
  126127. */
  126128. reset(): void;
  126129. /**
  126130. * Render the bounding boxes of a specific rendering group
  126131. * @param renderingGroupId defines the rendering group to render
  126132. */
  126133. render(renderingGroupId: number): void;
  126134. /**
  126135. * In case of occlusion queries, we can render the occlusion bounding box through this method
  126136. * @param mesh Define the mesh to render the occlusion bounding box for
  126137. */
  126138. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  126139. /**
  126140. * Dispose and release the resources attached to this renderer.
  126141. */
  126142. dispose(): void;
  126143. }
  126144. }
  126145. declare module BABYLON {
  126146. /** @hidden */
  126147. export var depthPixelShader: {
  126148. name: string;
  126149. shader: string;
  126150. };
  126151. }
  126152. declare module BABYLON {
  126153. /**
  126154. * This represents a depth renderer in Babylon.
  126155. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  126156. */
  126157. export class DepthRenderer {
  126158. private _scene;
  126159. private _depthMap;
  126160. private _effect;
  126161. private readonly _storeNonLinearDepth;
  126162. private readonly _clearColor;
  126163. /** Get if the depth renderer is using packed depth or not */
  126164. readonly isPacked: boolean;
  126165. private _cachedDefines;
  126166. private _camera;
  126167. /**
  126168. * Specifiess that the depth renderer will only be used within
  126169. * the camera it is created for.
  126170. * This can help forcing its rendering during the camera processing.
  126171. */
  126172. useOnlyInActiveCamera: boolean;
  126173. /** @hidden */
  126174. static _SceneComponentInitialization: (scene: Scene) => void;
  126175. /**
  126176. * Instantiates a depth renderer
  126177. * @param scene The scene the renderer belongs to
  126178. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  126179. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  126180. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  126181. */
  126182. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  126183. /**
  126184. * Creates the depth rendering effect and checks if the effect is ready.
  126185. * @param subMesh The submesh to be used to render the depth map of
  126186. * @param useInstances If multiple world instances should be used
  126187. * @returns if the depth renderer is ready to render the depth map
  126188. */
  126189. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126190. /**
  126191. * Gets the texture which the depth map will be written to.
  126192. * @returns The depth map texture
  126193. */
  126194. getDepthMap(): RenderTargetTexture;
  126195. /**
  126196. * Disposes of the depth renderer.
  126197. */
  126198. dispose(): void;
  126199. }
  126200. }
  126201. declare module BABYLON {
  126202. interface Scene {
  126203. /** @hidden (Backing field) */
  126204. _depthRenderer: {
  126205. [id: string]: DepthRenderer;
  126206. };
  126207. /**
  126208. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  126209. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  126210. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  126211. * @returns the created depth renderer
  126212. */
  126213. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  126214. /**
  126215. * Disables a depth renderer for a given camera
  126216. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  126217. */
  126218. disableDepthRenderer(camera?: Nullable<Camera>): void;
  126219. }
  126220. /**
  126221. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  126222. * in several rendering techniques.
  126223. */
  126224. export class DepthRendererSceneComponent implements ISceneComponent {
  126225. /**
  126226. * The component name helpfull to identify the component in the list of scene components.
  126227. */
  126228. readonly name: string;
  126229. /**
  126230. * The scene the component belongs to.
  126231. */
  126232. scene: Scene;
  126233. /**
  126234. * Creates a new instance of the component for the given scene
  126235. * @param scene Defines the scene to register the component in
  126236. */
  126237. constructor(scene: Scene);
  126238. /**
  126239. * Registers the component in a given scene
  126240. */
  126241. register(): void;
  126242. /**
  126243. * Rebuilds the elements related to this component in case of
  126244. * context lost for instance.
  126245. */
  126246. rebuild(): void;
  126247. /**
  126248. * Disposes the component and the associated ressources
  126249. */
  126250. dispose(): void;
  126251. private _gatherRenderTargets;
  126252. private _gatherActiveCameraRenderTargets;
  126253. }
  126254. }
  126255. declare module BABYLON {
  126256. /** @hidden */
  126257. export var outlinePixelShader: {
  126258. name: string;
  126259. shader: string;
  126260. };
  126261. }
  126262. declare module BABYLON {
  126263. /** @hidden */
  126264. export var outlineVertexShader: {
  126265. name: string;
  126266. shader: string;
  126267. };
  126268. }
  126269. declare module BABYLON {
  126270. interface Scene {
  126271. /** @hidden */
  126272. _outlineRenderer: OutlineRenderer;
  126273. /**
  126274. * Gets the outline renderer associated with the scene
  126275. * @returns a OutlineRenderer
  126276. */
  126277. getOutlineRenderer(): OutlineRenderer;
  126278. }
  126279. interface AbstractMesh {
  126280. /** @hidden (Backing field) */
  126281. _renderOutline: boolean;
  126282. /**
  126283. * Gets or sets a boolean indicating if the outline must be rendered as well
  126284. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  126285. */
  126286. renderOutline: boolean;
  126287. /** @hidden (Backing field) */
  126288. _renderOverlay: boolean;
  126289. /**
  126290. * Gets or sets a boolean indicating if the overlay must be rendered as well
  126291. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  126292. */
  126293. renderOverlay: boolean;
  126294. }
  126295. /**
  126296. * This class is responsible to draw bothe outline/overlay of meshes.
  126297. * It should not be used directly but through the available method on mesh.
  126298. */
  126299. export class OutlineRenderer implements ISceneComponent {
  126300. /**
  126301. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  126302. */
  126303. private static _StencilReference;
  126304. /**
  126305. * The name of the component. Each component must have a unique name.
  126306. */
  126307. name: string;
  126308. /**
  126309. * The scene the component belongs to.
  126310. */
  126311. scene: Scene;
  126312. /**
  126313. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  126314. */
  126315. zOffset: number;
  126316. private _engine;
  126317. private _effect;
  126318. private _cachedDefines;
  126319. private _savedDepthWrite;
  126320. /**
  126321. * Instantiates a new outline renderer. (There could be only one per scene).
  126322. * @param scene Defines the scene it belongs to
  126323. */
  126324. constructor(scene: Scene);
  126325. /**
  126326. * Register the component to one instance of a scene.
  126327. */
  126328. register(): void;
  126329. /**
  126330. * Rebuilds the elements related to this component in case of
  126331. * context lost for instance.
  126332. */
  126333. rebuild(): void;
  126334. /**
  126335. * Disposes the component and the associated ressources.
  126336. */
  126337. dispose(): void;
  126338. /**
  126339. * Renders the outline in the canvas.
  126340. * @param subMesh Defines the sumesh to render
  126341. * @param batch Defines the batch of meshes in case of instances
  126342. * @param useOverlay Defines if the rendering is for the overlay or the outline
  126343. */
  126344. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  126345. /**
  126346. * Returns whether or not the outline renderer is ready for a given submesh.
  126347. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  126348. * @param subMesh Defines the submesh to check readyness for
  126349. * @param useInstances Defines wheter wee are trying to render instances or not
  126350. * @returns true if ready otherwise false
  126351. */
  126352. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126353. private _beforeRenderingMesh;
  126354. private _afterRenderingMesh;
  126355. }
  126356. }
  126357. declare module BABYLON {
  126358. /**
  126359. * Class used to manage multiple sprites of different sizes on the same spritesheet
  126360. * @see http://doc.babylonjs.com/babylon101/sprites
  126361. */
  126362. export class SpritePackedManager extends SpriteManager {
  126363. /** defines the packed manager's name */
  126364. name: string;
  126365. /**
  126366. * Creates a new sprite manager from a packed sprite sheet
  126367. * @param name defines the manager's name
  126368. * @param imgUrl defines the sprite sheet url
  126369. * @param capacity defines the maximum allowed number of sprites
  126370. * @param scene defines the hosting scene
  126371. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  126372. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  126373. * @param samplingMode defines the smapling mode to use with spritesheet
  126374. * @param fromPacked set to true; do not alter
  126375. */
  126376. constructor(
  126377. /** defines the packed manager's name */
  126378. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  126379. }
  126380. }
  126381. declare module BABYLON {
  126382. /**
  126383. * Defines the list of states available for a task inside a AssetsManager
  126384. */
  126385. export enum AssetTaskState {
  126386. /**
  126387. * Initialization
  126388. */
  126389. INIT = 0,
  126390. /**
  126391. * Running
  126392. */
  126393. RUNNING = 1,
  126394. /**
  126395. * Done
  126396. */
  126397. DONE = 2,
  126398. /**
  126399. * Error
  126400. */
  126401. ERROR = 3
  126402. }
  126403. /**
  126404. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  126405. */
  126406. export abstract class AbstractAssetTask {
  126407. /**
  126408. * Task name
  126409. */ name: string;
  126410. /**
  126411. * Callback called when the task is successful
  126412. */
  126413. onSuccess: (task: any) => void;
  126414. /**
  126415. * Callback called when the task is not successful
  126416. */
  126417. onError: (task: any, message?: string, exception?: any) => void;
  126418. /**
  126419. * Creates a new AssetsManager
  126420. * @param name defines the name of the task
  126421. */
  126422. constructor(
  126423. /**
  126424. * Task name
  126425. */ name: string);
  126426. private _isCompleted;
  126427. private _taskState;
  126428. private _errorObject;
  126429. /**
  126430. * Get if the task is completed
  126431. */
  126432. readonly isCompleted: boolean;
  126433. /**
  126434. * Gets the current state of the task
  126435. */
  126436. readonly taskState: AssetTaskState;
  126437. /**
  126438. * Gets the current error object (if task is in error)
  126439. */
  126440. readonly errorObject: {
  126441. message?: string;
  126442. exception?: any;
  126443. };
  126444. /**
  126445. * Internal only
  126446. * @hidden
  126447. */
  126448. _setErrorObject(message?: string, exception?: any): void;
  126449. /**
  126450. * Execute the current task
  126451. * @param scene defines the scene where you want your assets to be loaded
  126452. * @param onSuccess is a callback called when the task is successfully executed
  126453. * @param onError is a callback called if an error occurs
  126454. */
  126455. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126456. /**
  126457. * Execute the current task
  126458. * @param scene defines the scene where you want your assets to be loaded
  126459. * @param onSuccess is a callback called when the task is successfully executed
  126460. * @param onError is a callback called if an error occurs
  126461. */
  126462. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126463. /**
  126464. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  126465. * This can be used with failed tasks that have the reason for failure fixed.
  126466. */
  126467. reset(): void;
  126468. private onErrorCallback;
  126469. private onDoneCallback;
  126470. }
  126471. /**
  126472. * Define the interface used by progress events raised during assets loading
  126473. */
  126474. export interface IAssetsProgressEvent {
  126475. /**
  126476. * Defines the number of remaining tasks to process
  126477. */
  126478. remainingCount: number;
  126479. /**
  126480. * Defines the total number of tasks
  126481. */
  126482. totalCount: number;
  126483. /**
  126484. * Defines the task that was just processed
  126485. */
  126486. task: AbstractAssetTask;
  126487. }
  126488. /**
  126489. * Class used to share progress information about assets loading
  126490. */
  126491. export class AssetsProgressEvent implements IAssetsProgressEvent {
  126492. /**
  126493. * Defines the number of remaining tasks to process
  126494. */
  126495. remainingCount: number;
  126496. /**
  126497. * Defines the total number of tasks
  126498. */
  126499. totalCount: number;
  126500. /**
  126501. * Defines the task that was just processed
  126502. */
  126503. task: AbstractAssetTask;
  126504. /**
  126505. * Creates a AssetsProgressEvent
  126506. * @param remainingCount defines the number of remaining tasks to process
  126507. * @param totalCount defines the total number of tasks
  126508. * @param task defines the task that was just processed
  126509. */
  126510. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  126511. }
  126512. /**
  126513. * Define a task used by AssetsManager to load meshes
  126514. */
  126515. export class MeshAssetTask extends AbstractAssetTask {
  126516. /**
  126517. * Defines the name of the task
  126518. */
  126519. name: string;
  126520. /**
  126521. * Defines the list of mesh's names you want to load
  126522. */
  126523. meshesNames: any;
  126524. /**
  126525. * Defines the root url to use as a base to load your meshes and associated resources
  126526. */
  126527. rootUrl: string;
  126528. /**
  126529. * Defines the filename of the scene to load from
  126530. */
  126531. sceneFilename: string;
  126532. /**
  126533. * Gets the list of loaded meshes
  126534. */
  126535. loadedMeshes: Array<AbstractMesh>;
  126536. /**
  126537. * Gets the list of loaded particle systems
  126538. */
  126539. loadedParticleSystems: Array<IParticleSystem>;
  126540. /**
  126541. * Gets the list of loaded skeletons
  126542. */
  126543. loadedSkeletons: Array<Skeleton>;
  126544. /**
  126545. * Gets the list of loaded animation groups
  126546. */
  126547. loadedAnimationGroups: Array<AnimationGroup>;
  126548. /**
  126549. * Callback called when the task is successful
  126550. */
  126551. onSuccess: (task: MeshAssetTask) => void;
  126552. /**
  126553. * Callback called when the task is successful
  126554. */
  126555. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  126556. /**
  126557. * Creates a new MeshAssetTask
  126558. * @param name defines the name of the task
  126559. * @param meshesNames defines the list of mesh's names you want to load
  126560. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  126561. * @param sceneFilename defines the filename of the scene to load from
  126562. */
  126563. constructor(
  126564. /**
  126565. * Defines the name of the task
  126566. */
  126567. name: string,
  126568. /**
  126569. * Defines the list of mesh's names you want to load
  126570. */
  126571. meshesNames: any,
  126572. /**
  126573. * Defines the root url to use as a base to load your meshes and associated resources
  126574. */
  126575. rootUrl: string,
  126576. /**
  126577. * Defines the filename of the scene to load from
  126578. */
  126579. sceneFilename: string);
  126580. /**
  126581. * Execute the current task
  126582. * @param scene defines the scene where you want your assets to be loaded
  126583. * @param onSuccess is a callback called when the task is successfully executed
  126584. * @param onError is a callback called if an error occurs
  126585. */
  126586. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126587. }
  126588. /**
  126589. * Define a task used by AssetsManager to load text content
  126590. */
  126591. export class TextFileAssetTask extends AbstractAssetTask {
  126592. /**
  126593. * Defines the name of the task
  126594. */
  126595. name: string;
  126596. /**
  126597. * Defines the location of the file to load
  126598. */
  126599. url: string;
  126600. /**
  126601. * Gets the loaded text string
  126602. */
  126603. text: string;
  126604. /**
  126605. * Callback called when the task is successful
  126606. */
  126607. onSuccess: (task: TextFileAssetTask) => void;
  126608. /**
  126609. * Callback called when the task is successful
  126610. */
  126611. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  126612. /**
  126613. * Creates a new TextFileAssetTask object
  126614. * @param name defines the name of the task
  126615. * @param url defines the location of the file to load
  126616. */
  126617. constructor(
  126618. /**
  126619. * Defines the name of the task
  126620. */
  126621. name: string,
  126622. /**
  126623. * Defines the location of the file to load
  126624. */
  126625. url: string);
  126626. /**
  126627. * Execute the current task
  126628. * @param scene defines the scene where you want your assets to be loaded
  126629. * @param onSuccess is a callback called when the task is successfully executed
  126630. * @param onError is a callback called if an error occurs
  126631. */
  126632. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126633. }
  126634. /**
  126635. * Define a task used by AssetsManager to load binary data
  126636. */
  126637. export class BinaryFileAssetTask extends AbstractAssetTask {
  126638. /**
  126639. * Defines the name of the task
  126640. */
  126641. name: string;
  126642. /**
  126643. * Defines the location of the file to load
  126644. */
  126645. url: string;
  126646. /**
  126647. * Gets the lodaded data (as an array buffer)
  126648. */
  126649. data: ArrayBuffer;
  126650. /**
  126651. * Callback called when the task is successful
  126652. */
  126653. onSuccess: (task: BinaryFileAssetTask) => void;
  126654. /**
  126655. * Callback called when the task is successful
  126656. */
  126657. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  126658. /**
  126659. * Creates a new BinaryFileAssetTask object
  126660. * @param name defines the name of the new task
  126661. * @param url defines the location of the file to load
  126662. */
  126663. constructor(
  126664. /**
  126665. * Defines the name of the task
  126666. */
  126667. name: string,
  126668. /**
  126669. * Defines the location of the file to load
  126670. */
  126671. url: string);
  126672. /**
  126673. * Execute the current task
  126674. * @param scene defines the scene where you want your assets to be loaded
  126675. * @param onSuccess is a callback called when the task is successfully executed
  126676. * @param onError is a callback called if an error occurs
  126677. */
  126678. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126679. }
  126680. /**
  126681. * Define a task used by AssetsManager to load images
  126682. */
  126683. export class ImageAssetTask extends AbstractAssetTask {
  126684. /**
  126685. * Defines the name of the task
  126686. */
  126687. name: string;
  126688. /**
  126689. * Defines the location of the image to load
  126690. */
  126691. url: string;
  126692. /**
  126693. * Gets the loaded images
  126694. */
  126695. image: HTMLImageElement;
  126696. /**
  126697. * Callback called when the task is successful
  126698. */
  126699. onSuccess: (task: ImageAssetTask) => void;
  126700. /**
  126701. * Callback called when the task is successful
  126702. */
  126703. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  126704. /**
  126705. * Creates a new ImageAssetTask
  126706. * @param name defines the name of the task
  126707. * @param url defines the location of the image to load
  126708. */
  126709. constructor(
  126710. /**
  126711. * Defines the name of the task
  126712. */
  126713. name: string,
  126714. /**
  126715. * Defines the location of the image to load
  126716. */
  126717. url: string);
  126718. /**
  126719. * Execute the current task
  126720. * @param scene defines the scene where you want your assets to be loaded
  126721. * @param onSuccess is a callback called when the task is successfully executed
  126722. * @param onError is a callback called if an error occurs
  126723. */
  126724. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126725. }
  126726. /**
  126727. * Defines the interface used by texture loading tasks
  126728. */
  126729. export interface ITextureAssetTask<TEX extends BaseTexture> {
  126730. /**
  126731. * Gets the loaded texture
  126732. */
  126733. texture: TEX;
  126734. }
  126735. /**
  126736. * Define a task used by AssetsManager to load 2D textures
  126737. */
  126738. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  126739. /**
  126740. * Defines the name of the task
  126741. */
  126742. name: string;
  126743. /**
  126744. * Defines the location of the file to load
  126745. */
  126746. url: string;
  126747. /**
  126748. * Defines if mipmap should not be generated (default is false)
  126749. */
  126750. noMipmap?: boolean | undefined;
  126751. /**
  126752. * Defines if texture must be inverted on Y axis (default is false)
  126753. */
  126754. invertY?: boolean | undefined;
  126755. /**
  126756. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126757. */
  126758. samplingMode: number;
  126759. /**
  126760. * Gets the loaded texture
  126761. */
  126762. texture: Texture;
  126763. /**
  126764. * Callback called when the task is successful
  126765. */
  126766. onSuccess: (task: TextureAssetTask) => void;
  126767. /**
  126768. * Callback called when the task is successful
  126769. */
  126770. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  126771. /**
  126772. * Creates a new TextureAssetTask object
  126773. * @param name defines the name of the task
  126774. * @param url defines the location of the file to load
  126775. * @param noMipmap defines if mipmap should not be generated (default is false)
  126776. * @param invertY defines if texture must be inverted on Y axis (default is false)
  126777. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126778. */
  126779. constructor(
  126780. /**
  126781. * Defines the name of the task
  126782. */
  126783. name: string,
  126784. /**
  126785. * Defines the location of the file to load
  126786. */
  126787. url: string,
  126788. /**
  126789. * Defines if mipmap should not be generated (default is false)
  126790. */
  126791. noMipmap?: boolean | undefined,
  126792. /**
  126793. * Defines if texture must be inverted on Y axis (default is false)
  126794. */
  126795. invertY?: boolean | undefined,
  126796. /**
  126797. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126798. */
  126799. samplingMode?: number);
  126800. /**
  126801. * Execute the current task
  126802. * @param scene defines the scene where you want your assets to be loaded
  126803. * @param onSuccess is a callback called when the task is successfully executed
  126804. * @param onError is a callback called if an error occurs
  126805. */
  126806. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126807. }
  126808. /**
  126809. * Define a task used by AssetsManager to load cube textures
  126810. */
  126811. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  126812. /**
  126813. * Defines the name of the task
  126814. */
  126815. name: string;
  126816. /**
  126817. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  126818. */
  126819. url: string;
  126820. /**
  126821. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  126822. */
  126823. extensions?: string[] | undefined;
  126824. /**
  126825. * Defines if mipmaps should not be generated (default is false)
  126826. */
  126827. noMipmap?: boolean | undefined;
  126828. /**
  126829. * Defines the explicit list of files (undefined by default)
  126830. */
  126831. files?: string[] | undefined;
  126832. /**
  126833. * Gets the loaded texture
  126834. */
  126835. texture: CubeTexture;
  126836. /**
  126837. * Callback called when the task is successful
  126838. */
  126839. onSuccess: (task: CubeTextureAssetTask) => void;
  126840. /**
  126841. * Callback called when the task is successful
  126842. */
  126843. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  126844. /**
  126845. * Creates a new CubeTextureAssetTask
  126846. * @param name defines the name of the task
  126847. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  126848. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  126849. * @param noMipmap defines if mipmaps should not be generated (default is false)
  126850. * @param files defines the explicit list of files (undefined by default)
  126851. */
  126852. constructor(
  126853. /**
  126854. * Defines the name of the task
  126855. */
  126856. name: string,
  126857. /**
  126858. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  126859. */
  126860. url: string,
  126861. /**
  126862. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  126863. */
  126864. extensions?: string[] | undefined,
  126865. /**
  126866. * Defines if mipmaps should not be generated (default is false)
  126867. */
  126868. noMipmap?: boolean | undefined,
  126869. /**
  126870. * Defines the explicit list of files (undefined by default)
  126871. */
  126872. files?: string[] | undefined);
  126873. /**
  126874. * Execute the current task
  126875. * @param scene defines the scene where you want your assets to be loaded
  126876. * @param onSuccess is a callback called when the task is successfully executed
  126877. * @param onError is a callback called if an error occurs
  126878. */
  126879. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126880. }
  126881. /**
  126882. * Define a task used by AssetsManager to load HDR cube textures
  126883. */
  126884. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  126885. /**
  126886. * Defines the name of the task
  126887. */
  126888. name: string;
  126889. /**
  126890. * Defines the location of the file to load
  126891. */
  126892. url: string;
  126893. /**
  126894. * Defines the desired size (the more it increases the longer the generation will be)
  126895. */
  126896. size: number;
  126897. /**
  126898. * Defines if mipmaps should not be generated (default is false)
  126899. */
  126900. noMipmap: boolean;
  126901. /**
  126902. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  126903. */
  126904. generateHarmonics: boolean;
  126905. /**
  126906. * 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)
  126907. */
  126908. gammaSpace: boolean;
  126909. /**
  126910. * Internal Use Only
  126911. */
  126912. reserved: boolean;
  126913. /**
  126914. * Gets the loaded texture
  126915. */
  126916. texture: HDRCubeTexture;
  126917. /**
  126918. * Callback called when the task is successful
  126919. */
  126920. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  126921. /**
  126922. * Callback called when the task is successful
  126923. */
  126924. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  126925. /**
  126926. * Creates a new HDRCubeTextureAssetTask object
  126927. * @param name defines the name of the task
  126928. * @param url defines the location of the file to load
  126929. * @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.
  126930. * @param noMipmap defines if mipmaps should not be generated (default is false)
  126931. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  126932. * @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)
  126933. * @param reserved Internal use only
  126934. */
  126935. constructor(
  126936. /**
  126937. * Defines the name of the task
  126938. */
  126939. name: string,
  126940. /**
  126941. * Defines the location of the file to load
  126942. */
  126943. url: string,
  126944. /**
  126945. * Defines the desired size (the more it increases the longer the generation will be)
  126946. */
  126947. size: number,
  126948. /**
  126949. * Defines if mipmaps should not be generated (default is false)
  126950. */
  126951. noMipmap?: boolean,
  126952. /**
  126953. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  126954. */
  126955. generateHarmonics?: boolean,
  126956. /**
  126957. * 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)
  126958. */
  126959. gammaSpace?: boolean,
  126960. /**
  126961. * Internal Use Only
  126962. */
  126963. reserved?: boolean);
  126964. /**
  126965. * Execute the current task
  126966. * @param scene defines the scene where you want your assets to be loaded
  126967. * @param onSuccess is a callback called when the task is successfully executed
  126968. * @param onError is a callback called if an error occurs
  126969. */
  126970. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126971. }
  126972. /**
  126973. * Define a task used by AssetsManager to load Equirectangular cube textures
  126974. */
  126975. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  126976. /**
  126977. * Defines the name of the task
  126978. */
  126979. name: string;
  126980. /**
  126981. * Defines the location of the file to load
  126982. */
  126983. url: string;
  126984. /**
  126985. * Defines the desired size (the more it increases the longer the generation will be)
  126986. */
  126987. size: number;
  126988. /**
  126989. * Defines if mipmaps should not be generated (default is false)
  126990. */
  126991. noMipmap: boolean;
  126992. /**
  126993. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  126994. * but the standard material would require them in Gamma space) (default is true)
  126995. */
  126996. gammaSpace: boolean;
  126997. /**
  126998. * Gets the loaded texture
  126999. */
  127000. texture: EquiRectangularCubeTexture;
  127001. /**
  127002. * Callback called when the task is successful
  127003. */
  127004. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  127005. /**
  127006. * Callback called when the task is successful
  127007. */
  127008. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  127009. /**
  127010. * Creates a new EquiRectangularCubeTextureAssetTask object
  127011. * @param name defines the name of the task
  127012. * @param url defines the location of the file to load
  127013. * @param size defines the desired size (the more it increases the longer the generation will be)
  127014. * If the size is omitted this implies you are using a preprocessed cubemap.
  127015. * @param noMipmap defines if mipmaps should not be generated (default is false)
  127016. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  127017. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  127018. * (default is true)
  127019. */
  127020. constructor(
  127021. /**
  127022. * Defines the name of the task
  127023. */
  127024. name: string,
  127025. /**
  127026. * Defines the location of the file to load
  127027. */
  127028. url: string,
  127029. /**
  127030. * Defines the desired size (the more it increases the longer the generation will be)
  127031. */
  127032. size: number,
  127033. /**
  127034. * Defines if mipmaps should not be generated (default is false)
  127035. */
  127036. noMipmap?: boolean,
  127037. /**
  127038. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  127039. * but the standard material would require them in Gamma space) (default is true)
  127040. */
  127041. gammaSpace?: boolean);
  127042. /**
  127043. * Execute the current task
  127044. * @param scene defines the scene where you want your assets to be loaded
  127045. * @param onSuccess is a callback called when the task is successfully executed
  127046. * @param onError is a callback called if an error occurs
  127047. */
  127048. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127049. }
  127050. /**
  127051. * This class can be used to easily import assets into a scene
  127052. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  127053. */
  127054. export class AssetsManager {
  127055. private _scene;
  127056. private _isLoading;
  127057. protected _tasks: AbstractAssetTask[];
  127058. protected _waitingTasksCount: number;
  127059. protected _totalTasksCount: number;
  127060. /**
  127061. * Callback called when all tasks are processed
  127062. */
  127063. onFinish: (tasks: AbstractAssetTask[]) => void;
  127064. /**
  127065. * Callback called when a task is successful
  127066. */
  127067. onTaskSuccess: (task: AbstractAssetTask) => void;
  127068. /**
  127069. * Callback called when a task had an error
  127070. */
  127071. onTaskError: (task: AbstractAssetTask) => void;
  127072. /**
  127073. * Callback called when a task is done (whatever the result is)
  127074. */
  127075. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  127076. /**
  127077. * Observable called when all tasks are processed
  127078. */
  127079. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  127080. /**
  127081. * Observable called when a task had an error
  127082. */
  127083. onTaskErrorObservable: Observable<AbstractAssetTask>;
  127084. /**
  127085. * Observable called when all tasks were executed
  127086. */
  127087. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  127088. /**
  127089. * Observable called when a task is done (whatever the result is)
  127090. */
  127091. onProgressObservable: Observable<IAssetsProgressEvent>;
  127092. /**
  127093. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  127094. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127095. */
  127096. useDefaultLoadingScreen: boolean;
  127097. /**
  127098. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  127099. * when all assets have been downloaded.
  127100. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  127101. */
  127102. autoHideLoadingUI: boolean;
  127103. /**
  127104. * Creates a new AssetsManager
  127105. * @param scene defines the scene to work on
  127106. */
  127107. constructor(scene: Scene);
  127108. /**
  127109. * Add a MeshAssetTask to the list of active tasks
  127110. * @param taskName defines the name of the new task
  127111. * @param meshesNames defines the name of meshes to load
  127112. * @param rootUrl defines the root url to use to locate files
  127113. * @param sceneFilename defines the filename of the scene file
  127114. * @returns a new MeshAssetTask object
  127115. */
  127116. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  127117. /**
  127118. * Add a TextFileAssetTask to the list of active tasks
  127119. * @param taskName defines the name of the new task
  127120. * @param url defines the url of the file to load
  127121. * @returns a new TextFileAssetTask object
  127122. */
  127123. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  127124. /**
  127125. * Add a BinaryFileAssetTask to the list of active tasks
  127126. * @param taskName defines the name of the new task
  127127. * @param url defines the url of the file to load
  127128. * @returns a new BinaryFileAssetTask object
  127129. */
  127130. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  127131. /**
  127132. * Add a ImageAssetTask to the list of active tasks
  127133. * @param taskName defines the name of the new task
  127134. * @param url defines the url of the file to load
  127135. * @returns a new ImageAssetTask object
  127136. */
  127137. addImageTask(taskName: string, url: string): ImageAssetTask;
  127138. /**
  127139. * Add a TextureAssetTask to the list of active tasks
  127140. * @param taskName defines the name of the new task
  127141. * @param url defines the url of the file to load
  127142. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127143. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  127144. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  127145. * @returns a new TextureAssetTask object
  127146. */
  127147. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  127148. /**
  127149. * Add a CubeTextureAssetTask to the list of active tasks
  127150. * @param taskName defines the name of the new task
  127151. * @param url defines the url of the file to load
  127152. * @param extensions defines the extension to use to load the cube map (can be null)
  127153. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127154. * @param files defines the list of files to load (can be null)
  127155. * @returns a new CubeTextureAssetTask object
  127156. */
  127157. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  127158. /**
  127159. *
  127160. * Add a HDRCubeTextureAssetTask to the list of active tasks
  127161. * @param taskName defines the name of the new task
  127162. * @param url defines the url of the file to load
  127163. * @param size defines the size you want for the cubemap (can be null)
  127164. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127165. * @param generateHarmonics defines if you want to automatically generate (true by default)
  127166. * @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)
  127167. * @param reserved Internal use only
  127168. * @returns a new HDRCubeTextureAssetTask object
  127169. */
  127170. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  127171. /**
  127172. *
  127173. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  127174. * @param taskName defines the name of the new task
  127175. * @param url defines the url of the file to load
  127176. * @param size defines the size you want for the cubemap (can be null)
  127177. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127178. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  127179. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  127180. * @returns a new EquiRectangularCubeTextureAssetTask object
  127181. */
  127182. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  127183. /**
  127184. * Remove a task from the assets manager.
  127185. * @param task the task to remove
  127186. */
  127187. removeTask(task: AbstractAssetTask): void;
  127188. private _decreaseWaitingTasksCount;
  127189. private _runTask;
  127190. /**
  127191. * Reset the AssetsManager and remove all tasks
  127192. * @return the current instance of the AssetsManager
  127193. */
  127194. reset(): AssetsManager;
  127195. /**
  127196. * Start the loading process
  127197. * @return the current instance of the AssetsManager
  127198. */
  127199. load(): AssetsManager;
  127200. /**
  127201. * Start the loading process as an async operation
  127202. * @return a promise returning the list of failed tasks
  127203. */
  127204. loadAsync(): Promise<void>;
  127205. }
  127206. }
  127207. declare module BABYLON {
  127208. /**
  127209. * Wrapper class for promise with external resolve and reject.
  127210. */
  127211. export class Deferred<T> {
  127212. /**
  127213. * The promise associated with this deferred object.
  127214. */
  127215. readonly promise: Promise<T>;
  127216. private _resolve;
  127217. private _reject;
  127218. /**
  127219. * The resolve method of the promise associated with this deferred object.
  127220. */
  127221. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  127222. /**
  127223. * The reject method of the promise associated with this deferred object.
  127224. */
  127225. readonly reject: (reason?: any) => void;
  127226. /**
  127227. * Constructor for this deferred object.
  127228. */
  127229. constructor();
  127230. }
  127231. }
  127232. declare module BABYLON {
  127233. /**
  127234. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  127235. */
  127236. export class MeshExploder {
  127237. private _centerMesh;
  127238. private _meshes;
  127239. private _meshesOrigins;
  127240. private _toCenterVectors;
  127241. private _scaledDirection;
  127242. private _newPosition;
  127243. private _centerPosition;
  127244. /**
  127245. * Explodes meshes from a center mesh.
  127246. * @param meshes The meshes to explode.
  127247. * @param centerMesh The mesh to be center of explosion.
  127248. */
  127249. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  127250. private _setCenterMesh;
  127251. /**
  127252. * Get class name
  127253. * @returns "MeshExploder"
  127254. */
  127255. getClassName(): string;
  127256. /**
  127257. * "Exploded meshes"
  127258. * @returns Array of meshes with the centerMesh at index 0.
  127259. */
  127260. getMeshes(): Array<Mesh>;
  127261. /**
  127262. * Explodes meshes giving a specific direction
  127263. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  127264. */
  127265. explode(direction?: number): void;
  127266. }
  127267. }
  127268. declare module BABYLON {
  127269. /**
  127270. * Class used to help managing file picking and drag'n'drop
  127271. */
  127272. export class FilesInput {
  127273. /**
  127274. * List of files ready to be loaded
  127275. */
  127276. static readonly FilesToLoad: {
  127277. [key: string]: File;
  127278. };
  127279. /**
  127280. * Callback called when a file is processed
  127281. */
  127282. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  127283. private _engine;
  127284. private _currentScene;
  127285. private _sceneLoadedCallback;
  127286. private _progressCallback;
  127287. private _additionalRenderLoopLogicCallback;
  127288. private _textureLoadingCallback;
  127289. private _startingProcessingFilesCallback;
  127290. private _onReloadCallback;
  127291. private _errorCallback;
  127292. private _elementToMonitor;
  127293. private _sceneFileToLoad;
  127294. private _filesToLoad;
  127295. /**
  127296. * Creates a new FilesInput
  127297. * @param engine defines the rendering engine
  127298. * @param scene defines the hosting scene
  127299. * @param sceneLoadedCallback callback called when scene is loaded
  127300. * @param progressCallback callback called to track progress
  127301. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  127302. * @param textureLoadingCallback callback called when a texture is loading
  127303. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  127304. * @param onReloadCallback callback called when a reload is requested
  127305. * @param errorCallback callback call if an error occurs
  127306. */
  127307. 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);
  127308. private _dragEnterHandler;
  127309. private _dragOverHandler;
  127310. private _dropHandler;
  127311. /**
  127312. * Calls this function to listen to drag'n'drop events on a specific DOM element
  127313. * @param elementToMonitor defines the DOM element to track
  127314. */
  127315. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  127316. /**
  127317. * Release all associated resources
  127318. */
  127319. dispose(): void;
  127320. private renderFunction;
  127321. private drag;
  127322. private drop;
  127323. private _traverseFolder;
  127324. private _processFiles;
  127325. /**
  127326. * Load files from a drop event
  127327. * @param event defines the drop event to use as source
  127328. */
  127329. loadFiles(event: any): void;
  127330. private _processReload;
  127331. /**
  127332. * Reload the current scene from the loaded files
  127333. */
  127334. reload(): void;
  127335. }
  127336. }
  127337. declare module BABYLON {
  127338. /**
  127339. * Defines the root class used to create scene optimization to use with SceneOptimizer
  127340. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127341. */
  127342. export class SceneOptimization {
  127343. /**
  127344. * Defines the priority of this optimization (0 by default which means first in the list)
  127345. */
  127346. priority: number;
  127347. /**
  127348. * Gets a string describing the action executed by the current optimization
  127349. * @returns description string
  127350. */
  127351. getDescription(): string;
  127352. /**
  127353. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127354. * @param scene defines the current scene where to apply this optimization
  127355. * @param optimizer defines the current optimizer
  127356. * @returns true if everything that can be done was applied
  127357. */
  127358. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127359. /**
  127360. * Creates the SceneOptimization object
  127361. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127362. * @param desc defines the description associated with the optimization
  127363. */
  127364. constructor(
  127365. /**
  127366. * Defines the priority of this optimization (0 by default which means first in the list)
  127367. */
  127368. priority?: number);
  127369. }
  127370. /**
  127371. * Defines an optimization used to reduce the size of render target textures
  127372. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127373. */
  127374. export class TextureOptimization extends SceneOptimization {
  127375. /**
  127376. * Defines the priority of this optimization (0 by default which means first in the list)
  127377. */
  127378. priority: number;
  127379. /**
  127380. * 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
  127381. */
  127382. maximumSize: number;
  127383. /**
  127384. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127385. */
  127386. step: number;
  127387. /**
  127388. * Gets a string describing the action executed by the current optimization
  127389. * @returns description string
  127390. */
  127391. getDescription(): string;
  127392. /**
  127393. * Creates the TextureOptimization object
  127394. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127395. * @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
  127396. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127397. */
  127398. constructor(
  127399. /**
  127400. * Defines the priority of this optimization (0 by default which means first in the list)
  127401. */
  127402. priority?: number,
  127403. /**
  127404. * 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
  127405. */
  127406. maximumSize?: number,
  127407. /**
  127408. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127409. */
  127410. step?: number);
  127411. /**
  127412. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127413. * @param scene defines the current scene where to apply this optimization
  127414. * @param optimizer defines the current optimizer
  127415. * @returns true if everything that can be done was applied
  127416. */
  127417. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127418. }
  127419. /**
  127420. * Defines an optimization used to increase or decrease the rendering resolution
  127421. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127422. */
  127423. export class HardwareScalingOptimization extends SceneOptimization {
  127424. /**
  127425. * Defines the priority of this optimization (0 by default which means first in the list)
  127426. */
  127427. priority: number;
  127428. /**
  127429. * Defines the maximum scale to use (2 by default)
  127430. */
  127431. maximumScale: number;
  127432. /**
  127433. * Defines the step to use between two passes (0.5 by default)
  127434. */
  127435. step: number;
  127436. private _currentScale;
  127437. private _directionOffset;
  127438. /**
  127439. * Gets a string describing the action executed by the current optimization
  127440. * @return description string
  127441. */
  127442. getDescription(): string;
  127443. /**
  127444. * Creates the HardwareScalingOptimization object
  127445. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127446. * @param maximumScale defines the maximum scale to use (2 by default)
  127447. * @param step defines the step to use between two passes (0.5 by default)
  127448. */
  127449. constructor(
  127450. /**
  127451. * Defines the priority of this optimization (0 by default which means first in the list)
  127452. */
  127453. priority?: number,
  127454. /**
  127455. * Defines the maximum scale to use (2 by default)
  127456. */
  127457. maximumScale?: number,
  127458. /**
  127459. * Defines the step to use between two passes (0.5 by default)
  127460. */
  127461. step?: number);
  127462. /**
  127463. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127464. * @param scene defines the current scene where to apply this optimization
  127465. * @param optimizer defines the current optimizer
  127466. * @returns true if everything that can be done was applied
  127467. */
  127468. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127469. }
  127470. /**
  127471. * Defines an optimization used to remove shadows
  127472. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127473. */
  127474. export class ShadowsOptimization extends SceneOptimization {
  127475. /**
  127476. * Gets a string describing the action executed by the current optimization
  127477. * @return description string
  127478. */
  127479. getDescription(): string;
  127480. /**
  127481. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127482. * @param scene defines the current scene where to apply this optimization
  127483. * @param optimizer defines the current optimizer
  127484. * @returns true if everything that can be done was applied
  127485. */
  127486. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127487. }
  127488. /**
  127489. * Defines an optimization used to turn post-processes off
  127490. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127491. */
  127492. export class PostProcessesOptimization extends SceneOptimization {
  127493. /**
  127494. * Gets a string describing the action executed by the current optimization
  127495. * @return description string
  127496. */
  127497. getDescription(): string;
  127498. /**
  127499. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127500. * @param scene defines the current scene where to apply this optimization
  127501. * @param optimizer defines the current optimizer
  127502. * @returns true if everything that can be done was applied
  127503. */
  127504. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127505. }
  127506. /**
  127507. * Defines an optimization used to turn lens flares off
  127508. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127509. */
  127510. export class LensFlaresOptimization extends SceneOptimization {
  127511. /**
  127512. * Gets a string describing the action executed by the current optimization
  127513. * @return description string
  127514. */
  127515. getDescription(): string;
  127516. /**
  127517. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127518. * @param scene defines the current scene where to apply this optimization
  127519. * @param optimizer defines the current optimizer
  127520. * @returns true if everything that can be done was applied
  127521. */
  127522. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127523. }
  127524. /**
  127525. * Defines an optimization based on user defined callback.
  127526. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127527. */
  127528. export class CustomOptimization extends SceneOptimization {
  127529. /**
  127530. * Callback called to apply the custom optimization.
  127531. */
  127532. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  127533. /**
  127534. * Callback called to get custom description
  127535. */
  127536. onGetDescription: () => string;
  127537. /**
  127538. * Gets a string describing the action executed by the current optimization
  127539. * @returns description string
  127540. */
  127541. getDescription(): string;
  127542. /**
  127543. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127544. * @param scene defines the current scene where to apply this optimization
  127545. * @param optimizer defines the current optimizer
  127546. * @returns true if everything that can be done was applied
  127547. */
  127548. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127549. }
  127550. /**
  127551. * Defines an optimization used to turn particles off
  127552. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127553. */
  127554. export class ParticlesOptimization extends SceneOptimization {
  127555. /**
  127556. * Gets a string describing the action executed by the current optimization
  127557. * @return description string
  127558. */
  127559. getDescription(): string;
  127560. /**
  127561. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127562. * @param scene defines the current scene where to apply this optimization
  127563. * @param optimizer defines the current optimizer
  127564. * @returns true if everything that can be done was applied
  127565. */
  127566. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127567. }
  127568. /**
  127569. * Defines an optimization used to turn render targets off
  127570. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127571. */
  127572. export class RenderTargetsOptimization extends SceneOptimization {
  127573. /**
  127574. * Gets a string describing the action executed by the current optimization
  127575. * @return description string
  127576. */
  127577. getDescription(): string;
  127578. /**
  127579. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127580. * @param scene defines the current scene where to apply this optimization
  127581. * @param optimizer defines the current optimizer
  127582. * @returns true if everything that can be done was applied
  127583. */
  127584. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127585. }
  127586. /**
  127587. * Defines an optimization used to merge meshes with compatible materials
  127588. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127589. */
  127590. export class MergeMeshesOptimization extends SceneOptimization {
  127591. private static _UpdateSelectionTree;
  127592. /**
  127593. * Gets or sets a boolean which defines if optimization octree has to be updated
  127594. */
  127595. /**
  127596. * Gets or sets a boolean which defines if optimization octree has to be updated
  127597. */
  127598. static UpdateSelectionTree: boolean;
  127599. /**
  127600. * Gets a string describing the action executed by the current optimization
  127601. * @return description string
  127602. */
  127603. getDescription(): string;
  127604. private _canBeMerged;
  127605. /**
  127606. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127607. * @param scene defines the current scene where to apply this optimization
  127608. * @param optimizer defines the current optimizer
  127609. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  127610. * @returns true if everything that can be done was applied
  127611. */
  127612. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  127613. }
  127614. /**
  127615. * Defines a list of options used by SceneOptimizer
  127616. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127617. */
  127618. export class SceneOptimizerOptions {
  127619. /**
  127620. * Defines the target frame rate to reach (60 by default)
  127621. */
  127622. targetFrameRate: number;
  127623. /**
  127624. * Defines the interval between two checkes (2000ms by default)
  127625. */
  127626. trackerDuration: number;
  127627. /**
  127628. * Gets the list of optimizations to apply
  127629. */
  127630. optimizations: SceneOptimization[];
  127631. /**
  127632. * Creates a new list of options used by SceneOptimizer
  127633. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  127634. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  127635. */
  127636. constructor(
  127637. /**
  127638. * Defines the target frame rate to reach (60 by default)
  127639. */
  127640. targetFrameRate?: number,
  127641. /**
  127642. * Defines the interval between two checkes (2000ms by default)
  127643. */
  127644. trackerDuration?: number);
  127645. /**
  127646. * Add a new optimization
  127647. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  127648. * @returns the current SceneOptimizerOptions
  127649. */
  127650. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  127651. /**
  127652. * Add a new custom optimization
  127653. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  127654. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  127655. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127656. * @returns the current SceneOptimizerOptions
  127657. */
  127658. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  127659. /**
  127660. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  127661. * @param targetFrameRate defines the target frame rate (60 by default)
  127662. * @returns a SceneOptimizerOptions object
  127663. */
  127664. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127665. /**
  127666. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  127667. * @param targetFrameRate defines the target frame rate (60 by default)
  127668. * @returns a SceneOptimizerOptions object
  127669. */
  127670. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127671. /**
  127672. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  127673. * @param targetFrameRate defines the target frame rate (60 by default)
  127674. * @returns a SceneOptimizerOptions object
  127675. */
  127676. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127677. }
  127678. /**
  127679. * Class used to run optimizations in order to reach a target frame rate
  127680. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127681. */
  127682. export class SceneOptimizer implements IDisposable {
  127683. private _isRunning;
  127684. private _options;
  127685. private _scene;
  127686. private _currentPriorityLevel;
  127687. private _targetFrameRate;
  127688. private _trackerDuration;
  127689. private _currentFrameRate;
  127690. private _sceneDisposeObserver;
  127691. private _improvementMode;
  127692. /**
  127693. * Defines an observable called when the optimizer reaches the target frame rate
  127694. */
  127695. onSuccessObservable: Observable<SceneOptimizer>;
  127696. /**
  127697. * Defines an observable called when the optimizer enables an optimization
  127698. */
  127699. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  127700. /**
  127701. * Defines an observable called when the optimizer is not able to reach the target frame rate
  127702. */
  127703. onFailureObservable: Observable<SceneOptimizer>;
  127704. /**
  127705. * Gets a boolean indicating if the optimizer is in improvement mode
  127706. */
  127707. readonly isInImprovementMode: boolean;
  127708. /**
  127709. * Gets the current priority level (0 at start)
  127710. */
  127711. readonly currentPriorityLevel: number;
  127712. /**
  127713. * Gets the current frame rate checked by the SceneOptimizer
  127714. */
  127715. readonly currentFrameRate: number;
  127716. /**
  127717. * Gets or sets the current target frame rate (60 by default)
  127718. */
  127719. /**
  127720. * Gets or sets the current target frame rate (60 by default)
  127721. */
  127722. targetFrameRate: number;
  127723. /**
  127724. * Gets or sets the current interval between two checks (every 2000ms by default)
  127725. */
  127726. /**
  127727. * Gets or sets the current interval between two checks (every 2000ms by default)
  127728. */
  127729. trackerDuration: number;
  127730. /**
  127731. * Gets the list of active optimizations
  127732. */
  127733. readonly optimizations: SceneOptimization[];
  127734. /**
  127735. * Creates a new SceneOptimizer
  127736. * @param scene defines the scene to work on
  127737. * @param options defines the options to use with the SceneOptimizer
  127738. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  127739. * @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)
  127740. */
  127741. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  127742. /**
  127743. * Stops the current optimizer
  127744. */
  127745. stop(): void;
  127746. /**
  127747. * Reset the optimizer to initial step (current priority level = 0)
  127748. */
  127749. reset(): void;
  127750. /**
  127751. * Start the optimizer. By default it will try to reach a specific framerate
  127752. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  127753. */
  127754. start(): void;
  127755. private _checkCurrentState;
  127756. /**
  127757. * Release all resources
  127758. */
  127759. dispose(): void;
  127760. /**
  127761. * Helper function to create a SceneOptimizer with one single line of code
  127762. * @param scene defines the scene to work on
  127763. * @param options defines the options to use with the SceneOptimizer
  127764. * @param onSuccess defines a callback to call on success
  127765. * @param onFailure defines a callback to call on failure
  127766. * @returns the new SceneOptimizer object
  127767. */
  127768. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  127769. }
  127770. }
  127771. declare module BABYLON {
  127772. /**
  127773. * Class used to serialize a scene into a string
  127774. */
  127775. export class SceneSerializer {
  127776. /**
  127777. * Clear cache used by a previous serialization
  127778. */
  127779. static ClearCache(): void;
  127780. /**
  127781. * Serialize a scene into a JSON compatible object
  127782. * @param scene defines the scene to serialize
  127783. * @returns a JSON compatible object
  127784. */
  127785. static Serialize(scene: Scene): any;
  127786. /**
  127787. * Serialize a mesh into a JSON compatible object
  127788. * @param toSerialize defines the mesh to serialize
  127789. * @param withParents defines if parents must be serialized as well
  127790. * @param withChildren defines if children must be serialized as well
  127791. * @returns a JSON compatible object
  127792. */
  127793. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  127794. }
  127795. }
  127796. declare module BABYLON {
  127797. /**
  127798. * Class used to host texture specific utilities
  127799. */
  127800. export class TextureTools {
  127801. /**
  127802. * Uses the GPU to create a copy texture rescaled at a given size
  127803. * @param texture Texture to copy from
  127804. * @param width defines the desired width
  127805. * @param height defines the desired height
  127806. * @param useBilinearMode defines if bilinear mode has to be used
  127807. * @return the generated texture
  127808. */
  127809. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  127810. }
  127811. }
  127812. declare module BABYLON {
  127813. /**
  127814. * This represents the different options available for the video capture.
  127815. */
  127816. export interface VideoRecorderOptions {
  127817. /** Defines the mime type of the video. */
  127818. mimeType: string;
  127819. /** Defines the FPS the video should be recorded at. */
  127820. fps: number;
  127821. /** Defines the chunk size for the recording data. */
  127822. recordChunckSize: number;
  127823. /** The audio tracks to attach to the recording. */
  127824. audioTracks?: MediaStreamTrack[];
  127825. }
  127826. /**
  127827. * This can help with recording videos from BabylonJS.
  127828. * This is based on the available WebRTC functionalities of the browser.
  127829. *
  127830. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  127831. */
  127832. export class VideoRecorder {
  127833. private static readonly _defaultOptions;
  127834. /**
  127835. * Returns whether or not the VideoRecorder is available in your browser.
  127836. * @param engine Defines the Babylon Engine.
  127837. * @returns true if supported otherwise false.
  127838. */
  127839. static IsSupported(engine: Engine): boolean;
  127840. private readonly _options;
  127841. private _canvas;
  127842. private _mediaRecorder;
  127843. private _recordedChunks;
  127844. private _fileName;
  127845. private _resolve;
  127846. private _reject;
  127847. /**
  127848. * True when a recording is already in progress.
  127849. */
  127850. readonly isRecording: boolean;
  127851. /**
  127852. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  127853. * @param engine Defines the BabylonJS Engine you wish to record.
  127854. * @param options Defines options that can be used to customize the capture.
  127855. */
  127856. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  127857. /**
  127858. * Stops the current recording before the default capture timeout passed in the startRecording function.
  127859. */
  127860. stopRecording(): void;
  127861. /**
  127862. * Starts recording the canvas for a max duration specified in parameters.
  127863. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  127864. * If null no automatic download will start and you can rely on the promise to get the data back.
  127865. * @param maxDuration Defines the maximum recording time in seconds.
  127866. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  127867. * @return A promise callback at the end of the recording with the video data in Blob.
  127868. */
  127869. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  127870. /**
  127871. * Releases internal resources used during the recording.
  127872. */
  127873. dispose(): void;
  127874. private _handleDataAvailable;
  127875. private _handleError;
  127876. private _handleStop;
  127877. }
  127878. }
  127879. declare module BABYLON {
  127880. /**
  127881. * Class containing a set of static utilities functions for screenshots
  127882. */
  127883. export class ScreenshotTools {
  127884. /**
  127885. * Captures a screenshot of the current rendering
  127886. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  127887. * @param engine defines the rendering engine
  127888. * @param camera defines the source camera
  127889. * @param size This parameter can be set to a single number or to an object with the
  127890. * following (optional) properties: precision, width, height. If a single number is passed,
  127891. * it will be used for both width and height. If an object is passed, the screenshot size
  127892. * will be derived from the parameters. The precision property is a multiplier allowing
  127893. * rendering at a higher or lower resolution
  127894. * @param successCallback defines the callback receives a single parameter which contains the
  127895. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  127896. * src parameter of an <img> to display it
  127897. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  127898. * Check your browser for supported MIME types
  127899. */
  127900. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  127901. /**
  127902. * Captures a screenshot of the current rendering
  127903. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  127904. * @param engine defines the rendering engine
  127905. * @param camera defines the source camera
  127906. * @param size This parameter can be set to a single number or to an object with the
  127907. * following (optional) properties: precision, width, height. If a single number is passed,
  127908. * it will be used for both width and height. If an object is passed, the screenshot size
  127909. * will be derived from the parameters. The precision property is a multiplier allowing
  127910. * rendering at a higher or lower resolution
  127911. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  127912. * Check your browser for supported MIME types
  127913. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  127914. * to the src parameter of an <img> to display it
  127915. */
  127916. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  127917. /**
  127918. * Generates an image screenshot from the specified camera.
  127919. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  127920. * @param engine The engine to use for rendering
  127921. * @param camera The camera to use for rendering
  127922. * @param size This parameter can be set to a single number or to an object with the
  127923. * following (optional) properties: precision, width, height. If a single number is passed,
  127924. * it will be used for both width and height. If an object is passed, the screenshot size
  127925. * will be derived from the parameters. The precision property is a multiplier allowing
  127926. * rendering at a higher or lower resolution
  127927. * @param successCallback The callback receives a single parameter which contains the
  127928. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  127929. * src parameter of an <img> to display it
  127930. * @param mimeType The MIME type of the screenshot image (default: image/png).
  127931. * Check your browser for supported MIME types
  127932. * @param samples Texture samples (default: 1)
  127933. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  127934. * @param fileName A name for for the downloaded file.
  127935. */
  127936. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  127937. /**
  127938. * Generates an image screenshot from the specified camera.
  127939. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  127940. * @param engine The engine to use for rendering
  127941. * @param camera The camera to use for rendering
  127942. * @param size This parameter can be set to a single number or to an object with the
  127943. * following (optional) properties: precision, width, height. If a single number is passed,
  127944. * it will be used for both width and height. If an object is passed, the screenshot size
  127945. * will be derived from the parameters. The precision property is a multiplier allowing
  127946. * rendering at a higher or lower resolution
  127947. * @param mimeType The MIME type of the screenshot image (default: image/png).
  127948. * Check your browser for supported MIME types
  127949. * @param samples Texture samples (default: 1)
  127950. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  127951. * @param fileName A name for for the downloaded file.
  127952. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  127953. * to the src parameter of an <img> to display it
  127954. */
  127955. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  127956. /**
  127957. * Gets height and width for screenshot size
  127958. * @private
  127959. */
  127960. private static _getScreenshotSize;
  127961. }
  127962. }
  127963. declare module BABYLON {
  127964. /**
  127965. * A cursor which tracks a point on a path
  127966. */
  127967. export class PathCursor {
  127968. private path;
  127969. /**
  127970. * Stores path cursor callbacks for when an onchange event is triggered
  127971. */
  127972. private _onchange;
  127973. /**
  127974. * The value of the path cursor
  127975. */
  127976. value: number;
  127977. /**
  127978. * The animation array of the path cursor
  127979. */
  127980. animations: Animation[];
  127981. /**
  127982. * Initializes the path cursor
  127983. * @param path The path to track
  127984. */
  127985. constructor(path: Path2);
  127986. /**
  127987. * Gets the cursor point on the path
  127988. * @returns A point on the path cursor at the cursor location
  127989. */
  127990. getPoint(): Vector3;
  127991. /**
  127992. * Moves the cursor ahead by the step amount
  127993. * @param step The amount to move the cursor forward
  127994. * @returns This path cursor
  127995. */
  127996. moveAhead(step?: number): PathCursor;
  127997. /**
  127998. * Moves the cursor behind by the step amount
  127999. * @param step The amount to move the cursor back
  128000. * @returns This path cursor
  128001. */
  128002. moveBack(step?: number): PathCursor;
  128003. /**
  128004. * Moves the cursor by the step amount
  128005. * If the step amount is greater than one, an exception is thrown
  128006. * @param step The amount to move the cursor
  128007. * @returns This path cursor
  128008. */
  128009. move(step: number): PathCursor;
  128010. /**
  128011. * Ensures that the value is limited between zero and one
  128012. * @returns This path cursor
  128013. */
  128014. private ensureLimits;
  128015. /**
  128016. * Runs onchange callbacks on change (used by the animation engine)
  128017. * @returns This path cursor
  128018. */
  128019. private raiseOnChange;
  128020. /**
  128021. * Executes a function on change
  128022. * @param f A path cursor onchange callback
  128023. * @returns This path cursor
  128024. */
  128025. onchange(f: (cursor: PathCursor) => void): PathCursor;
  128026. }
  128027. }
  128028. declare module BABYLON {
  128029. /**
  128030. * Block used to get the value of the first parameter raised to the power of the second
  128031. */
  128032. export class PowBlock extends NodeMaterialBlock {
  128033. /**
  128034. * Creates a new PowBlock
  128035. * @param name defines the block name
  128036. */
  128037. constructor(name: string);
  128038. /**
  128039. * Gets the current class name
  128040. * @returns the class name
  128041. */
  128042. getClassName(): string;
  128043. /**
  128044. * Gets the value operand input component
  128045. */
  128046. readonly value: NodeMaterialConnectionPoint;
  128047. /**
  128048. * Gets the power operand input component
  128049. */
  128050. readonly power: NodeMaterialConnectionPoint;
  128051. /**
  128052. * Gets the output component
  128053. */
  128054. readonly output: NodeMaterialConnectionPoint;
  128055. protected _buildBlock(state: NodeMaterialBuildState): this;
  128056. }
  128057. }
  128058. declare module BABYLON {
  128059. /** @hidden */
  128060. export var blurPixelShader: {
  128061. name: string;
  128062. shader: string;
  128063. };
  128064. }
  128065. declare module BABYLON {
  128066. /** @hidden */
  128067. export var pointCloudVertexDeclaration: {
  128068. name: string;
  128069. shader: string;
  128070. };
  128071. }
  128072. // Mixins
  128073. interface Window {
  128074. mozIndexedDB: IDBFactory;
  128075. webkitIndexedDB: IDBFactory;
  128076. msIndexedDB: IDBFactory;
  128077. webkitURL: typeof URL;
  128078. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  128079. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  128080. WebGLRenderingContext: WebGLRenderingContext;
  128081. MSGesture: MSGesture;
  128082. CANNON: any;
  128083. AudioContext: AudioContext;
  128084. webkitAudioContext: AudioContext;
  128085. PointerEvent: any;
  128086. Math: Math;
  128087. Uint8Array: Uint8ArrayConstructor;
  128088. Float32Array: Float32ArrayConstructor;
  128089. mozURL: typeof URL;
  128090. msURL: typeof URL;
  128091. VRFrameData: any; // WebVR, from specs 1.1
  128092. DracoDecoderModule: any;
  128093. setImmediate(handler: (...args: any[]) => void): number;
  128094. }
  128095. interface HTMLCanvasElement {
  128096. requestPointerLock(): void;
  128097. msRequestPointerLock?(): void;
  128098. mozRequestPointerLock?(): void;
  128099. webkitRequestPointerLock?(): void;
  128100. /** Track wether a record is in progress */
  128101. isRecording: boolean;
  128102. /** Capture Stream method defined by some browsers */
  128103. captureStream(fps?: number): MediaStream;
  128104. }
  128105. interface CanvasRenderingContext2D {
  128106. msImageSmoothingEnabled: boolean;
  128107. }
  128108. interface MouseEvent {
  128109. mozMovementX: number;
  128110. mozMovementY: number;
  128111. webkitMovementX: number;
  128112. webkitMovementY: number;
  128113. msMovementX: number;
  128114. msMovementY: number;
  128115. }
  128116. interface Navigator {
  128117. mozGetVRDevices: (any: any) => any;
  128118. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128119. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128120. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128121. webkitGetGamepads(): Gamepad[];
  128122. msGetGamepads(): Gamepad[];
  128123. webkitGamepads(): Gamepad[];
  128124. }
  128125. interface HTMLVideoElement {
  128126. mozSrcObject: any;
  128127. }
  128128. interface Math {
  128129. fround(x: number): number;
  128130. imul(a: number, b: number): number;
  128131. }
  128132. interface WebGLRenderingContext {
  128133. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  128134. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  128135. vertexAttribDivisor(index: number, divisor: number): void;
  128136. createVertexArray(): any;
  128137. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  128138. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  128139. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  128140. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  128141. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  128142. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  128143. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  128144. // Queries
  128145. createQuery(): WebGLQuery;
  128146. deleteQuery(query: WebGLQuery): void;
  128147. beginQuery(target: number, query: WebGLQuery): void;
  128148. endQuery(target: number): void;
  128149. getQueryParameter(query: WebGLQuery, pname: number): any;
  128150. getQuery(target: number, pname: number): any;
  128151. MAX_SAMPLES: number;
  128152. RGBA8: number;
  128153. READ_FRAMEBUFFER: number;
  128154. DRAW_FRAMEBUFFER: number;
  128155. UNIFORM_BUFFER: number;
  128156. HALF_FLOAT_OES: number;
  128157. RGBA16F: number;
  128158. RGBA32F: number;
  128159. R32F: number;
  128160. RG32F: number;
  128161. RGB32F: number;
  128162. R16F: number;
  128163. RG16F: number;
  128164. RGB16F: number;
  128165. RED: number;
  128166. RG: number;
  128167. R8: number;
  128168. RG8: number;
  128169. UNSIGNED_INT_24_8: number;
  128170. DEPTH24_STENCIL8: number;
  128171. /* Multiple Render Targets */
  128172. drawBuffers(buffers: number[]): void;
  128173. readBuffer(src: number): void;
  128174. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  128175. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  128176. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  128177. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  128178. // Occlusion Query
  128179. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  128180. ANY_SAMPLES_PASSED: number;
  128181. QUERY_RESULT_AVAILABLE: number;
  128182. QUERY_RESULT: number;
  128183. }
  128184. interface WebGLProgram {
  128185. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  128186. }
  128187. interface EXT_disjoint_timer_query {
  128188. QUERY_COUNTER_BITS_EXT: number;
  128189. TIME_ELAPSED_EXT: number;
  128190. TIMESTAMP_EXT: number;
  128191. GPU_DISJOINT_EXT: number;
  128192. QUERY_RESULT_EXT: number;
  128193. QUERY_RESULT_AVAILABLE_EXT: number;
  128194. queryCounterEXT(query: WebGLQuery, target: number): void;
  128195. createQueryEXT(): WebGLQuery;
  128196. beginQueryEXT(target: number, query: WebGLQuery): void;
  128197. endQueryEXT(target: number): void;
  128198. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  128199. deleteQueryEXT(query: WebGLQuery): void;
  128200. }
  128201. interface WebGLUniformLocation {
  128202. _currentState: any;
  128203. }
  128204. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  128205. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  128206. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  128207. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  128208. interface WebGLRenderingContext {
  128209. readonly RASTERIZER_DISCARD: number;
  128210. readonly DEPTH_COMPONENT24: number;
  128211. readonly TEXTURE_3D: number;
  128212. readonly TEXTURE_2D_ARRAY: number;
  128213. readonly TEXTURE_COMPARE_FUNC: number;
  128214. readonly TEXTURE_COMPARE_MODE: number;
  128215. readonly COMPARE_REF_TO_TEXTURE: number;
  128216. readonly TEXTURE_WRAP_R: number;
  128217. readonly HALF_FLOAT: number;
  128218. readonly RGB8: number;
  128219. readonly RED_INTEGER: number;
  128220. readonly RG_INTEGER: number;
  128221. readonly RGB_INTEGER: number;
  128222. readonly RGBA_INTEGER: number;
  128223. readonly R8_SNORM: number;
  128224. readonly RG8_SNORM: number;
  128225. readonly RGB8_SNORM: number;
  128226. readonly RGBA8_SNORM: number;
  128227. readonly R8I: number;
  128228. readonly RG8I: number;
  128229. readonly RGB8I: number;
  128230. readonly RGBA8I: number;
  128231. readonly R8UI: number;
  128232. readonly RG8UI: number;
  128233. readonly RGB8UI: number;
  128234. readonly RGBA8UI: number;
  128235. readonly R16I: number;
  128236. readonly RG16I: number;
  128237. readonly RGB16I: number;
  128238. readonly RGBA16I: number;
  128239. readonly R16UI: number;
  128240. readonly RG16UI: number;
  128241. readonly RGB16UI: number;
  128242. readonly RGBA16UI: number;
  128243. readonly R32I: number;
  128244. readonly RG32I: number;
  128245. readonly RGB32I: number;
  128246. readonly RGBA32I: number;
  128247. readonly R32UI: number;
  128248. readonly RG32UI: number;
  128249. readonly RGB32UI: number;
  128250. readonly RGBA32UI: number;
  128251. readonly RGB10_A2UI: number;
  128252. readonly R11F_G11F_B10F: number;
  128253. readonly RGB9_E5: number;
  128254. readonly RGB10_A2: number;
  128255. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  128256. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  128257. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  128258. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  128259. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  128260. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  128261. 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;
  128262. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  128263. readonly TRANSFORM_FEEDBACK: number;
  128264. readonly INTERLEAVED_ATTRIBS: number;
  128265. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  128266. createTransformFeedback(): WebGLTransformFeedback;
  128267. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  128268. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  128269. beginTransformFeedback(primitiveMode: number): void;
  128270. endTransformFeedback(): void;
  128271. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  128272. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128273. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128274. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128275. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  128276. }
  128277. interface ImageBitmap {
  128278. readonly width: number;
  128279. readonly height: number;
  128280. close(): void;
  128281. }
  128282. interface WebGLQuery extends WebGLObject {
  128283. }
  128284. declare var WebGLQuery: {
  128285. prototype: WebGLQuery;
  128286. new(): WebGLQuery;
  128287. };
  128288. interface WebGLSampler extends WebGLObject {
  128289. }
  128290. declare var WebGLSampler: {
  128291. prototype: WebGLSampler;
  128292. new(): WebGLSampler;
  128293. };
  128294. interface WebGLSync extends WebGLObject {
  128295. }
  128296. declare var WebGLSync: {
  128297. prototype: WebGLSync;
  128298. new(): WebGLSync;
  128299. };
  128300. interface WebGLTransformFeedback extends WebGLObject {
  128301. }
  128302. declare var WebGLTransformFeedback: {
  128303. prototype: WebGLTransformFeedback;
  128304. new(): WebGLTransformFeedback;
  128305. };
  128306. interface WebGLVertexArrayObject extends WebGLObject {
  128307. }
  128308. declare var WebGLVertexArrayObject: {
  128309. prototype: WebGLVertexArrayObject;
  128310. new(): WebGLVertexArrayObject;
  128311. };
  128312. // Type definitions for WebVR API
  128313. // Project: https://w3c.github.io/webvr/
  128314. // Definitions by: six a <https://github.com/lostfictions>
  128315. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  128316. interface VRDisplay extends EventTarget {
  128317. /**
  128318. * Dictionary of capabilities describing the VRDisplay.
  128319. */
  128320. readonly capabilities: VRDisplayCapabilities;
  128321. /**
  128322. * z-depth defining the far plane of the eye view frustum
  128323. * enables mapping of values in the render target depth
  128324. * attachment to scene coordinates. Initially set to 10000.0.
  128325. */
  128326. depthFar: number;
  128327. /**
  128328. * z-depth defining the near plane of the eye view frustum
  128329. * enables mapping of values in the render target depth
  128330. * attachment to scene coordinates. Initially set to 0.01.
  128331. */
  128332. depthNear: number;
  128333. /**
  128334. * An identifier for this distinct VRDisplay. Used as an
  128335. * association point in the Gamepad API.
  128336. */
  128337. readonly displayId: number;
  128338. /**
  128339. * A display name, a user-readable name identifying it.
  128340. */
  128341. readonly displayName: string;
  128342. readonly isConnected: boolean;
  128343. readonly isPresenting: boolean;
  128344. /**
  128345. * If this VRDisplay supports room-scale experiences, the optional
  128346. * stage attribute contains details on the room-scale parameters.
  128347. */
  128348. readonly stageParameters: VRStageParameters | null;
  128349. /**
  128350. * Passing the value returned by `requestAnimationFrame` to
  128351. * `cancelAnimationFrame` will unregister the callback.
  128352. * @param handle Define the hanle of the request to cancel
  128353. */
  128354. cancelAnimationFrame(handle: number): void;
  128355. /**
  128356. * Stops presenting to the VRDisplay.
  128357. * @returns a promise to know when it stopped
  128358. */
  128359. exitPresent(): Promise<void>;
  128360. /**
  128361. * Return the current VREyeParameters for the given eye.
  128362. * @param whichEye Define the eye we want the parameter for
  128363. * @returns the eye parameters
  128364. */
  128365. getEyeParameters(whichEye: string): VREyeParameters;
  128366. /**
  128367. * Populates the passed VRFrameData with the information required to render
  128368. * the current frame.
  128369. * @param frameData Define the data structure to populate
  128370. * @returns true if ok otherwise false
  128371. */
  128372. getFrameData(frameData: VRFrameData): boolean;
  128373. /**
  128374. * Get the layers currently being presented.
  128375. * @returns the list of VR layers
  128376. */
  128377. getLayers(): VRLayer[];
  128378. /**
  128379. * Return a VRPose containing the future predicted pose of the VRDisplay
  128380. * when the current frame will be presented. The value returned will not
  128381. * change until JavaScript has returned control to the browser.
  128382. *
  128383. * The VRPose will contain the position, orientation, velocity,
  128384. * and acceleration of each of these properties.
  128385. * @returns the pose object
  128386. */
  128387. getPose(): VRPose;
  128388. /**
  128389. * Return the current instantaneous pose of the VRDisplay, with no
  128390. * prediction applied.
  128391. * @returns the current instantaneous pose
  128392. */
  128393. getImmediatePose(): VRPose;
  128394. /**
  128395. * The callback passed to `requestAnimationFrame` will be called
  128396. * any time a new frame should be rendered. When the VRDisplay is
  128397. * presenting the callback will be called at the native refresh
  128398. * rate of the HMD. When not presenting this function acts
  128399. * identically to how window.requestAnimationFrame acts. Content should
  128400. * make no assumptions of frame rate or vsync behavior as the HMD runs
  128401. * asynchronously from other displays and at differing refresh rates.
  128402. * @param callback Define the eaction to run next frame
  128403. * @returns the request handle it
  128404. */
  128405. requestAnimationFrame(callback: FrameRequestCallback): number;
  128406. /**
  128407. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  128408. * Repeat calls while already presenting will update the VRLayers being displayed.
  128409. * @param layers Define the list of layer to present
  128410. * @returns a promise to know when the request has been fulfilled
  128411. */
  128412. requestPresent(layers: VRLayer[]): Promise<void>;
  128413. /**
  128414. * Reset the pose for this display, treating its current position and
  128415. * orientation as the "origin/zero" values. VRPose.position,
  128416. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  128417. * updated when calling resetPose(). This should be called in only
  128418. * sitting-space experiences.
  128419. */
  128420. resetPose(): void;
  128421. /**
  128422. * The VRLayer provided to the VRDisplay will be captured and presented
  128423. * in the HMD. Calling this function has the same effect on the source
  128424. * canvas as any other operation that uses its source image, and canvases
  128425. * created without preserveDrawingBuffer set to true will be cleared.
  128426. * @param pose Define the pose to submit
  128427. */
  128428. submitFrame(pose?: VRPose): void;
  128429. }
  128430. declare var VRDisplay: {
  128431. prototype: VRDisplay;
  128432. new(): VRDisplay;
  128433. };
  128434. interface VRLayer {
  128435. leftBounds?: number[] | Float32Array | null;
  128436. rightBounds?: number[] | Float32Array | null;
  128437. source?: HTMLCanvasElement | null;
  128438. }
  128439. interface VRDisplayCapabilities {
  128440. readonly canPresent: boolean;
  128441. readonly hasExternalDisplay: boolean;
  128442. readonly hasOrientation: boolean;
  128443. readonly hasPosition: boolean;
  128444. readonly maxLayers: number;
  128445. }
  128446. interface VREyeParameters {
  128447. /** @deprecated */
  128448. readonly fieldOfView: VRFieldOfView;
  128449. readonly offset: Float32Array;
  128450. readonly renderHeight: number;
  128451. readonly renderWidth: number;
  128452. }
  128453. interface VRFieldOfView {
  128454. readonly downDegrees: number;
  128455. readonly leftDegrees: number;
  128456. readonly rightDegrees: number;
  128457. readonly upDegrees: number;
  128458. }
  128459. interface VRFrameData {
  128460. readonly leftProjectionMatrix: Float32Array;
  128461. readonly leftViewMatrix: Float32Array;
  128462. readonly pose: VRPose;
  128463. readonly rightProjectionMatrix: Float32Array;
  128464. readonly rightViewMatrix: Float32Array;
  128465. readonly timestamp: number;
  128466. }
  128467. interface VRPose {
  128468. readonly angularAcceleration: Float32Array | null;
  128469. readonly angularVelocity: Float32Array | null;
  128470. readonly linearAcceleration: Float32Array | null;
  128471. readonly linearVelocity: Float32Array | null;
  128472. readonly orientation: Float32Array | null;
  128473. readonly position: Float32Array | null;
  128474. readonly timestamp: number;
  128475. }
  128476. interface VRStageParameters {
  128477. sittingToStandingTransform?: Float32Array;
  128478. sizeX?: number;
  128479. sizeY?: number;
  128480. }
  128481. interface Navigator {
  128482. getVRDisplays(): Promise<VRDisplay[]>;
  128483. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  128484. }
  128485. interface Window {
  128486. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  128487. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  128488. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  128489. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  128490. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  128491. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  128492. }
  128493. interface Gamepad {
  128494. readonly displayId: number;
  128495. }
  128496. type XRSessionMode =
  128497. | "inline"
  128498. | "immersive-vr"
  128499. | "immersive-ar";
  128500. type XRReferenceSpaceType =
  128501. | "viewer"
  128502. | "local"
  128503. | "local-floor"
  128504. | "bounded-floor"
  128505. | "unbounded";
  128506. type XREnvironmentBlendMode =
  128507. | "opaque"
  128508. | "additive"
  128509. | "alpha-blend";
  128510. type XRVisibilityState =
  128511. | "visible"
  128512. | "visible-blurred"
  128513. | "hidden";
  128514. type XRHandedness =
  128515. | "none"
  128516. | "left"
  128517. | "right";
  128518. type XRTargetRayMode =
  128519. | "gaze"
  128520. | "tracked-pointer"
  128521. | "screen";
  128522. type XREye =
  128523. | "none"
  128524. | "left"
  128525. | "right";
  128526. interface XRSpace extends EventTarget {
  128527. }
  128528. interface XRRenderState {
  128529. depthNear?: number;
  128530. depthFar?: number;
  128531. inlineVerticalFieldOfView?: number;
  128532. baseLayer?: XRWebGLLayer;
  128533. }
  128534. interface XRInputSource {
  128535. handedness: XRHandedness;
  128536. targetRayMode: XRTargetRayMode;
  128537. targetRaySpace: XRSpace;
  128538. gripSpace: XRSpace | undefined;
  128539. gamepad: Gamepad | undefined;
  128540. profiles: Array<string>;
  128541. }
  128542. interface XRSession {
  128543. addEventListener: Function;
  128544. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  128545. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  128546. requestAnimationFrame: Function;
  128547. end(): Promise<void>;
  128548. renderState: XRRenderState;
  128549. inputSources: Array<XRInputSource>;
  128550. }
  128551. interface XRReferenceSpace extends XRSpace {
  128552. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  128553. onreset: any;
  128554. }
  128555. interface XRFrame {
  128556. session: XRSession;
  128557. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  128558. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  128559. }
  128560. interface XRViewerPose extends XRPose {
  128561. views: Array<XRView>;
  128562. }
  128563. interface XRPose {
  128564. transform: XRRigidTransform;
  128565. emulatedPosition: boolean;
  128566. }
  128567. declare var XRWebGLLayer: {
  128568. prototype: XRWebGLLayer;
  128569. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  128570. };
  128571. interface XRWebGLLayer {
  128572. framebuffer: WebGLFramebuffer;
  128573. framebufferWidth: number;
  128574. framebufferHeight: number;
  128575. getViewport: Function;
  128576. }
  128577. interface XRRigidTransform {
  128578. position: DOMPointReadOnly;
  128579. orientation: DOMPointReadOnly;
  128580. matrix: Float32Array;
  128581. inverse: XRRigidTransform;
  128582. }
  128583. interface XRView {
  128584. eye: XREye;
  128585. projectionMatrix: Float32Array;
  128586. transform: XRRigidTransform;
  128587. }
  128588. interface XRInputSourceChangeEvent {
  128589. session: XRSession;
  128590. removed: Array<XRInputSource>;
  128591. added: Array<XRInputSource>;
  128592. }